windmill-components 1.28.7 → 1.35.1

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 (159) hide show
  1. package/common.d.ts +3 -0
  2. package/components/AppConnect.svelte +29 -13
  3. package/components/ArgInput.svelte +25 -14
  4. package/components/ArgInput.svelte.d.ts +4 -0
  5. package/components/CenteredPage.svelte +2 -2
  6. package/components/DisplayResult.svelte +3 -3
  7. package/components/Editor.svelte +70 -78
  8. package/components/Editor.svelte.d.ts +3 -0
  9. package/components/EditorBar.svelte +57 -38
  10. package/components/FlowBuilder.svelte +39 -33
  11. package/components/FlowEditor.svelte +17 -58
  12. package/components/FlowJobResult.svelte +16 -16
  13. package/components/FlowModulesViewer.svelte +97 -0
  14. package/components/FlowModulesViewer.svelte.d.ts +17 -0
  15. package/components/FlowPreview.svelte +46 -66
  16. package/components/FlowPreview.svelte.d.ts +2 -4
  17. package/components/FlowPreviewContent.svelte +59 -44
  18. package/components/FlowPreviewContent.svelte.d.ts +0 -1
  19. package/components/FlowStatusViewer.svelte +104 -204
  20. package/components/FlowStatusViewer.svelte.d.ts +7 -4
  21. package/components/FlowViewer.svelte +60 -156
  22. package/components/FlowViewer.svelte.d.ts +0 -1
  23. package/components/IconedPath.svelte +12 -0
  24. package/components/IconedPath.svelte.d.ts +16 -0
  25. package/components/IconedResourceType.svelte +24 -5
  26. package/components/IconedResourceType.svelte.d.ts +1 -0
  27. package/components/InputTransformForm.svelte +9 -8
  28. package/components/InputTransformForm.svelte.d.ts +1 -1
  29. package/components/InviteGlobalUser.svelte +1 -1
  30. package/components/ItemPicker.svelte +6 -1
  31. package/components/JobStatus.svelte +1 -1
  32. package/components/ModuleStep.svelte +74 -94
  33. package/components/ModuleStep.svelte.d.ts +7 -2
  34. package/components/Multiselect.svelte +1 -1
  35. package/components/Path.svelte +62 -40
  36. package/components/Path.svelte.d.ts +2 -0
  37. package/components/ProgressBar.svelte +31 -0
  38. package/components/ProgressBar.svelte.d.ts +17 -0
  39. package/components/ProgressBarPart.svelte +20 -0
  40. package/components/ProgressBarPart.svelte.d.ts +20 -0
  41. package/components/ResourceEditor.svelte +2 -1
  42. package/components/ResourcePicker.svelte +9 -0
  43. package/components/SchemaForm.svelte +9 -4
  44. package/components/SchemaForm.svelte.d.ts +1 -1
  45. package/components/SchemaModal.svelte +20 -3
  46. package/components/SchemaViewer.svelte +58 -68
  47. package/components/ScriptBuilder.svelte +145 -122
  48. package/components/ScriptBuilder.svelte.d.ts +1 -0
  49. package/components/ScriptEditor.svelte +118 -339
  50. package/components/ScriptEditor.svelte.d.ts +0 -2
  51. package/components/ScriptSchema.svelte +45 -44
  52. package/components/SharedBadge.svelte +8 -3
  53. package/components/VariableEditor.svelte +1 -1
  54. package/components/common/drawer/Drawer.svelte +108 -0
  55. package/components/common/drawer/Drawer.svelte.d.ts +23 -0
  56. package/components/common/drawer/DrawerContent.svelte +19 -0
  57. package/components/common/drawer/DrawerContent.svelte.d.ts +20 -0
  58. package/components/common/menu/Menu.svelte +57 -0
  59. package/components/common/menu/Menu.svelte.d.ts +23 -0
  60. package/components/common/menu/MenuItem.svelte +9 -0
  61. package/components/common/menu/MenuItem.svelte.d.ts +27 -0
  62. package/components/common/tabs/Tab.svelte +17 -0
  63. package/components/common/tabs/Tab.svelte.d.ts +18 -0
  64. package/components/common/tabs/TabContent.svelte +12 -0
  65. package/components/common/tabs/TabContent.svelte.d.ts +19 -0
  66. package/components/common/tabs/Tabs.svelte +20 -0
  67. package/components/common/tabs/Tabs.svelte.d.ts +24 -0
  68. package/components/flows/CopyFirstStepSchema.svelte +4 -3
  69. package/components/flows/DynamicInputHelpBox.svelte +6 -4
  70. package/components/flows/DynamicInputHelpBox.svelte.d.ts +1 -1
  71. package/components/flows/FlowBox.svelte +15 -2
  72. package/components/flows/FlowBox.svelte.d.ts +14 -14
  73. package/components/flows/FlowBoxHeader.svelte +10 -3
  74. package/components/flows/FlowBoxHeader.svelte.d.ts +3 -0
  75. package/components/flows/FlowInput.svelte +14 -12
  76. package/components/flows/FlowInputs.svelte +55 -35
  77. package/components/flows/FlowInputs.svelte.d.ts +3 -1
  78. package/components/flows/FlowModuleHeader.svelte +69 -54
  79. package/components/flows/FlowModuleHeader.svelte.d.ts +6 -6
  80. package/components/flows/FlowSettings.svelte +72 -91
  81. package/components/flows/FlowSettings.svelte.d.ts +0 -1
  82. package/components/flows/FlowTimeline.svelte +169 -0
  83. package/components/flows/FlowTimeline.svelte.d.ts +21 -0
  84. package/components/flows/flowState.d.ts +14 -0
  85. package/components/flows/flowState.js +52 -0
  86. package/components/flows/flowStateUtils.d.ts +37 -0
  87. package/components/flows/flowStateUtils.js +220 -0
  88. package/components/flows/flowStore.d.ts +1 -16
  89. package/components/flows/flowStore.js +26 -203
  90. package/components/flows/pickers/FlowScriptPicker.svelte +5 -9
  91. package/components/flows/pickers/FlowScriptPicker.svelte.d.ts +0 -1
  92. package/components/flows/pickers/PickHubScript.svelte +1 -1
  93. package/components/flows/pickers/PickHubScript.svelte.d.ts +1 -1
  94. package/components/flows/pickers/PickScript.svelte +1 -1
  95. package/components/flows/pickers/PickScript.svelte.d.ts +1 -1
  96. package/components/flows/scheduleUtils.d.ts +7 -0
  97. package/components/flows/scheduleUtils.js +21 -0
  98. package/components/flows/stepOpenedStore.d.ts +1 -0
  99. package/components/flows/stepOpenedStore.js +6 -0
  100. package/components/flows/utils.d.ts +6 -13
  101. package/components/flows/utils.js +47 -119
  102. package/components/icons/DiscordIcon.svelte +16 -0
  103. package/components/icons/DiscordIcon.svelte.d.ts +17 -0
  104. package/components/icons/GithubIcon.svelte +17 -0
  105. package/components/icons/GithubIcon.svelte.d.ts +17 -0
  106. package/components/icons/HttpIcon.svelte +21 -0
  107. package/components/icons/HttpIcon.svelte.d.ts +17 -0
  108. package/components/icons/MastodonIcon.svelte +16 -0
  109. package/components/icons/MastodonIcon.svelte.d.ts +17 -0
  110. package/components/icons/MatrixIcon.svelte +16 -0
  111. package/components/icons/MatrixIcon.svelte.d.ts +17 -0
  112. package/components/icons/S3Icon.svelte +16 -0
  113. package/components/icons/S3Icon.svelte.d.ts +17 -0
  114. package/components/icons/WindmillIcon.svelte +68 -0
  115. package/components/icons/WindmillIcon.svelte.d.ts +17 -0
  116. package/components/jobs/JobDetail.svelte +176 -0
  117. package/components/jobs/JobDetail.svelte.d.ts +17 -0
  118. package/components/landing/FlowGettingStarted.svelte +95 -0
  119. package/components/landing/FlowGettingStarted.svelte.d.ts +19 -0
  120. package/components/landing/FlowLandingBox.svelte +69 -0
  121. package/components/landing/FlowLandingBox.svelte.d.ts +17 -0
  122. package/components/landing/RessourceGettingStarted.svelte +51 -0
  123. package/components/landing/RessourceGettingStarted.svelte.d.ts +19 -0
  124. package/components/landing/ScriptBox.svelte +81 -0
  125. package/components/landing/ScriptBox.svelte.d.ts +17 -0
  126. package/components/landing/ScriptGettingStarted.svelte +93 -0
  127. package/components/landing/ScriptGettingStarted.svelte.d.ts +19 -0
  128. package/components/preview/FlowPreviewStatus.svelte +28 -0
  129. package/components/preview/FlowPreviewStatus.svelte.d.ts +17 -0
  130. package/components/propertyPicker/ObjectViewer.svelte +13 -13
  131. package/components/propertyPicker/utils.js +3 -2
  132. package/components/script_editor/LogPanel.svelte +172 -0
  133. package/components/script_editor/LogPanel.svelte.d.ts +22 -0
  134. package/components/sidebar/MenuLink.svelte +49 -0
  135. package/components/sidebar/MenuLink.svelte.d.ts +21 -0
  136. package/components/sidebar/SidebarContent.svelte +55 -0
  137. package/components/sidebar/SidebarContent.svelte.d.ts +16 -0
  138. package/components/sidebar/UserMenu.svelte +62 -0
  139. package/components/sidebar/UserMenu.svelte.d.ts +16 -0
  140. package/components/sidebar/WorkspaceMenu.svelte +66 -0
  141. package/components/sidebar/WorkspaceMenu.svelte.d.ts +16 -0
  142. package/gen/core/OpenAPI.js +1 -1
  143. package/gen/core/request.js +1 -0
  144. package/gen/models/FlowModule.d.ts +5 -3
  145. package/gen/models/ForloopFlow.d.ts +2 -2
  146. package/gen/models/MainArgSignature.d.ts +14 -3
  147. package/gen/services/JobService.d.ts +10 -2
  148. package/gen/services/JobService.js +4 -2
  149. package/gen/services/ScriptService.d.ts +22 -6
  150. package/gen/services/ScriptService.js +32 -2
  151. package/infer.js +47 -24
  152. package/logout.js +1 -1
  153. package/package.json +58 -23
  154. package/script_helpers.d.ts +4 -1
  155. package/script_helpers.js +68 -17
  156. package/stores.d.ts +0 -2
  157. package/stores.js +0 -4
  158. package/utils.d.ts +5 -2
  159. package/utils.js +36 -5
