@@ -2,19 +2,23 @@ import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
2
2
import { draggable } from '@atlaskit/pragmatic-drag-and-drop/element/adapter' ;
3
3
import type { SystemStyleObject } from '@invoke-ai/ui-library' ;
4
4
import { Button , Flex , Spacer } from '@invoke-ai/ui-library' ;
5
+ import { useStore } from '@nanostores/react' ;
5
6
import { useAppSelector } from 'app/store/storeHooks' ;
7
+ import { IAINoContentFallback } from 'common/components/IAIImageFallback' ;
6
8
import ScrollableContent from 'common/components/OverlayScrollbars/ScrollableContent' ;
7
9
import { firefoxDndFix } from 'features/dnd/util' ;
8
10
import { FormElementComponent } from 'features/nodes/components/sidePanel/builder/ContainerElementComponent' ;
9
11
import { buildFormElementDndData , useBuilderDndMonitor } from 'features/nodes/components/sidePanel/builder/dnd-hooks' ;
10
12
import { WorkflowBuilderEditMenu } from 'features/nodes/components/sidePanel/builder/WorkflowBuilderMenu' ;
13
+ import { $hasTemplates } from 'features/nodes/store/nodesSlice' ;
11
14
import { selectFormRootElementId , selectIsFormEmpty } from 'features/nodes/store/workflowSlice' ;
12
15
import type { FormElement } from 'features/nodes/types/workflow' ;
13
16
import { buildContainer , buildDivider , buildHeading , buildText } from 'features/nodes/types/workflow' ;
14
17
import { startCase } from 'lodash-es' ;
15
18
import type { RefObject } from 'react' ;
16
19
import { memo , useEffect , useRef , useState } from 'react' ;
17
20
import { useTranslation } from 'react-i18next' ;
21
+ import { useGetOpenAPISchemaQuery } from 'services/api/endpoints/appInfo' ;
18
22
import { assert } from 'tsafe' ;
19
23
20
24
const sx : SystemStyleObject = {
@@ -28,8 +32,7 @@ const sx: SystemStyleObject = {
28
32
29
33
export const WorkflowBuilder = memo ( ( ) => {
30
34
const { t } = useTranslation ( ) ;
31
- const rootElementId = useAppSelector ( selectFormRootElementId ) ;
32
- const isFormEmpty = useAppSelector ( selectIsFormEmpty ) ;
35
+
33
36
useBuilderDndMonitor ( ) ;
34
37
35
38
return (
@@ -47,16 +50,33 @@ export const WorkflowBuilder = memo(() => {
47
50
< WorkflowBuilderEditMenu />
48
51
</ Flex >
49
52
< ScrollableContent >
50
- < Flex sx = { sx } data-is-empty = { isFormEmpty } >
51
- < FormElementComponent id = { rootElementId } />
52
- </ Flex >
53
+ < WorkflowBuilderContent />
53
54
</ ScrollableContent >
54
55
</ Flex >
55
56
</ Flex >
56
57
) ;
57
58
} ) ;
58
59
WorkflowBuilder . displayName = 'WorkflowBuilder' ;
59
60
61
+ const WorkflowBuilderContent = memo ( ( ) => {
62
+ const { t } = useTranslation ( ) ;
63
+ const rootElementId = useAppSelector ( selectFormRootElementId ) ;
64
+ const isFormEmpty = useAppSelector ( selectIsFormEmpty ) ;
65
+ const openApiSchemaQuery = useGetOpenAPISchemaQuery ( ) ;
66
+ const loadedTemplates = useStore ( $hasTemplates ) ;
67
+
68
+ if ( openApiSchemaQuery . isLoading || ! loadedTemplates ) {
69
+ return < IAINoContentFallback label = { t ( 'nodes.loadingNodes' ) } icon = { null } /> ;
70
+ }
71
+
72
+ return (
73
+ < Flex sx = { sx } data-is-empty = { isFormEmpty } >
74
+ < FormElementComponent id = { rootElementId } />
75
+ </ Flex >
76
+ ) ;
77
+ } ) ;
78
+ WorkflowBuilderContent . displayName = 'WorkflowBuilderContent' ;
79
+
60
80
const useAddFormElementDnd = (
61
81
type : Exclude < FormElement [ 'type' ] , 'node-field' > ,
62
82
draggableRef : RefObject < HTMLElement >
0 commit comments