From fffb4b017488f3fa7c66f59dbdf1ddf8b1764230 Mon Sep 17 00:00:00 2001 From: Dean Date: Fri, 6 May 2022 15:52:49 +0100 Subject: [PATCH] Overview Tab refactoring and general updates to the homepage --- .../src/components/common/AppLockModal.svelte | 20 ++- .../src/components/deploy/VersionModal.svelte | 18 ++- .../src/components/start/AppRow.svelte | 2 +- .../pages/builder/portal/apps/index.svelte | 82 +++++------ .../overview/[application]/index.svelte | 50 ++----- .../overview/_components/OverviewTab.svelte | 64 +++++++-- .../overview/_components/SelfHostTab.svelte | 37 ----- .../overview/_components/SettingsTab.svelte | 131 ++++++++++++++++++ .../_components/VersionModalBody.svelte | 0 .../overview/_components/VersionTab.svelte | 48 ------- packages/server/src/middleware/builder.js | 14 +- 11 files changed, 265 insertions(+), 201 deletions(-) delete mode 100644 packages/builder/src/pages/builder/portal/overview/_components/SelfHostTab.svelte create mode 100644 packages/builder/src/pages/builder/portal/overview/_components/SettingsTab.svelte delete mode 100644 packages/builder/src/pages/builder/portal/overview/_components/VersionModalBody.svelte delete mode 100644 packages/builder/src/pages/builder/portal/overview/_components/VersionTab.svelte diff --git a/packages/builder/src/components/common/AppLockModal.svelte b/packages/builder/src/components/common/AppLockModal.svelte index 98da510a89..a08893a37d 100644 --- a/packages/builder/src/components/common/AppLockModal.svelte +++ b/packages/builder/src/components/common/AppLockModal.svelte @@ -5,20 +5,23 @@ ModalContent, Modal, notifications, + ProgressCircle, } from "@budibase/bbui" import { auth, apps } from "stores/portal" import { processStringSync } from "@budibase/string-templates" import { API } from "api" export let app + export let buttonSize = "M" - let APP_DEV_LOCK_SECONDS = 600 + let APP_DEV_LOCK_SECONDS = 600 //common area for this? let appLockModal + let processing = false $: lockedBy = app?.lockedBy $: lockedByYou = $auth.user.email === lockedBy?.email $: lockIdentifer = `${ - Object.prototype.hasOwnProperty.call(lockedBy, "firstName") + lockedBy && Object.prototype.hasOwnProperty.call(lockedBy, "firstName") ? lockedBy?.firstName : lockedBy?.email }` @@ -28,7 +31,7 @@ $: lockExpiry = getExpiryDuration(app) const getExpiryDuration = app => { - if (!app.lockedBy) { + if (!app?.lockedBy?.lockedAt) { return -1 } let expiry = @@ -37,6 +40,7 @@ } const releaseLock = async () => { + processing = true if (app) { try { await API.releaseAppLock(app.devId) @@ -48,6 +52,7 @@ } else { notifications.error("No application is selected") } + processing = false } @@ -57,6 +62,7 @@ quiet secondary icon="LockClosed" + size={buttonSize} on:click={() => { appLockModal.show() }} @@ -93,6 +99,7 @@ {/if} diff --git a/packages/builder/src/components/deploy/VersionModal.svelte b/packages/builder/src/components/deploy/VersionModal.svelte index 9707517c54..3ddc7a1115 100644 --- a/packages/builder/src/components/deploy/VersionModal.svelte +++ b/packages/builder/src/components/deploy/VersionModal.svelte @@ -11,6 +11,16 @@ import { API } from "api" import clientPackage from "@budibase/client/package.json" + export function show() { + updateModal.show() + } + + export function hide() { + updateModal.hide() + } + + export let hideIcon = false + let updateModal $: appId = $store.appId @@ -57,9 +67,11 @@ } -
- -
+{#if !hideIcon} +
+ +
+{/if}
- +
diff --git a/packages/builder/src/pages/builder/portal/apps/index.svelte b/packages/builder/src/pages/builder/portal/apps/index.svelte index 9b70068e10..9ee3854998 100644 --- a/packages/builder/src/pages/builder/portal/apps/index.svelte +++ b/packages/builder/src/pages/builder/portal/apps/index.svelte @@ -2,7 +2,6 @@ import { Heading, Layout, - Detail, Button, Input, Select, @@ -312,48 +311,7 @@ {welcomeBody} - -
- - {#if $apps?.length > 0} - - {/if} - {#if !$apps?.length} - - {/if} -
-
- - - -
-
{#if !$apps?.length && $templates?.length} @@ -363,7 +321,40 @@ {#if enrichedApps.length}
- Apps +
+ + {#if $apps?.length > 0} + + {/if} + {#if !$apps?.length} + + {/if} +
{#if enrichedApps.length > 1}
{#if cloud} @@ -394,7 +385,7 @@
{/if}
- +
{#each filteredApps as app (app.appId)} button) { margin-right: 10px; } - .title .welcome > .buttons { - padding-top: 30px; - } .title { display: flex; flex-direction: row; diff --git a/packages/builder/src/pages/builder/portal/overview/[application]/index.svelte b/packages/builder/src/pages/builder/portal/overview/[application]/index.svelte index 46fd95c1e9..b60f601b12 100644 --- a/packages/builder/src/pages/builder/portal/overview/[application]/index.svelte +++ b/packages/builder/src/pages/builder/portal/overview/[application]/index.svelte @@ -13,12 +13,9 @@ ProgressCircle, } from "@budibase/bbui" import OverviewTab from "../_components/OverviewTab.svelte" - import VersionTab from "../_components/VersionTab.svelte" - import SelfHostTab from "../_components/SelfHostTab.svelte" + import SettingsTab from "../_components/SettingsTab.svelte" import { API } from "api" - import { onMount } from "svelte" import { store } from "builderStore" - import { roles, flags } from "stores/backend" import { apps, auth } from "stores/portal" import analytics, { Events, EventSource } from "analytics" import { AppStatus } from "constants" @@ -37,7 +34,7 @@ $: lockedBy = selectedApp?.lockedBy $: lockedByYou = $auth.user.email === lockedBy?.email $: lockIdentifer = `${ - Object.prototype.hasOwnProperty.call(lockedBy, "firstName") + lockedBy && Object.prototype.hasOwnProperty.call(lockedBy, "firstName") ? lockedBy?.firstName : lockedBy?.email }` @@ -55,13 +52,7 @@ selectedApp?.status === AppStatus.DEPLOYED && latestDeployments?.length > 0 $: appUrl = `${window.origin}/app${selectedApp?.url}` - $: tabs = [ - "Overview", - "Automation History", - "Backups", - "App Version", - "Self-host", - ] + $: tabs = ["Overview", "Automation History", "Backups", "Settings"] $: selectedTab = "Overview" const handleTabChange = tabKey => { @@ -78,9 +69,8 @@ try { const pkg = await API.fetchAppPackage(application) await store.actions.initialise(pkg) - // await automationStore.actions.fetch() - await roles.fetch() - await flags.fetch() + await apps.load() + deployments = await fetchDeployments() return pkg } catch (error) { notifications.error(`Error initialising app: ${error?.message}`) @@ -108,8 +98,6 @@ } } - //Show prod: published, appUrl - //Behaviour incorrect. It should be enabled if at least 1 live deployment is available const viewApp = () => { if (isPublished) { analytics.captureEvent(Events.APP.VIEW_PUBLISHED, { @@ -129,18 +117,6 @@ } $goto(`../../../app/${app.devId}`) } - - onMount(async () => { - // if (!hasSynced && application) { - // try { - // await API.syncApp(application) - // } catch (error) { - // notifications.error("Failed to sync with production database") - // } - // hasSynced = true - // } - deployments = await fetchDeployments() - }) @@ -187,7 +163,14 @@ disabled={!isPublished} on:click={viewApp}>View app - @@ -213,11 +196,8 @@
Backups contents
- - - - - + + {:catch error} diff --git a/packages/builder/src/pages/builder/portal/overview/_components/OverviewTab.svelte b/packages/builder/src/pages/builder/portal/overview/_components/OverviewTab.svelte index 4319f51e0c..32bae0a6f5 100644 --- a/packages/builder/src/pages/builder/portal/overview/_components/OverviewTab.svelte +++ b/packages/builder/src/pages/builder/portal/overview/_components/OverviewTab.svelte @@ -1,17 +1,43 @@
@@ -46,14 +72,21 @@
- {app.updatedAt}
- -
- - -
{app.updatedBy.firstName}
-
+ {#await userPromise} + + {:then _} +
+ {#if appEditor} + +
+ {appEditor._id === $auth.user._id ? "You" : appEditorText} +
+ {/if} +
+ {:catch error} +

Could not fetch user: {error.message}

+ {/await}

{#if app} {processStringSync( @@ -70,7 +103,7 @@ title={"App Version"} showIcon={true} action={() => { - navigateTab("App Version") + navigateTab("Settings") }} >

@@ -81,7 +114,7 @@ { if (typeof navigateTab === "function") { - navigateTab("App Version") + navigateTab("Settings") } }} > @@ -120,7 +153,12 @@
- + { + navigateTab("Backups") + }} + >
test
diff --git a/packages/builder/src/pages/builder/portal/overview/_components/SelfHostTab.svelte b/packages/builder/src/pages/builder/portal/overview/_components/SelfHostTab.svelte deleted file mode 100644 index 16804a8eb6..0000000000 --- a/packages/builder/src/pages/builder/portal/overview/_components/SelfHostTab.svelte +++ /dev/null @@ -1,37 +0,0 @@ - - -
- - - - Self-host Budibase - - -

- Self-host Budibase for free to get unlimited apps and more - and it - only takes a few minutes! -

-
- -
- -
-
-
-
- - diff --git a/packages/builder/src/pages/builder/portal/overview/_components/SettingsTab.svelte b/packages/builder/src/pages/builder/portal/overview/_components/SettingsTab.svelte new file mode 100644 index 0000000000..1900ddd244 --- /dev/null +++ b/packages/builder/src/pages/builder/portal/overview/_components/SettingsTab.svelte @@ -0,0 +1,131 @@ + + +
+ + + + Name and Url + + +
+
+
Name
+
{app?.name}
+
+
+
Url Path
+
{appUrl}
+
+
+
+ +
+ +
+ + App Version + + + {#if updateAvailable} +

+ The app is currently using version {app?.version} + but version {clientPackage.version} is available. +

+ {:else} +

+ The app is currently using version {app?.version}. You're running the latest! +

+ {/if} +

+ Updates can contain new features, performance improvements and bug + fixes. +

+
+ +
+ +
+ + Self-host Budibase + + +

+ Self-host Budibase for free to get unlimited apps and more - and it + only takes a few minutes! +

+
+ +
+ +
+
+ + + + +
+
+ + diff --git a/packages/builder/src/pages/builder/portal/overview/_components/VersionModalBody.svelte b/packages/builder/src/pages/builder/portal/overview/_components/VersionModalBody.svelte deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/packages/builder/src/pages/builder/portal/overview/_components/VersionTab.svelte b/packages/builder/src/pages/builder/portal/overview/_components/VersionTab.svelte deleted file mode 100644 index 583c6af603..0000000000 --- a/packages/builder/src/pages/builder/portal/overview/_components/VersionTab.svelte +++ /dev/null @@ -1,48 +0,0 @@ - - -
- - - - App Version - - - {#if updateAvailable} -

- The app is currently using version {app?.version} - but version {clientPackage.version} is available. -

- {:else} -

- The app is currently using version {app?.version}. You're running the latest! -

- {/if} -

- Updates can contain new features, performance improvements and bug - fixes. -

-
- -
- -
-
-
-
- - diff --git a/packages/server/src/middleware/builder.js b/packages/server/src/middleware/builder.js index 964efee451..b63a086d48 100644 --- a/packages/server/src/middleware/builder.js +++ b/packages/server/src/middleware/builder.js @@ -52,20 +52,8 @@ async function updateAppUpdatedAt(ctx) { const metadata = await db.get(DocumentTypes.APP_METADATA) metadata.updatedAt = new Date().toISOString() - const getInitials = user => { - let initials = "" - initials += user.firstName ? user.firstName[0] : "" - initials += user.lastName ? user.lastName[0] : "" - return initials == "" ? undefined : initials - } + metadata.updatedBy = getGlobalIDFromUserMetadataID(ctx.user.userId) - metadata.updatedBy = { - email: ctx.user.email, - firstName: ctx.user.firstName, - lastName: ctx.user.lastName, - initials: getInitials(ctx.user), - _id: getGlobalIDFromUserMetadataID(ctx.user.userId), - } const response = await db.put(metadata) metadata._rev = response.rev await appCache.invalidateAppMetadata(appId, metadata)