From 31901c89f89969cf39d8304b84edb71e9e6e9e1b Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Thu, 13 May 2021 14:04:03 +0100 Subject: [PATCH] merge, UI for managing your own app locks --- packages/bbui/src/Link/Link.svelte | 1 + .../src/components/start/AppCard.svelte | 22 ++++--- .../src/components/start/AppRow.svelte | 7 +++ .../pages/builder/portal/apps/index.svelte | 58 +++++++------------ packages/server/src/api/controllers/dev.js | 2 +- 5 files changed, 39 insertions(+), 51 deletions(-) diff --git a/packages/bbui/src/Link/Link.svelte b/packages/bbui/src/Link/Link.svelte index 6447993430..f66554bd75 100644 --- a/packages/bbui/src/Link/Link.svelte +++ b/packages/bbui/src/Link/Link.svelte @@ -11,6 +11,7 @@
- + openApp(app)}> -<<<<<<< HEAD - {app._id} -======= ->>>>>>> c3e1b1d30235b8945424cf59a41e112f92942dc6 {app.name} @@ -43,14 +37,18 @@ deleteApp(app)} icon="Delete"> Delete - deleteApp(app)} icon="Code">Develop + {#if app.lockedBy && app.lockedBy?.email === $auth.user?.email} + releaseLock(app._id)} icon="LockOpen"> + Release Lock + + {/if}
Edited {Math.floor(1 + Math.random() * 10)} months ago - {#if appStatus === AppStatus.DEV && app.lockedBy} + {#if app.lockedBy} {/if}
diff --git a/packages/builder/src/components/start/AppRow.svelte b/packages/builder/src/components/start/AppRow.svelte index 113edae7ac..ed46669bc7 100644 --- a/packages/builder/src/components/start/AppRow.svelte +++ b/packages/builder/src/components/start/AppRow.svelte @@ -10,6 +10,7 @@ } from "@budibase/bbui" import { AppStatus } from "constants" import { url } from "@roxi/routify" + import { auth } from "stores/backend" export let app export let openApp @@ -17,6 +18,7 @@ export let deleteApp export let last export let appStatus + export let releaseLock let href = appStatus === AppStatus.DEV ? $url(`../../app/${app._id}`) : `/${app._id}` @@ -49,6 +51,11 @@ exportApp(app)} icon="Download">Export deleteApp(app)} icon="Delete">Delete + {#if app.lockedBy && app.lockedBy?.email === $auth.user?.email} + releaseLock(app._id)} icon="LockOpen"> + Release Lock + + {/if}
diff --git a/packages/builder/src/pages/builder/portal/apps/index.svelte b/packages/builder/src/pages/builder/portal/apps/index.svelte index 989f14e077..427a571666 100644 --- a/packages/builder/src/pages/builder/portal/apps/index.svelte +++ b/packages/builder/src/pages/builder/portal/apps/index.svelte @@ -23,6 +23,7 @@ import ConfirmDialog from "components/common/ConfirmDialog.svelte" import AppCard from "components/start/AppCard.svelte" import AppRow from "components/start/AppRow.svelte" + import { AppStatus } from "constants" let layout = "grid" let appStatus = "deployed" @@ -60,7 +61,11 @@ } const openApp = app => { - $goto(`../../app/${app._id}`) + if (appStatus === AppStatus.DEV) { + $goto(`../../app/${app._id}`) + } else { + window.open(`/${app._id}`, '_blank'); + } } const exportApp = app => { @@ -91,6 +96,19 @@ appToDelete = null } + const releaseLock = async appId => { + try { + const response = await del(`/api/dev/${appId}/lock`) + const json = await response.json() + if (json.status !== 200) throw json.message + + notifications.success("Lock released") + await apps.load(appStatus) + } catch (err) { + notifications.error(`Error releasing lock: ${err}`) + } + } + onMount(async () => { checkKeys() await apps.load(appStatus) @@ -99,41 +117,6 @@ -<<<<<<< HEAD - {#if $apps.length} - -
- Apps - - - - -
-
-
-