mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-11 16:09:39 +00:00
feat(frontend): Enable changing kind for string properties (#3925)
* feat(frontend): Enable changing kind for string properties * feat(frontend): Enable changing kind for string properties * feat(frontend): Enable changing kind for string properties
This commit is contained in:
@@ -46,6 +46,7 @@ export interface SchemaProperty {
|
||||
title?: string
|
||||
placeholder?: string
|
||||
oneOf?: SchemaProperty[]
|
||||
originalType?: string
|
||||
}
|
||||
|
||||
export interface ModalSchemaProperty {
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
export let noExtra = false
|
||||
export let dateFormat: string | undefined
|
||||
export let enumLabels: Record<string, string> = {}
|
||||
export let allowKindChange: boolean = true
|
||||
export let allowAddingOrDeletingEnumValues: boolean = true
|
||||
export let overrideAllowKindChange: boolean = true
|
||||
export let originalType: string | undefined = undefined
|
||||
|
||||
let kind: 'none' | 'pattern' | 'enum' | 'resource' | 'format' | 'base64' = computeKind(
|
||||
enum_,
|
||||
@@ -34,6 +34,8 @@
|
||||
format
|
||||
)
|
||||
|
||||
const allowKindChange = overrideAllowKindChange || originalType === 'string'
|
||||
|
||||
let patternStr: string = pattern ?? ''
|
||||
let resource: string | undefined
|
||||
|
||||
@@ -204,13 +206,13 @@
|
||||
/>
|
||||
{/if}
|
||||
|
||||
{#if allowAddingOrDeletingEnumValues}
|
||||
{#if allowKindChange}
|
||||
<Button size="sm" on:click={() => remove(e)}>-</Button>
|
||||
{/if}
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
{#if allowAddingOrDeletingEnumValues}
|
||||
{#if allowKindChange}
|
||||
<div class="flex flex-row my-1">
|
||||
<Button color="light" size="sm" on:click={add}>+</Button>
|
||||
</div>
|
||||
|
||||
@@ -148,8 +148,8 @@
|
||||
bind:disableVariablePicker={extra['disableVariablePicker']}
|
||||
bind:dateFormat={extra['dateFormat']}
|
||||
bind:enumLabels={extra['enumLabels']}
|
||||
allowKindChange={isFlowInput || isAppInput}
|
||||
allowAddingOrDeletingEnumValues={isFlowInput || isAppInput}
|
||||
originalType={extra['originalType']}
|
||||
overrideAllowKindChange={isFlowInput || isAppInput}
|
||||
/>
|
||||
{:else if type == 'number' || type == 'integer'}
|
||||
<NumberTypeNarrowing
|
||||
|
||||
@@ -36,6 +36,7 @@ export function argSigToJsonSchemaType(
|
||||
} else if (t === 'bytes') {
|
||||
newS.type = 'string'
|
||||
newS.contentEncoding = 'base64'
|
||||
newS.originalType = 'bytes'
|
||||
} else if (t === 'datetime') {
|
||||
newS.type = 'string'
|
||||
newS.format = 'date-time'
|
||||
@@ -78,8 +79,10 @@ export function argSigToJsonSchemaType(
|
||||
} else if (typeof t !== 'string' && `str` in t) {
|
||||
newS.type = 'string'
|
||||
if (t.str) {
|
||||
newS.originalType = 'enum'
|
||||
newS.enum = t.str
|
||||
} else {
|
||||
newS.originalType = 'string'
|
||||
newS.enum = undefined
|
||||
}
|
||||
} else if (typeof t !== 'string' && `resource` in t) {
|
||||
|
||||
Reference in New Issue
Block a user