@@ -1,25 +1,27 @@
1
1
  <script>import { goto } from '$app/navigation';
2
2
  import { page } from '$app/stores';
3
3
  import { FlowService, ScheduleService } from '../gen';
4
- import { clearPreviewResults, previewResults, workspaceStore } from '../stores';
4
+ import { workspaceStore } from '../stores';
5
5
  import { encodeState, formatCron, loadHubScripts, pathIsEmpty, sendUserToast, setQueryWithoutLoad } from '../utils';
6
6
  import { faPlay } from '@fortawesome/free-solid-svg-icons';
7
7
  import { Breadcrumb, BreadcrumbItem, Button } from 'flowbite-svelte';
8
8
  import { onDestroy, onMount } from 'svelte';
9
9
  import Icon from 'svelte-awesome';
10
10
  import { OFFSET } from './CronInput.svelte';
11
+ import Drawer from './common/drawer/Drawer.svelte';
11
12
  import FlowEditor from './FlowEditor.svelte';
12
13
  import FlowPreviewContent from './FlowPreviewContent.svelte';
13
- import { flowStore, mode } from './flows/flowStore';
14
- import { flowToMode, jobsToResults } from './flows/utils';
14
+ import { flowStateStore, flowStateToFlow } from './flows/flowState';
15
+ import { flowStore } from './flows/flowStore';
16
+ import { cleanInputs } from './flows/utils';
15
17
  import ScriptSchema from './ScriptSchema.svelte';
