From 2a6c775fa0849d00ee578ccb495737c566e8b250 Mon Sep 17 00:00:00 2001 From: Dean Date: Wed, 27 Apr 2022 14:50:30 +0100 Subject: [PATCH 1/3] Add a default screen to newly created apps not using templates --- .../components/start/CreateAppModal.svelte | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/packages/builder/src/components/start/CreateAppModal.svelte b/packages/builder/src/components/start/CreateAppModal.svelte index e75d7c4d09..0a2d226e55 100644 --- a/packages/builder/src/components/start/CreateAppModal.svelte +++ b/packages/builder/src/components/start/CreateAppModal.svelte @@ -10,6 +10,8 @@ import { createValidationStore } from "helpers/validation/yup" import * as appValidation from "helpers/validation/yup/app" import TemplateCard from "components/common/TemplateCard.svelte" + import createFromScratchScreen from "builderStore/store/screenTemplates/createFromScratchScreen" + import { Roles } from "constants/backend" export let template @@ -81,7 +83,7 @@ } data.append("useTemplate", template != null) if (template) { - data.append("templateName", template.name) + data.append("templateName", template.name) //or here? data.append("templateKey", template.key) data.append("templateFile", $values.file) } @@ -104,6 +106,22 @@ // Create user await API.updateOwnMetadata({ roleId: $values.roleId }) await auth.setInitInfo({}) + + // Create a default home screen if no template was selected + if (template == null) { + let defaultScreenTemplate = createFromScratchScreen.create() + defaultScreenTemplate.routing.route = "/home" + defaultScreenTemplate.routing.roldId = Roles.BASIC + try { + await store.actions.screens.save(defaultScreenTemplate) + } catch (err) { + console.error("Could not create a default application screen", err) + notifications.warn( + "Encountered an issue creating the default screen." + ) + } + } + $goto(`/builder/app/${createdApp.instance._id}`) } catch (error) { creating = false From eb8b086d2cdb6a91ae00c1a64bb4eb12028e57bc Mon Sep 17 00:00:00 2001 From: Dean Date: Tue, 10 May 2022 17:18:25 +0100 Subject: [PATCH 2/3] packages/builder/src/components/start/CreateAppModal.svelte --- packages/builder/src/components/start/CreateAppModal.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/builder/src/components/start/CreateAppModal.svelte b/packages/builder/src/components/start/CreateAppModal.svelte index 0a2d226e55..74d2e7675e 100644 --- a/packages/builder/src/components/start/CreateAppModal.svelte +++ b/packages/builder/src/components/start/CreateAppModal.svelte @@ -116,7 +116,7 @@ await store.actions.screens.save(defaultScreenTemplate) } catch (err) { console.error("Could not create a default application screen", err) - notifications.warn( + notifications.warning( "Encountered an issue creating the default screen." ) } From d9524ba3b6b04bb67cd780f40e672bc07f9863c6 Mon Sep 17 00:00:00 2001 From: Dean Date: Tue, 10 May 2022 22:40:27 +0100 Subject: [PATCH 3/3] Cypress test fixes --- packages/builder/cypress/integration/createScreen.js | 2 +- packages/builder/cypress/integration/revertApp.spec.js | 3 +++ packages/builder/cypress/support/commands.js | 1 - 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/builder/cypress/integration/createScreen.js b/packages/builder/cypress/integration/createScreen.js index ae10577ff0..94a827f26f 100644 --- a/packages/builder/cypress/integration/createScreen.js +++ b/packages/builder/cypress/integration/createScreen.js @@ -9,7 +9,7 @@ filterTests(["smoke", "all"], () => { }) it("Should successfully create a screen", () => { - cy.createScreen("/test") + cy.createScreen("test") cy.get(".nav-items-container").within(() => { cy.contains("/test").should("exist") }) diff --git a/packages/builder/cypress/integration/revertApp.spec.js b/packages/builder/cypress/integration/revertApp.spec.js index 9d5e4f0f63..01d5a04981 100644 --- a/packages/builder/cypress/integration/revertApp.spec.js +++ b/packages/builder/cypress/integration/revertApp.spec.js @@ -26,6 +26,8 @@ filterTests(['smoke', 'all'], () => { }) it("should revert a published app", () => { + cy.navigateToFrontend() + // Add initial component - Paragraph cy.addComponent("Elements", "Paragraph") // Publish app @@ -37,6 +39,7 @@ filterTests(['smoke', 'all'], () => { cy.get(".spectrum-ButtonGroup").within(() => { cy.get(".spectrum-Button").contains("Done").click({ force: true }) }) + // Add second component - Button cy.addComponent("Elements", "Button") // Click Revert diff --git a/packages/builder/cypress/support/commands.js b/packages/builder/cypress/support/commands.js index ce1fe2ec50..9f3b14a413 100644 --- a/packages/builder/cypress/support/commands.js +++ b/packages/builder/cypress/support/commands.js @@ -145,7 +145,6 @@ Cypress.Commands.add("createTestApp", () => { const appName = "Cypress Tests" cy.deleteApp(appName) cy.createApp(appName, "This app is used for Cypress testing.") - cy.createScreen("home") }) Cypress.Commands.add("createTestTableWithData", () => {