feat: missing alerts

This commit is contained in:
Arman
2023-08-28 17:19:57 +02:00
parent 13ec2b65ba
commit 1874c23da1
7 changed files with 142 additions and 114 deletions
@@ -7,13 +7,14 @@
InputTextarea,
InputText
} from '$lib/elements/forms';
import { Collapsible, CollapsibleItem, Modal } from '$lib/components';
import { Alert, Collapsible, CollapsibleItem, Modal } from '$lib/components';
import { sdk } from '$lib/stores/sdk';
import { createEventDispatcher } from 'svelte';
import { page } from '$app/stores';
import { invalidate } from '$app/navigation';
import { Dependencies } from '$lib/constants';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
import { func } from './store';
export let show = false;
@@ -77,20 +78,32 @@
placeholder="Entrypoint"
bind:value={entrypoint}
required />
<Collapsible>
<CollapsibleItem>
<svelte:fragment slot="title">Build settings</svelte:fragment>
<svelte:fragment slot="subtitle">(optional)</svelte:fragment>
<FormList>
<InputTextarea
label="Commands"
placeholder="Enter a build commad (e.g. 'npm install')"
tooltip="Enter a single command or chain multiple commands with the && operator"
id="build"
bind:value={buildCommand} />
</FormList>
</CollapsibleItem>
</Collapsible>
{#if $func.version !== 'v3'}
<Alert type="info">
<svelte:fragment slot="title"
>Build commands now available for functions v3.0</svelte:fragment>
Update your function version to make use of new features including build commands.
<svelte:fragment slot="buttons">
<!-- TODO: add link to docs -->
<Button href="#/" external text>Learn more</Button>
</svelte:fragment>
</Alert>
{:else}
<Collapsible>
<CollapsibleItem>
<svelte:fragment slot="title">Build settings</svelte:fragment>
<svelte:fragment slot="subtitle">(optional)</svelte:fragment>
<FormList>
<InputTextarea
label="Commands"
placeholder="Enter a build commad (e.g. 'npm install')"
tooltip="Enter a single command or chain multiple commands with the && operator"
id="build"
bind:value={buildCommand} />
</FormList>
</CollapsibleItem>
</Collapsible>
{/if}
<InputChoice label="Activate deployment after build" id="activate" bind:value={active}>
This deployment will be activated after the build is completed.
</InputChoice>
@@ -3,7 +3,7 @@
import { base } from '$app/paths';
import { page } from '$app/stores';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
import { Modal } from '$lib/components';
import { Alert, Modal } from '$lib/components';
import Collapsible from '$lib/components/collapsible.svelte';
import CollapsibleItem from '$lib/components/collapsibleItem.svelte';
import { Dependencies } from '$lib/constants';
@@ -105,98 +105,116 @@
</p>
<FormList>
<InputText label="Path" id="path" placeholder="/" bind:value={path} required />
{#if selectedFunction?.version !== 'v3'}
<Alert type="info">
<svelte:fragment>
Customizable execution data now available for functions v3.0
</svelte:fragment>
Update your function version to make use of new features including customizable HTTP
data in your executions.
<svelte:fragment slot="buttons">
<!-- TODO: add link to docs -->
<Button href="#/" external text>Learn more</Button>
</svelte:fragment>
</Alert>
<InputTextarea
label="Body"
placeholder={`{ "myKey": "myValue" }`}
id="body"
bind:value={body} />
{:else}
<InputText label="Path" id="path" placeholder="/" bind:value={path} required />
<InputSelect
required
id="method"
label="Method"
options={methodOptions}
bind:value={method} />
<InputSelect
required
id="method"
label="Method"
options={methodOptions}
bind:value={method} />
<Collapsible>
<CollapsibleItem>
<svelte:fragment slot="title">Advanced settings</svelte:fragment>
<svelte:fragment slot="subtitle">(optional)</svelte:fragment>
<FormList>
<p class="text">
Customize your execution with headers or body. To customize parameters, add
them to path.
</p>
<div>
<Label
tooltip="Headers should contain alphanumeric characters (a-z, A-Z, and 0-9) and hyphens only (- and _).">
Headers
</Label>
</div>
<div class="form u-grid u-gap-16">
<FormList>
{#if headers}
{#each headers as [name, value], index}
<FormItem isMultiple>
<InputText
isMultiple
fullWidth
label="Name"
placeholder="Enter Name"
id={`key-${index}`}
bind:value={name} />
<InputText
isMultiple
fullWidth
label="Value"
placeholder="Enter value"
id={`value-${index}`}
bind:value />
<FormItemPart alignEnd>
<Button
text
disabled={(!name || !value) && index === 0}
on:click={() => {
if (index === 0) {
headers = [['', '']];
} else {
headers.splice(index, 1);
headers = headers;
}
}}>
<span class="icon-x" aria-hidden="true" />
</Button>
</FormItemPart>
</FormItem>
{/each}
{/if}
</FormList>
<Button
noMargin
text
disabled={headers?.length &&
headers[headers.length - 1][0] &&
headers[headers.length - 1][1]
? false
: true}
on:click={() => {
if (
headers[headers.length - 1][0] &&
headers[headers.length - 1][1]
) {
headers.push(['', '']);
headers = headers;
}
}}>
<span class="icon-plus" aria-hidden="true" />
<span class="text">Add Header</span>
</Button>
</div>
<InputTextarea
label="Body"
placeholder={`{ "myKey": "myValue" }`}
id="body"
bind:value={body} />
</FormList>
</CollapsibleItem>
</Collapsible>
<Collapsible>
<CollapsibleItem>
<svelte:fragment slot="title">Advanced settings</svelte:fragment>
<svelte:fragment slot="subtitle">(optional)</svelte:fragment>
<FormList>
<p class="text">
Customize your execution with headers or body. To customize parameters,
add them to path.
</p>
<div>
<Label
tooltip="Headers should contain alphanumeric characters (a-z, A-Z, and 0-9) and hyphens only (- and _).">
Headers
</Label>
</div>
<div class="form u-grid u-gap-16">
<FormList>
{#if headers}
{#each headers as [name, value], index}
<FormItem isMultiple>
<InputText
isMultiple
fullWidth
label="Name"
placeholder="Enter Name"
id={`key-${index}`}
bind:value={name} />
<InputText
isMultiple
fullWidth
label="Value"
placeholder="Enter value"
id={`value-${index}`}
bind:value />
<FormItemPart alignEnd>
<Button
text
disabled={(!name || !value) && index === 0}
on:click={() => {
if (index === 0) {
headers = [['', '']];
} else {
headers.splice(index, 1);
headers = headers;
}
}}>
<span class="icon-x" aria-hidden="true" />
</Button>
</FormItemPart>
</FormItem>
{/each}
{/if}
</FormList>
<Button
noMargin
text
disabled={headers?.length &&
headers[headers.length - 1][0] &&
headers[headers.length - 1][1]
? false
: true}
on:click={() => {
if (
headers[headers.length - 1][0] &&
headers[headers.length - 1][1]
) {
headers.push(['', '']);
headers = headers;
}
}}>
<span class="icon-plus" aria-hidden="true" />
<span class="text">Add Header</span>
</Button>
</div>
<InputTextarea
label="Body"
placeholder={`{ "myKey": "myValue" }`}
id="body"
bind:value={body} />
</FormList>
</CollapsibleItem>
</Collapsible>
{/if}
</FormList>
<svelte:fragment slot="footer">
@@ -46,7 +46,8 @@
<Alert type="warning" dismissible class="u-margin-block-start-24">
<svelte:fragment slot="title">Your function is outdated</svelte:fragment>
Update your function version to make use of new features including build commands and HTTP
data in your executions. To update, follow the steps outlined in our documentation.
data in your executions. To update, follow the steps outlined in our
<a href="#/" target="_blank" rel="noopener noreferrer" class="link">documentation</a>.
<svelte:fragment slot="buttons">
<!-- TODO: Add link to docs -->
<Button href="#/" external text>Learn more</Button>
@@ -49,7 +49,7 @@
import InputSelectSearch from '$lib/elements/forms/inputSelectSearch.svelte';
import { installations } from '$lib/wizards/functions/store';
import { isSelfHosted } from '$lib/system';
import { consoleVariables } from '$lib/stores/variables';
import { consoleVariables } from '$lib/stores/consoleVariables';
const functionId = $page.params.function;
@@ -174,8 +174,6 @@
selectedDir !== $func?.providerRootDirectory;
$: isVcsEnabled = $consoleVariables?._APP_VCS_ENABLED === true;
$: console.log($consoleVariables);
</script>
<Form onSubmit={updateConfiguration}>
@@ -4,7 +4,7 @@
import { Pill } from '$lib/elements';
import { Button } from '$lib/elements/forms';
import { Container } from '$lib/layout';
import { consoleVariables } from '$lib/stores/variables';
import { consoleVariables } from '$lib/stores/consoleVariables';
import { isSelfHosted } from '$lib/system';
import { connectTemplate } from '$lib/wizards/functions/cover.svelte';
import { template } from './store';
@@ -29,7 +29,7 @@
import GitDisconnectModal from './GitDisconnectModal.svelte';
import dayjs from 'dayjs';
import { isSelfHosted } from '$lib/system';
import { consoleVariables } from '$lib/stores/variables';
import { consoleVariables } from '$lib/stores/consoleVariables';
export let total: number;
export let limit: number;
@@ -78,8 +78,6 @@
}
$: isVcsEnabled = $consoleVariables?._APP_VCS_ENABLED === true;
$: console.log($consoleVariables, isVcsEnabled);
</script>
<CardGrid>