feat(ux): refonte barre latérale /compte et fix CLI tokens
- Déconnexion déplacée dans la sidebar (lien discret) et retirée du dropdown navbar - Email utilisateur connecté = lien simple vers /compte/admin (sans dropdown) - Hover orange pâle sur les nav-links des sidebars - fix(cli): load_dotenv() dans tokens_cli pour charger .env hors contexte app Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DRGb8NAMwaTZxUszSbaj4N
This commit is contained in:
@@ -2,10 +2,13 @@ import argparse
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
from src.api import tokens_db
|
from src.api import tokens_db
|
||||||
|
|
||||||
|
|
||||||
def main(argv=None, env=None) -> int:
|
def main(argv=None, env=None) -> int:
|
||||||
|
load_dotenv()
|
||||||
env = env if env is not None else os.environ
|
env = env if env is not None else os.environ
|
||||||
parser = argparse.ArgumentParser(prog="python -m src.api.tokens_cli")
|
parser = argparse.ArgumentParser(prog="python -m src.api.tokens_cli")
|
||||||
sub = parser.add_subparsers(dest="cmd", required=True)
|
sub = parser.add_subparsers(dest="cmd", required=True)
|
||||||
|
|||||||
+1
-31
@@ -262,37 +262,7 @@ def _auth_nav(_):
|
|||||||
if current_user.is_authenticated:
|
if current_user.is_authenticated:
|
||||||
email = current_user.email
|
email = current_user.email
|
||||||
display = email if len(email) <= 30 else email[:27] + "..."
|
display = email if len(email) <= 30 else email[:27] + "..."
|
||||||
return dbc.DropdownMenu(
|
return dbc.NavItem(dbc.NavLink(display, href="/compte/admin"))
|
||||||
label=display,
|
|
||||||
nav=True,
|
|
||||||
in_navbar=True,
|
|
||||||
children=[
|
|
||||||
dbc.DropdownMenuItem("Mon compte", href="/compte/admin"),
|
|
||||||
dbc.DropdownMenuItem(
|
|
||||||
html.Form(
|
|
||||||
method="POST",
|
|
||||||
action="/auth/logout",
|
|
||||||
style={"display": "inline"},
|
|
||||||
children=[
|
|
||||||
dcc.Input(
|
|
||||||
type="hidden",
|
|
||||||
id={"type": "csrf-input", "index": "navbar-logout"},
|
|
||||||
name="csrf_token",
|
|
||||||
),
|
|
||||||
html.Button(
|
|
||||||
"D\u00e9connexion",
|
|
||||||
type="submit",
|
|
||||||
className="btn btn-link p-0",
|
|
||||||
style={
|
|
||||||
"textDecoration": "none",
|
|
||||||
"color": "inherit",
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
return dbc.NavItem(dbc.NavLink("Connexion", href="/connexion"))
|
return dbc.NavItem(dbc.NavLink("Connexion", href="/connexion"))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -195,6 +195,12 @@ p.version > a {
|
|||||||
text-wrap: wrap;
|
text-wrap: wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Account form */
|
||||||
|
|
||||||
|
input[type="email"] {
|
||||||
|
max-width: 400px;
|
||||||
|
}
|
||||||
|
|
||||||
/* --- Dashboard inputs --- */
|
/* --- Dashboard inputs --- */
|
||||||
|
|
||||||
.Select--multi .Select-value {
|
.Select--multi .Select-value {
|
||||||
|
|||||||
@@ -70,12 +70,39 @@ def account_guard(path: str, require_subscription: bool):
|
|||||||
return dcc.Location(href=href, id="compte-guard-redirect") if href else None
|
return dcc.Location(href=href, id="compte-guard-redirect") if href else None
|
||||||
|
|
||||||
|
|
||||||
|
def _logout_item():
|
||||||
|
return dbc.NavItem(
|
||||||
|
html.Form(
|
||||||
|
method="POST",
|
||||||
|
action="/auth/logout",
|
||||||
|
children=[
|
||||||
|
dcc.Input(
|
||||||
|
type="hidden",
|
||||||
|
id={"type": "csrf-input", "index": "sidebar-logout"},
|
||||||
|
name="csrf_token",
|
||||||
|
),
|
||||||
|
html.Button(
|
||||||
|
"Déconnexion",
|
||||||
|
type="submit",
|
||||||
|
className="nav-link",
|
||||||
|
style={
|
||||||
|
"background": "none",
|
||||||
|
"border": "none",
|
||||||
|
"width": "100%",
|
||||||
|
"textAlign": "left",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def _nav(active: str):
|
def _nav(active: str):
|
||||||
links = [
|
links = [
|
||||||
dbc.NavLink(s["label"], href=s["href"], active=(s["key"] == active))
|
dbc.NavLink(s["label"], href=s["href"], active=(s["key"] == active))
|
||||||
for s in visible_sections(current_user_has_subscription())
|
for s in visible_sections(current_user_has_subscription())
|
||||||
]
|
]
|
||||||
return dbc.Nav(links, vertical=True, class_name="account-nav")
|
return dbc.Nav(links + [_logout_item()], vertical=True, class_name="account-nav")
|
||||||
|
|
||||||
|
|
||||||
def account_shell(active: str, contenu):
|
def account_shell(active: str, contenu):
|
||||||
|
|||||||
Reference in New Issue
Block a user