Files
windmill/frontend/src/lib/components/ScriptSchema.svelte
2022-10-14 16:32:15 +02:00

69 lines
2.2 KiB
Svelte

<script lang="ts">
import type { Schema } from '$lib/common'
import SchemaForm from './SchemaForm.svelte'
import Tab from './common/tabs/Tab.svelte'
import Tabs from './common/tabs/Tabs.svelte'
import TabContent from './common/tabs/TabContent.svelte'
import Highlight from 'svelte-highlight'
import json from 'svelte-highlight/languages/json'
import SvelteMarkdown from 'svelte-markdown'
export let schema: Schema
export let summary: string
export let description: string | undefined
export function setSchema(newSchema: Schema) {
schema = newSchema
}
</script>
<div class="w-full">
<h1 class="mb-4">UI customisation</h1>
<Tabs selected="ui">
<Tab value="ui">UI</Tab>
<Tab value="jsonschema">JSON Schema</Tab>
<svelte:fragment slot="content">
<TabContent value="ui">
<h2 class="border-b pb-1 mt-6">Display</h2>
<div class="grid grid-cols-3 gap-2 mt-4">
<label>
<div class="text-gray-700 text-sm">Summary</div>
<textarea bind:value={summary} placeholder="Edit summary" class="text-sm" />
</label>
<label class="col-span-2">
<div class="text-gray-700 text-sm">Description</div>
<textarea bind:value={description} placeholder="Edit description" class="text-sm" />
<div class="mt-1 px-2">
{#if description}
<div
class="prose !max-w-full !max-h-48 text-xs shadow-inner shadow-blue overflow-auto mt-1"
>
<SvelteMarkdown source={description} />
</div>
{:else}
<div class="text-xs text-gray-500"> Enter a description to see the preview </div>
{/if}
</div>
</label>
</div>
<h2 class="border-b pb-1 mt-6">Arguments</h2>
<div class="bg-blue-100 border-l-4 border-blue-600 text-blue-700 p-4 m-4" role="alert">
<p class="font-bold">Synchronized with main signature</p>
<p>
Argument names, being required or not, and default values are derived from the main
signature of step 2 and cannot be edited directly. Change the main signature to edit
them.
</p>
</div>
<SchemaForm {schema} editableSchema={true} />
</TabContent>
<TabContent value="jsonschema">
<Highlight language={json} code={JSON.stringify(schema, null, 4)} />
</TabContent>
</svelte:fragment>
</Tabs>
</div>