From 2304032423eeb5cca745ac923d621641a2d2a18c Mon Sep 17 00:00:00 2001 From: Dean Date: Fri, 16 Jun 2023 12:30:08 +0100 Subject: [PATCH] Added embed state, behaviours and event tracking to client app. UI/UX Refactoring --- hosting/nginx.dev.conf | 10 + hosting/proxy/nginx.prod.conf | 10 + .../src/events/publishers/serve.ts | 7 +- .../SetupPanel/AutomationBlockSetup.svelte | 2 +- .../src/components/deploy/AppActions.svelte | 104 ++--- .../src/components/deploy/DeleteModal.svelte | 45 +++ .../src/components/deploy/RevertModal.svelte | 18 +- .../src/components/deploy/VersionModal.svelte | 4 +- .../src/components/portal/onboarding/tours.js | 14 +- .../components/portal/page/SideNavItem.svelte | 17 +- .../builder/app/[application]/_layout.svelte | 4 +- .../app/[application]/settings/_layout.svelte | 33 +- .../settings/automation-history/index.svelte | 7 - .../app/[application]/settings/embed.svelte | 4 +- .../portal/overview/[appId]/_layout.svelte | 252 ------------ .../access/_components/AssignmentModal.svelte | 211 ---------- .../_components/EditableRoleRenderer.svelte | 26 -- .../overview/[appId]/access/index.svelte | 271 ------------- .../_components/HistoryDetailsPanel.svelte | 82 ---- .../_components/StatusRenderer.svelte | 27 -- .../[appId]/automation-history/index.svelte | 263 ------------- .../_components/ActionsRenderer.svelte | 87 ----- .../_components/AppSizeRenderer.svelte | 41 -- .../_components/CreateRestoreModal.svelte | 27 -- .../_components/DatasourceRenderer.svelte | 21 - .../backups/_components/StatusRenderer.svelte | 15 - .../_components/TimeAgoRenderer.svelte | 10 - .../backups/_components/TypeRenderer.svelte | 36 -- .../backups/_components/UserRenderer.svelte | 18 - .../overview/[appId]/backups/index.svelte | 344 ---------------- .../portal/overview/[appId]/index.svelte | 4 - .../overview/[appId]/name-and-url.svelte | 77 ---- .../portal/overview/[appId]/overview.svelte | 368 ------------------ .../portal/overview/[appId]/version.svelte | 39 -- .../builder/portal/overview/_layout.svelte | 15 - .../builder/portal/overview/index.svelte | 4 - .../client/src/components/ClientApp.svelte | 17 +- .../client/src/components/app/Layout.svelte | 10 +- packages/client/src/index.js | 3 + packages/client/src/stores/app.js | 14 +- packages/client/src/stores/builder.js | 4 +- packages/client/src/stores/screens.js | 3 +- packages/frontend-core/src/api/analytics.js | 4 +- .../server/src/api/controllers/analytics.ts | 3 +- .../src/api/controllers/static/index.ts | 5 + .../api/controllers/static/templates/app.hbs | 2 +- packages/types/src/api/web/analytics.ts | 1 + packages/types/src/sdk/events/serve.ts | 1 + 48 files changed, 243 insertions(+), 2341 deletions(-) create mode 100644 packages/builder/src/components/deploy/DeleteModal.svelte delete mode 100644 packages/builder/src/pages/builder/portal/overview/[appId]/_layout.svelte delete mode 100644 packages/builder/src/pages/builder/portal/overview/[appId]/access/_components/AssignmentModal.svelte delete mode 100644 packages/builder/src/pages/builder/portal/overview/[appId]/access/_components/EditableRoleRenderer.svelte delete mode 100644 packages/builder/src/pages/builder/portal/overview/[appId]/access/index.svelte delete mode 100644 packages/builder/src/pages/builder/portal/overview/[appId]/automation-history/_components/HistoryDetailsPanel.svelte delete mode 100644 packages/builder/src/pages/builder/portal/overview/[appId]/automation-history/_components/StatusRenderer.svelte delete mode 100644 packages/builder/src/pages/builder/portal/overview/[appId]/automation-history/index.svelte delete mode 100644 packages/builder/src/pages/builder/portal/overview/[appId]/backups/_components/ActionsRenderer.svelte delete mode 100644 packages/builder/src/pages/builder/portal/overview/[appId]/backups/_components/AppSizeRenderer.svelte delete mode 100644 packages/builder/src/pages/builder/portal/overview/[appId]/backups/_components/CreateRestoreModal.svelte delete mode 100644 packages/builder/src/pages/builder/portal/overview/[appId]/backups/_components/DatasourceRenderer.svelte delete mode 100644 packages/builder/src/pages/builder/portal/overview/[appId]/backups/_components/StatusRenderer.svelte delete mode 100644 packages/builder/src/pages/builder/portal/overview/[appId]/backups/_components/TimeAgoRenderer.svelte delete mode 100644 packages/builder/src/pages/builder/portal/overview/[appId]/backups/_components/TypeRenderer.svelte delete mode 100644 packages/builder/src/pages/builder/portal/overview/[appId]/backups/_components/UserRenderer.svelte delete mode 100644 packages/builder/src/pages/builder/portal/overview/[appId]/backups/index.svelte delete mode 100644 packages/builder/src/pages/builder/portal/overview/[appId]/index.svelte delete mode 100644 packages/builder/src/pages/builder/portal/overview/[appId]/name-and-url.svelte delete mode 100644 packages/builder/src/pages/builder/portal/overview/[appId]/overview.svelte delete mode 100644 packages/builder/src/pages/builder/portal/overview/[appId]/version.svelte delete mode 100644 packages/builder/src/pages/builder/portal/overview/_layout.svelte delete mode 100644 packages/builder/src/pages/builder/portal/overview/index.svelte diff --git a/hosting/nginx.dev.conf b/hosting/nginx.dev.conf index 1ecee422cd..915125cbce 100644 --- a/hosting/nginx.dev.conf +++ b/hosting/nginx.dev.conf @@ -126,6 +126,16 @@ http { proxy_pass http://app-service; } + location /embed { + rewrite /embed/(.*) /app/$1 break; + proxy_pass http://app-service; + proxy_redirect off; + proxy_set_header Host $host; + proxy_set_header x-budibase-embed "true"; + add_header x-budibase-embed "true"; + add_header Content-Security-Policy "frame-ancestors *"; + } + location /builder { proxy_read_timeout 120s; proxy_connect_timeout 120s; diff --git a/hosting/proxy/nginx.prod.conf b/hosting/proxy/nginx.prod.conf index 001a08a9a6..9ce6b54053 100644 --- a/hosting/proxy/nginx.prod.conf +++ b/hosting/proxy/nginx.prod.conf @@ -92,6 +92,16 @@ http { proxy_pass $apps; } + location /embed { + rewrite /embed/(.*) /app/$1 break; + proxy_pass $apps; + proxy_redirect off; + proxy_set_header Host $host; + proxy_set_header x-budibase-embed "true"; + add_header x-budibase-embed "true"; + add_header Content-Security-Policy "frame-ancestors *"; + } + location = / { proxy_pass $apps; } diff --git a/packages/backend-core/src/events/publishers/serve.ts b/packages/backend-core/src/events/publishers/serve.ts index 64e24e20a7..5fb0883b0b 100644 --- a/packages/backend-core/src/events/publishers/serve.ts +++ b/packages/backend-core/src/events/publishers/serve.ts @@ -14,10 +14,15 @@ async function servedBuilder(timezone: string) { await publishEvent(Event.SERVED_BUILDER, properties) } -async function servedApp(app: App, timezone: string) { +async function servedApp( + app: App, + timezone: string, + embed: boolean | undefined +) { const properties: AppServedEvent = { appVersion: app.version, timezone, + embed, } await publishEvent(Event.SERVED_APP, properties) } diff --git a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte index a8fa700b90..3144a7b44b 100644 --- a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte +++ b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte @@ -333,7 +333,7 @@ : null}>{value.title || (key === "row" ? "Table" : key)} {/if} - {#if value.type === "string" && value.enum && canShowField(key)} + {#if value.type === "string" && value.enum && canShowField(key, value)} + diff --git a/packages/builder/src/components/deploy/RevertModal.svelte b/packages/builder/src/components/deploy/RevertModal.svelte index 364add9053..a36ecb0b79 100644 --- a/packages/builder/src/components/deploy/RevertModal.svelte +++ b/packages/builder/src/components/deploy/RevertModal.svelte @@ -5,6 +5,7 @@ notifications, ModalContent, ActionButton, + Link, } from "@budibase/bbui" import { store } from "builderStore" import { API } from "api" @@ -28,16 +29,15 @@ notifications.error(`Error reverting changes: ${error}`) } } - - + export const hide = () => { + revertModal.hide() + } + + export const show = () => { + revertModal.show() + } + {#if !hideIcon && updateAvailable} - - Update available - + Update {/if} { title: "Data", route: "/builder/app/:application/data", layout: OnboardingData, - query: ".topcenternav .spectrum-Tabs-item#builder-data-tab", + query: ".topleftnav .spectrum-Tabs-item#builder-data-tab", onLoad: async () => { tourEvent(TOUR_STEP_KEYS.BUILDER_DATA_SECTION) }, @@ -45,20 +45,20 @@ const getTours = () => { title: "Design", route: "/builder/app/:application/design", layout: OnboardingDesign, - query: ".topcenternav .spectrum-Tabs-item#builder-design-tab", + query: ".topleftnav .spectrum-Tabs-item#builder-design-tab", onLoad: () => { tourEvent(TOUR_STEP_KEYS.BUILDER_DESIGN_SECTION) }, align: "left", }, { - id: TOUR_STEP_KEYS.BUILDER_AUTOMATE_SECTION, + id: TOUR_STEP_KEYS.BUILDER_AUTOMATION_SECTION, title: "Automations", - route: "/builder/app/:application/automate", - query: ".topcenternav .spectrum-Tabs-item#builder-automate-tab", + route: "/builder/app/:application/automation", + query: ".topleftnav .spectrum-Tabs-item#builder-automation-tab", body: "Once you have your app screens made, you can set up automations to fit in with your current workflow", onLoad: () => { - tourEvent(TOUR_STEP_KEYS.BUILDER_AUTOMATE_SECTION) + tourEvent(TOUR_STEP_KEYS.BUILDER_AUTOMATION_SECTION) }, align: "left", }, diff --git a/packages/builder/src/components/portal/page/SideNavItem.svelte b/packages/builder/src/components/portal/page/SideNavItem.svelte index c22b8b6113..ff627acfc5 100644 --- a/packages/builder/src/components/portal/page/SideNavItem.svelte +++ b/packages/builder/src/components/portal/page/SideNavItem.svelte @@ -4,18 +4,27 @@ export let active = false - - {text || ""} - +{#if url} + + {text || ""} + +{:else} + + + {text || ""} + +{/if} diff --git a/packages/builder/src/pages/builder/portal/overview/[appId]/access/_components/AssignmentModal.svelte b/packages/builder/src/pages/builder/portal/overview/[appId]/access/_components/AssignmentModal.svelte deleted file mode 100644 index b3aed56a48..0000000000 --- a/packages/builder/src/pages/builder/portal/overview/[appId]/access/_components/AssignmentModal.svelte +++ /dev/null @@ -1,211 +0,0 @@ - - - addData(data)} - showCloseIcon={false} - disabled={!valid} -> - {#if data.length} - - {#each data as input, index} -
-
- x._id !== Constants.Roles.PUBLIC - )} - secondaryPlaceholder="Access" - bind:primaryValue={input.id} - bind:secondaryValue={input.role} - bind:searchTerm={search} - getPrimaryOptionLabel={group => group.name} - getPrimaryOptionValue={group => group.name} - getPrimaryOptionIcon={group => group.icon} - getPrimaryOptionColour={group => group.colour} - getSecondaryOptionLabel={role => role.name} - getSecondaryOptionValue={role => role._id} - getSecondaryOptionColour={role => - RoleUtils.getRoleColour(role._id)} - /> -
-
- removeItem(index)} - /> -
-
- {/each} -
- {/if} -
- Add more -
-
- - diff --git a/packages/builder/src/pages/builder/portal/overview/[appId]/access/_components/EditableRoleRenderer.svelte b/packages/builder/src/pages/builder/portal/overview/[appId]/access/_components/EditableRoleRenderer.svelte deleted file mode 100644 index d92a522602..0000000000 --- a/packages/builder/src/pages/builder/portal/overview/[appId]/access/_components/EditableRoleRenderer.svelte +++ /dev/null @@ -1,26 +0,0 @@ - - -
- rolesContext.updateRole(e.detail, row._id)} - on:remove={() => rolesContext.removeRole(row._id)} - /> -
- - diff --git a/packages/builder/src/pages/builder/portal/overview/[appId]/access/index.svelte b/packages/builder/src/pages/builder/portal/overview/[appId]/access/index.svelte deleted file mode 100644 index 62c5da12ec..0000000000 --- a/packages/builder/src/pages/builder/portal/overview/[appId]/access/index.svelte +++ /dev/null @@ -1,271 +0,0 @@ - - - - - Access - Assign users to your app and set their access - - - - {#if $usersFetch.loaded} - -
- Users - -
- -
- You have no users assigned yet -
-
- -
- {/if} - - {#if $usersFetch.loaded && $licensing.groupsEnabled} - -
- Groups - -
- -
- You have no groups assigned yet -
-
-
- {/if} -
-
- - - - - - diff --git a/packages/builder/src/pages/builder/portal/overview/[appId]/automation-history/_components/HistoryDetailsPanel.svelte b/packages/builder/src/pages/builder/portal/overview/[appId]/automation-history/_components/HistoryDetailsPanel.svelte deleted file mode 100644 index 565c0d1f2f..0000000000 --- a/packages/builder/src/pages/builder/portal/overview/[appId]/automation-history/_components/HistoryDetailsPanel.svelte +++ /dev/null @@ -1,82 +0,0 @@ - - -{#if history} - -
- - -
- - {history.automationName} - - - {#if history.status === STOPPED_ERROR} -
- -
- {/if} - {#if exists} -
- -
- {/if} - {#key history} -
- -
- {/key} -
-{:else} - No details found -{/if} - - diff --git a/packages/builder/src/pages/builder/portal/overview/[appId]/automation-history/_components/StatusRenderer.svelte b/packages/builder/src/pages/builder/portal/overview/[appId]/automation-history/_components/StatusRenderer.svelte deleted file mode 100644 index f041faa349..0000000000 --- a/packages/builder/src/pages/builder/portal/overview/[appId]/automation-history/_components/StatusRenderer.svelte +++ /dev/null @@ -1,27 +0,0 @@ - - - - {info.message} - diff --git a/packages/builder/src/pages/builder/portal/overview/[appId]/automation-history/index.svelte b/packages/builder/src/pages/builder/portal/overview/[appId]/automation-history/index.svelte deleted file mode 100644 index 5eb8b9d965..0000000000 --- a/packages/builder/src/pages/builder/portal/overview/[appId]/automation-history/index.svelte +++ /dev/null @@ -1,263 +0,0 @@ - - - - - Automation History - View the automations your app has executed - - - -
-