windmill-components 1.22.42 → 1.28.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (250) hide show
  1. package/components/AppConnect.svelte +93 -47
  2. package/components/AppConnect.svelte.d.ts +2 -2
  3. package/components/ArgInfo.svelte +0 -5
  4. package/components/ArgInput.svelte +91 -64
  5. package/components/ArgInput.svelte.d.ts +8 -3
  6. package/components/Button.svelte +4 -4
  7. package/components/CenteredPage.svelte +1 -1
  8. package/components/CollapseLink.svelte +12 -0
  9. package/components/CollapseLink.svelte.d.ts +19 -0
  10. package/components/CronInput.svelte +84 -0
  11. package/components/CronInput.svelte.d.ts +18 -0
  12. package/components/DisplayResult.svelte +28 -15
  13. package/components/Editor.svelte +136 -66
  14. package/components/Editor.svelte.d.ts +2 -0
  15. package/components/EditorBar.svelte +56 -45
  16. package/components/FlowBuilder.svelte +155 -70
  17. package/components/FlowEditor.svelte +79 -200
  18. package/components/FlowEditor.svelte.d.ts +3 -2
  19. package/components/FlowJobResult.svelte +1 -1
  20. package/components/FlowPreview.svelte +18 -24
  21. package/components/FlowPreviewContent.svelte +68 -0
  22. package/components/FlowPreviewContent.svelte.d.ts +21 -0
  23. package/components/FlowStatusViewer.svelte +85 -37
  24. package/components/FlowStatusViewer.svelte.d.ts +3 -2
  25. package/components/FlowViewer.svelte +85 -45
  26. package/components/FlowViewer.svelte.d.ts +2 -1
  27. package/components/IconedResourceType.svelte +30 -5
  28. package/components/InputTransformForm.svelte +209 -0
  29. package/components/InputTransformForm.svelte.d.ts +26 -0
  30. package/components/InputTransformsViewer.svelte +19 -0
  31. package/components/InputTransformsViewer.svelte.d.ts +17 -0
  32. package/components/InviteGlobalUser.svelte +2 -2
  33. package/components/InviteUser.svelte +2 -2
  34. package/components/JobStatus.svelte +32 -25
  35. package/components/Modal.svelte +44 -42
  36. package/components/ModuleStep.svelte +94 -79
  37. package/components/ObjectResourceInput.svelte +58 -38
  38. package/components/ObjectTypeNarrowing.svelte +4 -19
  39. package/components/Path.svelte +1 -0
  40. package/components/Path.svelte.d.ts +1 -1
  41. package/components/RadioButton.svelte +11 -96
  42. package/components/RadioButton.svelte.d.ts +4 -2
  43. package/components/ResourceEditor.svelte +4 -5
  44. package/components/ResourceEditor.svelte.d.ts +2 -2
  45. package/components/ResourcePicker.svelte +25 -2
  46. package/components/ResourcePicker.svelte.d.ts +3 -0
  47. package/components/ResourceTypePicker.svelte +17 -29
  48. package/components/ResourceTypePicker.svelte.d.ts +1 -0
  49. package/components/RunForm.svelte +14 -15
  50. package/components/RunForm.svelte.d.ts +1 -1
  51. package/components/SchemaEditor.svelte +87 -71
  52. package/components/SchemaEditor.svelte.d.ts +2 -0
  53. package/components/SchemaEditorProperty.svelte +11 -0
  54. package/components/SchemaEditorProperty.svelte.d.ts +17 -0
  55. package/components/SchemaForm.svelte +21 -127
  56. package/components/SchemaForm.svelte.d.ts +3 -4
  57. package/components/SchemaModal.svelte +20 -33
  58. package/components/SchemaModal.svelte.d.ts +1 -1
  59. package/components/SchemaViewer.svelte +4 -6
  60. package/components/ScriptBuilder.svelte +40 -43
  61. package/components/ScriptEditor.svelte +71 -66
  62. package/components/ScriptPicker.svelte +10 -12
  63. package/components/ScriptPicker.svelte.d.ts +1 -1
  64. package/components/ScriptSchema.svelte +0 -5
  65. package/components/ShareModal.svelte +1 -1
  66. package/components/SharedBadge.svelte +12 -10
  67. package/components/StringTypeNarrowing.svelte +8 -4
  68. package/components/StringTypeNarrowing.svelte.d.ts +1 -0
  69. package/components/TableCustom.svelte +7 -9
  70. package/components/TableSimple.svelte +1 -1
  71. package/components/Toggle.svelte +8 -10
  72. package/components/Toggle.svelte.d.ts +5 -11
  73. package/components/Tooltip.svelte +3 -2
  74. package/components/VariableEditor.svelte +21 -6
  75. package/components/flows/CopyFirstStepSchema.svelte +7 -5
  76. package/components/flows/DynamicInputHelpBox.svelte +1 -1
  77. package/components/flows/FlowBox.svelte +3 -0
  78. package/components/flows/FlowBox.svelte.d.ts +23 -0
  79. package/components/flows/FlowBoxHeader.svelte +9 -0
  80. package/components/flows/FlowBoxHeader.svelte.d.ts +18 -0
  81. package/components/flows/FlowInput.svelte +20 -0
  82. package/components/flows/FlowInput.svelte.d.ts +14 -0
  83. package/components/flows/FlowInputs.svelte +7 -3
  84. package/components/flows/FlowModuleHeader.svelte +42 -40
  85. package/components/flows/FlowModuleHeader.svelte.d.ts +1 -1
  86. package/components/flows/FlowSettings.svelte +174 -0
  87. package/components/flows/FlowSettings.svelte.d.ts +21 -0
  88. package/components/flows/flowStore.d.ts +5 -2
  89. package/components/flows/flowStore.js +65 -9
  90. package/components/flows/pickers/FlowScriptPicker.svelte +6 -1
  91. package/components/flows/pickers/FlowScriptPicker.svelte.d.ts +1 -0
  92. package/components/flows/utils.d.ts +11 -7
  93. package/components/flows/utils.js +114 -45
  94. package/components/icons/AirtableIcon.svelte +17 -0
  95. package/components/icons/AirtableIcon.svelte.d.ts +17 -0
  96. package/components/icons/GCloudIcon.svelte +16 -0
  97. package/components/icons/GCloudIcon.svelte.d.ts +17 -0
  98. package/components/icons/GItlabIcon.svelte +16 -0
  99. package/components/icons/GItlabIcon.svelte.d.ts +17 -0
  100. package/components/icons/GSheetsIcon.svelte +16 -0
  101. package/components/icons/GSheetsIcon.svelte.d.ts +17 -0
  102. package/components/icons/GcalIcon.svelte +16 -0
  103. package/components/icons/GcalIcon.svelte.d.ts +17 -0
  104. package/components/icons/GdriveIcon.svelte +16 -0
  105. package/components/icons/GdriveIcon.svelte.d.ts +17 -0
  106. package/components/icons/GmailIcon.svelte +16 -0
  107. package/components/icons/GmailIcon.svelte.d.ts +17 -0
  108. package/components/icons/PostgresIcon.svelte +8 -49
  109. package/components/icons/Slack.svelte +9 -18
  110. package/components/icons/TogglIcon.svelte +59 -0
  111. package/components/icons/TogglIcon.svelte.d.ts +17 -0
  112. package/components/propertyPicker/ObjectViewer.svelte +35 -37
  113. package/components/propertyPicker/ObjectViewer.svelte.d.ts +2 -0
  114. package/components/propertyPicker/OverlayPropertyPicker.svelte +53 -53
  115. package/components/propertyPicker/OverlayPropertyPicker.svelte.d.ts +5 -2
  116. package/components/propertyPicker/PropPicker.svelte +13 -15
  117. package/components/propertyPicker/PropPicker.svelte.d.ts +1 -1
  118. package/components/propertyPicker/WarningMessage.svelte +14 -41
  119. package/components/propertyPicker/WarningMessage.svelte.d.ts +11 -8
  120. package/components/propertyPicker/utils.d.ts +1 -0
  121. package/components/propertyPicker/utils.js +25 -0
  122. package/gen/core/OpenAPI.js +1 -1
  123. package/gen/index.d.ts +11 -2
  124. package/gen/index.js +1 -2
  125. package/gen/models/CompletedJob.d.ts +1 -1
  126. package/gen/models/Flow.d.ts +3 -13
  127. package/gen/models/FlowMetadata.d.ts +9 -0
  128. package/gen/models/FlowMetadata.js +4 -0
  129. package/gen/models/FlowModuleValue.d.ts +5 -22
  130. package/gen/models/FlowModuleValue.js +1 -15
  131. package/gen/models/ForloopFlow.d.ts +8 -0
  132. package/gen/models/ForloopFlow.js +4 -0
  133. package/gen/models/InputTransform.d.ts +3 -12
  134. package/gen/models/InputTransform.js +1 -8
  135. package/gen/models/JavascriptTransform.d.ts +4 -0
  136. package/gen/models/JavascriptTransform.js +4 -0
  137. package/gen/models/MainArgSignature.d.ts +1 -1
  138. package/gen/models/NewSchedule.d.ts +1 -0
  139. package/gen/models/OpenFlowWPath.d.ts +4 -0
  140. package/gen/models/OpenFlowWPath.js +4 -0
  141. package/gen/models/PathFlow.d.ts +4 -0
  142. package/gen/models/PathFlow.js +4 -0
  143. package/gen/models/PathScript.d.ts +4 -0
  144. package/gen/models/PathScript.js +4 -0
  145. package/gen/models/RawScript.d.ts +12 -0
  146. package/gen/models/RawScript.js +11 -0
  147. package/gen/models/Schedule.d.ts +1 -1
  148. package/gen/models/StaticTransform.d.ts +4 -0
  149. package/gen/models/StaticTransform.js +4 -0
  150. package/gen/models/TokenResponse.d.ts +3 -3
  151. package/gen/models/Usage.d.ts +5 -0
  152. package/gen/models/Usage.js +4 -0
  153. package/gen/models/User.d.ts +2 -0
  154. package/gen/schemas/$AuditLog.d.ts +32 -0
  155. package/gen/schemas/$AuditLog.js +35 -0
  156. package/gen/schemas/$CompletedJob.d.ts +98 -0
  157. package/gen/schemas/$CompletedJob.js +103 -0
  158. package/gen/schemas/$ContextualVariable.d.ts +16 -0
  159. package/gen/schemas/$ContextualVariable.js +19 -0
  160. package/gen/schemas/$CreateResource.d.ts +22 -0
  161. package/gen/schemas/$CreateResource.js +25 -0
  162. package/gen/schemas/$CreateVariable.d.ts +26 -0
  163. package/gen/schemas/$CreateVariable.js +29 -0
  164. package/gen/schemas/$CreateWorkspace.d.ts +20 -0
  165. package/gen/schemas/$CreateWorkspace.js +23 -0
  166. package/gen/schemas/$EditResource.d.ts +13 -0
  167. package/gen/schemas/$EditResource.js +16 -0
  168. package/gen/schemas/$EditResourceType.d.ts +10 -0
  169. package/gen/schemas/$EditResourceType.js +13 -0
  170. package/gen/schemas/$EditSchedule.d.ts +20 -0
  171. package/gen/schemas/$EditSchedule.js +23 -0
  172. package/gen/schemas/$EditVariable.d.ts +16 -0
  173. package/gen/schemas/$EditVariable.js +19 -0
  174. package/gen/schemas/$EditWorkspaceUser.d.ts +7 -0
  175. package/gen/schemas/$EditWorkspaceUser.js +10 -0
  176. package/gen/schemas/$Flow.d.ts +23 -0
  177. package/gen/schemas/$Flow.js +26 -0
  178. package/gen/schemas/$FlowMetadata.d.ts +31 -0
  179. package/gen/schemas/$FlowMetadata.js +34 -0
  180. package/gen/schemas/$FlowPreview.d.ts +80 -0
  181. package/gen/schemas/$FlowPreview.js +83 -0
  182. package/gen/schemas/$GlobalUserInfo.d.ts +26 -0
  183. package/gen/schemas/$GlobalUserInfo.js +29 -0
  184. package/gen/schemas/$Group.d.ts +23 -0
  185. package/gen/schemas/$Group.js +26 -0
  186. package/gen/schemas/$Job.d.ts +17 -0
  187. package/gen/schemas/$Job.js +20 -0
  188. package/gen/schemas/$ListableVariable.d.ts +35 -0
  189. package/gen/schemas/$ListableVariable.js +38 -0
  190. package/gen/schemas/$Login.d.ts +12 -0
  191. package/gen/schemas/$Login.js +15 -0
  192. package/gen/schemas/$MainArgSignature.d.ts +50 -0
  193. package/gen/schemas/$MainArgSignature.js +53 -0
  194. package/gen/schemas/$NewSchedule.d.ts +30 -0
  195. package/gen/schemas/$NewSchedule.js +33 -0
  196. package/gen/schemas/$NewToken.d.ts +11 -0
  197. package/gen/schemas/$NewToken.js +14 -0
  198. package/gen/schemas/$NewUser.d.ts +16 -0
  199. package/gen/schemas/$NewUser.js +19 -0
  200. package/gen/schemas/$Preview.d.ts +19 -0
  201. package/gen/schemas/$Preview.js +22 -0
  202. package/gen/schemas/$QueuedJob.d.ts +139 -0
  203. package/gen/schemas/$QueuedJob.js +144 -0
  204. package/gen/schemas/$Resource.d.ts +31 -0
  205. package/gen/schemas/$Resource.js +34 -0
  206. package/gen/schemas/$ResourceType.d.ts +17 -0
  207. package/gen/schemas/$ResourceType.js +20 -0
  208. package/gen/schemas/$Schedule.d.ts +47 -0
  209. package/gen/schemas/$Schedule.js +50 -0
  210. package/gen/schemas/$Script.d.ts +77 -0
  211. package/gen/schemas/$Script.js +80 -0
  212. package/gen/schemas/$ScriptArgs.d.ts +6 -0
  213. package/gen/schemas/$ScriptArgs.js +9 -0
  214. package/gen/schemas/$SlackToken.d.ts +24 -0
  215. package/gen/schemas/$SlackToken.js +27 -0
  216. package/gen/schemas/$TokenResponse.d.ts +23 -0
  217. package/gen/schemas/$TokenResponse.js +26 -0
  218. package/gen/schemas/$TruncatedToken.d.ts +25 -0
  219. package/gen/schemas/$TruncatedToken.js +28 -0
  220. package/gen/schemas/$Usage.d.ts +13 -0
  221. package/gen/schemas/$Usage.js +16 -0
  222. package/gen/schemas/$User.d.ts +42 -0
  223. package/gen/schemas/$User.js +45 -0
  224. package/gen/schemas/$UserWorkspaceList.d.ts +28 -0
  225. package/gen/schemas/$UserWorkspaceList.js +31 -0
  226. package/gen/schemas/$WorkerPing.d.ts +31 -0
  227. package/gen/schemas/$WorkerPing.js +34 -0
  228. package/gen/schemas/$Workspace.d.ts +19 -0
  229. package/gen/schemas/$Workspace.js +22 -0
  230. package/gen/schemas/$WorkspaceInvite.d.ts +16 -0
  231. package/gen/schemas/$WorkspaceInvite.js +19 -0
  232. package/gen/services/FlowService.d.ts +24 -23
  233. package/gen/services/FlowService.js +14 -0
  234. package/gen/services/JobService.d.ts +1 -1
  235. package/gen/services/ScriptService.d.ts +13 -19
  236. package/gen/services/ScriptService.js +0 -14
  237. package/gen/services/WorkspaceService.d.ts +1 -1
  238. package/gen/services/WorkspaceService.js +1 -1
  239. package/infer.js +8 -1
  240. package/package.json +85 -16
  241. package/script_helpers.d.ts +1 -1
  242. package/script_helpers.js +11 -13
  243. package/sql.d.ts +89 -0
  244. package/sql.js +817 -0
  245. package/stores.d.ts +0 -1
  246. package/stores.js +0 -6
  247. package/utils.d.ts +12 -5
  248. package/utils.js +55 -9
  249. package/components/RadioButtonV2.svelte +0 -33
  250. package/components/RadioButtonV2.svelte.d.ts +0 -20
