autoset base_url if empty

This commit is contained in:
Ruben Fiszel
2023-12-11 00:27:59 +01:00
parent 09e0112eff
commit 4bc7960908
2 changed files with 11 additions and 4 deletions
@@ -51,7 +51,12 @@
await Promise.all(
Object.entries(settings).map(
async ([_, y]) =>
await Promise.all(y.map(async (x) => [x.key, await getValue(x.key, x.storage)]))
await Promise.all(
y.map(async (x) => [
x.key,
(await getValue(x.key, x.storage)) ?? x.defaultValue?.()
])
)
)
)
).flat()
@@ -452,8 +457,7 @@
{#if hasError}
<span class="text-red-500 text-xs">
Base url must start with http:// or https:// and must NOT end with a
trailing slash.
{setting.error ?? ''}
</span>
{/if}
{:else}
@@ -18,6 +18,8 @@ export interface Setting {
| 'license_key'
storage: SettingStorage
isValid?: (value: any) => boolean
error?: string
defaultValue?: () => any
}
export type SettingStorage = 'setting' | 'config'
@@ -32,7 +34,8 @@ export const settings: Record<string, Setting[]> = {
placeholder: 'https://windmill.com',
storage: 'setting',
isValid: (value: string | undefined) =>
value ? value?.startsWith('http') && value.includes('://') && !value?.endsWith('/') : true
value ? value?.startsWith('http') && value.includes('://') && !value?.endsWith('/') : true,
defaultValue: () => window.location.origin
},
{
label: 'Request Size Limit In MB',