mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-30 11:11:53 +00:00
fIx: side toolbar tab tooltip not reactive when changing locale (#4213)
Co-authored-by: Huang Yun Qi <yun-qi.huang@ubisoft.com>
This commit is contained in:
@@ -6,7 +6,8 @@
|
|||||||
:key="tab.id"
|
:key="tab.id"
|
||||||
:icon="tab.icon"
|
:icon="tab.icon"
|
||||||
:icon-badge="tab.iconBadge"
|
:icon-badge="tab.iconBadge"
|
||||||
:tooltip="tab.tooltip + getTabTooltipSuffix(tab)"
|
:tooltip="tab.tooltip"
|
||||||
|
:tooltip-suffix="getTabTooltipSuffix(tab)"
|
||||||
:selected="tab.id === selectedTab?.id"
|
:selected="tab.id === selectedTab?.id"
|
||||||
:class="tab.id + '-tab-button'"
|
:class="tab.id + '-tab-button'"
|
||||||
@click="onTabClick(tab)"
|
@click="onTabClick(tab)"
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import PrimeVue from 'primevue/config'
|
|||||||
import OverlayBadge from 'primevue/overlaybadge'
|
import OverlayBadge from 'primevue/overlaybadge'
|
||||||
import Tooltip from 'primevue/tooltip'
|
import Tooltip from 'primevue/tooltip'
|
||||||
import { describe, expect, it } from 'vitest'
|
import { describe, expect, it } from 'vitest'
|
||||||
|
import { createI18n } from 'vue-i18n'
|
||||||
|
|
||||||
import SidebarIcon from './SidebarIcon.vue'
|
import SidebarIcon from './SidebarIcon.vue'
|
||||||
|
|
||||||
@@ -15,6 +16,14 @@ type SidebarIconProps = {
|
|||||||
iconBadge?: string | (() => string | null)
|
iconBadge?: string | (() => string | null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const i18n = createI18n({
|
||||||
|
legacy: false,
|
||||||
|
locale: 'en',
|
||||||
|
messages: {
|
||||||
|
en: {}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
describe('SidebarIcon', () => {
|
describe('SidebarIcon', () => {
|
||||||
const exampleProps: SidebarIconProps = {
|
const exampleProps: SidebarIconProps = {
|
||||||
icon: 'pi pi-cog',
|
icon: 'pi pi-cog',
|
||||||
@@ -24,7 +33,7 @@ describe('SidebarIcon', () => {
|
|||||||
const mountSidebarIcon = (props: Partial<SidebarIconProps>, options = {}) => {
|
const mountSidebarIcon = (props: Partial<SidebarIconProps>, options = {}) => {
|
||||||
return mount(SidebarIcon, {
|
return mount(SidebarIcon, {
|
||||||
global: {
|
global: {
|
||||||
plugins: [PrimeVue],
|
plugins: [PrimeVue, i18n],
|
||||||
directives: { tooltip: Tooltip },
|
directives: { tooltip: Tooltip },
|
||||||
components: { OverlayBadge, Button }
|
components: { OverlayBadge, Button }
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<Button
|
<Button
|
||||||
v-tooltip="{ value: tooltip, showDelay: 300, hideDelay: 300 }"
|
v-tooltip="{
|
||||||
|
value: computedTooltip,
|
||||||
|
showDelay: 300,
|
||||||
|
hideDelay: 300
|
||||||
|
}"
|
||||||
text
|
text
|
||||||
:pt="{
|
:pt="{
|
||||||
root: {
|
root: {
|
||||||
@@ -9,7 +13,7 @@
|
|||||||
? 'p-button-primary side-bar-button-selected'
|
? 'p-button-primary side-bar-button-selected'
|
||||||
: 'p-button-secondary'
|
: 'p-button-secondary'
|
||||||
}`,
|
}`,
|
||||||
'aria-label': tooltip
|
'aria-label': computedTooltip
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
@click="emit('click', $event)"
|
@click="emit('click', $event)"
|
||||||
@@ -27,16 +31,20 @@
|
|||||||
import Button from 'primevue/button'
|
import Button from 'primevue/button'
|
||||||
import OverlayBadge from 'primevue/overlaybadge'
|
import OverlayBadge from 'primevue/overlaybadge'
|
||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
|
import { useI18n } from 'vue-i18n'
|
||||||
|
|
||||||
|
const { t } = useI18n()
|
||||||
const {
|
const {
|
||||||
icon = '',
|
icon = '',
|
||||||
selected = false,
|
selected = false,
|
||||||
tooltip = '',
|
tooltip = '',
|
||||||
|
tooltipSuffix = '',
|
||||||
iconBadge = ''
|
iconBadge = ''
|
||||||
} = defineProps<{
|
} = defineProps<{
|
||||||
icon?: string
|
icon?: string
|
||||||
selected?: boolean
|
selected?: boolean
|
||||||
tooltip?: string
|
tooltip?: string
|
||||||
|
tooltipSuffix?: string
|
||||||
iconBadge?: string | (() => string | null)
|
iconBadge?: string | (() => string | null)
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
@@ -47,6 +55,7 @@ const overlayValue = computed(() =>
|
|||||||
typeof iconBadge === 'function' ? iconBadge() ?? '' : iconBadge
|
typeof iconBadge === 'function' ? iconBadge() ?? '' : iconBadge
|
||||||
)
|
)
|
||||||
const shouldShowBadge = computed(() => !!overlayValue.value)
|
const shouldShowBadge = computed(() => !!overlayValue.value)
|
||||||
|
const computedTooltip = computed(() => t(tooltip) + tooltipSuffix)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { markRaw } from 'vue'
|
import { markRaw } from 'vue'
|
||||||
import { useI18n } from 'vue-i18n'
|
|
||||||
|
|
||||||
import ModelLibrarySidebarTab from '@/components/sidebar/tabs/ModelLibrarySidebarTab.vue'
|
import ModelLibrarySidebarTab from '@/components/sidebar/tabs/ModelLibrarySidebarTab.vue'
|
||||||
import { useElectronDownloadStore } from '@/stores/electronDownloadStore'
|
import { useElectronDownloadStore } from '@/stores/electronDownloadStore'
|
||||||
@@ -7,13 +6,11 @@ import type { SidebarTabExtension } from '@/types/extensionTypes'
|
|||||||
import { isElectron } from '@/utils/envUtil'
|
import { isElectron } from '@/utils/envUtil'
|
||||||
|
|
||||||
export const useModelLibrarySidebarTab = (): SidebarTabExtension => {
|
export const useModelLibrarySidebarTab = (): SidebarTabExtension => {
|
||||||
const { t } = useI18n()
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: 'model-library',
|
id: 'model-library',
|
||||||
icon: 'pi pi-box',
|
icon: 'pi pi-box',
|
||||||
title: t('sideToolbar.modelLibrary'),
|
title: 'sideToolbar.modelLibrary',
|
||||||
tooltip: t('sideToolbar.modelLibrary'),
|
tooltip: 'sideToolbar.modelLibrary',
|
||||||
component: markRaw(ModelLibrarySidebarTab),
|
component: markRaw(ModelLibrarySidebarTab),
|
||||||
type: 'vue',
|
type: 'vue',
|
||||||
iconBadge: () => {
|
iconBadge: () => {
|
||||||
|
|||||||
@@ -1,16 +1,14 @@
|
|||||||
import { markRaw } from 'vue'
|
import { markRaw } from 'vue'
|
||||||
import { useI18n } from 'vue-i18n'
|
|
||||||
|
|
||||||
import NodeLibrarySidebarTab from '@/components/sidebar/tabs/NodeLibrarySidebarTab.vue'
|
import NodeLibrarySidebarTab from '@/components/sidebar/tabs/NodeLibrarySidebarTab.vue'
|
||||||
import type { SidebarTabExtension } from '@/types/extensionTypes'
|
import type { SidebarTabExtension } from '@/types/extensionTypes'
|
||||||
|
|
||||||
export const useNodeLibrarySidebarTab = (): SidebarTabExtension => {
|
export const useNodeLibrarySidebarTab = (): SidebarTabExtension => {
|
||||||
const { t } = useI18n()
|
|
||||||
return {
|
return {
|
||||||
id: 'node-library',
|
id: 'node-library',
|
||||||
icon: 'pi pi-book',
|
icon: 'pi pi-book',
|
||||||
title: t('sideToolbar.nodeLibrary'),
|
title: 'sideToolbar.nodeLibrary',
|
||||||
tooltip: t('sideToolbar.nodeLibrary'),
|
tooltip: 'sideToolbar.nodeLibrary',
|
||||||
component: markRaw(NodeLibrarySidebarTab),
|
component: markRaw(NodeLibrarySidebarTab),
|
||||||
type: 'vue'
|
type: 'vue'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
import { markRaw } from 'vue'
|
import { markRaw } from 'vue'
|
||||||
import { useI18n } from 'vue-i18n'
|
|
||||||
|
|
||||||
import QueueSidebarTab from '@/components/sidebar/tabs/QueueSidebarTab.vue'
|
import QueueSidebarTab from '@/components/sidebar/tabs/QueueSidebarTab.vue'
|
||||||
import { useQueuePendingTaskCountStore } from '@/stores/queueStore'
|
import { useQueuePendingTaskCountStore } from '@/stores/queueStore'
|
||||||
import type { SidebarTabExtension } from '@/types/extensionTypes'
|
import type { SidebarTabExtension } from '@/types/extensionTypes'
|
||||||
|
|
||||||
export const useQueueSidebarTab = (): SidebarTabExtension => {
|
export const useQueueSidebarTab = (): SidebarTabExtension => {
|
||||||
const { t } = useI18n()
|
|
||||||
const queuePendingTaskCountStore = useQueuePendingTaskCountStore()
|
const queuePendingTaskCountStore = useQueuePendingTaskCountStore()
|
||||||
return {
|
return {
|
||||||
id: 'queue',
|
id: 'queue',
|
||||||
@@ -15,8 +13,8 @@ export const useQueueSidebarTab = (): SidebarTabExtension => {
|
|||||||
const value = queuePendingTaskCountStore.count.toString()
|
const value = queuePendingTaskCountStore.count.toString()
|
||||||
return value === '0' ? null : value
|
return value === '0' ? null : value
|
||||||
},
|
},
|
||||||
title: t('sideToolbar.queue'),
|
title: 'sideToolbar.queue',
|
||||||
tooltip: t('sideToolbar.queue'),
|
tooltip: 'sideToolbar.queue',
|
||||||
component: markRaw(QueueSidebarTab),
|
component: markRaw(QueueSidebarTab),
|
||||||
type: 'vue'
|
type: 'vue'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { markRaw } from 'vue'
|
import { markRaw } from 'vue'
|
||||||
import { useI18n } from 'vue-i18n'
|
|
||||||
|
|
||||||
import WorkflowsSidebarTab from '@/components/sidebar/tabs/WorkflowsSidebarTab.vue'
|
import WorkflowsSidebarTab from '@/components/sidebar/tabs/WorkflowsSidebarTab.vue'
|
||||||
import { useSettingStore } from '@/stores/settingStore'
|
import { useSettingStore } from '@/stores/settingStore'
|
||||||
@@ -7,10 +6,8 @@ import { useWorkflowStore } from '@/stores/workflowStore'
|
|||||||
import type { SidebarTabExtension } from '@/types/extensionTypes'
|
import type { SidebarTabExtension } from '@/types/extensionTypes'
|
||||||
|
|
||||||
export const useWorkflowsSidebarTab = (): SidebarTabExtension => {
|
export const useWorkflowsSidebarTab = (): SidebarTabExtension => {
|
||||||
const { t } = useI18n()
|
|
||||||
const settingStore = useSettingStore()
|
const settingStore = useSettingStore()
|
||||||
const workflowStore = useWorkflowStore()
|
const workflowStore = useWorkflowStore()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: 'workflows',
|
id: 'workflows',
|
||||||
icon: 'pi pi-folder-open',
|
icon: 'pi pi-folder-open',
|
||||||
@@ -23,8 +20,8 @@ export const useWorkflowsSidebarTab = (): SidebarTabExtension => {
|
|||||||
const value = workflowStore.openWorkflows.length.toString()
|
const value = workflowStore.openWorkflows.length.toString()
|
||||||
return value === '0' ? null : value
|
return value === '0' ? null : value
|
||||||
},
|
},
|
||||||
title: t('sideToolbar.workflows'),
|
title: 'sideToolbar.workflows',
|
||||||
tooltip: t('sideToolbar.workflows'),
|
tooltip: 'sideToolbar.workflows',
|
||||||
component: markRaw(WorkflowsSidebarTab),
|
component: markRaw(WorkflowsSidebarTab),
|
||||||
type: 'vue'
|
type: 'vue'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ export const useSidebarTabStore = defineStore('sidebarTab', () => {
|
|||||||
useCommandStore().registerCommand({
|
useCommandStore().registerCommand({
|
||||||
id: `Workspace.ToggleSidebarTab.${tab.id}`,
|
id: `Workspace.ToggleSidebarTab.${tab.id}`,
|
||||||
icon: tab.icon,
|
icon: tab.icon,
|
||||||
label: `Toggle ${tab.title} Sidebar`,
|
label: tab.title,
|
||||||
tooltip: tab.tooltip,
|
tooltip: tab.tooltip,
|
||||||
versionAdded: '1.3.9',
|
versionAdded: '1.3.9',
|
||||||
function: () => {
|
function: () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user