@@ -1,93 +1,149 @@
1
1
  <script>import { goto } from '$app/navigation';
2
2
  import { page } from '$app/stores';
3
- import { FlowService, ScriptService } from '../gen';
4
- import { clearPreviewResults, hubScripts, workspaceStore } from '../stores';
5
- import { loadHubScripts, sendUserToast, setQueryWithoutLoad } from '../utils';
6
- import { faFileExport, faFileImport } from '@fortawesome/free-solid-svg-icons';
7
- import { onMount } from 'svelte';
3
+ import { FlowService, ScheduleService } from '../gen';
4
+ import { clearPreviewResults, previewResults, workspaceStore } from '../stores';
5
+ import { encodeState, formatCron, loadHubScripts, pathIsEmpty, sendUserToast, setQueryWithoutLoad } from '../utils';
6
+ import { faPlay } from '@fortawesome/free-solid-svg-icons';
7
+ import { Breadcrumb, BreadcrumbItem, Button } from 'flowbite-svelte';
8
+ import { onDestroy, onMount } from 'svelte';
8
9
  import Icon from 'svelte-awesome';
10
+ import { OFFSET } from './CronInput.svelte';
9
11
  import FlowEditor from './FlowEditor.svelte';
10
- import { flowStore } from './flows/flowStore';
11
- import { flowToMode } from './flows/utils';
12
+ import FlowPreviewContent from './FlowPreviewContent.svelte';
13
+ import { flowStore, mode } from './flows/flowStore';
14
+ import { flowToMode, jobsToResults } from './flows/utils';
12
15
  import ScriptSchema from './ScriptSchema.svelte';
