negate export button

This commit is contained in:
Peter Clement 2022-06-06 15:17:14 +01:00
parent 88c98d0227
commit bd737cc1ca
3 changed files with 14 additions and 14 deletions

View File

@ -2,15 +2,15 @@
import { ModalContent, Toggle } from "@budibase/bbui" import { ModalContent, Toggle } from "@budibase/bbui"
export let app export let app
let includeRows = true let excludeRows = false
const exportApp = () => { const exportApp = () => {
const id = app.deployed ? app.prodId : app.devId const id = app.deployed ? app.prodId : app.devId
const appName = encodeURIComponent(app.name) const appName = encodeURIComponent(app.name)
window.location = `/api/backups/export?appId=${id}&appname=${appName}&includeRows=${includeRows}` window.location = `/api/backups/export?appId=${id}&appname=${appName}&excludeRows=${excludeRows}`
} }
</script> </script>
<ModalContent title={"Export"} confirmText={"Export"} onConfirm={exportApp}> <ModalContent title={"Export"} confirmText={"Export"} onConfirm={exportApp}>
<Toggle text="Include Data" bind:value={includeRows} /> <Toggle text="Exclude Rows" bind:value={excludeRows} />
</ModalContent> </ModalContent>

View File

@ -1,11 +1,11 @@
const { streamBackup } = require("../../utilities/fileSystem") const { streamBackup } = require("../../utilities/fileSystem")
exports.exportAppDump = async function (ctx) { exports.exportAppDump = async function (ctx) {
let { appId, includeRows } = ctx.query let { appId, excludeRows } = ctx.query
const appName = decodeURI(ctx.query.appname) const appName = decodeURI(ctx.query.appname)
includeRows = includeRows === "true" excludeRows = excludeRows === "true"
const backupIdentifier = `${appName}-export-${new Date().getTime()}.txt` const backupIdentifier = `${appName}-export-${new Date().getTime()}.txt`
ctx.attachment(backupIdentifier) ctx.attachment(backupIdentifier)
ctx.body = await streamBackup(appId, includeRows) ctx.body = await streamBackup(appId, excludeRows)
} }

View File

@ -110,20 +110,20 @@ exports.apiFileReturn = contents => {
return fs.createReadStream(path) return fs.createReadStream(path)
} }
exports.defineFilter = includeRows => { exports.defineFilter = excludeRows => {
if (includeRows) { if (excludeRows) {
return doc =>
!(
doc._id.includes(USER_METDATA_PREFIX) ||
doc._id.includes(LINK_USER_METADATA_PREFIX)
)
} else if (!includeRows) {
return doc => return doc =>
!( !(
doc._id.includes(USER_METDATA_PREFIX) || doc._id.includes(USER_METDATA_PREFIX) ||
doc._id.includes(LINK_USER_METADATA_PREFIX) || doc._id.includes(LINK_USER_METADATA_PREFIX) ||
doc._id.includes(TABLE_ROW_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)
)
} }
} }