mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-10-08 16:02:30 +00:00
feat: add support for yaml format as a string format
This commit is contained in:
@@ -183,7 +183,7 @@
|
||||
bind:value={description}
|
||||
placeholder="Field description"
|
||||
/>
|
||||
{#if type == 'string' && !contentEncoding && format != 'date-time'}
|
||||
{#if type == 'string' && format != 'date-time'}
|
||||
<StringTypeNarrowing bind:format bind:pattern bind:enum_ bind:contentEncoding />
|
||||
{:else if type == 'object'}
|
||||
<ObjectTypeNarrowing bind:format />
|
||||
@@ -326,13 +326,13 @@
|
||||
</select>
|
||||
{:else if inputCat == 'date'}
|
||||
<input {autofocus} class="inline-block" type="datetime-local" bind:value />
|
||||
{:else if inputCat == 'sql'}
|
||||
<div class="border rounded mb-4 w-full border-gray-700">
|
||||
{:else if inputCat == 'sql' || inputCat == 'yaml'}
|
||||
<div class="border mb-4 w-full border-gray-400">
|
||||
<SimpleEditor
|
||||
on:focus={() => dispatch('focus')}
|
||||
on:blur={() => dispatch('blur')}
|
||||
bind:this={editor}
|
||||
lang="sql"
|
||||
lang={inputCat}
|
||||
bind:code={value}
|
||||
class="few-lines-editor"
|
||||
on:change={async () => {
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
}
|
||||
|
||||
function isStaticTemplate(inputCat: InputCat) {
|
||||
return inputCat === 'string' || inputCat === 'sql'
|
||||
return inputCat === 'string' || inputCat === 'sql' || inputCat == 'yaml'
|
||||
}
|
||||
|
||||
function connectProperty(rawValue: string) {
|
||||
|
||||
@@ -14,6 +14,17 @@
|
||||
|
||||
import libStdContent from '$lib/es5.d.ts.txt?raw'
|
||||
|
||||
meditor.defineTheme('myTheme', {
|
||||
base: 'vs',
|
||||
inherit: true,
|
||||
rules: [],
|
||||
colors: {
|
||||
'editorLineNumber.foreground': '#999',
|
||||
'editorGutter.background': '#F9FAFB'
|
||||
}
|
||||
})
|
||||
meditor.setTheme('myTheme')
|
||||
|
||||
languages.typescript.javascriptDefaults.setCompilerOptions({
|
||||
target: languages.typescript.ScriptTarget.Latest,
|
||||
allowNonTsExtensions: true,
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
export let format: string | undefined
|
||||
export let contentEncoding: 'base64' | 'binary' | undefined
|
||||
|
||||
let kind: 'none' | 'pattern' | 'enum' | 'resource' | 'format' | 'base64' = 'none'
|
||||
let kind: 'none' | 'pattern' | 'enum' | 'resource' | 'format' | 'base64' = computeKind()
|
||||
let patternStr: string = pattern ?? ''
|
||||
|
||||
let resource: string | undefined
|
||||
@@ -18,7 +18,9 @@
|
||||
'hostname',
|
||||
'uri',
|
||||
'uuid',
|
||||
'ipv4'
|
||||
'ipv4',
|
||||
'yaml',
|
||||
'sql'
|
||||
// 'time',
|
||||
// 'date',
|
||||
// 'duration',
|
||||
@@ -41,6 +43,25 @@
|
||||
enum_ = undefined
|
||||
}
|
||||
}
|
||||
|
||||
function computeKind(): 'base64' | 'none' | 'pattern' | 'enum' | 'resource' | 'format' {
|
||||
if (enum_ != undefined) {
|
||||
return 'enum'
|
||||
}
|
||||
if (contentEncoding == 'base64') {
|
||||
return 'base64'
|
||||
}
|
||||
if (pattern != undefined) {
|
||||
return 'pattern'
|
||||
}
|
||||
if (format != undefined) {
|
||||
if (format.startsWith('resource')) {
|
||||
return 'resource'
|
||||
}
|
||||
return 'format'
|
||||
}
|
||||
return 'none'
|
||||
}
|
||||
</script>
|
||||
|
||||
<RadioButton
|
||||
@@ -81,12 +102,14 @@
|
||||
{:else if kind == 'enum'}
|
||||
<label for="input" class="mb-2 text-gray-700 text-xs">
|
||||
Enums
|
||||
{#each enum_ || [] as e}
|
||||
<div class="flex flex-row max-w-md">
|
||||
<input id="input" type="text" bind:value={e} />
|
||||
<Button size="sm" btnClasses="ml-6" on:click={() => remove(e)}>-</Button>
|
||||
</div>
|
||||
{/each}
|
||||
<div class="flex flex-col gap-1">
|
||||
{#each enum_ || [] as e}
|
||||
<div class="flex flex-row max-w-md">
|
||||
<input id="input" type="text" bind:value={e} />
|
||||
<Button size="sm" btnClasses="ml-6" on:click={() => remove(e)}>-</Button>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
<div class="flex flex-row my-1">
|
||||
<Button size="sm" on:click={add}>+</Button>
|
||||
<Button variant="border" size="sm" btnClasses="ml-2" on:click={() => (enum_ = undefined)}>
|
||||
|
||||
@@ -41,6 +41,8 @@ export function langToExt(lang: string): string {
|
||||
return 'json'
|
||||
case 'sql':
|
||||
return 'sql'
|
||||
case 'yaml':
|
||||
return 'yaml'
|
||||
case 'typescript':
|
||||
return 'ts'
|
||||
case 'python':
|
||||
|
||||
@@ -81,6 +81,9 @@ function argSigToJsonSchemaType(
|
||||
} else if (t === 'sql') {
|
||||
newS.type = 'string'
|
||||
newS.format = 'sql'
|
||||
} else if (t === 'yaml') {
|
||||
newS.type = 'string'
|
||||
newS.format = 'yaml'
|
||||
} else if (t === 'bytes') {
|
||||
newS.type = 'string'
|
||||
newS.contentEncoding = 'base64'
|
||||
|
||||
@@ -434,6 +434,7 @@ export type InputCat =
|
||||
| 'resource-string'
|
||||
| 'object'
|
||||
| 'sql'
|
||||
| 'yaml'
|
||||
|
||||
export function setInputCat(
|
||||
type: string | undefined,
|
||||
@@ -458,6 +459,8 @@ export function setInputCat(
|
||||
return 'date'
|
||||
} else if (type == 'string' && format == 'sql') {
|
||||
return 'sql'
|
||||
} else if (type == 'string' && format == 'yaml') {
|
||||
return 'yaml'
|
||||
} else if (type == 'string' && contentEncoding == 'base64') {
|
||||
return 'base64'
|
||||
} else if (type == 'string' && format?.startsWith('resource')) {
|
||||
|
||||
Reference in New Issue
Block a user