13
16
  export let initialPath = '';
14
17
  let pathError = '';
15
- let mode;
18
+ let scheduleArgs;
19
+ let scheduleEnabled;
20
+ let scheduleCron;
21
+ let previewOpen = false;
16
22
  $: step = Number($page.url.searchParams.get('step')) || 1;
23
+ async function createSchedule(path) {
24
+ await ScheduleService.createSchedule({
25
+ workspace: $workspaceStore,
26
+ requestBody: {
27
+ path: path,
28
+ schedule: formatCron(scheduleCron),
29
+ offset: OFFSET,
30
+ script_path: path,
31
+ is_flow: true,
32
+ args: scheduleArgs,
33
+ enabled: scheduleEnabled
34
+ }
35
+ });
36
+ }
17
37
  async function saveFlow() {
18
- const newFlow = flowToMode($flowStore, mode);
38
+ const flow = flowToMode($flowStore, $mode);
19
39
  if (initialPath === '') {
20
40
  await FlowService.createFlow({
21
41
  workspace: $workspaceStore,
22
42
  requestBody: {
23
- path: newFlow.path,
24
- summary: newFlow.summary,
25
- description: newFlow.description ?? '',
26
- value: newFlow.value,
27
- schema: newFlow.schema
43
+ path: flow.path,
44
+ summary: flow.summary,
45
+ description: flow.description ?? '',
46
+ value: flow.value,
47
+ schema: flow.schema
28
48
  }
29
49
  });
50
+ if ($mode == 'pull') {
51
+ await createSchedule(flow.path);
52
+ }
30
53
  }
31
54
  else {
32
55
  await FlowService.updateFlow({
33
56
  workspace: $workspaceStore,
34
- path: newFlow.path,
57
+ path: initialPath,
35
58
  requestBody: {
36
- path: newFlow.path,
37
- summary: newFlow.summary,
38
- description: newFlow.description ?? '',
39
- value: newFlow.value,
40
- schema: newFlow.schema
59
+ path: flow.path,
60
+ summary: flow.summary,
61
+ description: flow.description ?? '',
62
+ value: flow.value,
63
+ schema: flow.schema
41
64
  }
42
65
  });
66
+ const scheduleExists = await ScheduleService.existsSchedule({
67
+ workspace: $workspaceStore ?? '',
68
+ path: initialPath
69
+ });
70
+ if (scheduleExists) {
71
+ const schedule = await ScheduleService.getSchedule({
72
+ workspace: $workspaceStore ?? '',
73
+ path: initialPath
74
+ });
75
+ if (schedule.path != flow.path ||
76
+ JSON.stringify(schedule.args) != JSON.stringify(scheduleArgs) ||
77
+ schedule.schedule != scheduleCron) {
78
+ await ScheduleService.updateSchedule({
79
+ workspace: $workspaceStore ?? '',
80
+ path: initialPath,
81
+ requestBody: {
82
+ schedule: formatCron(scheduleCron),
83
+ script_path: flow.path,
84
+ is_flow: true,
85
+ args: scheduleArgs
86
+ }
87
+ });
88
+ }
89
+ if (scheduleEnabled != schedule.enabled) {
90
+ await ScheduleService.setScheduleEnabled({
91
+ workspace: $workspaceStore ?? '',
92
+ path: flow.path,
93
+ requestBody: { enabled: scheduleEnabled }
94
+ });
95
+ }
96
+ }
97
+ else {
98
+ await createSchedule(flow.path);
99
+ }
43
100
  }
44
101
  sendUserToast(`Success! flow saved at ${$flowStore.path}`);
45
102
  goto(`/flows/get/${$flowStore.path}`);
46
103
  }
