Fixing issue #3199 - don't allow submitting automation creation modal without name, adding error message.

This commit is contained in:
mike12345567 2021-11-03 11:55:01 +00:00
parent b0a9de45cf
commit bbcee67e4c
1 changed files with 10 additions and 2 deletions

View File

@ -8,10 +8,13 @@
let name let name
let selectedTrigger let selectedTrigger
let nameTouched = false
let triggerVal let triggerVal
export let webhookModal export let webhookModal
$: instanceId = $database._id $: instanceId = $database._id
$: nameError =
nameTouched && !name ? "Please specify a name for the automation." : null
async function createAutomation() { async function createAutomation() {
await automationStore.actions.create({ await automationStore.actions.create({
@ -51,13 +54,18 @@
confirmText="Save" confirmText="Save"
size="M" size="M"
onConfirm={createAutomation} onConfirm={createAutomation}
disabled={!selectedTrigger} disabled={!selectedTrigger || !name}
> >
<Body size="XS" <Body size="XS"
>Please name your automation, then select a trigger. Every automation must >Please name your automation, then select a trigger. Every automation must
start with a trigger. start with a trigger.
</Body> </Body>
<Input bind:value={name} label="Name" /> <Input
bind:value={name}
on:change={() => (nameTouched = true)}
bind:error={nameError}
label="Name"
/>
<Layout noPadding> <Layout noPadding>
<Body size="S">Triggers</Body> <Body size="S">Triggers</Body>