Merge pull request #6867 from Budibase/fix/export-fixes

Export issues and fix for automation app action permissions spamming
This commit is contained in:
Michael Drury 2022-07-26 13:35:01 +01:00 committed by GitHub
commit 166a1690a1
3 changed files with 25 additions and 20 deletions

View File

@ -52,8 +52,9 @@
x => x.blockToLoop === block.id x => x.blockToLoop === block.id
) )
$: setPermissions(role) $: isAppAction = block?.stepId === TriggerStepID.APP
$: getPermissions(automationId) $: isAppAction && setPermissions(role)
$: isAppAction && getPermissions(automationId)
async function setPermissions(role) { async function setPermissions(role) {
if (!role || !automationId) { if (!role || !automationId) {
@ -238,7 +239,7 @@
</div> </div>
{/if} {/if}
{#if block.stepId === TriggerStepID.APP} {#if isAppAction}
<Label>Role</Label> <Label>Role</Label>
<RoleSelect bind:value={role} /> <RoleSelect bind:value={role} />
{/if} {/if}

View File

@ -139,9 +139,10 @@
notifications.success("App ID copied to clipboard.") notifications.success("App ID copied to clipboard.")
} }
const exportApp = app => { const exportApp = (app, opts = { published: false }) => {
const id = isPublished ? app.prodId : app.devId
const appName = encodeURIComponent(app.name) 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}` window.location = `/api/backups/export?appId=${id}&appname=${appName}`
} }
@ -266,12 +267,21 @@
<span slot="control" class="app-overview-actions-icon"> <span slot="control" class="app-overview-actions-icon">
<Icon hoverable name="More" /> <Icon hoverable name="More" />
</span> </span>
<MenuItem on:click={() => exportApp(selectedApp)} icon="Download"> <MenuItem
Export on:click={() => exportApp(selectedApp, { published: false })}
icon="DownloadFromCloud"
>
Export latest
</MenuItem> </MenuItem>
{#if isPublished} {#if isPublished}
<MenuItem
on:click={() => exportApp(selectedApp, { published: true })}
icon="DownloadFromCloudOutline"
>
Export published
</MenuItem>
<MenuItem on:click={() => copyAppId(selectedApp)} icon="Copy"> <MenuItem on:click={() => copyAppId(selectedApp)} icon="Copy">
Copy App ID Copy app ID
</MenuItem> </MenuItem>
{/if} {/if}
{#if !isPublished} {#if !isPublished}

View File

@ -111,20 +111,12 @@ exports.apiFileReturn = contents => {
} }
exports.defineFilter = excludeRows => { exports.defineFilter = excludeRows => {
const ids = [USER_METDATA_PREFIX, LINK_USER_METADATA_PREFIX]
if (excludeRows) { if (excludeRows) {
return doc => ids.push(TABLE_ROW_PREFIX)
!(
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)
)
} }
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. * data or user relationships.
* @param {string} appId The app to backup * @param {string} appId The app to backup
* @param {object} config Config to send to export DB * @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 * @returns {*} either a string or a stream of the backup
*/ */
const backupAppData = async (appId, config, includeRows) => { 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 * 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 {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 * @returns {*} a readable stream of the backup which is written in real time
*/ */
exports.streamBackup = async (appId, includeRows) => { exports.streamBackup = async (appId, includeRows) => {