Making app creation experience more cohesive, allowing app import even when no apps exist.

This commit is contained in:
mike12345567 2021-10-19 14:06:43 +01:00
parent 9cc9461c50
commit a054cfdb4d
3 changed files with 28 additions and 10 deletions

View File

@ -39,9 +39,11 @@
let submitting = false let submitting = false
let valid = false let valid = false
let wasShowingTemplates
$: checkValidity($values, validator) $: checkValidity($values, validator)
$: showTemplateSelection = !template?.fromFile && !template?.key $: showTemplateSelection =
!template || (!template?.fromFile && !template?.key)
onMount(async () => { onMount(async () => {
await hostingStore.actions.fetchDeployedApps() await hostingStore.actions.fetchDeployedApps()
@ -145,15 +147,20 @@
size="L" size="L"
onConfirm={() => { onConfirm={() => {
showTemplateSelection = false showTemplateSelection = false
wasShowingTemplates = true
return false return false
}} }}
showCancelButton={false} showCancelButton={false}
showCloseIcon={false} showCloseIcon={false}
> >
<TemplateList <TemplateList
onSelect={selected => { onSelect={(selected, { useImport } = {}) => {
if (!selected) { if (!selected) {
if (useImport) {
template = { fromFile: true }
}
showTemplateSelection = false showTemplateSelection = false
wasShowingTemplates = true
return return
} }
@ -166,6 +173,8 @@
title={template?.fromFile ? "Import app" : "Create app"} title={template?.fromFile ? "Import app" : "Create app"}
confirmText={template?.fromFile ? "Import app" : "Create app"} confirmText={template?.fromFile ? "Import app" : "Create app"}
onConfirm={createNewApp} onConfirm={createNewApp}
onCancel={wasShowingTemplates ? () => (template = null) : null}
cancelText={wasShowingTemplates ? "Back" : undefined}
disabled={!valid} disabled={!valid}
> >
{#if template?.fromFile} {#if template?.fromFile}

View File

@ -7,7 +7,6 @@
async function fetchTemplates() { async function fetchTemplates() {
const response = await api.get("/api/templates?type=app") const response = await api.get("/api/templates?type=app")
console.log("Responded")
return await response.json() return await response.json()
} }
@ -48,6 +47,19 @@
<Heading size="XS">Start from scratch</Heading> <Heading size="XS">Start from scratch</Heading>
<p class="detail">BLANK</p> <p class="detail">BLANK</p>
</div> </div>
<div
class="template import"
on:click={() => onSelect(null, { useImport: true })}
>
<div
class="background-icon"
style={`background: rgb(50, 50, 50); color: white;`}
>
<Icon name="Add" />
</div>
<Heading size="XS">Import app</Heading>
<p class="detail">BLANK</p>
</div>
</div> </div>
{:catch err} {:catch err}
<h1 style="color:red">{err}</h1> <h1 style="color:red">{err}</h1>
@ -95,4 +107,8 @@
background: var(--spectrum-global-color-gray-50); background: var(--spectrum-global-color-gray-50);
margin-top: 20px; margin-top: 20px;
} }
.import {
background: var(--spectrum-global-color-gray-50);
}
</style> </style>

View File

@ -84,12 +84,6 @@
} }
} }
const initiateAppImport = () => {
template = { fromFile: true }
creationModal.show()
creatingApp = true
}
const stopAppCreation = () => { const stopAppCreation = () => {
template = null template = null
creatingApp = false creatingApp = false
@ -207,7 +201,6 @@
{#if cloud} {#if cloud}
<Button secondary on:click={initiateAppsExport}>Export apps</Button> <Button secondary on:click={initiateAppsExport}>Export apps</Button>
{/if} {/if}
<Button secondary on:click={initiateAppImport}>Import app</Button>
<Button cta on:click={initiateAppCreation}>Create app</Button> <Button cta on:click={initiateAppCreation}>Create app</Button>
</ButtonGroup> </ButtonGroup>
</div> </div>