From f1777c23f715111a837c2186af365d980fc2be60 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 10 May 2022 18:20:26 +0100 Subject: [PATCH] Add fallback UI when no screens exist and add custom theme metadata to new apps --- .../design/_old/[assetType]/_layout.svelte | 61 +------------------ .../app/[application]/design/index.svelte | 48 ++++++++++++++- .../server/src/api/controllers/application.ts | 9 +++ 3 files changed, 57 insertions(+), 61 deletions(-) diff --git a/packages/builder/src/components/design/_old/[assetType]/_layout.svelte b/packages/builder/src/components/design/_old/[assetType]/_layout.svelte index 264e245d95..6132eaa32c 100644 --- a/packages/builder/src/components/design/_old/[assetType]/_layout.svelte +++ b/packages/builder/src/components/design/_old/[assetType]/_layout.svelte @@ -13,7 +13,6 @@ import AppThemeSelect from "components/design/AppPreview/AppThemeSelect.svelte" import ThemeEditor from "components/design/AppPreview/ThemeEditor.svelte" import DevicePreviewSelect from "components/design/AppPreview/DevicePreviewSelect.svelte" - import Logo from "assets/bb-space-man.svg" import ScreenWizard from "components/design/navigation/ScreenWizard.svelte" // Cache previous values so we don't update the URL more than necessary @@ -150,28 +149,7 @@ -
- {#if $currentAsset}{:else} -
-
- - logo -
- LET’S BRING THIS APP TO LIFE -
- -
-
-
- {/if} -
+
{#if $selectedComponent != null}
@@ -192,30 +170,7 @@ flex: 1 1 auto; height: 0; } - .new-screen-text { - width: 160px; - text-align: center; - color: #2c2c2c; - font-weight: 600; - } - .new-screen-button { - margin-left: 5px; - height: 20px; - width: 100px; - display: flex; - align-items: center; - } - - .background-icon { - margin-top: 4px; - margin-right: 4px; - } - - .img-size { - width: 160px; - height: 160px; - } .ui-nav { grid-column: 1; background-color: var(--background); @@ -236,18 +191,4 @@ border-left: var(--border-light); overflow-x: hidden; } - - .centered { - width: calc(100% - 350px); - height: calc(100% - 100px); - position: absolute; - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; - } - - .main { - width: 300px; - } diff --git a/packages/builder/src/pages/builder/app/[application]/design/index.svelte b/packages/builder/src/pages/builder/app/[application]/design/index.svelte index 3f66f1511d..6490000b35 100644 --- a/packages/builder/src/pages/builder/app/[application]/design/index.svelte +++ b/packages/builder/src/pages/builder/app/[application]/design/index.svelte @@ -2,9 +2,28 @@ import { store, selectedScreen } from "builderStore" import { onMount } from "svelte" import { redirect } from "@roxi/routify" + import { Layout, Button, Detail, notifications } from "@budibase/bbui" + import Logo from "assets/bb-space-man.svg" + import createFromScratchScreen from "builderStore/store/screenTemplates/createFromScratchScreen" + import { Roles } from "constants/backend" let loaded = false + const createFirstScreen = async () => { + let screen = createFromScratchScreen.create() + screen.routing.route = "/home" + screen.routing.roldId = Roles.BASIC + screen.routing.homeScreen = true + try { + const savedScreen = await store.actions.screens.save(screen) + notifications.success("Screen created successfully") + $redirect(`./${savedScreen._id}`) + } catch (err) { + console.error("Could not create screen", err) + notifications.error("Error creating screen") + } + } + onMount(() => { if ($selectedScreen) { $redirect(`./${$selectedScreen._id}`) @@ -17,5 +36,32 @@ {#if loaded} - You need to create a screen! +
+ + logo +
+ LET’S BRING THIS APP TO LIFE +
+ +
+
{/if} + + diff --git a/packages/server/src/api/controllers/application.ts b/packages/server/src/api/controllers/application.ts index 5d05592f32..337c8b9e09 100644 --- a/packages/server/src/api/controllers/application.ts +++ b/packages/server/src/api/controllers/application.ts @@ -277,8 +277,17 @@ const performAppCreate = async (ctx: any) => { title: name, navWidth: "Large", navBackground: "var(--spectrum-global-color-gray-50)", + links: [ + { + url: "/home", + text: "Home", + }, + ], }, theme: "spectrum--light", + customTheme: { + buttonBorderRadius: "16px", + }, } const response = await db.put(newApplication, { force: true }) newApplication._rev = response.rev