From a84d4d014d4b7a9390c39a12789b58370ad6999e Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 22 Jul 2022 18:16:14 +0100 Subject: [PATCH 1/3] Fixing issues with exporting apps, first removing the deleted documents when exporting and second making it so that the user has a choice whether to export the development app or the published app from the UI. --- .../portal/overview/[application]/index.svelte | 18 ++++++++++++++---- .../server/src/utilities/fileSystem/index.js | 18 ++++++------------ 2 files changed, 20 insertions(+), 16 deletions(-) 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 293f19ebe4..2a5cdaf3bd 100644 --- a/packages/builder/src/pages/builder/portal/overview/[application]/index.svelte +++ b/packages/builder/src/pages/builder/portal/overview/[application]/index.svelte @@ -139,9 +139,10 @@ notifications.success("App ID copied to clipboard.") } - const exportApp = app => { - const id = isPublished ? app.prodId : app.devId + const exportApp = (app, opts = { published: false }) => { const appName = encodeURIComponent(app.name) + const id = opts?.published ? app.prodId : app.devId + // always export the development version window.location = `/api/backups/export?appId=${id}&appname=${appName}` } @@ -266,12 +267,21 @@ - exportApp(selectedApp)} icon="Download"> + exportApp(selectedApp, { published: false })} + icon="DownloadFromCloud" + > Export {#if isPublished} + exportApp(selectedApp, { published: true })} + icon="DownloadFromCloudOutline" + > + Export published + copyAppId(selectedApp)} icon="Copy"> - Copy App ID + Copy app ID {/if} {#if !isPublished} diff --git a/packages/server/src/utilities/fileSystem/index.js b/packages/server/src/utilities/fileSystem/index.js index ed1cb1923a..f4aebd11a8 100644 --- a/packages/server/src/utilities/fileSystem/index.js +++ b/packages/server/src/utilities/fileSystem/index.js @@ -111,20 +111,12 @@ exports.apiFileReturn = contents => { } exports.defineFilter = excludeRows => { + const ids = [USER_METDATA_PREFIX, LINK_USER_METADATA_PREFIX] if (excludeRows) { - return doc => - !( - doc._id.includes(USER_METDATA_PREFIX) || - doc._id.includes(LINK_USER_METADATA_PREFIX) || - doc._id.includes(TABLE_ROW_PREFIX) - ) - } else if (!excludeRows) { - return doc => - !( - doc._id.includes(USER_METDATA_PREFIX) || - doc._id.includes(LINK_USER_METADATA_PREFIX) - ) + ids.push(TABLE_ROW_PREFIX) } + return doc => + !ids.map(key => doc._id.includes(key)).reduce((prev, curr) => prev || curr) } /** @@ -132,6 +124,7 @@ exports.defineFilter = excludeRows => { * data or user relationships. * @param {string} appId The app to backup * @param {object} config Config to send to export DB + * @param {boolean} includeRows Flag to state whether the export should include data. * @returns {*} either a string or a stream of the backup */ const backupAppData = async (appId, config, includeRows) => { @@ -154,6 +147,7 @@ exports.performBackup = async (appId, backupName) => { /** * Streams a backup of the database state for an app * @param {string} appId The ID of the app which is to be backed up. + * @param {boolean} includeRows Flag to state whether the export should include data. * @returns {*} a readable stream of the backup which is written in real time */ exports.streamBackup = async (appId, includeRows) => { From ff1ae2f8fa5248536face11a4c0218cb8a36b442 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 22 Jul 2022 18:43:35 +0100 Subject: [PATCH 2/3] Fix for permission spamming in the automation UI. --- .../automation/AutomationBuilder/FlowChart/FlowItem.svelte | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte index 412683721f..c1618a890f 100644 --- a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte +++ b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte @@ -52,8 +52,9 @@ x => x.blockToLoop === block.id ) - $: setPermissions(role) - $: getPermissions(automationId) + $: isAppAction = block?.stepId === TriggerStepID.APP + $: isAppAction && setPermissions(role) + $: isAppAction && getPermissions(automationId) async function setPermissions(role) { if (!role || !automationId) { @@ -238,7 +239,7 @@ {/if} - {#if block.stepId === TriggerStepID.APP} + {#if isAppAction} {/if} From e504c6a37ce1e0436cdf942b9692d0f45f8fcd44 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 26 Jul 2022 11:19:28 +0100 Subject: [PATCH 3/3] Updating based on PR comments. --- .../pages/builder/portal/overview/[application]/index.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 2a5cdaf3bd..b2dac7682f 100644 --- a/packages/builder/src/pages/builder/portal/overview/[application]/index.svelte +++ b/packages/builder/src/pages/builder/portal/overview/[application]/index.svelte @@ -271,7 +271,7 @@ on:click={() => exportApp(selectedApp, { published: false })} icon="DownloadFromCloud" > - Export + Export latest {#if isPublished}