|
|
@ -17,6 +17,7 @@ |
|
|
import { capitalise } from "helpers" |
|
|
import { capitalise } from "helpers" |
|
|
import { goto } from "@roxi/routify" |
|
|
import { goto } from "@roxi/routify" |
|
|
import { APP_NAME_REGEX } from "constants" |
|
|
import { APP_NAME_REGEX } from "constants" |
|
|
|
|
|
import TemplateList from "./TemplateList.svelte" |
|
|
|
|
|
|
|
|
export let template |
|
|
export let template |
|
|
|
|
|
|
|
|
@ -31,12 +32,16 @@ |
|
|
APP_NAME_REGEX, |
|
|
APP_NAME_REGEX, |
|
|
"App name must be letters, numbers and spaces only" |
|
|
"App name must be letters, numbers and spaces only" |
|
|
), |
|
|
), |
|
|
file: template ? mixed().required("Please choose a file to import") : null, |
|
|
file: template?.fromFile |
|
|
|
|
|
? mixed().required("Please choose a file to import") |
|
|
|
|
|
: null, |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
let submitting = false |
|
|
let submitting = false |
|
|
let valid = false |
|
|
let valid = false |
|
|
|
|
|
|
|
|
$: checkValidity($values, validator) |
|
|
$: checkValidity($values, validator) |
|
|
|
|
|
$: showTemplateSelection = !template?.fromFile && !template?.key |
|
|
|
|
|
|
|
|
onMount(async () => { |
|
|
onMount(async () => { |
|
|
await hostingStore.actions.fetchDeployedApps() |
|
|
await hostingStore.actions.fetchDeployedApps() |
|
|
@ -73,7 +78,7 @@ |
|
|
submitting = true |
|
|
submitting = true |
|
|
|
|
|
|
|
|
// Check a template exists if we are important |
|
|
// Check a template exists if we are important |
|
|
if (template && !$values.file) { |
|
|
if (template?.fromFile && !$values.file) { |
|
|
$errors.file = "Please choose a file to import" |
|
|
$errors.file = "Please choose a file to import" |
|
|
valid = false |
|
|
valid = false |
|
|
submitting = false |
|
|
submitting = false |
|
|
@ -133,33 +138,59 @@ |
|
|
} |
|
|
} |
|
|
</script> |
|
|
</script> |
|
|
|
|
|
|
|
|
<ModalContent |
|
|
{#if showTemplateSelection} |
|
|
title={template ? "Import app" : "Create app"} |
|
|
<ModalContent |
|
|
confirmText={template ? "Import app" : "Create app"} |
|
|
title={"Get started quickly"} |
|
|
onConfirm={createNewApp} |
|
|
showConfirmButton={false} |
|
|
disabled={!valid} |
|
|
size="L" |
|
|
> |
|
|
onConfirm={() => { |
|
|
{#if template} |
|
|
showTemplateSelection = false |
|
|
<Dropzone |
|
|
return false |
|
|
error={$touched.file && $errors.file} |
|
|
}} |
|
|
gallery={false} |
|
|
showCancelButton={false} |
|
|
label="File to import" |
|
|
showCloseIcon={false} |
|
|
value={[$values.file]} |
|
|
> |
|
|
on:change={e => { |
|
|
<Body size="M">Select a template below, or start from scratch.</Body> |
|
|
$values.file = e.detail?.[0] |
|
|
<TemplateList |
|
|
$touched.file = true |
|
|
onSelect={selected => { |
|
|
|
|
|
if (!selected) { |
|
|
|
|
|
showTemplateSelection = false |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template = selected |
|
|
}} |
|
|
}} |
|
|
/> |
|
|
/> |
|
|
{/if} |
|
|
</ModalContent> |
|
|
<Body size="S"> |
|
|
{:else} |
|
|
Give your new app a name, and choose which groups have access (paid plans |
|
|
<ModalContent |
|
|
only). |
|
|
title={template?.fromFile ? "Import app" : "Create app"} |
|
|
</Body> |
|
|
confirmText={template?.fromFile ? "Import app" : "Create app"} |
|
|
<Input |
|
|
onConfirm={createNewApp} |
|
|
bind:value={$values.name} |
|
|
disabled={!valid} |
|
|
error={$touched.name && $errors.name} |
|
|
> |
|
|
on:blur={() => ($touched.name = true)} |
|
|
{#if template?.fromFile} |
|
|
label="Name" |
|
|
<Dropzone |
|
|
/> |
|
|
error={$touched.file && $errors.file} |
|
|
<Checkbox label="Group access" disabled value={true} text="All users" /> |
|
|
gallery={false} |
|
|
</ModalContent> |
|
|
label="File to import" |
|
|
|
|
|
value={[$values.file]} |
|
|
|
|
|
on:change={e => { |
|
|
|
|
|
$values.file = e.detail?.[0] |
|
|
|
|
|
$touched.file = true |
|
|
|
|
|
}} |
|
|
|
|
|
/> |
|
|
|
|
|
{/if} |
|
|
|
|
|
<Body size="S"> |
|
|
|
|
|
Give your new app a name, and choose which groups have access (paid plans |
|
|
|
|
|
only). |
|
|
|
|
|
</Body> |
|
|
|
|
|
<Input |
|
|
|
|
|
bind:value={$values.name} |
|
|
|
|
|
error={$touched.name && $errors.name} |
|
|
|
|
|
on:blur={() => ($touched.name = true)} |
|
|
|
|
|
label="Name" |
|
|
|
|
|
/> |
|
|
|
|
|
<Checkbox label="Group access" disabled value={true} text="All users" /> |
|
|
|
|
|
</ModalContent> |
|
|
|
|
|
{/if} |
|
|
|