Add toggle command for each sidebar tab registered (#1108)

* Add toggle command for each sidebar tab registered

* nit
This commit is contained in:
Chenlei Hu
2024-10-04 20:22:10 -04:00
committed by GitHub
parent 18476d28dc
commit b30d285025
3 changed files with 27 additions and 16 deletions

View File

@@ -261,19 +261,6 @@ export const useCommandStore = defineStore('command', () => {
app.queuePrompt(-1, batchCount)
}
},
{
id: 'Comfy.ToggleQueueSidebarTab',
icon: 'pi pi-history',
label: 'Queue',
versionAdded: '1.3.7',
function: () => {
const tabId = 'queue'
const workspaceStore = useWorkspaceStore()
workspaceStore.updateActiveSidebarTab(
workspaceStore.activeSidebarTab === tabId ? null : tabId
)
}
},
{
id: 'Comfy.ShowSettingsDialog',
icon: 'pi pi-cog',

View File

@@ -34,13 +34,25 @@ export const CORE_KEYBINDINGS: Keybinding[] = [
combo: {
key: 'q'
},
commandId: 'Comfy.ToggleQueueSidebarTab'
commandId: 'Workspace.ToggleSidebarTab.queue'
},
{
combo: {
key: 'h'
key: 'w'
},
commandId: 'Comfy.ToggleQueueSidebarTab'
commandId: 'Workspace.ToggleSidebarTab.workflows'
},
{
combo: {
key: 'n'
},
commandId: 'Workspace.ToggleSidebarTab.node-library'
},
{
combo: {
key: 'm'
},
commandId: 'Workspace.ToggleSidebarTab.model-library'
},
{
combo: {

View File

@@ -39,8 +39,20 @@ export const useWorkspaceStore = defineStore('workspace', {
updateActiveSidebarTab(tabId: string) {
this.activeSidebarTab = tabId
},
toggleSidebarTab(tabId: string) {
this.activeSidebarTab = this.activeSidebarTab === tabId ? null : tabId
},
registerSidebarTab(tab: SidebarTabExtension) {
this.sidebarTabs = [...this.sidebarTabs, tab]
useCommandStore().registerCommand({
id: `Workspace.ToggleSidebarTab.${tab.id}`,
icon: tab.icon,
label: tab.tooltip,
tooltip: tab.tooltip,
function: () => {
this.toggleSidebarTab(tab.id)
}
})
},
unregisterSidebarTab(id: string) {
const index = this.sidebarTabs.findIndex((tab) => tab.id === id)