mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-20 00:02:19 +00:00
bee719813e
* feat: app select policy * fix: question marks
54 lines
1.2 KiB
Svelte
54 lines
1.2 KiB
Svelte
<script lang="ts">
|
|
import LightweightResourcePicker from './LightweightResourcePicker.svelte'
|
|
|
|
export let format: string
|
|
export let value: any
|
|
export let disablePortal = false
|
|
export let unsupported = false
|
|
|
|
function isString(value: any) {
|
|
return typeof value === 'string' || value instanceof String
|
|
}
|
|
|
|
let path: string = ''
|
|
|
|
function resourceToValue() {
|
|
if (path) {
|
|
value = `$res:${path}`
|
|
} else {
|
|
value = undefined
|
|
}
|
|
}
|
|
|
|
function isResource() {
|
|
return isString(value) && value.length >= '$res:'.length
|
|
}
|
|
|
|
function valueToPath() {
|
|
if (isResource()) {
|
|
path = value.substr('$res:'.length)
|
|
}
|
|
}
|
|
|
|
$: value && valueToPath()
|
|
</script>
|
|
|
|
<div class="flex flex-row w-full flex-wrap gap-x-2 gap-y-0.5">
|
|
{#if unsupported}
|
|
<div class=" text-xs text-yellow-600 dark:text-yellow-500">
|
|
Resource argument is unsupported for security reasons and won't be displayed, use the resource
|
|
select component instead.
|
|
</div>
|
|
{:else}
|
|
<LightweightResourcePicker
|
|
{disablePortal}
|
|
on:change={(e) => {
|
|
path = e.detail
|
|
resourceToValue()
|
|
}}
|
|
bind:value={path}
|
|
resourceType={format.split('-').length > 1 ? format.substring('resource-'.length) : undefined}
|
|
/>
|
|
{/if}
|
|
</div>
|