From 02b505c75c1c7fb5d69e0f1ebcd4e6d306346f9c Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Fri, 21 Oct 2022 14:10:08 +0100 Subject: [PATCH] fix download issue and pass name for backup after restore --- .../portal/overview/backups/ActionsRenderer.svelte | 12 +++--------- .../portal/overview/backups/BackupsTab.svelte | 2 +- .../portal/overview/backups/StatusRenderer.svelte | 2 +- packages/builder/src/stores/portal/backups.js | 4 ++-- 4 files changed, 7 insertions(+), 13 deletions(-) diff --git a/packages/builder/src/components/portal/overview/backups/ActionsRenderer.svelte b/packages/builder/src/components/portal/overview/backups/ActionsRenderer.svelte index 6a6a5a8060..bb09ad3f6d 100644 --- a/packages/builder/src/components/portal/overview/backups/ActionsRenderer.svelte +++ b/packages/builder/src/components/portal/overview/backups/ActionsRenderer.svelte @@ -11,8 +11,6 @@ import ConfirmDialog from "components/common/ConfirmDialog.svelte" import CreateRestoreModal from "./CreateRestoreModal.svelte" import { createEventDispatcher } from "svelte" - import download from "downloadjs" - import { backups } from "stores/portal" export let row @@ -20,7 +18,6 @@ let restoreDialog let updateDialog let name - let restoreBackupName let restoreBackupModal const dispatch = createEventDispatcher() @@ -30,7 +27,7 @@ type: "backupRestore", name, backupId: row._id, - restoreBackupName, + restoreBackupName: name, }) } @@ -48,12 +45,9 @@ name, }) } + async function downloadExport() { - let resp = await backups.downloadBackup({ - backupId: row._id, - appId: row.appId, - }) - download(resp, row.filename) + window.location = `/api/apps/${row.appId}/backups/${row._id}/file` } diff --git a/packages/builder/src/components/portal/overview/backups/BackupsTab.svelte b/packages/builder/src/components/portal/overview/backups/BackupsTab.svelte index 3d257db5a8..d435360362 100644 --- a/packages/builder/src/components/portal/overview/backups/BackupsTab.svelte +++ b/packages/builder/src/components/portal/overview/backups/BackupsTab.svelte @@ -107,7 +107,6 @@ } async function handleButtonClick({ detail }) { - console.log(detail.type) if (detail.type === "backupDelete") { await backups.deleteBackup({ appId: app.instance._id, @@ -118,6 +117,7 @@ await backups.restoreBackup({ appId: app.instance._id, backupId: detail.backupId, + name: detail.restoreBackupName, }) } else if (detail.type === "backupUpdate") { await backups.updateBackup({ diff --git a/packages/builder/src/components/portal/overview/backups/StatusRenderer.svelte b/packages/builder/src/components/portal/overview/backups/StatusRenderer.svelte index 8fd98f663e..610b080d37 100644 --- a/packages/builder/src/components/portal/overview/backups/StatusRenderer.svelte +++ b/packages/builder/src/components/portal/overview/backups/StatusRenderer.svelte @@ -2,7 +2,7 @@ import { Badge } from "@budibase/bbui" export let value = "started" - $: status = value.charAt(0).toUpperCase() + value.slice(1) + $: status = value?.charAt(0).toUpperCase() + value?.slice(1) diff --git a/packages/builder/src/stores/portal/backups.js b/packages/builder/src/stores/portal/backups.js index 2e0139cf6a..af336c73ab 100644 --- a/packages/builder/src/stores/portal/backups.js +++ b/packages/builder/src/stores/portal/backups.js @@ -15,8 +15,8 @@ export function createBackupsStore() { return API.searchBackups({ appId, trigger, page, startDate, endDate }) } - async function restoreBackup({ appId, backupId }) { - return API.restoreBackup({ appId, backupId }) + async function restoreBackup({ appId, backupId, name }) { + return API.restoreBackup({ appId, backupId, name }) } async function deleteBackup({ appId, backupId }) {