Merge pull request #3086 from Budibase/fix/create-app-exp
Make it possible for first app to be an imported one
This commit is contained in:
commit
381687f663
|
@ -35,7 +35,7 @@ Cypress.Commands.add("login", () => {
|
|||
Cypress.Commands.add("createApp", name => {
|
||||
cy.visit(`localhost:${Cypress.env("PORT")}/builder`)
|
||||
cy.wait(500)
|
||||
cy.contains(/Start from scratch/).click()
|
||||
cy.contains(/Start from scratch/).dblclick()
|
||||
cy.get(".spectrum-Modal").within(() => {
|
||||
cy.get("input").eq(0).type(name).should("have.value", name).blur()
|
||||
cy.get(".spectrum-ButtonGroup").contains("Create app").click()
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
import TemplateList from "./TemplateList.svelte"
|
||||
|
||||
export let template
|
||||
export let inline
|
||||
|
||||
const values = writable({ name: null })
|
||||
const errors = writable({})
|
||||
|
@ -39,9 +40,10 @@
|
|||
|
||||
let submitting = false
|
||||
let valid = false
|
||||
let initialTemplateInfo = template?.fromFile || template?.key
|
||||
|
||||
$: checkValidity($values, validator)
|
||||
$: showTemplateSelection = !template?.fromFile && !template?.key
|
||||
$: showTemplateSelection = !template && !initialTemplateInfo
|
||||
|
||||
onMount(async () => {
|
||||
await hostingStore.actions.fetchDeployedApps()
|
||||
|
@ -75,10 +77,12 @@
|
|||
}
|
||||
|
||||
async function createNewApp() {
|
||||
const letTemplateToUse =
|
||||
Object.keys(template).length === 0 ? null : template
|
||||
submitting = true
|
||||
|
||||
// Check a template exists if we are important
|
||||
if (template?.fromFile && !$values.file) {
|
||||
if (letTemplateToUse?.fromFile && !$values.file) {
|
||||
$errors.file = "Please choose a file to import"
|
||||
valid = false
|
||||
submitting = false
|
||||
|
@ -89,10 +93,10 @@
|
|||
// Create form data to create app
|
||||
let data = new FormData()
|
||||
data.append("name", $values.name.trim())
|
||||
data.append("useTemplate", template != null)
|
||||
if (template) {
|
||||
data.append("templateName", template.name)
|
||||
data.append("templateKey", template.key)
|
||||
data.append("useTemplate", letTemplateToUse != null)
|
||||
if (letTemplateToUse) {
|
||||
data.append("templateName", letTemplateToUse.name)
|
||||
data.append("templateKey", letTemplateToUse.key)
|
||||
data.append("templateFile", $values.file)
|
||||
}
|
||||
|
||||
|
@ -106,7 +110,7 @@
|
|||
analytics.captureEvent(Events.APP.CREATED, {
|
||||
name: $values.name,
|
||||
appId: appJson.instance._id,
|
||||
template,
|
||||
letTemplateToUse,
|
||||
})
|
||||
|
||||
// Select Correct Application/DB in prep for creating user
|
||||
|
@ -144,19 +148,18 @@
|
|||
showConfirmButton={false}
|
||||
size="L"
|
||||
onConfirm={() => {
|
||||
showTemplateSelection = false
|
||||
template = {}
|
||||
return false
|
||||
}}
|
||||
showCancelButton={false}
|
||||
showCloseIcon={false}
|
||||
showCancelButton={!inline}
|
||||
showCloseIcon={!inline}
|
||||
>
|
||||
<TemplateList
|
||||
onSelect={selected => {
|
||||
onSelect={(selected, { useImport } = {}) => {
|
||||
if (!selected) {
|
||||
showTemplateSelection = false
|
||||
template = useImport ? { fromFile: true } : {}
|
||||
return
|
||||
}
|
||||
|
||||
template = selected
|
||||
}}
|
||||
/>
|
||||
|
@ -166,6 +169,9 @@
|
|||
title={template?.fromFile ? "Import app" : "Create app"}
|
||||
confirmText={template?.fromFile ? "Import app" : "Create app"}
|
||||
onConfirm={createNewApp}
|
||||
onCancel={inline ? () => (template = null) : null}
|
||||
cancelText={inline ? "Back" : undefined}
|
||||
showCloseIcon={!inline}
|
||||
disabled={!valid}
|
||||
>
|
||||
{#if template?.fromFile}
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
async function fetchTemplates() {
|
||||
const response = await api.get("/api/templates?type=app")
|
||||
console.log("Responded")
|
||||
return await response.json()
|
||||
}
|
||||
|
||||
|
@ -48,6 +47,19 @@
|
|||
<Heading size="XS">Start from scratch</Heading>
|
||||
<p class="detail">BLANK</p>
|
||||
</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 an app</Heading>
|
||||
<p class="detail">BLANK</p>
|
||||
</div>
|
||||
</div>
|
||||
{:catch err}
|
||||
<h1 style="color:red">{err}</h1>
|
||||
|
@ -95,4 +107,8 @@
|
|||
background: var(--spectrum-global-color-gray-50);
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.import {
|
||||
background: var(--spectrum-global-color-gray-50);
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -268,7 +268,7 @@
|
|||
{#if !enrichedApps.length && !creatingApp && loaded}
|
||||
<div class="empty-wrapper">
|
||||
<Modal inline>
|
||||
<CreateAppModal {template} />
|
||||
<CreateAppModal {template} inline={true} />
|
||||
</Modal>
|
||||
</div>
|
||||
{/if}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue