From 26c19891bb3c2dab1ed04020addff5dd75ed4a71 Mon Sep 17 00:00:00 2001 From: Dean Date: Tue, 19 Apr 2022 14:38:09 +0100 Subject: [PATCH] Unpublish refactored to stop development applications being mistakenly deleted. Minor updates to the modal content component to allow the replacement of the header. Further work to implement the publishing workflow changes --- packages/backend-core/src/context/index.js | 2 + packages/bbui/src/Modal/ModalContent.svelte | 14 +- packages/bbui/src/Popover/Popover.svelte | 5 +- packages/bbui/src/Popover/PopoverMenu.svelte | 81 +++++++++ packages/bbui/src/index.js | 1 + .../FlowChart/ResultsModal.svelte | 14 +- .../src/components/deploy/DeployModal.svelte | 87 ++++++++- .../deploy/DeploymentHistory.svelte | 37 ++-- .../builder/src/components/deploy/utils.js | 25 +++ .../src/components/start/AppRow.svelte | 53 ++++-- .../builder/app/[application]/_layout.svelte | 171 +++++++++++++++++- .../pages/builder/portal/apps/index.svelte | 5 + .../server/src/api/controllers/application.js | 18 +- .../src/api/controllers/deploy/index.js | 3 + 14 files changed, 457 insertions(+), 59 deletions(-) create mode 100644 packages/bbui/src/Popover/PopoverMenu.svelte create mode 100644 packages/builder/src/components/deploy/utils.js diff --git a/packages/backend-core/src/context/index.js b/packages/backend-core/src/context/index.js index ba9a7831db..9cb61ea8c9 100644 --- a/packages/backend-core/src/context/index.js +++ b/packages/backend-core/src/context/index.js @@ -174,9 +174,11 @@ function getDB(key, opts) { if (db && isEqual(opts, storedOpts)) { return db } + const appId = exports.getAppId() const CouchDB = getCouch() let toUseAppId + switch (key) { case ContextKeys.CURRENT_DB: toUseAppId = appId diff --git a/packages/bbui/src/Modal/ModalContent.svelte b/packages/bbui/src/Modal/ModalContent.svelte index 89c10bb625..4c608f1025 100644 --- a/packages/bbui/src/Modal/ModalContent.svelte +++ b/packages/bbui/src/Modal/ModalContent.svelte @@ -72,12 +72,20 @@ class:header-spacing={$$slots.header} > {title} + + {:else if $$slots.header} +

- {#if showDivider} - - {/if} {/if} + {#if showDivider && (title || $$slots.header)} + + {/if} +
diff --git a/packages/bbui/src/Popover/Popover.svelte b/packages/bbui/src/Popover/Popover.svelte index 6c9c6cc9a3..b7a0f08aae 100644 --- a/packages/bbui/src/Popover/Popover.svelte +++ b/packages/bbui/src/Popover/Popover.svelte @@ -11,6 +11,9 @@ export let align = "right" export let portalTarget + let clazz + export { clazz as class } + export const show = () => { dispatch("open") open = true @@ -37,7 +40,7 @@ use:positionDropdown={{ anchor, align }} use:clickOutside={hide} on:keydown={handleEscape} - class="spectrum-Popover is-open" + class={"spectrum-Popover is-open " + clazz} role="presentation" > diff --git a/packages/bbui/src/Popover/PopoverMenu.svelte b/packages/bbui/src/Popover/PopoverMenu.svelte new file mode 100644 index 0000000000..7c9d52f499 --- /dev/null +++ b/packages/bbui/src/Popover/PopoverMenu.svelte @@ -0,0 +1,81 @@ + + +
+
+ +
+ + {#if showTip} + {@html tipSvg} + {/if} + +
+
+ +
+
+
+
+ + diff --git a/packages/bbui/src/index.js b/packages/bbui/src/index.js index 2b16f32b84..6a2d3824f0 100644 --- a/packages/bbui/src/index.js +++ b/packages/bbui/src/index.js @@ -25,6 +25,7 @@ export { default as RadioGroup } from "./Form/RadioGroup.svelte" export { default as Checkbox } from "./Form/Checkbox.svelte" export { default as DetailSummary } from "./DetailSummary/DetailSummary.svelte" export { default as Popover } from "./Popover/Popover.svelte" +export { default as PopoverMenu } from "./Popover/PopoverMenu.svelte" export { default as ProgressBar } from "./ProgressBar/ProgressBar.svelte" export { default as ProgressCircle } from "./ProgressCircle/ProgressCircle.svelte" export { default as Label } from "./Label/Label.svelte" diff --git a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/ResultsModal.svelte b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/ResultsModal.svelte index 7dfdff20a7..7e55deb6a2 100644 --- a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/ResultsModal.svelte +++ b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/ResultsModal.svelte @@ -10,11 +10,11 @@ -
-
+
+ Test Automation +
{#if isTrigger || testResult[0].outputs.success}
@@ -89,6 +89,14 @@ diff --git a/packages/builder/src/components/deploy/DeploymentHistory.svelte b/packages/builder/src/components/deploy/DeploymentHistory.svelte index e933142348..6b584b92e6 100644 --- a/packages/builder/src/components/deploy/DeploymentHistory.svelte +++ b/packages/builder/src/components/deploy/DeploymentHistory.svelte @@ -7,12 +7,10 @@ import { notifications } from "@budibase/bbui" import CreateWebhookDeploymentModal from "./CreateWebhookDeploymentModal.svelte" import { store } from "builderStore" - - const DeploymentStatus = { - SUCCESS: "SUCCESS", - PENDING: "PENDING", - FAILURE: "FAILURE", - } + import { + checkIncomingDeploymentStatus, + DeploymentStatus, + } from "components/deploy/utils" const DATE_OPTIONS = { fullDate: { @@ -42,30 +40,17 @@ const formatDate = (date, format) => Intl.DateTimeFormat("en-GB", DATE_OPTIONS[format]).format(date) - // Required to check any updated deployment statuses between polls - function checkIncomingDeploymentStatus(current, incoming) { - for (let incomingDeployment of incoming) { - if (incomingDeployment.status === DeploymentStatus.FAILURE) { - const currentDeployment = current.find( - deployment => deployment._id === incomingDeployment._id - ) - - // We have just been notified of an ongoing deployments failure - if ( - !currentDeployment || - currentDeployment.status === DeploymentStatus.PENDING - ) { - showErrorReasonModal(incomingDeployment.err) - } - } - } - } - async function fetchDeployments() { try { const newDeployments = await API.getAppDeployments() if (deployments.length > 0) { - checkIncomingDeploymentStatus(deployments, newDeployments) + const pendingDeployments = checkIncomingDeploymentStatus( + deployments, + newDeployments + ) + if (pendingDeployments.length) { + showErrorReasonModal(incomingDeployment.err) + } } deployments = newDeployments } catch (err) { diff --git a/packages/builder/src/components/deploy/utils.js b/packages/builder/src/components/deploy/utils.js new file mode 100644 index 0000000000..49cf7a49fa --- /dev/null +++ b/packages/builder/src/components/deploy/utils.js @@ -0,0 +1,25 @@ +export const DeploymentStatus = { + SUCCESS: "SUCCESS", + PENDING: "PENDING", + FAILURE: "FAILURE", +} + +// Required to check any updated deployment statuses between polls +export function checkIncomingDeploymentStatus(current, incoming) { + return incoming.reduce((acc, incomingDeployment) => { + if (incomingDeployment.status === DeploymentStatus.FAILURE) { + const currentDeployment = current.find( + deployment => deployment._id === incomingDeployment._id + ) + + //We have just been notified of an ongoing deployments failure + if ( + !currentDeployment || + currentDeployment.status === DeploymentStatus.PENDING + ) { + acc.push(incomingDeployment) + } + } + return acc; + }, []) +} \ No newline at end of file diff --git a/packages/builder/src/components/start/AppRow.svelte b/packages/builder/src/components/start/AppRow.svelte index d6dc4e1800..b4d73bfdc0 100644 --- a/packages/builder/src/components/start/AppRow.svelte +++ b/packages/builder/src/components/start/AppRow.svelte @@ -5,6 +5,7 @@ Icon, ActionMenu, MenuItem, + ButtonGroup, StatusLight, } from "@budibase/bbui" import { processStringSync } from "@budibase/string-templates" @@ -15,6 +16,7 @@ export let editApp export let updateApp export let deleteApp + export let previewApp export let unpublishApp export let releaseLock export let editIcon @@ -57,19 +59,36 @@
- - {#if app.deployed}Published{:else}Unpublished{/if} - +
+ {#if app.deployed} + + Published + {:else} + + Unpublished + {/if} +
- +
+ {#if app.deployed} + + {:else} + + {/if} + +
{#if app.deployed} @@ -97,6 +116,18 @@