@@ -14,8 +14,70 @@ import {
14
14
DocumentTriggerType ,
15
15
} from '@latitude-data/constants'
16
16
import { ConfiguredTriggers } from './_components/ConfiguredTriggers'
17
+ import { IsLoadingOnboardingItem } from '../../../lib/IsLoadingOnboardingItem'
17
18
18
- export function ConfigureTriggersStep ( {
19
+ export function ConfigureTriggersIconAndTitle ( ) {
20
+ const project = useCurrentProject ( )
21
+ const commit = useCurrentCommit ( )
22
+
23
+ const { data : triggers } = useDocumentTriggers ( {
24
+ projectId : project . project . id ,
25
+ commitUuid : commit . commit . uuid ,
26
+ } )
27
+
28
+ const sortedIntegrationTriggersByPendingFirst = useMemo ( ( ) => {
29
+ return triggers
30
+ . filter (
31
+ ( trigger ) => trigger . triggerType === DocumentTriggerType . Integration ,
32
+ )
33
+ . sort ( ( a ) => {
34
+ return a . triggerStatus === DocumentTriggerStatus . Pending ? - 1 : 1
35
+ } )
36
+ } , [ triggers ] )
37
+
38
+ const allUnconfiguredTriggers = useMemo ( ( ) => {
39
+ return sortedIntegrationTriggersByPendingFirst . filter (
40
+ ( trigger ) => trigger . triggerStatus === DocumentTriggerStatus . Pending ,
41
+ )
42
+ } , [ sortedIntegrationTriggersByPendingFirst ] )
43
+
44
+ const allTriggersConfigured = useMemo ( ( ) => {
45
+ return allUnconfiguredTriggers . length === 0
46
+ } , [ allUnconfiguredTriggers ] )
47
+
48
+ return (
49
+ < Fragment >
50
+ < div className = 'p-2 border-2 rounded-lg' >
51
+ < Icon className = '' name = 'wrench' size = 'medium' />
52
+ </ div >
53
+ { ! allTriggersConfigured ? (
54
+ < >
55
+ < Text . H2M color = 'foreground' noWrap >
56
+ Configure{ ' ' }
57
+ < Text . H2M color = 'foregroundMuted' >
58
+ { allUnconfiguredTriggers . length }
59
+ </ Text . H2M > { ' ' }
60
+ agent triggers
61
+ </ Text . H2M >
62
+ < Text . H5 color = 'foregroundMuted' >
63
+ Some triggers may require additional configuration
64
+ </ Text . H5 >
65
+ </ >
66
+ ) : (
67
+ < >
68
+ < Text . H2M color = 'foreground' noWrap >
69
+ All triggers configured!
70
+ </ Text . H2M >
71
+ < Text . H5 color = 'foregroundMuted' >
72
+ You can proceed to the next step
73
+ </ Text . H5 >
74
+ </ >
75
+ ) }
76
+ </ Fragment >
77
+ )
78
+ }
79
+
80
+ export function ConfigureTriggersContent ( {
19
81
moveNextOnboardingStep,
20
82
} : {
21
83
moveNextOnboardingStep : ( ) => void
@@ -24,11 +86,12 @@ export function ConfigureTriggersStep({
24
86
moveNextOnboardingStep ( )
25
87
} , [ moveNextOnboardingStep ] )
26
88
27
- const { data : integrations } = useIntegrations ( )
89
+ const { data : integrations , isLoading : isLoadingIntegrations } =
90
+ useIntegrations ( )
28
91
const project = useCurrentProject ( )
29
92
const commit = useCurrentCommit ( )
30
93
31
- const { data : triggers } = useDocumentTriggers ( {
94
+ const { data : triggers , isLoading : isLoadingTriggers } = useDocumentTriggers ( {
32
95
projectId : project . project . id ,
33
96
commitUuid : commit . commit . uuid ,
34
97
} )
@@ -54,61 +117,40 @@ export function ConfigureTriggersStep({
54
117
} , [ allUnconfiguredTriggers ] )
55
118
56
119
return (
57
- < div className = 'flex flex-col h-full items-center p-32 gap-10' >
58
- < div className = 'flex flex-col items-center gap-2' >
59
- < div className = 'p-2 border-2 rounded-lg' >
60
- < Icon className = '' name = 'wrench' size = 'medium' />
61
- </ div >
62
- { ! allTriggersConfigured ? (
63
- < >
64
- < Text . H2M color = 'foreground' noWrap >
65
- Configure{ ' ' }
66
- < Text . H2M color = 'foregroundMuted' >
67
- { allUnconfiguredTriggers . length }
68
- </ Text . H2M > { ' ' }
69
- agent triggers
70
- </ Text . H2M >
71
- < Text . H5 color = 'foregroundMuted' >
72
- Some triggers may require additional configuration
73
- </ Text . H5 >
74
- </ >
120
+ < Fragment >
121
+ < div className = 'flex flex-col items-center gap-2 border-dashed border-2 rounded-xl p-2 w-full max-w-[600px]' >
122
+ { isLoadingTriggers || isLoadingIntegrations ? (
123
+ < IsLoadingOnboardingItem
124
+ highlightedText = 'Triggers'
125
+ nonHighlightedText = 'will appear in a moment...'
126
+ />
75
127
) : (
76
- < >
77
- < Text . H2M color = 'foreground' noWrap >
78
- All triggers configured!
79
- </ Text . H2M >
80
- < Text . H5 color = 'foregroundMuted' >
81
- You can proceed to the next step
82
- </ Text . H5 >
83
- </ >
128
+ sortedIntegrationTriggersByPendingFirst . map ( ( trigger ) => (
129
+ < Fragment key = { trigger . uuid } >
130
+ { trigger . triggerStatus === DocumentTriggerStatus . Pending && (
131
+ < UnconfiguredTriggers
132
+ trigger = { trigger }
133
+ integrations = { integrations }
134
+ />
135
+ ) }
136
+ { trigger . triggerStatus === DocumentTriggerStatus . Deployed && (
137
+ < ConfiguredTriggers
138
+ trigger = { trigger }
139
+ integrations = { integrations }
140
+ />
141
+ ) }
142
+ </ Fragment >
143
+ ) )
84
144
) }
85
145
</ div >
86
- < div className = 'flex flex-col items-center gap-2 border-dashed border-2 rounded-xl p-2 w-full max-w-[600px]' >
87
- { sortedIntegrationTriggersByPendingFirst . map ( ( trigger ) => (
88
- < Fragment key = { trigger . uuid } >
89
- { trigger . triggerStatus === DocumentTriggerStatus . Pending && (
90
- < UnconfiguredTriggers
91
- trigger = { trigger }
92
- integrations = { integrations }
93
- />
94
- ) }
95
- { trigger . triggerStatus === DocumentTriggerStatus . Deployed && (
96
- < ConfiguredTriggers
97
- trigger = { trigger }
98
- integrations = { integrations }
99
- />
100
- ) }
101
- </ Fragment >
102
- ) ) }
103
- </ div >
104
146
< Button
105
147
fancy
106
148
onClick = { handleNext }
107
149
iconProps = { { name : 'chevronRight' , placement : 'right' } }
108
150
disabled = { ! allTriggersConfigured }
109
151
>
110
152
Next
111
- </ Button >
112
- </ div >
153
+ </ Button > { ' ' }
154
+ </ Fragment >
113
155
)
114
156
}
0 commit comments