From 854950581c5247921e0050850aa0527f830a306f Mon Sep 17 00:00:00 2001 From: Dean Date: Thu, 29 Jun 2023 09:53:13 +0100 Subject: [PATCH 1/3] App metadata screen fixes, copy code button casing and delete app button hidden on publish --- .../src/builderStore/store/frontend.js | 1 + .../src/components/deploy/AppActions.svelte | 9 +++++-- .../components/start/UpdateAppModal.svelte | 2 +- .../app/[application]/settings/_layout.svelte | 24 ++++++++++++------- .../app/[application]/settings/embed.svelte | 2 +- .../settings/name-and-url.svelte | 18 ++++++++------ .../builder/src/stores/portal/overview.js | 21 ---------------- 7 files changed, 37 insertions(+), 40 deletions(-) delete mode 100644 packages/builder/src/stores/portal/overview.js diff --git a/packages/builder/src/builderStore/store/frontend.js b/packages/builder/src/builderStore/store/frontend.js index 9dfd11a537..5ed1c6b24a 100644 --- a/packages/builder/src/builderStore/store/frontend.js +++ b/packages/builder/src/builderStore/store/frontend.js @@ -155,6 +155,7 @@ export const getFrontendStore = () => { ...INITIAL_FRONTEND_STATE.features, ...application.features, }, + icon: application.icon || {}, initialised: true, })) screenHistoryStore.reset() diff --git a/packages/builder/src/components/deploy/AppActions.svelte b/packages/builder/src/components/deploy/AppActions.svelte index 0c478b9992..6f12cc2890 100644 --- a/packages/builder/src/components/deploy/AppActions.svelte +++ b/packages/builder/src/components/deploy/AppActions.svelte @@ -275,7 +275,7 @@ } }} > - {selectedApp ? `${selectedApp?.url}` : ""} + {$store.url} {#if isPublished} {:else} @@ -344,7 +344,12 @@ { await initialiseApp() }} diff --git a/packages/builder/src/components/start/UpdateAppModal.svelte b/packages/builder/src/components/start/UpdateAppModal.svelte index 3d825003a1..83cd0ad950 100644 --- a/packages/builder/src/components/start/UpdateAppModal.svelte +++ b/packages/builder/src/components/start/UpdateAppModal.svelte @@ -47,7 +47,7 @@ async function updateApp() { try { - await apps.update(app.instance._id, { + await apps.update(app.devId, { name: $values.name?.trim(), url: $values.url?.trim(), icon: { diff --git a/packages/builder/src/pages/builder/app/[application]/settings/_layout.svelte b/packages/builder/src/pages/builder/app/[application]/settings/_layout.svelte index 225e3977c3..a05e6e0014 100644 --- a/packages/builder/src/pages/builder/app/[application]/settings/_layout.svelte +++ b/packages/builder/src/pages/builder/app/[application]/settings/_layout.svelte @@ -3,8 +3,14 @@ import { Page, Layout } from "@budibase/bbui" import { url, isActive } from "@roxi/routify" import DeleteModal from "components/deploy/DeleteModal.svelte" + import { apps } from "stores/portal" + import { store } from "builderStore" let deleteModal + + $: filteredApps = $apps.filter(app => app.devId === $store.appId) + $: selectedApp = filteredApps?.length ? filteredApps[0] : null + $: isPublished = selectedApp?.status === "published" @@ -43,14 +49,16 @@ url={$url("./version")} active={$isActive("./version")} /> -
- { - deleteModal.show() - }} - /> -
+ {#if !isPublished} +
+ { + deleteModal.show() + }} + /> +
+ {/if} diff --git a/packages/builder/src/pages/builder/app/[application]/settings/embed.svelte b/packages/builder/src/pages/builder/app/[application]/settings/embed.svelte index 1a9cb57dcf..40450793d7 100644 --- a/packages/builder/src/pages/builder/app/[application]/settings/embed.svelte +++ b/packages/builder/src/pages/builder/app/[application]/settings/embed.svelte @@ -39,7 +39,7 @@ notifications.success("Copied") }} > - Copy Code + Copy code {:else} diff --git a/packages/builder/src/pages/builder/app/[application]/settings/name-and-url.svelte b/packages/builder/src/pages/builder/app/[application]/settings/name-and-url.svelte index 56a10553dc..0ff86d2e4d 100644 --- a/packages/builder/src/pages/builder/app/[application]/settings/name-and-url.svelte +++ b/packages/builder/src/pages/builder/app/[application]/settings/name-and-url.svelte @@ -19,11 +19,10 @@ $: filteredApps = $apps.filter(app => app.devId == $store.appId) $: app = filteredApps.length ? filteredApps[0] : {} - $: appUrl = `${window.origin}/app${app?.url}` $: appDeployed = app?.status === AppStatus.DEPLOYED const initialiseApp = async () => { - const applicationPkg = await API.fetchAppPackage(app.devId) + const applicationPkg = await API.fetchAppPackage($store.appId) await store.actions.initialise(applicationPkg) } @@ -37,7 +36,7 @@ - {app?.name} + {$store?.name} @@ -45,15 +44,15 @@
- {appUrl} + {$store.url}
@@ -75,7 +74,12 @@ { await initialiseApp() }} diff --git a/packages/builder/src/stores/portal/overview.js b/packages/builder/src/stores/portal/overview.js deleted file mode 100644 index aa5dc4cac4..0000000000 --- a/packages/builder/src/stores/portal/overview.js +++ /dev/null @@ -1,21 +0,0 @@ -import { writable, derived } from "svelte/store" -import { apps } from "./apps" - -const createOverviewStore = () => { - const store = writable({ - selectedAppId: null, - }) - const derivedStore = derived([store, apps], ([$store, $apps]) => { - return { - ...$store, - selectedApp: $apps?.find(app => app.devId === $store.selectedAppId), - } - }) - - return { - update: store.update, - subscribe: derivedStore.subscribe, - } -} - -export const overview = createOverviewStore() From 8d98f6ac0298c3312acf670df8a046e1c0279484 Mon Sep 17 00:00:00 2001 From: Dean Date: Thu, 29 Jun 2023 10:47:47 +0100 Subject: [PATCH 2/3] Removed the publish check from the delete app button --- .../app/[application]/settings/_layout.svelte | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/packages/builder/src/pages/builder/app/[application]/settings/_layout.svelte b/packages/builder/src/pages/builder/app/[application]/settings/_layout.svelte index a05e6e0014..225e3977c3 100644 --- a/packages/builder/src/pages/builder/app/[application]/settings/_layout.svelte +++ b/packages/builder/src/pages/builder/app/[application]/settings/_layout.svelte @@ -3,14 +3,8 @@ import { Page, Layout } from "@budibase/bbui" import { url, isActive } from "@roxi/routify" import DeleteModal from "components/deploy/DeleteModal.svelte" - import { apps } from "stores/portal" - import { store } from "builderStore" let deleteModal - - $: filteredApps = $apps.filter(app => app.devId === $store.appId) - $: selectedApp = filteredApps?.length ? filteredApps[0] : null - $: isPublished = selectedApp?.status === "published" @@ -49,16 +43,14 @@ url={$url("./version")} active={$isActive("./version")} /> - {#if !isPublished} -
- { - deleteModal.show() - }} - /> -
- {/if} +
+ { + deleteModal.show() + }} + /> +
From a5dae87fa91cd6d496ff7aebd7b4920e997daf6c Mon Sep 17 00:00:00 2001 From: Dean Date: Thu, 29 Jun 2023 16:51:32 +0100 Subject: [PATCH 3/3] App update validation updates --- .../src/components/deploy/AppActions.svelte | 2 +- .../components/start/UpdateAppModal.svelte | 21 ++++++++++++++++--- .../builder/src/helpers/validation/yup/app.js | 8 ++++++- .../settings/name-and-url.svelte | 2 +- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/packages/builder/src/components/deploy/AppActions.svelte b/packages/builder/src/components/deploy/AppActions.svelte index 6f12cc2890..a9aa3ff506 100644 --- a/packages/builder/src/components/deploy/AppActions.svelte +++ b/packages/builder/src/components/deploy/AppActions.svelte @@ -348,7 +348,7 @@ name: $store.name, url: $store.url, icon: $store.icon, - devId: $store.appId, + appId: $store.appId, }} onUpdateComplete={async () => { await initialiseApp() diff --git a/packages/builder/src/components/start/UpdateAppModal.svelte b/packages/builder/src/components/start/UpdateAppModal.svelte index 83cd0ad950..5302104a45 100644 --- a/packages/builder/src/components/start/UpdateAppModal.svelte +++ b/packages/builder/src/components/start/UpdateAppModal.svelte @@ -16,6 +16,9 @@ export let app export let onUpdateComplete + $: appIdParts = app.appId ? app.appId?.split("_") : [] + $: appId = appIdParts.slice(-1)[0] + const values = writable({ name: app.name, url: app.url, @@ -35,8 +38,20 @@ const setupValidation = async () => { const applications = svelteGet(apps) - appValidation.name(validation, { apps: applications, currentApp: app }) - appValidation.url(validation, { apps: applications, currentApp: app }) + appValidation.name(validation, { + apps: applications, + currentApp: { + ...app, + appId, + }, + }) + appValidation.url(validation, { + apps: applications, + currentApp: { + ...app, + appId, + }, + }) // init validation const { url } = $values validation.check({ @@ -47,7 +62,7 @@ async function updateApp() { try { - await apps.update(app.devId, { + await apps.update(app.appId, { name: $values.name?.trim(), url: $values.url?.trim(), icon: { diff --git a/packages/builder/src/helpers/validation/yup/app.js b/packages/builder/src/helpers/validation/yup/app.js index 8498255cc9..1947844f63 100644 --- a/packages/builder/src/helpers/validation/yup/app.js +++ b/packages/builder/src/helpers/validation/yup/app.js @@ -52,7 +52,13 @@ export const url = (validation, { apps, currentApp } = { apps: [] }) => { } return !apps .map(app => app.url) - .some(appUrl => appUrl?.toLowerCase() === value.toLowerCase()) + .some(appUrl => { + const url = + appUrl?.[0] === "/" + ? appUrl.substring(1, appUrl.length) + : appUrl + return url?.toLowerCase() === value.toLowerCase() + }) } ) .test("valid-url", "Not a valid URL", value => { diff --git a/packages/builder/src/pages/builder/app/[application]/settings/name-and-url.svelte b/packages/builder/src/pages/builder/app/[application]/settings/name-and-url.svelte index 0ff86d2e4d..54417aef35 100644 --- a/packages/builder/src/pages/builder/app/[application]/settings/name-and-url.svelte +++ b/packages/builder/src/pages/builder/app/[application]/settings/name-and-url.svelte @@ -78,7 +78,7 @@ name: $store.name, url: $store.url, icon: $store.icon, - devId: $store.appId, + appId: $store.appId, }} onUpdateComplete={async () => { await initialiseApp()