Skip to content

Commit ab94a55

Browse files
authored
Show user avatar on top menu if available (#3572)
1 parent 1bcf5e2 commit ab94a55

File tree

2 files changed

+51
-26
lines changed

2 files changed

+51
-26
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<!-- A button that shows current authenticated user's avatar -->
2+
<template>
3+
<Button
4+
v-if="isAuthenticated"
5+
v-tooltip="{ value: $t('userSettings.title'), showDelay: 300 }"
6+
class="user-profile-button p-1"
7+
severity="secondary"
8+
text
9+
:aria-label="$t('userSettings.title')"
10+
@click="openUserSettings"
11+
>
12+
<div
13+
class="flex items-center gap-2 pr-2 rounded-full bg-[var(--p-content-background)]"
14+
>
15+
<!-- User Avatar if available -->
16+
<div v-if="user?.photoURL" class="flex items-center gap-1">
17+
<img
18+
:src="user.photoURL"
19+
:alt="user.displayName || ''"
20+
class="w-8 h-8 rounded-full"
21+
/>
22+
</div>
23+
24+
<!-- User Icon if no avatar -->
25+
<div v-else class="w-8 h-8 rounded-full flex items-center justify-center">
26+
<i class="pi pi-user text-sm" />
27+
</div>
28+
29+
<i class="pi pi-chevron-down" :style="{ fontSize: '0.5rem' }" />
30+
</div>
31+
</Button>
32+
</template>
33+
34+
<script setup lang="ts">
35+
import Button from 'primevue/button'
36+
import { computed } from 'vue'
37+
38+
import { useDialogService } from '@/services/dialogService'
39+
import { useFirebaseAuthStore } from '@/stores/firebaseAuthStore'
40+
41+
const authStore = useFirebaseAuthStore()
42+
const dialogService = useDialogService()
43+
const isAuthenticated = computed(() => authStore.isAuthenticated)
44+
const user = computed(() => authStore.currentUser)
45+
46+
const openUserSettings = () => {
47+
dialogService.showSettingsDialog('user')
48+
}
49+
</script>

src/components/topbar/TopMenubar.vue

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
</div>
1313
<div ref="menuRight" class="comfyui-menu-right flex-shrink-0" />
1414
<Actionbar />
15+
<CurrentUserButton class="flex-shrink-0" />
1516
<BottomPanelToggleButton class="flex-shrink-0" />
1617
<Button
1718
v-tooltip="{ value: $t('menu.hideMenu'), showDelay: 300 }"
@@ -23,23 +24,6 @@
2324
@click="workspaceState.focusMode = true"
2425
@contextmenu="showNativeSystemMenu"
2526
/>
26-
<Button
27-
v-if="isAuthenticated"
28-
v-tooltip="{ value: $t('userSettings.title'), showDelay: 300 }"
29-
class="flex-shrink-0 user-profile-button"
30-
severity="secondary"
31-
text
32-
:aria-label="$t('userSettings.title')"
33-
@click="openUserSettings"
34-
>
35-
<template #icon>
36-
<div
37-
class="w-6 h-6 rounded-full bg-neutral-100 dark:bg-neutral-700 flex items-center justify-center"
38-
>
39-
<i class="pi pi-user text-sm" />
40-
</div>
41-
</template>
42-
</Button>
4327
<div
4428
v-show="menuSetting !== 'Bottom'"
4529
class="window-actions-spacer flex-shrink-0"
@@ -61,10 +45,9 @@ import { computed, onMounted, provide, ref } from 'vue'
6145
import Actionbar from '@/components/actionbar/ComfyActionbar.vue'
6246
import BottomPanelToggleButton from '@/components/topbar/BottomPanelToggleButton.vue'
6347
import CommandMenubar from '@/components/topbar/CommandMenubar.vue'
48+
import CurrentUserButton from '@/components/topbar/CurrentUserButton.vue'
6449
import WorkflowTabs from '@/components/topbar/WorkflowTabs.vue'
6550
import { app } from '@/scripts/app'
66-
import { useDialogService } from '@/services/dialogService'
67-
import { useFirebaseAuthStore } from '@/stores/firebaseAuthStore'
6851
import { useSettingStore } from '@/stores/settingStore'
6952
import { useWorkspaceStore } from '@/stores/workspaceStore'
7053
import {
@@ -76,10 +59,7 @@ import {
7659
7760
const workspaceState = useWorkspaceStore()
7861
const settingStore = useSettingStore()
79-
const authStore = useFirebaseAuthStore()
80-
const dialogService = useDialogService()
8162
82-
const isAuthenticated = computed(() => authStore.isAuthenticated)
8363
const workflowTabsPosition = computed(() =>
8464
settingStore.get('Comfy.Workflow.WorkflowTabsPosition')
8565
)
@@ -89,10 +69,6 @@ const showTopMenu = computed(
8969
() => betaMenuEnabled.value && !workspaceState.focusMode
9070
)
9171
92-
const openUserSettings = () => {
93-
dialogService.showSettingsDialog('user')
94-
}
95-
9672
const menuRight = ref<HTMLDivElement | null>(null)
9773
// Menu-right holds legacy topbar elements attached by custom scripts
9874
onMounted(() => {

0 commit comments

Comments
 (0)