Files
windmill/frontend/src/lib/components/SchemaViewer.svelte
T
258445e523 feat(frontend): unify all triggers UX and simplify flow settings (#4259)
* feat(frontend): added list of triggers in the flow graph

* feat(frontend): added list of triggers in the flow graph

* feat(frontend): clean up

* feat(frontend): improve UX

* feat(frontend): triggers

* feat(frontend): triggers

* feat(frontend): done

* feat(frontend): fix trigger when position when a preprocessor is presetn

* Glm/rework flow settings v2 (#4497)

* fat(frontend): simplify flow settings menu

* improve scroll

* changing mute toggle

* Add advanced settings badge

* Add nord theme colors

* Add bage for advanced options

* fix minor issue

* fix minor issue

* Add triggers menu to flow settings

* Add quick trigger access

* remove triggers in flow settings

* fix minor issue

* Move triggers settings to flow right panel

* polishing

* fix unset store

* remove save up to for triggers

* fix padding

* reset default tag color

* remove custom select component

* revert path change

* revert section modif

* Revert unused feature

---------

Co-authored-by: Guilhem <guilhem@mbp-de-windmill.home>

* Connect top bar cron to schedules settings

* Turn copilot into node

* fix copilot placement

* remove useless import

* fix center copilot

* fix binding

* remove copilot on top of preprocessor

* render copilot node on condition

* quickfix

* remove copilot node

* fix minor issues

* fix route count update

* fix schedule sync

* harmonize colors

* fix alignment and add edges

* recenter node summary

* fix schedules sync

* Add id title

* all

* all

* all

* iteration

* all

* all

* done

* fix

* more fixes

---------

Co-authored-by: Guilhem <guilhemlemouel@gmail.com>
Co-authored-by: Guilhem <guilhem@mbp-de-windmill.home>
Co-authored-by: Ruben Fiszel <ruben@windmill.dev>
Co-authored-by: Ruben Fiszel <ruben@rubenfiszel.com>
2024-10-16 17:58:15 +02:00

102 lines
3.0 KiB
Svelte

<script lang="ts">
import type { Schema } from '$lib/common'
import { copyToClipboard, emptySchema } from '$lib/utils'
import Highlight from 'svelte-highlight'
import json from 'svelte-highlight/languages/json'
import TableCustom from './TableCustom.svelte'
import Tab from './common/tabs/Tab.svelte'
import TabContent from './common/tabs/TabContent.svelte'
import Tabs from './common/tabs/Tabs.svelte'
import { Badge } from './common'
import HighlightTheme from './HighlightTheme.svelte'
import Button from './common/button/Button.svelte'
import { ClipboardCopy } from 'lucide-svelte'
export let schema: Schema | undefined | any = emptySchema()
function getProperties(schema: Schema) {
if (schema.properties) {
return Object.entries(schema.properties)
}
return []
}
</script>
<HighlightTheme />
<div class="w-full">
<Tabs selected="arguments">
<Tab value="arguments">Arguments</Tab>
<Tab value="advanced">Advanced</Tab>
<svelte:fragment slot="content">
<div class="overflow-auto pt-2">
<TabContent value="arguments">
{#if schema && schema.properties && Object.keys(schema.properties).length > 0 && schema.required}
<div class="flex flex-row">
<TableCustom>
<tr slot="header-row" class="underline">
<th>name</th>
<th>type</th>
<th>description</th>
<th>default</th>
<th>format</th>
<th>required</th>
</tr>
<tbody slot="body">
{#each getProperties(schema) as [name, property] (name)}
<tr>
<td class="font-semibold pl-1">{name}</td>
<td
><Badge color="blue"
>{#if !property.type} any {:else} {property.type} {/if}</Badge
></td
>
<td>{property.description ?? ''}</td>
<td
>{property.default == '<function call>'
? '<function call>'
: property.default
? JSON.stringify(property.default)
: ''}</td
>
<td
>{property.format ?? ''}
{property.contentEncoding
? `(encoding: ${property.contentEncoding})`
: ''}</td
>
<td
>{#if schema.required.includes(name)}
<span class="text-red-600 font-bold text-lg">*</span>
{/if}</td
>
</tr>
{/each}
</tbody>
</TableCustom>
</div>
{:else}
<div class="text-secondary text-xs italic m-1">No arguments</div>
{/if}
</TabContent>
<TabContent value="advanced">
<div class="h-full relative">
<Button
wrapperClasses="absolute top-2 right-2 z-20"
on:click={() => copyToClipboard(JSON.stringify(schema, null, 4))}
color="light"
size="xs2"
startIcon={{
icon: ClipboardCopy
}}
iconOnly
/>
<Highlight language={json} code={JSON.stringify(schema, null, 4)} />
</div>
</TabContent>
</div>
</svelte:fragment>
</Tabs>
</div>