fix select picker initialization

This commit is contained in:
Ruben Fiszel
2022-12-03 01:13:51 +01:00
parent ec163bd8c3
commit aabeaf6e5f
4 changed files with 11 additions and 2 deletions
@@ -38,6 +38,7 @@
<div class="flex flex-row gap-x-1 w-full">
<Select
value={collection.find((x) => x.value == value)}
bind:justValue={value}
items={collection}
class="grow"
@@ -11,6 +11,7 @@
import { Button, Drawer, DrawerContent } from './common'
import HighlightCode from './HighlightCode.svelte'
export let initialPath: string | undefined = undefined
export let scriptPath: string | undefined = undefined
export let allowFlow = false
export let allowHub = false
@@ -49,7 +50,7 @@
}
}
$: $workspaceStore && itemKind && loadItems()
$: itemKind && $workspaceStore && loadItems()
</script>
<div class="flex flex-row items-center gap-4 w-full">
@@ -60,6 +61,7 @@
{/if}
<Select
value={items.find((x) => x.value == initialPath)}
class="grow"
on:change={() => {
dispatch('select', { path: scriptPath })
+3
View File
@@ -29,6 +29,7 @@
let schedule: string = '0 0 12 * *'
let script_path = $page.url.searchParams.get('path') || ''
let initialScriptPath = script_path
let is_flow = $page.url.searchParams.get('isFlow') == 'true'
let itemKind: 'flow' | 'script' = is_flow ? 'flow' : 'script'
@@ -69,6 +70,7 @@
enabled = s.enabled
schedule = s.schedule
script_path = s.script_path ?? ''
initialScriptPath = script_path
args = s.args ?? {}
} catch (err) {
sendUserToast(`Could not load schedule: ${err}`, true)
@@ -135,6 +137,7 @@
Pick a script or flow to be triggered by the schedule<Required required={true} />
</p>
<ScriptPicker
initialPath={initialScriptPath}
kind={Script.kind.SCRIPT}
allowFlow={true}
bind:itemKind
@@ -34,6 +34,7 @@
let filteredUsers: User[] | undefined
let userFilter = ''
let scriptPath: string
let initialPath: string
let team_name: string | undefined
let itemKind: 'flow' | 'script' = 'flow'
@@ -81,7 +82,8 @@
async function loadSlack(): Promise<void> {
const settings = await WorkspaceService.getSettings({ workspace: $workspaceStore! })
team_name = settings.slack_name
scriptPath = settings.slack_command_script ?? ''
scriptPath = (settings.slack_command_script ?? '').split('/').slice(1).join('/')
initialPath = scriptPath
}
async function listUsers(): Promise<void> {
@@ -244,6 +246,7 @@
allowFlow
bind:itemKind
bind:scriptPath
{initialPath}
on:select={editSlackCommand}
/>