fix copy first step schema + import buttons

This commit is contained in:
Ruben Fiszel
2022-11-07 21:54:49 +01:00
parent 8e537a80bd
commit 2c81c4dc39
5 changed files with 25 additions and 23 deletions
@@ -173,6 +173,6 @@
.few-lines-editor {
/* stylelint-disable-next-line unit-allowed-list */
height: 150px;
height: 100px;
}
</style>
+11 -2
View File
@@ -108,10 +108,19 @@ export async function initFlow(flow: Flow) {
export async function copyFirstStepSchema() {
const flowState = get(flowStateStore)
flowStore.update((flow) => {
const firstModuleId = flow.value.modules[0].id
const firstModuleId = flow.value.modules[0]?.id
if (flowState[firstModuleId]) {
if (flowState[firstModuleId] && firstModuleId) {
flow.schema = flowState[firstModuleId].schema
const v = flow.value.modules[0].value
if (v.type == 'rawscript' || v.type == 'script') {
Object.keys(v.input_transforms ?? {}).forEach((key) => {
v.input_transforms[key] = {
type: 'javascript',
expr: `flow_input.${key}`
}
})
}
}
return flow
})
@@ -26,26 +26,20 @@
}
</script>
<Menu placement="bottom-end">
<div slot="trigger">
<Button nonCaptureEvent={true} color="light" size="sm" variant="border">Import/Export</Button>
</div>
<div class="divide-y divide-gray-200">
<MenuItem on:click={() => jsonSetterDrawer.toggleDrawer()}>
<Icon data={faFileImport} scale={0.6} class="inline mr-2" />
Import from a JSON OpenFlow
</MenuItem>
<MenuItem on:click={() => jsonViewerDrawer.toggleDrawer()}>
<Icon data={faFileExport} scale={0.6} class="inline mr-2" />
Export to a JSON OpenFlow
</MenuItem>
</div>
</Menu>
<div class="flex-row gap-x-2 hidden sm:flex">
<Button size="sm" variant="border" color="light" on:click={() => jsonSetterDrawer.toggleDrawer()}>
<Icon data={faFileImport} scale={0.6} class="inline mr-2" />
Import JSON
</Button>
<Button size="sm" variant="border" color="light" on:click={() => jsonViewerDrawer.toggleDrawer()}>
<Icon data={faFileExport} scale={0.6} class="inline mr-2" />
Export JSON
</Button>
</div>
<Drawer bind:this={jsonSetterDrawer} size="800px">
<DrawerContent title="Import JSON" on:close={() => jsonSetterDrawer.toggleDrawer()}>
<Button size="sm" on:click={importJson}>Import</Button>
<Button slot="submission" size="sm" on:click={importJson}>Import</Button>
<SimpleEditor bind:code={pendingJson} lang="json" class="h-full" />
</DrawerContent>
</Drawer>
@@ -120,7 +120,7 @@
<!-- Raw JSON -->
<Drawer bind:this={drawers.json} size="800px">
<DrawerContent title="Import JSON" on:close={() => drawers.json?.toggleDrawer()}>
<div class="p-2"><Button size="sm" on:click={importJson}>Import</Button></div>
<SimpleEditor bind:code={pendingJson} lang="json" class="h-full" />
<span slot="submission"><Button size="sm" on:click={importJson}>Import</Button></span>
</DrawerContent>
</Drawer>
+1 -2
View File
@@ -3,8 +3,7 @@ const plugin = require('tailwindcss/plugin');
/** @type {import('tailwindcss').Config} */
const config = {
content: [
'./src/**/*.{html,js,svelte,ts}',
"./node_modules/flowbite-svelte/**/*.{html,js,svelte,ts}",
'./src/**/*.{html,js,svelte,ts}'
],
safelist: [
'hljs',