windmill-components 1.352.4 → 1.352.6
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.
- package/package/components/EditableSchemaForm.svelte +42 -40
- package/package/components/EditableSchemaForm.svelte.d.ts +1 -0
- package/package/components/EditorBar.svelte +2 -2
- package/package/components/ResourceEditor.svelte +138 -141
- package/package/components/ResourceEditor.svelte.d.ts +9 -2
- package/package/components/ResourceEditorDrawer.svelte +45 -0
- package/package/components/ResourceEditorDrawer.svelte.d.ts +21 -0
- package/package/components/ResourcePicker.svelte +2 -2
- package/package.json +22 -1
|
@@ -231,48 +231,50 @@ let editor = undefined;
|
|
|
231
231
|
<div class="flex flex-row gap-2">
|
|
232
232
|
{argName}
|
|
233
233
|
{#if !uiOnly}
|
|
234
|
-
<
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
<
|
|
241
|
-
color="light"
|
|
242
|
-
size="xs2"
|
|
243
|
-
nonCaptureEvent
|
|
244
|
-
startIcon={{ icon: Pen }}
|
|
245
|
-
iconOnly
|
|
246
|
-
/>
|
|
247
|
-
</svelte:fragment>
|
|
248
|
-
<Label label="Name">
|
|
249
|
-
<div class="flex flex-col gap-2">
|
|
250
|
-
<input
|
|
251
|
-
type="text"
|
|
252
|
-
class="w-full !bg-surface"
|
|
253
|
-
value={argName}
|
|
254
|
-
id={argName + i}
|
|
255
|
-
on:keydown={(event) => {
|
|
256
|
-
if (event.key === 'Enter') {
|
|
257
|
-
renameProperty(argName, argName + i)
|
|
258
|
-
close(null)
|
|
259
|
-
}
|
|
260
|
-
}}
|
|
261
|
-
/>
|
|
234
|
+
<div on:click|stopPropagation|preventDefault>
|
|
235
|
+
<Popup
|
|
236
|
+
floatingConfig={{ strategy: 'absolute', placement: 'bottom-end' }}
|
|
237
|
+
containerClasses="border rounded-lg shadow-lg p-4 bg-surface"
|
|
238
|
+
let:close
|
|
239
|
+
>
|
|
240
|
+
<svelte:fragment slot="button">
|
|
262
241
|
<Button
|
|
263
|
-
variant="border"
|
|
264
242
|
color="light"
|
|
265
|
-
size="
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
243
|
+
size="xs2"
|
|
244
|
+
nonCaptureEvent
|
|
245
|
+
startIcon={{ icon: Pen }}
|
|
246
|
+
iconOnly
|
|
247
|
+
/>
|
|
248
|
+
</svelte:fragment>
|
|
249
|
+
<Label label="Name">
|
|
250
|
+
<div class="flex flex-col gap-2">
|
|
251
|
+
<input
|
|
252
|
+
type="text"
|
|
253
|
+
class="w-full !bg-surface"
|
|
254
|
+
value={argName}
|
|
255
|
+
id={argName + i}
|
|
256
|
+
on:keydown={(event) => {
|
|
257
|
+
if (event.key === 'Enter') {
|
|
258
|
+
renameProperty(argName, argName + i)
|
|
259
|
+
close(null)
|
|
260
|
+
}
|
|
261
|
+
}}
|
|
262
|
+
/>
|
|
263
|
+
<Button
|
|
264
|
+
variant="border"
|
|
265
|
+
color="light"
|
|
266
|
+
size="xs"
|
|
267
|
+
on:click={() => {
|
|
268
|
+
renameProperty(argName, argName + i)
|
|
269
|
+
close(null)
|
|
270
|
+
}}
|
|
271
|
+
>
|
|
272
|
+
Rename
|
|
273
|
+
</Button>
|
|
274
|
+
</div>
|
|
275
|
+
</Label>
|
|
276
|
+
</Popup>
|
|
277
|
+
</div>
|
|
276
278
|
{/if}
|
|
277
279
|
</div>
|
|
278
280
|
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
<script>import { ResourceService, VariableService } from '../gen';
|
|
5
5
|
import { workspaceStore } from '../stores';
|
|
6
6
|
import ItemPicker from './ItemPicker.svelte';
|
|
7
|
-
import ResourceEditor from './ResourceEditor.svelte';
|
|
8
7
|
import VariableEditor from './VariableEditor.svelte';
|
|
9
8
|
import Button from './common/button/Button.svelte';
|
|
10
9
|
import HighlightCode from './HighlightCode.svelte';
|
|
@@ -27,6 +26,7 @@ import ScriptGen from './copilot/ScriptGen.svelte';
|
|
|
27
26
|
import { getResetCode } from '../script_helpers';
|
|
28
27
|
import CodeCompletionStatus from './copilot/CodeCompletionStatus.svelte';
|
|
29
28
|
import Popover from './Popover.svelte';
|
|
29
|
+
import ResourceEditorDrawer from './ResourceEditorDrawer.svelte';
|
|
30
30
|
export let lang;
|
|
31
31
|
export let editor;
|
|
32
32
|
export let websocketAlive;
|
|
@@ -470,7 +470,7 @@ $res = json_decode(curl_exec($ch));`)
|
|
|
470
470
|
await ResourceService.listResourceType({ workspace: $workspaceStore ?? 'NO_W' })}
|
|
471
471
|
/>
|
|
472
472
|
{/if}
|
|
473
|
-
<
|
|
473
|
+
<ResourceEditorDrawer bind:this={resourceEditor} on:refresh={resourcePicker.openDrawer} />
|
|
474
474
|
<VariableEditor bind:this={variableEditor} on:create={variablePicker.openDrawer} />
|
|
475
475
|
|
|
476
476
|
<div class="flex justify-between items-center overflow-y-auto w-full p-0.5">
|
|
@@ -1,58 +1,66 @@
|
|
|
1
1
|
<script>import { ResourceService } from '../gen';
|
|
2
2
|
import { canWrite, emptyString, isOwner, urlize } from '../utils';
|
|
3
3
|
import { createEventDispatcher } from 'svelte';
|
|
4
|
-
import { Alert,
|
|
4
|
+
import { Alert, Skeleton } from './common';
|
|
5
5
|
import Path from './Path.svelte';
|
|
6
6
|
import Required from './Required.svelte';
|
|
7
7
|
import { userStore, workspaceStore } from '../stores';
|
|
8
|
-
import DrawerContent from './common/drawer/DrawerContent.svelte';
|
|
9
8
|
import SchemaForm from './SchemaForm.svelte';
|
|
10
9
|
import SimpleEditor from './SimpleEditor.svelte';
|
|
11
10
|
import Toggle from './Toggle.svelte';
|
|
12
11
|
import { sendUserToast } from '../toast';
|
|
13
12
|
import TestConnection from './TestConnection.svelte';
|
|
14
|
-
import { Pen
|
|
13
|
+
import { Pen } from 'lucide-svelte';
|
|
15
14
|
import Markdown from 'svelte-exmarkdown';
|
|
16
15
|
import autosize from '../autosize';
|
|
17
16
|
import GfmMarkdown from './GfmMarkdown.svelte';
|
|
18
|
-
let
|
|
19
|
-
let
|
|
20
|
-
let
|
|
17
|
+
export let canSave = true;
|
|
18
|
+
export let resource_type = undefined;
|
|
19
|
+
export let path = '';
|
|
20
|
+
export let newResource = false;
|
|
21
|
+
export let hidePath = false;
|
|
22
|
+
let isValid = true;
|
|
23
|
+
let jsonError = '';
|
|
24
|
+
let can_write = true;
|
|
25
|
+
$: canSave = can_write && isValid && jsonError == '';
|
|
26
|
+
let initialPath = path;
|
|
27
|
+
let resourceToEdit = undefined;
|
|
21
28
|
let description = '';
|
|
22
29
|
let DESCRIPTION_PLACEHOLDER = `Describe what this resource is for`;
|
|
23
|
-
let
|
|
24
|
-
let resourceSchema;
|
|
30
|
+
let resourceSchema = undefined;
|
|
25
31
|
let args = {};
|
|
26
|
-
let
|
|
27
|
-
let loadingSchema = false;
|
|
32
|
+
let loadingSchema = true;
|
|
28
33
|
let linkedVars = [];
|
|
29
|
-
let drawer;
|
|
30
34
|
let resourceTypeInfo = undefined;
|
|
31
|
-
let
|
|
35
|
+
let editDescription = false;
|
|
36
|
+
let viewJsonSchema = false;
|
|
32
37
|
let rawCode = undefined;
|
|
33
38
|
const dispatch = createEventDispatcher();
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
path = p;
|
|
37
|
-
resourceToEdit = undefined;
|
|
38
|
-
resourceSchema = undefined;
|
|
39
|
-
viewJsonSchema = false;
|
|
40
|
-
loadingSchema = true;
|
|
41
|
-
drawer.openDrawer?.();
|
|
42
|
-
resourceToEdit = await ResourceService.getResource({ workspace: $workspaceStore, path: p });
|
|
39
|
+
async function initEdit() {
|
|
40
|
+
resourceToEdit = await ResourceService.getResource({ workspace: $workspaceStore, path });
|
|
43
41
|
description = resourceToEdit.description ?? '';
|
|
44
|
-
|
|
42
|
+
resource_type = resourceToEdit.resource_type;
|
|
43
|
+
args = resourceToEdit?.value ?? {};
|
|
45
44
|
loadResourceType();
|
|
46
|
-
args = resourceToEdit.value;
|
|
47
45
|
can_write =
|
|
48
46
|
resourceToEdit.workspace_id == $workspaceStore &&
|
|
49
|
-
canWrite(
|
|
47
|
+
canWrite(path, resourceToEdit.extra_perms ?? {}, $userStore);
|
|
50
48
|
linkedVars = Object.entries(args)
|
|
51
49
|
.filter(([_, v]) => typeof v == 'string' && v == `$var:${initialPath}`)
|
|
52
50
|
.map(([k, _]) => k);
|
|
53
|
-
renderDescription = false;
|
|
54
51
|
}
|
|
55
|
-
|
|
52
|
+
if (!newResource) {
|
|
53
|
+
initEdit();
|
|
54
|
+
}
|
|
55
|
+
else if (resource_type) {
|
|
56
|
+
loadResourceType();
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
sendUserToast('Resource type cannot be undefined for new resource creation', true);
|
|
60
|
+
}
|
|
61
|
+
$: rawCode && parseJson();
|
|
62
|
+
$: linkedVars.length > 0 && path && updateArgsFromLinkedVars();
|
|
63
|
+
export async function editResource() {
|
|
56
64
|
if (resourceToEdit) {
|
|
57
65
|
await ResourceService.updateResource({
|
|
58
66
|
workspace: $workspaceStore,
|
|
@@ -61,18 +69,25 @@ async function editResource() {
|
|
|
61
69
|
});
|
|
62
70
|
sendUserToast(`Updated resource at ${path}`);
|
|
63
71
|
dispatch('refresh', path);
|
|
64
|
-
drawer.closeDrawer?.();
|
|
65
72
|
}
|
|
66
73
|
else {
|
|
67
74
|
throw Error('Cannot edit undefined resourceToEdit');
|
|
68
75
|
}
|
|
69
76
|
}
|
|
77
|
+
export async function createResource() {
|
|
78
|
+
await ResourceService.createResource({
|
|
79
|
+
workspace: $workspaceStore,
|
|
80
|
+
requestBody: { path, value: args, description, resource_type: resource_type }
|
|
81
|
+
});
|
|
82
|
+
sendUserToast(`Updated resource at ${path}`);
|
|
83
|
+
dispatch('refresh', path);
|
|
84
|
+
}
|
|
70
85
|
async function loadResourceType() {
|
|
71
|
-
if (
|
|
86
|
+
if (resource_type) {
|
|
72
87
|
try {
|
|
73
88
|
const resourceType = await ResourceService.getResourceType({
|
|
74
89
|
workspace: $workspaceStore,
|
|
75
|
-
path:
|
|
90
|
+
path: resource_type
|
|
76
91
|
});
|
|
77
92
|
resourceTypeInfo = resourceType;
|
|
78
93
|
if (resourceType.schema) {
|
|
@@ -90,9 +105,6 @@ async function loadResourceType() {
|
|
|
90
105
|
}
|
|
91
106
|
loadingSchema = false;
|
|
92
107
|
}
|
|
93
|
-
let isValid = true;
|
|
94
|
-
let jsonError = '';
|
|
95
|
-
$: rawCode && parseJson();
|
|
96
108
|
function parseJson() {
|
|
97
109
|
try {
|
|
98
110
|
args = JSON.parse(rawCode ?? '');
|
|
@@ -102,13 +114,11 @@ function parseJson() {
|
|
|
102
114
|
jsonError = e.message;
|
|
103
115
|
}
|
|
104
116
|
}
|
|
105
|
-
$: linkedVars.length > 0 && path && updateArgsFromLinkedVars();
|
|
106
117
|
function updateArgsFromLinkedVars() {
|
|
107
118
|
linkedVars.forEach((k) => {
|
|
108
119
|
args[k] = `$var:${path}`;
|
|
109
120
|
});
|
|
110
121
|
}
|
|
111
|
-
let viewJsonSchema = false;
|
|
112
122
|
function switchTab(asJson) {
|
|
113
123
|
viewJsonSchema = asJson;
|
|
114
124
|
if (asJson) {
|
|
@@ -120,118 +130,105 @@ function switchTab(asJson) {
|
|
|
120
130
|
}
|
|
121
131
|
</script>
|
|
122
132
|
|
|
123
|
-
<
|
|
124
|
-
<
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
<div class="m-2">
|
|
133
|
-
<Alert type="warning" title="Only read access">
|
|
134
|
-
You only have read access to this resource and cannot edit it
|
|
135
|
-
</Alert>
|
|
136
|
-
</div>
|
|
137
|
-
{/if}
|
|
138
|
-
<Path
|
|
139
|
-
disabled={initialPath != '' && !isOwner(initialPath, $userStore, $workspaceStore)}
|
|
140
|
-
bind:path
|
|
141
|
-
{initialPath}
|
|
142
|
-
namePlaceholder="resource"
|
|
143
|
-
kind="resource"
|
|
144
|
-
/>
|
|
145
|
-
</div>
|
|
146
|
-
{#if !emptyString(resourceTypeInfo?.description)}
|
|
147
|
-
<h4 class="mt-4 mb-2">{resourceTypeInfo?.name} description</h4>
|
|
148
|
-
<div class="text-sm">
|
|
149
|
-
<Markdown md={urlize(resourceTypeInfo?.description ?? '', 'md')} />
|
|
133
|
+
<div>
|
|
134
|
+
<div class="flex flex-col gap-3 py-3">
|
|
135
|
+
{#if !hidePath}
|
|
136
|
+
<div>
|
|
137
|
+
{#if !can_write}
|
|
138
|
+
<div class="m-2">
|
|
139
|
+
<Alert type="warning" title="Only read access">
|
|
140
|
+
You only have read access to this resource and cannot edit it
|
|
141
|
+
</Alert>
|
|
150
142
|
</div>
|
|
151
143
|
{/if}
|
|
152
|
-
<
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
144
|
+
<Path
|
|
145
|
+
disabled={initialPath != '' && !isOwner(initialPath, $userStore, $workspaceStore)}
|
|
146
|
+
bind:path
|
|
147
|
+
{initialPath}
|
|
148
|
+
namePlaceholder="resource"
|
|
149
|
+
kind="resource"
|
|
150
|
+
/>
|
|
151
|
+
</div>
|
|
152
|
+
{/if}
|
|
161
153
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
<
|
|
174
|
-
|
|
175
|
-
|
|
154
|
+
{#if !emptyString(resourceTypeInfo?.description)}
|
|
155
|
+
<h4 class="mt-4 mb-2">{resourceTypeInfo?.name} description</h4>
|
|
156
|
+
<div class="text-sm">
|
|
157
|
+
<Markdown md={urlize(resourceTypeInfo?.description ?? '', 'md')} />
|
|
158
|
+
</div>
|
|
159
|
+
{/if}
|
|
160
|
+
<h4 class="mt-4 inline-flex items-center gap-4"
|
|
161
|
+
>Resource description <Required required={false} />
|
|
162
|
+
{#if can_write}
|
|
163
|
+
<div class="flex gap-1 items-center">
|
|
164
|
+
<Toggle size="xs" bind:checked={editDescription} />
|
|
165
|
+
<Pen size={14} />
|
|
166
|
+
</div>
|
|
167
|
+
{/if}</h4
|
|
168
|
+
>
|
|
176
169
|
|
|
177
|
-
|
|
170
|
+
{#if can_write && editDescription}
|
|
171
|
+
<div>
|
|
172
|
+
<div class="flex flex-row-reverse text-2xs text-tertiary -mt-1">GH Markdown</div>
|
|
173
|
+
<textarea
|
|
174
|
+
disabled={!can_write}
|
|
175
|
+
use:autosize
|
|
176
|
+
bind:value={description}
|
|
177
|
+
placeholder={DESCRIPTION_PLACEHOLDER}
|
|
178
|
+
/>
|
|
179
|
+
</div>
|
|
180
|
+
{:else if description == undefined || description == ''}
|
|
181
|
+
<div class="text-sm text-tertiary">No description provided</div>
|
|
182
|
+
{:else}
|
|
183
|
+
<div class="mt-2" />
|
|
184
|
+
|
|
185
|
+
<GfmMarkdown md={description} />
|
|
186
|
+
{/if}
|
|
187
|
+
<div class="flex w-full justify-between max-w-lg items-center mt-4">
|
|
188
|
+
<Toggle
|
|
189
|
+
on:change={(e) => switchTab(e.detail)}
|
|
190
|
+
options={{
|
|
191
|
+
right: 'As JSON'
|
|
192
|
+
}}
|
|
193
|
+
/>
|
|
194
|
+
<TestConnection resourceType={resourceToEdit?.resource_type} {args} />
|
|
195
|
+
</div>
|
|
196
|
+
<div class="text-sm">
|
|
197
|
+
{#if loadingSchema}
|
|
198
|
+
<Skeleton layout={[[4]]} />
|
|
199
|
+
{:else if !viewJsonSchema && resourceSchema && resourceSchema?.properties}
|
|
200
|
+
<SchemaForm
|
|
201
|
+
onlyMaskPassword
|
|
202
|
+
noDelete
|
|
203
|
+
disabled={!can_write}
|
|
204
|
+
compact
|
|
205
|
+
schema={resourceSchema}
|
|
206
|
+
bind:args
|
|
207
|
+
bind:isValid
|
|
208
|
+
/>
|
|
209
|
+
{:else if !can_write}
|
|
210
|
+
<input type="text" disabled value={rawCode} />
|
|
211
|
+
{:else}
|
|
212
|
+
{#if !viewJsonSchema}
|
|
213
|
+
<p class="italic text-secondary text-xs mb-4">
|
|
214
|
+
No corresponding resource type found in your workspace for {resource_type}. Define the
|
|
215
|
+
value in JSON directly
|
|
216
|
+
</p>
|
|
178
217
|
{/if}
|
|
179
|
-
<div class="flex w-full justify-between max-w-lg items-center mt-4">
|
|
180
|
-
<Toggle
|
|
181
|
-
on:change={(e) => switchTab(e.detail)}
|
|
182
|
-
options={{
|
|
183
|
-
right: 'As JSON'
|
|
184
|
-
}}
|
|
185
|
-
/>
|
|
186
|
-
<TestConnection resourceType={resourceToEdit?.resource_type} {args} />
|
|
187
|
-
</div>
|
|
188
|
-
<div class="text-sm">
|
|
189
|
-
{#if loadingSchema}
|
|
190
|
-
<Skeleton layout={[[4]]} />
|
|
191
|
-
{:else if !viewJsonSchema && resourceSchema && resourceSchema?.properties}
|
|
192
|
-
<SchemaForm
|
|
193
|
-
onlyMaskPassword
|
|
194
|
-
noDelete
|
|
195
|
-
disabled={!can_write}
|
|
196
|
-
compact
|
|
197
|
-
schema={resourceSchema}
|
|
198
|
-
bind:args
|
|
199
|
-
bind:isValid
|
|
200
|
-
/>
|
|
201
|
-
{:else if !can_write}
|
|
202
|
-
<input type="text" disabled value={rawCode} />
|
|
203
|
-
{:else}
|
|
204
|
-
{#if !viewJsonSchema}
|
|
205
|
-
<p class="italic text-secondary text-xs mb-4">
|
|
206
|
-
No corresponding resource type found in your workspace for {selectedResourceType}.
|
|
207
|
-
Define the value in JSON directly
|
|
208
|
-
</p>
|
|
209
|
-
{/if}
|
|
210
218
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
</div>
|
|
223
|
-
{/if}
|
|
219
|
+
{#if !emptyString(jsonError)}<span class="text-red-400 text-xs mb-1 flex flex-row-reverse"
|
|
220
|
+
>{jsonError}</span
|
|
221
|
+
>{:else}<div class="py-2" />{/if}
|
|
222
|
+
<div class="h-full w-full border p-1 rounded">
|
|
223
|
+
<SimpleEditor
|
|
224
|
+
autoHeight
|
|
225
|
+
class="editor"
|
|
226
|
+
lang="json"
|
|
227
|
+
bind:code={rawCode}
|
|
228
|
+
fixedOverflowWidgets={false}
|
|
229
|
+
/>
|
|
224
230
|
</div>
|
|
225
|
-
|
|
231
|
+
{/if}
|
|
226
232
|
</div>
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
startIcon={{ icon: Save }}
|
|
230
|
-
on:click={editResource}
|
|
231
|
-
disabled={!can_write || !isValid || jsonError != ''}
|
|
232
|
-
>
|
|
233
|
-
Save
|
|
234
|
-
</Button>
|
|
235
|
-
</svelte:fragment>
|
|
236
|
-
</DrawerContent>
|
|
237
|
-
</Drawer>
|
|
233
|
+
</div>
|
|
234
|
+
</div>
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
|
-
|
|
4
|
+
canSave?: boolean | undefined;
|
|
5
|
+
resource_type?: string | undefined;
|
|
6
|
+
path?: string | undefined;
|
|
7
|
+
newResource?: boolean | undefined;
|
|
8
|
+
hidePath?: boolean | undefined;
|
|
9
|
+
editResource?: (() => Promise<void>) | undefined;
|
|
10
|
+
createResource?: (() => Promise<void>) | undefined;
|
|
5
11
|
};
|
|
6
12
|
events: {
|
|
7
13
|
refresh: CustomEvent<any>;
|
|
@@ -14,6 +20,7 @@ export type ResourceEditorProps = typeof __propDef.props;
|
|
|
14
20
|
export type ResourceEditorEvents = typeof __propDef.events;
|
|
15
21
|
export type ResourceEditorSlots = typeof __propDef.slots;
|
|
16
22
|
export default class ResourceEditor extends SvelteComponent<ResourceEditorProps, ResourceEditorEvents, ResourceEditorSlots> {
|
|
17
|
-
get
|
|
23
|
+
get editResource(): () => Promise<void>;
|
|
24
|
+
get createResource(): () => Promise<void>;
|
|
18
25
|
}
|
|
19
26
|
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<script>import ResourceEditor from './ResourceEditor.svelte';
|
|
2
|
+
import { Button, Drawer } from './common';
|
|
3
|
+
import DrawerContent from './common/drawer/DrawerContent.svelte';
|
|
4
|
+
import { Save } from 'lucide-svelte';
|
|
5
|
+
let drawer;
|
|
6
|
+
let canSave = true;
|
|
7
|
+
let resource_type = undefined;
|
|
8
|
+
let resourceEditor = undefined;
|
|
9
|
+
let path = undefined;
|
|
10
|
+
export async function initEdit(p) {
|
|
11
|
+
resource_type = undefined;
|
|
12
|
+
path = p;
|
|
13
|
+
drawer.openDrawer?.();
|
|
14
|
+
}
|
|
15
|
+
export async function initNew(resourceType) {
|
|
16
|
+
path = undefined;
|
|
17
|
+
resource_type = resourceType;
|
|
18
|
+
drawer.openDrawer?.();
|
|
19
|
+
}
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<Drawer bind:this={drawer} size="800px">
|
|
23
|
+
<DrawerContent title={path ? 'Edit ' + path : 'Add a resource'} on:close={drawer.closeDrawer}>
|
|
24
|
+
<ResourceEditor
|
|
25
|
+
newResource
|
|
26
|
+
{path}
|
|
27
|
+
{resource_type}
|
|
28
|
+
on:refresh
|
|
29
|
+
bind:this={resourceEditor}
|
|
30
|
+
bind:canSave
|
|
31
|
+
/>
|
|
32
|
+
<svelte:fragment slot="actions">
|
|
33
|
+
<Button
|
|
34
|
+
startIcon={{ icon: Save }}
|
|
35
|
+
on:click={() => {
|
|
36
|
+
resourceEditor?.editResource()
|
|
37
|
+
drawer.closeDrawer()
|
|
38
|
+
}}
|
|
39
|
+
disabled={!canSave}
|
|
40
|
+
>
|
|
41
|
+
Save
|
|
42
|
+
</Button>
|
|
43
|
+
</svelte:fragment>
|
|
44
|
+
</DrawerContent>
|
|
45
|
+
</Drawer>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
initEdit?: ((p: string) => Promise<void>) | undefined;
|
|
5
|
+
initNew?: ((resourceType: string) => Promise<void>) | undefined;
|
|
6
|
+
};
|
|
7
|
+
events: {
|
|
8
|
+
refresh: CustomEvent<any>;
|
|
9
|
+
} & {
|
|
10
|
+
[evt: string]: CustomEvent<any>;
|
|
11
|
+
};
|
|
12
|
+
slots: {};
|
|
13
|
+
};
|
|
14
|
+
export type ResourceEditorDrawerProps = typeof __propDef.props;
|
|
15
|
+
export type ResourceEditorDrawerEvents = typeof __propDef.events;
|
|
16
|
+
export type ResourceEditorDrawerSlots = typeof __propDef.slots;
|
|
17
|
+
export default class ResourceEditorDrawer extends SvelteComponent<ResourceEditorDrawerProps, ResourceEditorDrawerEvents, ResourceEditorDrawerSlots> {
|
|
18
|
+
get initEdit(): (p: string) => Promise<void>;
|
|
19
|
+
get initNew(): (resourceType: string) => Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -5,10 +5,10 @@ import Select from './apps/svelte-select/lib/index';
|
|
|
5
5
|
import { SELECT_INPUT_DEFAULT_STYLE } from '../defaults';
|
|
6
6
|
import AppConnect from './AppConnectDrawer.svelte';
|
|
7
7
|
import { Button } from './common';
|
|
8
|
-
import ResourceEditor from './ResourceEditor.svelte';
|
|
9
8
|
import DBSchemaExplorer from './DBSchemaExplorer.svelte';
|
|
10
9
|
import DarkModeObserver from './DarkModeObserver.svelte';
|
|
11
10
|
import { Pen, Plus, RotateCw } from 'lucide-svelte';
|
|
11
|
+
import ResourceEditorDrawer from './ResourceEditorDrawer.svelte';
|
|
12
12
|
const dispatch = createEventDispatcher();
|
|
13
13
|
export let initialValue = undefined;
|
|
14
14
|
export let value = initialValue;
|
|
@@ -73,7 +73,7 @@ let darkMode = false;
|
|
|
73
73
|
bind:this={appConnect}
|
|
74
74
|
/>
|
|
75
75
|
|
|
76
|
-
<
|
|
76
|
+
<ResourceEditorDrawer
|
|
77
77
|
bind:this={resourceEditor}
|
|
78
78
|
on:refresh={async (e) => {
|
|
79
79
|
await loadResources(resourceType)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "windmill-components",
|
|
3
|
-
"version": "1.352.
|
|
3
|
+
"version": "1.352.6",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "vite dev",
|
|
6
6
|
"build": "vite build",
|
|
@@ -244,11 +244,26 @@
|
|
|
244
244
|
"svelte": "./package/components/SchemaForm.svelte",
|
|
245
245
|
"default": "./package/components/SchemaForm.svelte"
|
|
246
246
|
},
|
|
247
|
+
"./components/EditableSchemaWrapper.svelte": {
|
|
248
|
+
"types": "./package/components/schema/EditableSchemaWrapper.svelte.d.ts",
|
|
249
|
+
"svelte": "./package/components/schema/EditableSchemaWrapper.svelte",
|
|
250
|
+
"default": "./package/components/schema/EditableSchemaWrapper.svelte"
|
|
251
|
+
},
|
|
252
|
+
"./components/ResourceEditor.svelte": {
|
|
253
|
+
"types": "./package/components/ResourceEditor.svelte.d.ts",
|
|
254
|
+
"svelte": "./package/components/ResourceEditor.svelte",
|
|
255
|
+
"default": "./package/components/ResourceEditor.svelte"
|
|
256
|
+
},
|
|
247
257
|
"./components/SchemaEditor.svelte": {
|
|
248
258
|
"types": "./package/components/EditableSchemaForm.svelte.d.ts",
|
|
249
259
|
"svelte": "./package/components/EditableSchemaForm.svelte",
|
|
250
260
|
"default": "./package/components/EditableSchemaForm.svelte"
|
|
251
261
|
},
|
|
262
|
+
"./components/ScriptEditor.svelte": {
|
|
263
|
+
"types": "./package/components/ScriptEditor.svelte.d.ts",
|
|
264
|
+
"svelte": "./package/components/ScriptEditor.svelte",
|
|
265
|
+
"default": "./package/components/ScriptEditor.svelte"
|
|
266
|
+
},
|
|
252
267
|
"./components/scriptEditor/LogPanel.svelte": {
|
|
253
268
|
"types": "./package/components/scriptEditor/LogPanel.svelte.d.ts",
|
|
254
269
|
"svelte": "./package/components/scriptEditor/LogPanel.svelte",
|
|
@@ -328,6 +343,9 @@
|
|
|
328
343
|
"components/scriptEditor/LogPanel.svelte": [
|
|
329
344
|
"./package/components/scriptEditor/LogPanel.svelte.d.ts"
|
|
330
345
|
],
|
|
346
|
+
"components/ScriptEditor.svelte": [
|
|
347
|
+
"./package/components/ScriptEditor.svelte.d.ts"
|
|
348
|
+
],
|
|
331
349
|
"components/common/kbd/Kbd.svelte": [
|
|
332
350
|
"./package/components/common/kbd/Kbd.svelte.d.ts"
|
|
333
351
|
],
|
|
@@ -376,6 +394,9 @@
|
|
|
376
394
|
"components/SchemaEditor.svelte": [
|
|
377
395
|
"./package/components/SchemaEditor.svelte.d.ts"
|
|
378
396
|
],
|
|
397
|
+
"components/EditableSchemaWrapper.svelte": [
|
|
398
|
+
"./package/components/schema/EditableSchemaWrapper.svelte.d.ts"
|
|
399
|
+
],
|
|
379
400
|
"utils": [
|
|
380
401
|
"./package/utils.d.ts"
|
|
381
402
|
],
|