From 1eac53230ede21f9e8287a0d491445704573e05f Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Thu, 20 Oct 2022 18:46:16 +0100 Subject: [PATCH] Adding restore work - new modal to create a backup. --- .../overview/backups/ActionsRenderer.svelte | 14 +++++++++--- .../backups/CreateRestoreModal.svelte | 22 +++++++++++++++++++ packages/frontend-core/src/api/backups.js | 3 ++- packages/types/src/documents/app/backup.ts | 1 + 4 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 packages/builder/src/components/portal/overview/backups/CreateRestoreModal.svelte diff --git a/packages/builder/src/components/portal/overview/backups/ActionsRenderer.svelte b/packages/builder/src/components/portal/overview/backups/ActionsRenderer.svelte index 834b2b1969..6a6a5a8060 100644 --- a/packages/builder/src/components/portal/overview/backups/ActionsRenderer.svelte +++ b/packages/builder/src/components/portal/overview/backups/ActionsRenderer.svelte @@ -6,8 +6,10 @@ Input, Heading, Body, + Modal, } from "@budibase/bbui" 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" @@ -19,12 +21,14 @@ let updateDialog let name let restoreBackupName + let restoreBackupModal const dispatch = createEventDispatcher() - const onClickRestore = () => { + const onClickRestore = name => { dispatch("buttonclick", { type: "backupRestore", + name, backupId: row._id, restoreBackupName, }) @@ -68,6 +72,10 @@ + + onClickRestore(name)} /> + + diff --git a/packages/builder/src/components/portal/overview/backups/CreateRestoreModal.svelte b/packages/builder/src/components/portal/overview/backups/CreateRestoreModal.svelte new file mode 100644 index 0000000000..3c554563da --- /dev/null +++ b/packages/builder/src/components/portal/overview/backups/CreateRestoreModal.svelte @@ -0,0 +1,22 @@ + + + confirm(name)} + title="Backup your current version" + confirmText="Confirm Restore" +> + Create a backup of your current app to allow you to roll back after + restoring this backup + + + + diff --git a/packages/frontend-core/src/api/backups.js b/packages/frontend-core/src/api/backups.js index 82fb9533d8..85df0eab1e 100644 --- a/packages/frontend-core/src/api/backups.js +++ b/packages/frontend-core/src/api/backups.js @@ -40,9 +40,10 @@ export const buildBackupsEndpoints = API => ({ }) }, - restoreBackup: async ({ appId, backupId }) => { + restoreBackup: async ({ appId, backupId, name }) => { return await API.post({ url: `/api/apps/${appId}/backups/${backupId}/import`, + body: { name }, }) }, diff --git a/packages/types/src/documents/app/backup.ts b/packages/types/src/documents/app/backup.ts index 520013a8bb..9179852331 100644 --- a/packages/types/src/documents/app/backup.ts +++ b/packages/types/src/documents/app/backup.ts @@ -59,6 +59,7 @@ export interface AppBackupQueueData { } import?: { backupId: string + nameForBackup: string createdBy?: string } }