windmill-components 1.21.0 → 1.22.0

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.
@@ -274,9 +274,7 @@ export let inputCat = computeInputCat(type, format, itemsType?.type, enum_, cont
274
274
  {disabled}
275
275
  class="default-button-secondary items-center leading-4 py-0 my-px px-1 float-right"
276
276
  on:click={() => (value = undefined)}
277
- >Reset<Tooltip class="pl-1" position={'above'} direction={'left'}
278
- >Reset to default value
279
- </Tooltip></button
277
+ >Reset<Tooltip>Reset to default value</Tooltip></button
280
278
  >
281
279
  </div>
282
280
  {/if}
@@ -3,7 +3,9 @@ import { page } from '$app/stores';
3
3
  import { FlowService, ScriptService } from '../gen';
4
4
  import { clearPreviewResults, hubScripts, workspaceStore } from '../stores';
5
5
  import { sendUserToast, setQueryWithoutLoad } from '../utils';
6
+ import { faFileExport, faFileImport } from '@fortawesome/free-solid-svg-icons';
6
7
  import { onMount } from 'svelte';
8
+ import Icon from 'svelte-awesome';
7
9
  import FlowEditor from './FlowEditor.svelte';
8
10
  import { flowStore } from './flows/flowStore';
9
11
  import { flowToMode } from './flows/utils';
@@ -1,5 +1,5 @@
1
1
  <script>import { FlowModuleValue } from '../gen';
2
- import { faPlus } from '@fortawesome/free-solid-svg-icons';
2
+ import { faFileExport, faFileImport, faGlobe, faPlus } from '@fortawesome/free-solid-svg-icons';
3
3
  import Icon from 'svelte-awesome';
4
4
  import FlowPreview from './FlowPreview.svelte';
5
5
  import CopyFirstStepSchema from './flows/CopyFirstStepSchema.svelte';
@@ -9,15 +9,51 @@ import Path from './Path.svelte';
9
9
  import RadioButtonV2 from './RadioButtonV2.svelte';
10
10
  import SchemaEditor from './SchemaEditor.svelte';
11
11
  import Required from './Required.svelte';
12
- import { pathIsEmpty } from '../utils';
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';
13
18
  export let pathError = '';
14
19
  export let initialPath = '';
20
+ let jsonSetter;
21
+ let jsonViewer;
22
+ let jsonValue = '';
15
23
  let open = 0;
16
24
  let args = {};
17
25
  export let mode = $flowStore?.value.modules[1]?.value.type == FlowModuleValue.type.FORLOOPFLOW ? 'pull' : 'push';
18
26
  $: numberOfSteps = $flowStore?.value.modules.length - 1;
19
27
  </script>
20
28
 
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"
37
+ on:click={() => {
38
+ Object.assign($flowStore, JSON.parse(jsonValue))
39
+ $flowStore = $flowStore
40
+ open = -1
41
+ sendUserToast('Flow imported from JSON')
42
+ jsonSetter.closeModal()
43
+ }}
44
+ >
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" />
54
+ </div>
55
+ </Modal>
56
+
21
57
  <div class="flow-root bg-gray-50 rounded-xl border border-gray-200">
22
58
  <ul class="relative -mt-10">
23
59
  <span class="absolute top-0 left-1/2 h-full w-1 bg-gray-400" aria-hidden="true" />
@@ -26,15 +62,51 @@ $: numberOfSteps = $flowStore?.value.modules.length - 1;
26
62
  <div
27
63
  class="bg-white border border-gray xl-rounded shadow-lg w-full max-w-4xl mx-4 md:mx-auto p-4"
28
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>
29
101
  <div class="mb-8 p-4">
30
102
  <Path
31
103
  bind:error={pathError}
32
104
  bind:path={$flowStore.path}
33
105
  {initialPath}
34
- namePlaceholder="example/my/flow"
106
+ namePlaceholder="my_flow"
35
107
  kind="flow"
36
108
  >
37
- <div slot="ownerToolkit" class="text-gray-700 text-2xs">
109
+ <div slot="ownerToolkit">
38
110
  Flow permissions depend on their path. Select the group <span class="font-mono"
39
111
  >all</span
40
112
  >
@@ -8,6 +8,12 @@ import github from 'svelte-highlight/styles/github';
8
8
  import { slide } from 'svelte/transition';
9
9
  import Tabs from './Tabs.svelte';
10
10
  export let flow;
11
+ let flowFiltered = {
12
+ summary: flow.summary,
13
+ description: flow.description,
14
+ value: flow.value,
15
+ schema: flow.schema
16
+ };
11
17
  export let embedded = false;
12
18
  export let tab = 'ui';
13
19
  let open = {};
@@ -90,5 +96,5 @@ let open = {};
90
96
  </ul>
91
97
  </div>
92
98
  {:else}
93
- <Highlight language={json} code={JSON.stringify(flow.value, null, 4)} />
99
+ <Highlight language={json} code={JSON.stringify(flowFiltered, null, 4)} />
94
100
  {/if}
@@ -1,8 +1,13 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
- import { type Flow } from '../gen';
2
+ import { type FlowValue } from '../gen';
3
3
  declare const __propDef: {
4
4
  props: {
5
- flow: Flow;
5
+ flow: {
6
+ summary: string;
7
+ description?: string;
8
+ value: FlowValue;
9
+ schema?: any;
10
+ };
6
11
  embedded?: boolean | undefined;
7
12
  tab?: "json" | "ui" | undefined;
8
13
  };
@@ -3,10 +3,12 @@ export let open = false;
3
3
  export let z = 'z-30';
4
4
  const dispatch = createEventDispatcher();
5
5
  export function closeModal() {
6
+ document.body.style.overflow = 'auto';
6
7
  open = false;
7
8
  dispatch('close');
8
9
  }
9
10
  export function openModal() {
11
+ document.body.style.overflow = 'hidden';
10
12
  open = true;
11
13
  dispatch('open');
12
14
  }
@@ -23,9 +25,9 @@ function handleKeyUp(event) {
23
25
 
24
26
  <svelte:window on:keyup={handleKeyUp} />
25
27
 
26
- <div class="blurred-background z-0 {open ? '' : 'hidden'}" />
28
+ <div class="blurred-background {open ? '' : 'hidden'}" />
27
29
 
28
- <div class="fixed top-0 w-screen h-screen {open ? '' : 'hidden'} {z}">
30
+ <div class="fixed top-0 w-screen h-screen {open ? '' : 'hidden'} {z}">
29
31
  <div
30
32
  class="fixed right-0 flex flex-col w-3/4 sm:w-2/3 lg:w-1/2 h-screen border border-gray-300 shadow-xl"
31
33
  >
@@ -90,5 +92,5 @@ function handleKeyUp(event) {
90
92
  <style>
91
93
  .blurred-background {
92
94
  /* @apply absolute sm:top-6 lg:top-8 left-28 sm:left-40 md:left-48; */ /* If we wanted to make the navbars visible */ position: fixed; top: 0px; left: 0px; --tw-bg-opacity: 1; background-color: rgb(156 163 175 / var(--tw-bg-opacity)); opacity: 0.75; width: 100vw; height: 100vh;
93
- z-index: 1;
95
+ z-index: 10;
94
96
  }</style>
@@ -9,6 +9,7 @@ import FlowInputs from './flows/FlowInputs.svelte';
9
9
  import FlowModuleHeader from './flows/FlowModuleHeader.svelte';
10
10
  import { createInlineScriptModule, flowStore, loadSchema, pickScript, schemasStore } from './flows/flowStore';
11
11
  import SchemaForm from './SchemaForm.svelte';
12
+ import Tooltip from './Tooltip.svelte';
12
13
  export let open;
13
14
  export let mode;
14
15
  export let i;
@@ -29,6 +30,17 @@ $: extraLib = buildExtraLib(i === 0 ? schemaToTsType($flowStore?.schema) : objec
29
30
  <FlowModuleHeader bind:open {mod} {i} {shouldPick}>
30
31
  <div>
31
32
  <h3 class="text-lg font-bold text-gray-900">Step {i + 1}</h3>
33
+ {#if i == 0 && mode == 'pull'}
34
+ <h3 class="font-bold">
35
+ Trigger Script <Tooltip
36
+ >When a flow is 'Pull', the first step is a trigger script. Trigger scripts are
37
+ scripts that must return a list which are the new items to be treated one by one by
38
+ the rest of the flow, usually the list of new items since last time the flow was
39
+ run. One can retrieve the item in the next step using `previous_result._value`. To
40
+ easily compute the diff, windmill provides some helpers under the form of
41
+ `getInternalState` and `setInternalState`.</Tooltip
42
+ >
43
+ </h3>{/if}
32
44
  <p>
33
45
  {#if mod.value.path}
34
46
  {mod.value.path}
@@ -105,3 +117,14 @@ $: extraLib = buildExtraLib(i === 0 ? schemaToTsType($flowStore?.schema) : objec
105
117
  {/if}
106
118
  </div>
107
119
  </li>
120
+ {#if i == 0 && mode == 'pull'}
121
+ <li class="relative m-20 ">
122
+ <div class="relative flex justify-center bg-white shadow p-2">
123
+ Starting from here, the flow for loop over items from step 1's result above &nbsp;<Tooltip
124
+ >This flow being in 'Pull' mode, the rest of the flow will for loop over the list of items
125
+ returned by the trigger script right above. Retrieve the item value using
126
+ `previous_result._value`</Tooltip
127
+ >
128
+ </div>
129
+ </li>
130
+ {/if}
@@ -114,8 +114,8 @@ $: {
114
114
  <div>
115
115
  <div class="flex flex-col sm:grid sm:grid-cols-4 sm:gap-4 pb-0 mb-1">
116
116
  <label class="block">
117
- <span class="text-gray-700 text-sm">
118
- Owner Kind<Tooltip class="mx-1">
117
+ <span class="text-gray-700 text-sm whitespace-nowrap">
118
+ Owner Kind <Tooltip>
119
119
  <slot name="ownerToolkit" />
120
120
  </Tooltip>
121
121
  </span>
@@ -1,38 +1,33 @@
1
1
  <script>export let options;
2
2
  export let value;
3
3
  import { createEventDispatcher } from 'svelte';
4
+ import Tooltip from './Tooltip.svelte';
4
5
  $: dispatch('change', value);
5
6
  const dispatch = createEventDispatcher();
6
7
  </script>
7
8
 
8
- <div class="flex flex-row space-x-4 m-4 reveal">
9
+ <div class="flex flex-row gap-x-4 m-4 reveal flex-wrap ">
9
10
  {#each options as [label, val]}
10
11
  <button
11
12
  type="button"
12
13
  on:click={() => {
13
14
  value = val
14
15
  }}
15
- class="flex flex-col default-secondary-button-v2 mb-2 w-full"
16
+ class="flex flex-col default-secondary-button-v2 mb-2 grow"
16
17
  class:selected={value == val}
17
18
  >
18
- <h2 class="mb-2">{label.title}</h2>
19
- <p class="hidden">
20
- {label.desc}
21
- </p>
19
+ <h2 class="mb-2 whitespace-nowrap">{label.title} <Tooltip>{label.desc}</Tooltip></h2>
22
20
  </button>
23
21
  {/each}
24
22
  </div>
25
23
 
26
24
  <style>
27
- .reveal:hover > button > p {
28
- display: block;
29
- }
30
25
  .selected {
31
- background-color: rgb(59 130 246 / 0.7);
32
- --tw-text-opacity: 1;
33
- color: rgb(255 255 255 / var(--tw-text-opacity));
26
+ background-color: rgb(59 130 246 / 0.7);
27
+ --tw-text-opacity: 1;
28
+ color: rgb(255 255 255 / var(--tw-text-opacity))
34
29
  }
35
30
  .selected > h2 {
36
- --tw-text-opacity: 1;
37
- color: rgb(255 255 255 / var(--tw-text-opacity));
31
+ --tw-text-opacity: 1;
32
+ color: rgb(255 255 255 / var(--tw-text-opacity))
38
33
  }</style>
@@ -118,7 +118,7 @@ $: isValid = allTrue(inputCheck) ?? false;
118
118
  namePlaceholder="my/resource"
119
119
  kind="resource"
120
120
  >
121
- <div slot="ownerToolkit" class="text-gray-700 text-2xs">
121
+ <div slot="ownerToolkit">
122
122
  Resource permissions depend on their path. Select the group <span class="font-mono"
123
123
  >all</span
124
124
  >
@@ -156,7 +156,7 @@ onDestroy(() => {
156
156
  namePlaceholder="example/my/script"
157
157
  kind="script"
158
158
  >
159
- <div slot="ownerToolkit" class="text-gray-700 text-2xs">
159
+ <div slot="ownerToolkit">
160
160
  Script permissions depend on their path. Select the group <span class="font-mono"
161
161
  >all</span
162
162
  >
@@ -1,93 +1,66 @@
1
1
  <script>import Icon from 'svelte-awesome';
2
2
  import { faInfoCircle } from '@fortawesome/free-solid-svg-icons';
3
+ import { createPopperActions } from 'svelte-popperjs';
3
4
  import { fade } from 'svelte/transition';
4
- export let position = 'above';
5
- export let direction = 'default';
6
- let viewTooltip = false;
7
- let mouseOnMessage = false;
8
- let mouseOver = false;
9
- // This function makes sure the tooltip does not disappear when moving the mouse to the tooltip
10
- // message, so that users can click links there for example
11
- function hideTooltip() {
12
- setTimeout(function () {
13
- if (!mouseOnMessage && !mouseOver) {
14
- viewTooltip = false;
5
+ const [popperRef, popperContent] = createPopperActions({
6
+ placement: 'auto'
7
+ });
8
+ const betterPreventOverflow = (options) => ({
9
+ name: 'preventOverflow',
10
+ options,
11
+ effect: ({ state }) => {
12
+ const { padding = 0 } = options;
13
+ state.elements.popper.style.maxWidth = `calc(100vw - ${padding * 2}px)`;
14
+ }
15
+ });
16
+ const extraOpts = {
17
+ modifiers: [
18
+ betterPreventOverflow({ padding: 50 }),
19
+ { name: 'offset', options: { offset: [8, 8] } },
20
+ {
21
+ name: 'arrow',
22
+ options: {
23
+ padding: 10 // 5px from the edges of the popper
24
+ }
15
25
  }
16
- else {
17
- hideTooltip();
18
- }
19
- }, 300);
26
+ ]
27
+ };
28
+ let showTooltip = false;
29
+ let timeout;
30
+ function open() {
31
+ clearTimeout(timeout);
32
+ showTooltip = true;
33
+ }
34
+ function close() {
35
+ timeout = setTimeout(() => (showTooltip = false), 200);
20
36
  }
21
37
  </script>
22
38
 
23
- <div class="inline-block has-tooltip {$$props.class}">
24
- {#if viewTooltip}
25
- <span
26
- transition:fade
27
- class="tooltip rounded shadow-lg p-1 leading-4 {position === 'above' ? '-mt-8' : 'mt-6'}
28
- {viewTooltip ? 'tooltip-visible' : 'tooltip'} {direction === 'left' ? 'right-0' : ''}
29
- text-2xs text-gray-700"
30
- on:mouseover={() => {
31
- mouseOnMessage = true
32
- }}
33
- on:focus={() => {}}
34
- on:mouseout={() => {
35
- mouseOnMessage = false
36
- }}
37
- on:blur={() => {}}
38
- ><slot />
39
- </span>
40
- {/if}
41
- <Icon class="text-gray-500 font-thin inline-block align-middle" data={faInfoCircle} scale={0.6} />
42
- <!-- Hovering on this (invisible) area triggers the apparition of the tooltip. Needed because the icon is too small-->
39
+ <button use:popperRef on:mouseenter={open} on:mouseleave={close}>
40
+ <Icon class="text-gray-500 font-thin inline-block align-middle" data={faInfoCircle} scale={0.8} />
41
+ </button>
42
+ {#if showTooltip}
43
43
  <div
44
- class="relative w-4 h-5 -mt-5 -ml-1"
45
- on:mouseover={() => {
46
- viewTooltip = true
47
- mouseOver = true
48
- }}
49
- on:focus={() => {
50
- viewTooltip = true
51
- }}
52
- on:mouseout={() => {
53
- hideTooltip()
54
- mouseOver = false
55
- }}
56
- on:blur={() => {}}
57
- />
58
- </div>
44
+ transition:fade
45
+ id="tooltip"
46
+ use:popperContent={extraOpts}
47
+ on:mouseenter={open}
48
+ on:mouseleave={close}
49
+ >
50
+ <slot />
51
+ <div id="arrow" data-popper-arrow />
52
+ </div>
53
+ {/if}
59
54
 
60
55
  <style>
61
- .tooltip {
62
-
63
- visibility: hidden;
64
-
65
- position: absolute;
66
-
67
- transition-property: opacity;
68
-
69
- transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
70
-
71
- transition-duration: 100ms
72
- }
73
-
74
- .tooltip-visible {
75
-
76
- visibility: visible;
77
-
78
- position: absolute;
79
-
56
+ #tooltip {
80
57
  z-index: 50;
81
-
58
+ white-space: normal;
59
+ border-radius: 0.75rem;
82
60
  --tw-bg-opacity: 1;
83
-
84
- background-color: rgb(255 255 255 / var(--tw-bg-opacity));
85
-
86
- max-width: 24rem;
87
-
88
- transition-property: opacity;
89
-
90
- transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
91
-
92
- transition-duration: 150ms
61
+ background-color: rgb(39 39 42 / var(--tw-bg-opacity));
62
+ padding: 1rem;
63
+ font-weight: 400;
64
+ --tw-text-opacity: 1;
65
+ color: rgb(209 213 219 / var(--tw-text-opacity))
93
66
  }</style>
@@ -1,10 +1,6 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
2
  declare const __propDef: {
3
- props: {
4
- [x: string]: any;
5
- position?: ("above" | "below") | undefined;
6
- direction?: ("default" | "left") | undefined;
7
- };
3
+ props: {};
8
4
  events: {
9
5
  [evt: string]: CustomEvent<any>;
10
6
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "windmill-components",
3
- "version": "1.21.0",
3
+ "version": "1.22.0",
4
4
  "devDependencies": {
5
5
  "@playwright/test": "^1.23.4",
6
6
  "@sveltejs/adapter-static": "^1.0.0-next.37",
@@ -29,6 +29,7 @@
29
29
  "svelte-highlight": "^6.2.0",
30
30
  "svelte-markdown": "^0.2.1",
31
31
  "svelte-overlay": "^1.4.1",
32
+ "svelte-popperjs": "^1.2.11",
32
33
  "svelte-preprocess": "^4.9.8",
33
34
  "svelte-split-pane": "^0.1.2",
34
35
  "svelte2tsx": "^0.5.11",