Line data Source code
1 : import { useWorkflowTemplateSelectorDialog } from '@/platform/workflow/templates/composables/useWorkflowTemplateSelectorDialog'
2 : import { app } from '@/scripts/app'
3 : import { useDialogService } from '@/services/dialogService'
4 : import { useDialogStore } from '@/stores/dialogStore'
5 :
6 : import EmptyWorkflowDialogContent from './EmptyWorkflowDialogContent.vue'
7 :
8 2355 : const DIALOG_KEY = 'builder-empty-workflow'
9 :
10 7734 : export function useEmptyWorkflowDialog() {
11 7734 : const dialogService = useDialogService()
12 7734 : const dialogStore = useDialogStore()
13 7734 : const templateSelectorDialog = useWorkflowTemplateSelectorDialog()
14 :
15 2 : function show(options: {
16 : onEnterBuilder: () => void
17 : onDismiss: () => void
18 : }) {
19 2 : dialogService.showLayoutDialog({
20 : key: DIALOG_KEY,
21 : component: EmptyWorkflowDialogContent,
22 : props: {
23 : onBackToWorkflow: () => {
24 1 : closeDialog()
25 1 : options.onDismiss()
26 : },
27 : onLoadTemplate: () => {
28 1 : closeDialog()
29 1 : templateSelectorDialog.show('appbuilder', {
30 : afterClose: () => {
31 0 : if (app.rootGraphOrUndefined?.nodes.length)
32 0 : options.onEnterBuilder()
33 : }
34 : })
35 : }
36 : }
37 : })
38 : }
39 :
40 2 : function closeDialog() {
41 2 : dialogStore.closeDialog({ key: DIALOG_KEY })
42 : }
43 :
44 7734 : return { show }
45 : }
|