47
104
  async function changeStep(step) {
105
+ if (step === 2 && previewOpen) {
106
+ previewOpen = false;
107
+ }
48
108
  goto(`?step=${step}`);
49
109
  }
50
110
  flowStore.subscribe((flow) => {
51
- setQueryWithoutLoad($page.url, 'state', btoa(JSON.stringify(flowToMode(flow, mode))));
111
+ if (flow) {
112
+ setQueryWithoutLoad($page.url, 'state', encodeState(flowToMode(flow, $mode)));
113
+ }
52
114
  });
53
115
  onMount(() => {
54
116
  loadHubScripts();
55
117
  clearPreviewResults();
56
118
  });
119
+ onDestroy(() => {
120
+ //@ts-ignore
121
+ $flowStore = undefined;
122
+ });
57
123
  </script>
58
124
 
59
- <div class="flex flex-col h-screen max-w-screen-lg xl:-ml-20 xl:pl-4 w-full -mt-4 pt-4 md:mx-10 ">
60
- <!-- Nav between steps-->
61
- <div class="flex flex-col w-full">
62
- <div class="justify-between flex flex-row drop-shadow-sm w-full">
63
- <div class="wizard-nav flex flex-row w-full">
64
- <button
65
- disabled={pathError != ''}
66
- class="{step === 1
67
- ? 'default-button-disabled text-gray-700'
68
- : 'default-button-secondary'} min-w-max ml-2"
69
- on:click={() => {
70
- changeStep(1)
71
- }}>Step 1: Flow</button
72
- >
73
- <button
74
- disabled={pathError != ''}
75
- class="{step === 2
76
- ? 'default-button-disabled text-gray-700'
77
- : 'default-button-secondary'} min-w-max ml-2"
78
- on:click={() => {
79
- changeStep(2)
80
- }}>Step 2: UI customisation</button
81
- >
82
- </div>
125
+ <div class="flex flex-row w-full h-full justify-between">
126
+ <div class={`flex flex-col mb-96 m-auto w-1/2`}>
127
+ <!-- Nav between steps-->
128
+ <div class="justify-between flex flex-row w-full my-4">
129
+ <Breadcrumb>
130
+ <BreadcrumbItem>
131
+ <button on:click={() => changeStep(1)} class={step === 1 ? 'font-bold' : null}>
132
+ Flow Editor
133
+ </button>
134
+ </BreadcrumbItem>
135
+ <BreadcrumbItem>
136
+ <button on:click={() => changeStep(2)} class={step === 2 ? 'font-bold' : null}>
137
+ UI customisation
138
+ </button>
139
+ </BreadcrumbItem>
140
+ </Breadcrumb>
83
141
  <div class="flex flex-row-reverse ml-2">
