mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-24 14:45:36 +00:00
## Summary Prompts users to load a template or return to graph when entering builder mode on an empty workflow ## Screenshots (if applicable) <img width="627" height="275" alt="image" src="https://github.com/user-attachments/assets/c1a35dc3-4e8f-4abd-95b9-2f92524e8ebf" /> ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-9379-feat-Show-empty-workflow-dialog-when-entering-app-builder-with-no-nodes-3196d73d36508123b643ec893cd86cac) by [Unito](https://www.unito.io)
48 lines
1.4 KiB
TypeScript
48 lines
1.4 KiB
TypeScript
import WorkflowTemplateSelectorDialog from '@/components/custom/widget/WorkflowTemplateSelectorDialog.vue'
|
|
import { useTelemetry } from '@/platform/telemetry'
|
|
import type { TemplateLibraryMetadata } from '@/platform/telemetry/types'
|
|
import { useDialogService } from '@/services/dialogService'
|
|
import { useNewUserService } from '@/services/useNewUserService'
|
|
import { useDialogStore } from '@/stores/dialogStore'
|
|
|
|
const DIALOG_KEY = 'global-workflow-template-selector'
|
|
const GETTING_STARTED_CATEGORY_ID = 'basics-getting-started'
|
|
|
|
export const useWorkflowTemplateSelectorDialog = () => {
|
|
const dialogService = useDialogService()
|
|
const dialogStore = useDialogStore()
|
|
const newUserService = useNewUserService()
|
|
|
|
function hide() {
|
|
dialogStore.closeDialog({ key: DIALOG_KEY })
|
|
}
|
|
|
|
function show(
|
|
source: TemplateLibraryMetadata['source'] = 'command',
|
|
options?: { initialCategory?: string; afterClose?: () => void }
|
|
) {
|
|
useTelemetry()?.trackTemplateLibraryOpened({ source })
|
|
|
|
const initialCategory =
|
|
options?.initialCategory ??
|
|
(newUserService.isNewUser() ? GETTING_STARTED_CATEGORY_ID : 'all')
|
|
|
|
dialogService.showLayoutDialog({
|
|
key: DIALOG_KEY,
|
|
component: WorkflowTemplateSelectorDialog,
|
|
props: {
|
|
onClose: () => {
|
|
hide()
|
|
options?.afterClose?.()
|
|
},
|
|
initialCategory
|
|
}
|
|
})
|
|
}
|
|
|
|
return {
|
|
show,
|
|
hide
|
|
}
|
|
}
|