Skip to content

Commit

Permalink
enhance: display username too (logseq#11105)
Browse files Browse the repository at this point in the history
* enhance: display username too

* enhance(ui): polish the user item from the global dots menu

---------

Co-authored-by: charlie <[email protected]>
  • Loading branch information
RCmerci and xyhp915 authored Mar 12, 2024
1 parent 451b7a6 commit 7f26dee
Show file tree
Hide file tree
Showing 15 changed files with 20 additions and 21 deletions.
22 changes: 14 additions & 8 deletions src/main/frontend/components/header.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@
[{:keys [current-repo t]}]
(let [page-menu (page-menu/page-menu nil)
page-menu-and-hr (when (seq page-menu)
(concat page-menu [{:hr true}]))]
(concat page-menu [{:hr true}]))
login? (and (state/sub :auth/id-token) (user-handler/logged-in?))]
(ui/dropdown-with-links
(fn [{:keys [toggle-fn]}]
[:button.button.icon.toolbar-dots-btn
Expand Down Expand Up @@ -136,13 +137,18 @@
:options {:on-click #(state/toggle-theme!)}
:icon (ui/icon "bulb")})

(when (and (state/sub :auth/id-token) (user-handler/logged-in?))
{:title (t :logout-user (user-handler/email))
:options {:on-click #(user-handler/logout)}
:icon (ui/icon "logout")})]
(concat page-menu-and-hr)
(remove nil?))
{})))
(when login? {:hr true})
(when login?
{:item [:span.flex.flex-col.relative.group.pt-1
[:b.leading-none (user-handler/username)]
[:small.opacity-70 (user-handler/email)]
[:i.absolute.opacity-0.group-hover:opacity-100.text-red-rx-09
{:class "right-1 top-3" :title (t :logout)}
(ui/icon "logout")]]
:options {:on-click #(user-handler/logout)}})]
(concat page-menu-and-hr)
(remove nil?))
{})))

(rum/defc back-and-forward
< {:key-fn #(identity "nav-history-buttons")}
Expand Down
6 changes: 6 additions & 0 deletions src/main/frontend/handler/user.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@
parse-jwt
:email))

(defn username []
(some->
(state/get-auth-id-token)
parse-jwt
:cognito:username))

(defn user-uuid []
(some->
(state/get-auth-id-token)
Expand Down
1 change: 0 additions & 1 deletion src/resources/dicts/de.edn
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
:loading-files "Dateien laden"
:login "Einloggen"
:logout "Ausloggen"
:logout-user "Ausloggen ({1})"
:new-graph "Neuen Graphen hinzufügen"
:new-page "Neue Seite:"
:open-a-directory "Öffne ein lokales Verzeichnis"
Expand Down
1 change: 0 additions & 1 deletion src/resources/dicts/en.edn
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,6 @@
:loading-files "Loading files"
:login "Login"
:logout "Logout"
:logout-user "Logout ({1})"
:download "Download"
:language "Language"
:remove-background "Remove background"
Expand Down
1 change: 0 additions & 1 deletion src/resources/dicts/es.edn
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
:loading-files "Cargando archivos"
:login "Iniciar sesión"
:logout "Cerrar sesión"
:logout-user "Cerrar sesión ({1})"
:new-graph "Añadir nuevo grafo"
:new-page "Nueva página:"
:open-a-directory "Abrir un directorio local"
Expand Down
1 change: 0 additions & 1 deletion src/resources/dicts/fa.edn
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,6 @@
:loading-files "بار کردن پرونده‌ها"
:login "ورود"
:logout "خروج"
:logout-user "خروج ({1})"
:download "بارگیری"
:language "زبان"
:remove-background "حذف پس‌زمینه"
Expand Down
1 change: 0 additions & 1 deletion src/resources/dicts/fr.edn
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,6 @@
:export-save-to-file "Enregistrer le fichier"
:export-transparent-background "Arrière-plan transparent"
:home "Accueil"
:logout-user "Déconnecter {1}"
:new-page "Nouvelle page :"
:remove-orphaned-pages "Supprimer les pages orphelines ?"
:toggle-theme "Changer le thème"
Expand Down
1 change: 0 additions & 1 deletion src/resources/dicts/id.edn
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,6 @@
:loading-files "Memuat berkas"
:login "Masuk"
:logout "Keluar"
:logout-user "Keluar ({1})"
:download "Unduh"
:language "Bahasa"
:remove-background "Hapus latar belakang"
Expand Down
1 change: 0 additions & 1 deletion src/resources/dicts/it.edn
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@
:host "Host"
:importing "Importando"
:loading "Caricamento..."
:logout-user "Disconnettiti ({1})"
:new-page "Nuova pagina:"
:remove-heading "Rimuovi titolo"
:remove-orphaned-pages "Rimuovere le pagine orfane?"
Expand Down
1 change: 0 additions & 1 deletion src/resources/dicts/ja.edn
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,6 @@
:loading-files "ファイルロード中"
:login "ログイン"
:logout "ログアウト"
:logout-user "ログアウト ({1})"
:download "ダウンロード"
:language "言語"
:remove-background "背景を消去"
Expand Down
1 change: 0 additions & 1 deletion src/resources/dicts/nb-no.edn
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,6 @@
:window/restore "Gjenopprett"

:loading "Laster..."
:logout-user "Logg av ({1})"
:new-page "Ny side:"
:remove-orphaned-pages "Fjern foreldreløse sider?"
:bug-report/inspector-page-btn-back "Gå tilbake"
Expand Down
1 change: 0 additions & 1 deletion src/resources/dicts/pt-br.edn
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,6 @@
:loading-files "Carregando arquivos"
:login "Entrar"
:logout "Sair"
:logout-user "Sair ({1})"
:download "Baixar"
:language "Idioma"
:remove-background "Remover fundo"
Expand Down
1 change: 0 additions & 1 deletion src/resources/dicts/ru.edn
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,6 @@
:loading-files "Загрузка файлов"
:login "Вход"
:logout "Выйти"
:logout-user "Выйти ({1})"
:download "Скачать"
:language "Язык"
:remove-background "Удалить фон"
Expand Down
1 change: 0 additions & 1 deletion src/resources/dicts/sk.edn
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,6 @@
:loading-files "Načítavajú sa súbory"
:login "Prihlásiť sa"
:logout "Odhlásiť sa"
:logout-user "Odhlásiť ({1})"
:download "Stiahnuť"
:language "Jazyk"
:remove-background "Odstrániť pozadie"
Expand Down
1 change: 0 additions & 1 deletion src/resources/dicts/tr.edn
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,6 @@
:loading-files "Dosyalar yükleniyor"
:login "Oturum aç"
:logout "Oturumu kapat"
:logout-user "Oturumu kapat ({1})"
:download "İndir"
:language "Dil"
:remove-background "Arka planı kaldır"
Expand Down

0 comments on commit 7f26dee

Please sign in to comment.