84
142
  {#if step == 1}
85
143
  <button
86
144
  disabled={pathError != ''}
87
145
  class="default-button px-6 max-h-8"
88
- on:click={() => {
89
- changeStep(step + 1)
90
- }}
146
+ on:click={() => changeStep(2)}
91
147
  >
92
148
  Next
93
149
  </button>
@@ -105,31 +161,60 @@ onMount(() => {
105
161
  </div>
106
162
  <div class="flex flex-row-reverse">
107
163
  <span class="my-1 text-sm text-gray-500 italic">
108
- {#if initialPath && initialPath != $flowStore.path} {initialPath} &rightarrow; {/if}
109
- {$flowStore.path}
164
+ {#if initialPath && initialPath != $flowStore?.path} {initialPath} &rightarrow; {/if}
165
+ {$flowStore?.path}
110
166
  </span>
111
167
  </div>
112
- </div>
113
168
 
114
- <!-- metadata -->
169
+ <!-- metadata -->
115
170
 
116
- {#if step === 1}
117
- <FlowEditor bind:mode bind:pathError bind:initialPath />
118
- {:else if step === 2}
119
- <ScriptSchema
120
- synchronizedHeader={false}
121
- bind:summary={$flowStore.summary}
122
- bind:description={$flowStore.description}
123
- bind:schema={$flowStore.schema}
124
- />
125
- {/if}
126
- </div>
171
+ {#if $flowStore}
172
+ {#if step === 1}
173
+ <FlowEditor
174
+ bind:pathError
175
+ bind:initialPath
176
+ bind:scheduleEnabled
177
+ bind:scheduleCron
178
+ bind:scheduleArgs
179
+ />
180
+ <Button
181
+ disabled={pathIsEmpty($flowStore.path)}
182
+ size="lg"
183
+ pill
184
+ on:click={() => (previewOpen = !previewOpen)}
185
+ class={`blue-button fixed bottom-10 right-10 ${previewOpen ? 'hidden' : ''}`}
186
+ >
187
+ Preview flow
188
+ {pathIsEmpty($flowStore.path) ? '(pick a name first!)' : ''}
127
189
 
128
- <style>
129
- /* .wizard-nav {
130
- @apply w-1/2 sm:w-1/4;
131
- } */
190
+ <Icon data={faPlay} class="ml-2" />
191
+ </Button>
192
+ {:else if step === 2}
193
+ <ScriptSchema
194
+ synchronizedHeader={false}
195
+ bind:summary={$flowStore.summary}
196
+ bind:description={$flowStore.description}
197
+ bind:schema={$flowStore.schema}
198
+ />
199
+ {/if}
200
+ {:else}
201
+ <p>Loading</p>
202
+ {/if}
203
+ </div>
132
204
 
133
- .wizard-nav button {
134
- max-height: 30px;
135
- }</style>
205
+ <div class={`relative h-screen w-1/3 ${previewOpen ? '' : 'hidden'}`}>
206
+ <div class="absolute top-0 h-full">
207
+ {#if $flowStore && step === 1}
208
+ <div class="fixed border-l-2 right-0 h-screen w-1/3">
209
+ <FlowPreviewContent
210
+ bind:args={scheduleArgs}
211
+ on:close={() => (previewOpen = !previewOpen)}
212
+ on:change={(e) => {
213
+ previewResults.set(jobsToResults(e.detail))
214
+ }}
215
+ />
216
+ </div>
217
+ {/if}
218
+ </div>
219
+ </div>
220
+ </div>
@@ -1,214 +1,93 @@
1
- <script>import { FlowModuleValue } from '../gen';
2
- import { faFileExport, faFileImport, faGlobe, faPlus } from '@fortawesome/free-solid-svg-icons';
1
+ <script>import { ScheduleService } from '../gen';
2
+ import { workspaceStore } from '../stores';
3
+ import { pathIsEmpty } from '../utils';
4
+ import { faPlus } from '@fortawesome/free-solid-svg-icons';
5
+ import { Button } from 'flowbite-svelte';
3
6
  import Icon from 'svelte-awesome';
4
- import FlowPreview from './FlowPreview.svelte';
5
- import CopyFirstStepSchema from './flows/CopyFirstStepSchema.svelte';
6
- import { addModule, flowStore } from './flows/flowStore';
7
+ import FlowInput from './flows/FlowInput.svelte';
8
+ import FlowSettings from './flows/FlowSettings.svelte';
9
+ import { addModule, flowStore, mode } from './flows/flowStore';
7
10
  import ModuleStep from './ModuleStep.svelte';
8
- import Path from './Path.svelte';
9
- import RadioButtonV2 from './RadioButtonV2.svelte';
10
- import SchemaEditor from './SchemaEditor.svelte';
11
- import Required from './Required.svelte';
12
- import { pathIsEmpty, sendUserToast } from '../utils';
13
- import Dropdown from './Dropdown.svelte';
14
- import Editor from './Editor.svelte';
15
- import Modal from './Modal.svelte';
16
- import FlowViewer from './FlowViewer.svelte';
17
- import { flowToMode } from './flows/utils';
11
+ import Tooltip from './Tooltip.svelte';
18
12
  export let pathError = '';
19
13
  export let initialPath = '';
20
- let jsonSetter;
21
- let jsonViewer;
22
- let jsonValue = '';
14
+ export let scheduleArgs = {};
15
+ export let scheduleEnabled = false;
16
+ export let scheduleCron = '0 */5 * * *';
17
+ let scheduleLoaded = false;
18
+ async function loadSchedule() {
19
+ if (!scheduleLoaded) {
20
+ scheduleLoaded = true;
21
+ const existsSchedule = await ScheduleService.existsSchedule({
22
+ workspace: $workspaceStore ?? '',
23
+ path: initialPath
24
+ });
25
+ if (existsSchedule) {
26
+ const schedule = await ScheduleService.getSchedule({
27
+ workspace: $workspaceStore ?? '',
28
+ path: initialPath
29
+ });
30
+ scheduleEnabled = schedule.enabled;
31
+ scheduleCron = schedule.schedule;
32
+ scheduleArgs = schedule.args ?? {};
33
+ }
34
+ }
35
+ }
36
+ $: if ($flowStore && $workspaceStore && initialPath != '') {
37
+ loadSchedule();
38
+ }
23
39
  let open = 0;
24
40
  let args = {};
25
- export let mode = $flowStore?.value.modules[1]?.value.type == FlowModuleValue.type.FORLOOPFLOW ? 'pull' : 'push';
26
- $: numberOfSteps = $flowStore?.value.modules.length - 1;
27
41
  </script>
28
42
 
29
- <Modal bind:this={jsonSetter}>
30
- <div slot="title">Import JSON</div>
31
- <div slot="content" class="h-full">
32
- <Editor bind:code={jsonValue} lang={'json'} class="h-full" />
33
- </div>
34
- <div slot="submission">
35
- <button
36
- class="default-button px-4 py-2 font-semibold"
43
+ {#if $flowStore}
44
+ <div class="flex space-y-8 flex-col items-center line">
45
+ <FlowSettings
46
+ bind:pathError
47
+ bind:initialPath
48
+ bind:scheduleArgs
49
+ bind:scheduleCron
50
+ bind:scheduleEnabled
51
+ bind:open
52
+ />
53
+ <FlowInput />
54
+ {#each $flowStore?.value.modules as mod, i}
55
+ <ModuleStep bind:open bind:mod bind:args {i} mode={$mode} />
56
+ {#if i == 0 && $mode == 'pull'}
57
+ <div class="flex justify-center bg-white shadow p-2">
58
+ <p>
59
+ Starting from here, the flow for loop over items from the 1rst step's result right above
60
+ &nbsp; <br />We do not support any other kind of for-loop at the moment but we will very
61
+ soon (See <a href="https://github.com/windmill-labs/windmill/issues/350">#350</a>)
62
+ </p>
63
+ <Tooltip>
64
+ This flow being in 'Pull' mode, the rest of the flow will for loop over the list of
65
+ items returned by the trigger script right above. Retrieve the item value using
66
+ `flow_input._value`
67
+ </Tooltip>
68
+ </div>
69
+ {/if}
70
+ {/each}
71
+ <Button
72
+ disabled={pathIsEmpty($flowStore.path)}
73
+ class="blue-button"
37
74
  on:click={() => {
38
- Object.assign($flowStore, JSON.parse(jsonValue))
39
- $flowStore = $flowStore
40
- open = -1
41
- sendUserToast('Flow imported from JSON')
42
- jsonSetter.closeModal()
75
+ addModule()
76
+ open = $flowStore?.value.modules.length - 1
43
77
  }}
44
78
  >
45
- Import
46
- </button>
47
- </div></Modal
48
- >
49
-
50
- <Modal bind:this={jsonViewer}>
51
- <div slot="title">See JSON</div>
52
- <div slot="content" class="h-full">
53
- <FlowViewer flow={flowToMode($flowStore, mode)} tab="json" />
79
+ <Icon class="text-white mr-2" data={faPlus} />
80
+ Add step {pathIsEmpty($flowStore?.path) ? '(pick a name first!)' : ''}
81
+ </Button>
54
82
  </div>
55
- </Modal>
56
-
57
- <div class="flow-root bg-gray-50 rounded-xl border border-gray-200">
58
- <ul class="relative -mt-10">
59
- <span class="absolute top-0 left-1/2 h-full w-1 bg-gray-400" aria-hidden="true" />
60
- <div class="relative">
61
- <li class="flex flex-row flex-shrink max-w-full mx-auto mt-20">
62
- <div
63
- class="bg-white border border-gray xl-rounded shadow-lg w-full max-w-4xl mx-4 md:mx-auto p-4"
64
- >
65
- <div class="flex flex-row-reverse mr-4">
66
- <Dropdown
67
- dropdownItems={[
68
- {
69
- displayName: 'Import from JSON',
70
- icon: faFileImport,
71
- action: () => {
72
- jsonSetter.openModal()
73
- }
74
- },
75
- {
76
- displayName: 'Export to JSON',
77
- icon: faFileExport,
78
- action: () => {
79
- jsonViewer.openModal()
80
- }
81
- },
82
- {
83
- displayName: 'Publish to Hub',
84
- icon: faGlobe,
85
- action: () => {
86
- const url = new URL('https://hub.windmill.dev/flows/add')
87
- url.searchParams.append(
88
- 'flow',
89
- btoa(JSON.stringify(flowToMode($flowStore, mode).value))
90
- )
91
- url.searchParams.append('schema', btoa(JSON.stringify($flowStore.schema)))
92
- url.searchParams.append('description', $flowStore.description ?? '')
93
- url.searchParams.append('summary', $flowStore.summary)
94
- window.open(url, '_blank')?.focus()
95
- }
96
- }
97
- ]}
98
- relative={false}
99
- />
100
- </div>
101
- <div class="mb-8 p-4">
102
- <Path
103
- bind:error={pathError}
104
- bind:path={$flowStore.path}
105
- {initialPath}
106
- namePlaceholder="my_flow"
107
- kind="flow"
108
- >
109
- <div slot="ownerToolkit">
110
- Flow permissions depend on their path. Select the group <span class="font-mono"
111
- >all</span
112
- >
113
- to share your flow, and <span class="font-mono">user</span> to keep it private.
114
- <a href="https://docs.windmill.dev/docs/reference/namespaces">docs</a>
115
- </div>
116
- </Path>
117
-
118
- <label class="block mt-4">
119
- <span class="text-gray-700">Summary <Required required={false} /></span>
120
- <textarea
121
- bind:value={$flowStore.summary}
122
- class="
123
- mt-1
124
- block
125
- w-full
126
- rounded-md
127
- border-gray-300
128
- shadow-sm
129
- focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50
130
- "
131
- placeholder="A very short summary of the flow displayed when the flow is listed"
132
- rows="1"
133
- />
134
- </label>
135
- </div>
136
- <RadioButtonV2
137
- options={[
138
- [
139
- {
140
- title: 'Push',
141
- desc: 'Trigger this flow through the generated UI, a manual schedule or by calling the associated webhook'
142
- },
143
- 'push'
144
- ],
145
- [
146
- {
147
- title: 'Pull',
148
- desc: 'The first module of this flow is a trigger script whose purpose is to pull data from an external source and return all new items since last run. This flow is meant to be scheduled very regularly to reduce latency to react to new events. It will trigger the rest of the flow once per item. If no new items, the flow will be skipped.'
149
- },
150
- 'pull'
151
- ]
152
- ]}
153
- bind:value={mode}
154
- />
155
- </div>
156
- </li>
157
- <li class="flex flex-row flex-shrink max-w-full mx-auto mt-20">
158
- <div class="bg-white border border-gray xl-rounded shadow-lg w-full mx-4 xl:mx-20">
159
- <div
160
- class="flex items-center justify-between flex-wra px-4 py-5 border-b border-gray-200 sm:px-6"
161
- >
162
- <h3 class="text-lg leading-6 font-medium text-gray-900">Flow Input</h3>
163
- <CopyFirstStepSchema />
164
- </div>
165
- <div class="p-4">
166
- <SchemaEditor schema={$flowStore.schema} />
167
- <div class="my-4" />
168
- <FlowPreview {mode} flow={$flowStore} i={numberOfSteps} bind:args />
169
- </div>
170
- </div>
171
- </li>
172
- {#each $flowStore?.value.modules as mod, i}
173
- <li class="relative mt-16">
174
- <div class="relative flex justify-center">
175
- <button
176
- class="default-button h-10 w-10 shadow-blue-600/40 border-blue-600 shadow"
177
- on:click={() => {
178
- addModule(i)
179
- open = i
180
- }}
181
- >
182
- <Icon class="text-white mb-1" data={faPlus} />
183
- </button>
184
- </div>
185
- </li>
186
- <ModuleStep bind:open bind:mod bind:args {i} {mode} />
187
- {/each}
188
- <li class="relative m-20 ">
189
- <div class="relative flex justify-center">
190
- <button
191
- disabled={pathIsEmpty($flowStore.path)}
192
- class="default-button h-10 w-10 shadow"
193
- on:click={() => {
194
- addModule()
195
- open = $flowStore?.value.modules.length - 1
196
- }}
197
- >
198
- <Icon class="text-white mb-1" data={faPlus} />
199
- Add step {pathIsEmpty($flowStore.path) ? '(pick a name first!)' : ''}
200
- </button>
201
- </div>
202
- </li>
203
- </div>
204
- </ul>
205
- </div>
206
- <div class="py-10 bg-white" />
83
+ {:else}
84
+ <h3>Loading flow</h3>
85
+ {/if}
207
86
 
208
87
  <style>
209
- .shadow:not([disabled]) {
210
- --tw-border-opacity: 1;
211
- border-color: rgb(37 99 235 / var(--tw-border-opacity));
212
- --tw-shadow-color: rgb(37 99 235 / 0.4);
213
- --tw-shadow: var(--tw-shadow-colored)
214
- }</style>
88
+ .line {
89
+ background-image: linear-gradient(#e5e7eb, #e5e7eb);
90
+ background-size: 2px 100%;
91
+ background-repeat: no-repeat;
92
+ background-position: center center;
93
+ }</style>
@@ -1,10 +1,11 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
- import { type FlowMode } from './flows/flowStore';
3
2
  declare const __propDef: {
4
3
  props: {
5
4
  pathError?: string | undefined;
6
5
  initialPath?: string | undefined;
7
- mode?: FlowMode | undefined;
6
+ scheduleArgs?: Record<string, any> | undefined;
7
+ scheduleEnabled?: boolean | undefined;
8
+ scheduleCron?: string | undefined;
8
9
  };
9
10
  events: {
10
11
  [evt: string]: CustomEvent<any>;
@@ -14,7 +14,7 @@ export let job;
14
14
  </div>
15
15
  <div>
16
16
  <ChevronButton text="logs" viewOptions={true}>
17
- <div class="text-xs p-4 bg-gray-50 overflow-auto max-h-lg">
17
+ <div class="text-xs p-4 bg-gray-50 overflow-auto max-h-80 border mt-1">
18
18
  <pre class="w-full">{job.logs}</pre>
19
19
  </div>
20
20
  </ChevronButton>