16
18
  export let initialPath = '';
17
19
  let pathError = '';
18
- let scheduleArgs;
19
- let previewArgs;
20
- let scheduleEnabled;
21
- let scheduleCron;
22
20
  let previewOpen = false;
21
+ let scheduleArgs = {};
22
+ let previewArgs = {};
23
+ let scheduleEnabled = false;
24
+ let scheduleCron = '';
23
25
  $: step = Number($page.url.searchParams.get('step')) || 1;
24
26
  async function createSchedule(path) {
25
27
  await ScheduleService.createSchedule({
@@ -36,7 +38,7 @@ async function createSchedule(path) {
36
38
  });
37
39
  }
38
40
  async function saveFlow() {
39
- const flow = flowToMode($flowStore, $mode);
41
+ const flow = cleanInputs(flowStateToFlow($flowStateStore, $flowStore));
40
42
  if (initialPath === '') {
41
43
  await FlowService.createFlow({
42
44
  workspace: $workspaceStore,
@@ -48,7 +50,7 @@ async function saveFlow() {
48
50
  schema: flow.schema
49
51
  }
50
52
  });
51
- if ($mode == 'pull') {
53
+ if (scheduleEnabled) {
52
54
  await createSchedule(flow.path);
53
55
  }
54
56
  }
@@ -103,28 +105,36 @@ async function saveFlow() {
103
105
  goto(`/flows/get/${$flowStore.path}`);
104
106
  }
105
107
  async function changeStep(step) {
106
- if (step === 2 && previewOpen) {
107
- previewOpen = false;
108
- }
109
108
  goto(`?step=${step}`);
110
109
  }
110
+ flowStateStore.subscribe((flowState) => {
111
+ if (flowState) {
112
+ flowStore.update((flow) => {
113
+ if (flow) {
114
+ return flowStateToFlow(flowState, flow);
115
+ }
116
+ return flow;
117
+ });
118
+ }
119
+ });
111
120
  flowStore.subscribe((flow) => {
112
121
  if (flow) {
113
- setQueryWithoutLoad($page.url, 'state', encodeState(flowToMode(flow, $mode)));
122
+ setQueryWithoutLoad($page.url, 'state', encodeState(flow));
114
123
  }
115
124
  });
116
125
  onMount(() => {
117
126
  loadHubScripts();
118
- clearPreviewResults();
119
127
  });
120
128
  onDestroy(() => {
121
129
  //@ts-ignore
122
130
  $flowStore = undefined;
131
+ //@ts-ignore
132
+ $flowStateStore = undefined;
123
133
  });
124
134
  </script>
125
135
 
126
- <div class="flex flex-row w-full h-full justify-between">
127
- <div class={`flex flex-col mb-96 m-auto w-full sm:w-3/4 lg:w-2/3 xl:w-1/2`}>
136
+ <div class="flex flex-row w-full h-full justify-between ">
137
+ <div class={`flex flex-col mb-96 m-auto w-full`}>
128
138
  <!-- Nav between steps-->
129
139
  <div class="justify-between flex flex-row w-full my-4">
130
140
  <Breadcrumb>
@@ -157,6 +167,12 @@ onDestroy(() => {
157
167
  </button>
158
168
  {:else}
159
169
  <button class="default-button px-6 self-end" on:click={saveFlow}>Save</button>
170
+ <button
171
+ class="default-button-secondary px-6 max-h-8 mr-2"
172
+ on:click={async () => {
173
+ changeStep(1)
174
+ }}>Back</button
175
+ >
160
176
  {/if}
161
177
  </div>
162
178
  </div>
@@ -169,7 +185,7 @@ onDestroy(() => {
169
185
 
170
186
  <!-- metadata -->
171
187
 
172
- {#if $flowStore}
188
+ {#if $flowStateStore}
173
189
  {#if step === 1}
174
190
  <FlowEditor
175
191
  bind:pathError
@@ -203,20 +219,10 @@ onDestroy(() => {
203
219
  <p>Loading</p>
204
220
  {/if}
205
221
  </div>
206
-
207
- <div class={`relative h-screen w-1/3 ${previewOpen ? '' : 'hidden'}`}>
208
- <div class="absolute top-0 h-full">
209
- {#if $flowStore && step === 1}
210
- <div class="fixed border-l-2 right-0 h-screen w-1/2 sm:w-1/3">
211
- <FlowPreviewContent
212
- bind:args={previewArgs}
213
- on:close={() => (previewOpen = !previewOpen)}
214
- on:change={(e) => {
215
- previewResults.set(jobsToResults(e.detail))
216
- }}
217
- />
218
- </div>
219
- {/if}
220
- </div>
221
- </div>
222
222
  </div>
223
+
224
+ {#if $flowStateStore && $flowStore}
225
+ <Drawer bind:open={previewOpen} size="800px">
226
+ <FlowPreviewContent bind:args={previewArgs} on:close={() => (previewOpen = !previewOpen)} />
227
+ </Drawer>
228
+ {/if}
@@ -1,14 +1,9 @@
1
1
  <script>import { ScheduleService } from '../gen';
2
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';
6
- import Icon from 'svelte-awesome';
7
- import FlowInput from './flows/FlowInput.svelte';
8
3
  import FlowSettings from './flows/FlowSettings.svelte';
9
- import { addModule, flowStore, mode } from './flows/flowStore';
10
- import ModuleStep from './ModuleStep.svelte';
11
- import Tooltip from './Tooltip.svelte';
4
+ import { flowStateStore } from './flows/flowState';
5
+ import { flowStore } from './flows/flowStore';
6
+ import FlowTimeline from './flows/FlowTimeline.svelte';
12
7
  export let pathError = '';
13
8
  export let initialPath = '';
14
9
  export let scheduleArgs = {};
@@ -38,59 +33,23 @@ async function loadSchedule() {
38
33
  $: if ($flowStore && $workspaceStore && initialPath != '') {
39
34
  loadSchedule();
40
35
  }
41
- let open = 0;
42
36
  </script>
43
37
 
44
- {#if $flowStore}
45
- <div class="flex space-y-8 flex-col items-center line">
46
- <FlowSettings
47
- bind:pathError
48
- bind:initialPath
49
- bind:scheduleArgs
50
- {previewArgs}
51
- bind:scheduleCron
52
- bind:scheduleEnabled
53
- bind:open
54
- />
55
- <FlowInput />
56
- {#each $flowStore?.value.modules as mod, i}
57
- <ModuleStep bind:open bind:mod bind:args={previewArgs} {i} />
58
- {#if i == 0 && $mode == 'pull'}
59
- <div class="flex justify-center bg-white shadow p-2">
60
- <p>
61
- Starting from here, the flow for loop over items from the 1st step's result right above.
62
- &nbsp; <br />For-loops insertable at other points is not supported yet but coming soon
63
- (See
64
- <a href="https://github.com/windmill-labs/windmill/issues/350">#350</a>.)
65
- </p>
66
- <Tooltip>
67
- This flow being in 'Pull' mode, the rest of the flow will for loop over the list of
68
- items returned by the trigger script right above. Retrieve the item value using
69
- `flow_input._value`
70
- </Tooltip>
71
- </div>
72
- {/if}
73
- {/each}
74
- <Button
75
- disabled={pathIsEmpty($flowStore.path)}
76
- class="blue-button"
77
- on:click={() => {
78
- addModule()
79
- open = $flowStore?.value.modules.length - 1
80
- }}
81
- >
82
- <Icon class="text-white mr-2" data={faPlus} />
83
- Add step {pathIsEmpty($flowStore?.path) ? '(pick a name first!)' : ''}
84
- </Button>
38
+ {#if $flowStateStore}
39
+ <div class="flex space-y-8 flex-col items-center">
40
+ <FlowTimeline bind:args={previewArgs} bind:flowModuleSchemas={$flowStateStore}>
41
+ <div slot="settings">
42
+ <FlowSettings
43
+ bind:pathError
44
+ bind:initialPath
45
+ bind:scheduleArgs
46
+ {previewArgs}
47
+ bind:scheduleCron
48
+ bind:scheduleEnabled
49
+ />
50
+ </div>
51
+ </FlowTimeline>
85
52
  </div>
86
53
  {:else}
87
54
  <h3>Loading flow</h3>
88
55
  {/if}
89
-
90
- <style>
91
- .line {
92
- background-image: linear-gradient(#e5e7eb, #e5e7eb);
93
- background-size: 2px 100%;
94
- background-repeat: no-repeat;
95
- background-position: center center;
96
- }</style>
@@ -1,23 +1,23 @@
1
- <script>import ChevronButton from './ChevronButton.svelte';
2
- import DisplayResult from './DisplayResult.svelte';
1
+ <script>import DisplayResult from './DisplayResult.svelte';
2
+ import Tabs from './common/tabs/Tabs.svelte';
3
+ import Tab from './common/tabs/Tab.svelte';
4
+ import TabContent from './common/tabs/TabContent.svelte';
3
5
  export let job;
4
6
  </script>
5
7
 
6
8
  {#if job}
7
- <div class="flex flex-col ml-10">
8
- <div>
9
- <ChevronButton text="result" viewOptions={true}>
10
- <div class="text-xs">
11
- <DisplayResult result={job.result} />
12
- </div>
13
- </ChevronButton>
14
- </div>
15
- <div>
16
- <ChevronButton text="logs" viewOptions={true}>
17
- <div class="text-xs p-4 bg-gray-50 overflow-auto max-h-80 border mt-1">
9
+ <Tabs selected="results">
10
+ <Tab value="results">Results</Tab>
11
+ <Tab value="logs">Logs</Tab>
12
+ <svelte:fragment slot="content">
13
+ <TabContent value="results" class="border p-2 h-36 overflow-y-scroll">
14
+ <DisplayResult result={job.result} />
15
+ </TabContent>
16
+ <TabContent value="logs" class="border p-2 h-36 overflow-y-scroll">
17
+ <div class="text-xs p-4 bg-gray-50 overflow-auto max-h-80 border">
18
18
  <pre class="w-full">{job.logs}</pre>
19
19
  </div>
20
- </ChevronButton>
21
- </div>
22
- </div>
20
+ </TabContent>
21
+ </svelte:fragment>
22
+ </Tabs>
23
23
  {/if}
@@ -0,0 +1,97 @@
1
+ <script>import { scriptPathToHref } from '../utils';
2
+ import Highlight from 'svelte-highlight';
3
+ import python from 'svelte-highlight/languages/python';
4
+ import typescript from 'svelte-highlight/languages/typescript';
5
+ import { slide } from 'svelte/transition';
6
+ import InputTransformsViewer from './InputTransformsViewer.svelte';
7
+ import IconedPath from './IconedPath.svelte';
8
+ export let modules;
9
+ let open = {};
10
+ </script>
11
+
12
+ <p class="font-black text-lg my-6 w-full">
13
+ <span>{modules?.length} Step{modules?.length > 1 ? 's' : ''} </span>
14
+ <span class="mt-4" />
15
+ </p>
16
+ <ul class="-mb-8 w-full">
17
+ {#each modules ?? [] as mod, i}
18
+ <li class="w-full">
19
+ <div class="relative pb-8 w-full">
20
+ {#if i < (modules ?? []).length - 1}
21
+ <span class="absolute top-4 left-4 -ml-px h-full w-0.5 bg-gray-200" aria-hidden="true" />
22
+ {/if}
23
+ <div class="relative flex space-x-3">
24
+ <div>
25
+ <span
26
+ class="h-8 w-8 rounded-full bg-blue-600 flex items-center justify-center ring-8 ring-white text-white"
27
+ >{i + 1}
28
+ </span>
29
+ </div>
30
+ <div class="min-w-0 flex-1 pt-1.5 flex justify-between space-x-4 w-full">
31
+ <div class="w-full">
32
+ <span class="text-black">{mod?.summary ?? ''}</span>
33
+ <p class="text-sm text-gray-500">
34
+ {#if mod?.value?.type == 'script'}
35
+ <a
36
+ target="_blank"
37
+ href={scriptPathToHref(mod?.value?.path ?? '')}
38
+ class="font-medium text-gray-900"
39
+ >
40
+ <IconedPath path={mod?.value?.path ?? ''} />
41
+ </a>
42
+ {#if mod?.value?.path?.startsWith('hub/')}
43
+ <div>
44
+ <button
45
+ on:click={async () => {
46
+ open[i] = !open[i]
47
+ }}
48
+ class="mb-2 underline text-black"
49
+ >
50
+ View code and inputs {open[i] ? '(-)' : '(+)'}</button
51
+ >
52
+ {#if open[i]}
53
+ <div class="border border-black p-2 bg-gray-50 divide-y">
54
+ <InputTransformsViewer inputTransforms={mod?.input_transforms} />
55
+ <div class="w-full h-full mt-6">
56
+ <iframe
57
+ style="height: 400px;"
58
+ class="w-full h-full text-sm"
59
+ title="embedded script from hub"
60
+ frameborder="0"
61
+ src="https://hub.windmill.dev/embed/script/{mod?.value?.path?.substring(
62
+ 4
63
+ )}"
64
+ />
65
+ </div>
66
+ </div>
67
+ {/if}
68
+ </div>
69
+ {/if}
70
+ {:else if mod?.value?.type == 'rawscript'}
71
+ <button on:click={() => (open[i] = !open[i])} class="mb-2 underline text-black">
72
+ Raw {mod?.value?.language} script {open[i] ? '(-)' : '(+)'}</button
73
+ >
74
+
75
+ {#if open[i]}
76
+ <div transition:slide class="border border-black p-2 bg-gray-50 w-full">
77
+ <InputTransformsViewer inputTransforms={mod?.input_transforms} />
78
+ <Highlight
79
+ language={mod?.value?.language == 'deno' ? typescript : python}
80
+ code={mod?.value?.content}
81
+ />
82
+ </div>
83
+ {/if}
84
+ {:else if mod?.value?.type == 'flow'}
85
+ Flow at path {mod?.value?.path}
86
+ {:else if mod?.value?.type == 'forloopflow'}
87
+ For loop over all the elements of the list returned as a result of step {i}:
88
+ <svelte:self modules={mod.value.modules} />
89
+ {/if}
90
+ </p>
91
+ </div>
92
+ </div>
93
+ </div>
94
+ </div>
95
+ </li>
96
+ {/each}
97
+ </ul>
@@ -0,0 +1,17 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ import type { FlowModule } from '../gen';
3
+ declare const __propDef: {
4
+ props: {
5
+ modules: FlowModule[];
6
+ };
7
+ events: {
8
+ [evt: string]: CustomEvent<any>;
9
+ };
10
+ slots: {};
11
+ };
12
+ export declare type FlowModulesViewerProps = typeof __propDef.props;
13
+ export declare type FlowModulesViewerEvents = typeof __propDef.events;
14
+ export declare type FlowModulesViewerSlots = typeof __propDef.slots;
15
+ export default class FlowModulesViewer extends SvelteComponentTyped<FlowModulesViewerProps, FlowModulesViewerEvents, FlowModulesViewerSlots> {
16
+ }
17
+ export {};
@@ -1,35 +1,28 @@
1
- <script>import { Job, JobService } from '../gen';
2
- import { workspaceStore } from '../stores';
3
- import { sendUserToast, truncateRev } from '../utils';
1
+ <script>import { sendUserToast, truncateRev } from '../utils';
4
2
  import { faChevronDown, faChevronUp } from '@fortawesome/free-solid-svg-icons';
5
- import { createEventDispatcher, onDestroy } from 'svelte';
6
3
  import Icon from 'svelte-awesome';
7
- import FlowJobResult from './FlowJobResult.svelte';
4
+ import { flowStateStore, flowStateToFlow } from './flows/flowState';
5
+ import { mapJobResultsToFlowState } from './flows/flowStateUtils';
8
6
  import { runFlowPreview } from './flows/utils';
9
7
  import FlowStatusViewer from './FlowStatusViewer.svelte';
10
8
  import RunForm from './RunForm.svelte';
11
- import Tabs from './Tabs.svelte';
12
- const dispatch = createEventDispatcher();
9
+ import Tab from './common/tabs/Tab.svelte';
10
+ import TabContent from './common/tabs/TabContent.svelte';
11
+ import Tabs from './common/tabs/Tabs.svelte';
13
12
  export let i;
14
13
  export let flow;
15
- export let schemas = [];
14
+ export let schema;
16
15
  export let args = {};
17
16
  let stepArgs = {};
18
17
  let tab = 'upto';
19
18
  let viewPreview = false;
20
- let intervalId;
21
19
  let uptoText = i >= flow.value.modules.length - 1 ? 'Preview whole flow' : 'Preview up to this step';
22
- let job;
23
- let jobs = [];
24
20
  let jobId;
25
- $: dispatch('change', jobs);
26
21
  export async function runPreview(args) {
27
22
  viewPreview = true;
28
- intervalId && clearInterval(intervalId);
23
+ flow = flowStateToFlow($flowStateStore, flow);
29
24
  let newFlow = tab == 'upto' ? truncateFlow(flow) : setInputTransformFromArgs(extractStep(flow), args);
30
25
  jobId = await runFlowPreview(args, newFlow);
31
- jobs = [];
32
- intervalId = setInterval(loadJob, 1000);
33
26
  sendUserToast(`started preview ${truncateRev(jobId, 10)}`);
34
27
  }
35
28
  function truncateFlow(flow) {
@@ -40,35 +33,20 @@ function truncateFlow(flow) {
40
33
  function extractStep(flow) {
41
34
  const localFlow = JSON.parse(JSON.stringify(flow));
42
35
  localFlow.value.modules = flow.value.modules.slice(i, i + 1);
43
- localFlow.schema = schemas[i];
36
+ localFlow.schema = schema;
44
37
  return localFlow;
45
38
  }
46
39
  function setInputTransformFromArgs(flow, args) {
47
- let input_transform = {};
40
+ let input_transforms = {};
48
41
  Object.entries(args).forEach(([key, value]) => {
49
- input_transform[key] = {
42
+ input_transforms[key] = {
50
43
  type: 'static',
51
44
  value: value
52
45
  };
53
46
  });
54
- flow.value.modules[0].input_transform = input_transform;
47
+ flow.value.modules[0].input_transforms = input_transforms;
55
48
  return flow;
56
49
  }
57
- async function loadJob() {
58
- try {
59
- job = await JobService.getJob({ workspace: $workspaceStore, id: jobId });
60
- if (job?.type == 'CompletedJob') {
61
- //only CompletedJob has success property
62
- clearInterval(intervalId);
63
- }
64
- }
65
- catch (err) {
66
- sendUserToast(err, true);
67
- }
68
- }
69
- onDestroy(() => {
70
- intervalId && clearInterval(intervalId);
71
- });
72
50
  </script>
73
51
 
74
52
  <button
@@ -87,41 +65,43 @@ onDestroy(() => {
87
65
 
88
66
  {#if viewPreview}
89
67
  {#if i != flow.value.modules.length}
90
- <Tabs
91
- tabs={[
92
- ['upto', uptoText],
93
- ['justthis', 'preview just this step']
94
- ]}
95
- bind:tab
96
- />
97
- {/if}
98
- <div class="my-2" />
99
- {#if tab == 'upto'}
100
- <RunForm
101
- runnable={truncateFlow(flow)}
102
- runAction={(_, args) => runPreview(args)}
103
- schedulable={false}
104
- buttonText={uptoText}
105
- detailed={false}
106
- bind:args
107
- />
108
- {:else}
109
- <RunForm
110
- runnable={extractStep(flow)}
111
- runAction={(_, args) => runPreview(args)}
112
- schedulable={false}
113
- buttonText="Preview just this step"
114
- detailed={false}
115
- args={stepArgs}
116
- />
68
+ <div class="mt-2">
69
+ <Tabs bind:selected={tab}>
70
+ <Tab value="upto">{uptoText}</Tab>
71
+ <Tab value="justthis">Preview just this step</Tab>
72
+ <svelte:fragment slot="content">
73
+ <TabContent value="upto">
74
+ <RunForm
75
+ runnable={truncateFlow(flow)}
76
+ runAction={(_, args) => runPreview(args)}
77
+ schedulable={false}
78
+ buttonText={uptoText}
79
+ detailed={false}
80
+ bind:args
81
+ />
82
+ </TabContent>
83
+ <TabContent value="justthis">
84
+ <RunForm
85
+ runnable={extractStep(flow)}
86
+ runAction={(_, args) => runPreview(args)}
87
+ schedulable={false}
88
+ buttonText="Preview just this step"
89
+ detailed={false}
90
+ args={stepArgs}
91
+ />
92
+ </TabContent>
93
+ </svelte:fragment>
94
+ </Tabs>
95
+ </div>
117
96
  {/if}
118
97
 
119
- {#if job}
98
+ {#if jobId}
120
99
  <div class="w-full flex justify-center">
121
- <FlowStatusViewer {job} bind:jobs />
100
+ <FlowStatusViewer
101
+ {jobId}
102
+ on:jobsLoaded={(e) => mapJobResultsToFlowState(e.detail, tab, i)}
103
+ root={true}
104
+ />
122
105
  </div>
123
- {#if `result` in job}
124
- <FlowJobResult {job} />
125
- {/if}
126
106
  {/if}
127
107
  {/if}
@@ -1,17 +1,15 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
2
  import type { Schema } from '../common';
3
- import { type Flow } from '../gen';
3
+ import type { Flow } from '../gen';
4
4
  declare const __propDef: {
5
5
  props: {
6
6
  i: number;
7
7
  flow: Flow;
8
- schemas?: Schema[] | undefined;
8
+ schema: Schema;
9
9
  args?: Record<string, any> | undefined;
10
10
  runPreview?: ((args: any) => Promise<void>) | undefined;
11
11
  };
12
12
  events: {
13
- change: CustomEvent<any>;
14
- } & {
15
13
  [evt: string]: CustomEvent<any>;
16
14
  };
17
15
  slots: {};