From 11252f07f9dba4cc35899c11f6eebb0c4d1e0790 Mon Sep 17 00:00:00 2001 From: DarkPhoenix2704 Date: Thu, 28 Nov 2024 14:47:59 +0000 Subject: [PATCH] fix: snapshot creare and delete modal and ui --- .../settings/BaseSettings/Snapshots.vue | 46 +++++++++--- .../nc-gui/components/dlg/Snapshot/Delete.vue | 51 ++++++++++++++ .../components/dlg/Snapshot/Restore.vue | 70 +++++++++++++++++++ .../nc-gui/composables/useBaseSettings.ts | 45 ++++++++---- packages/nc-gui/lang/en.json | 1 + 5 files changed, 191 insertions(+), 22 deletions(-) create mode 100644 packages/nc-gui/components/dlg/Snapshot/Delete.vue create mode 100644 packages/nc-gui/components/dlg/Snapshot/Restore.vue diff --git a/packages/nc-gui/components/dashboard/settings/BaseSettings/Snapshots.vue b/packages/nc-gui/components/dashboard/settings/BaseSettings/Snapshots.vue index 88de484c57..ff9b7c1037 100644 --- a/packages/nc-gui/components/dashboard/settings/BaseSettings/Snapshots.vue +++ b/packages/nc-gui/components/dashboard/settings/BaseSettings/Snapshots.vue @@ -3,8 +3,6 @@ import dayjs from 'dayjs' const { t } = useI18n() -const { $api } = useNuxtApp() - const { sorts, sortDirection, loadSorts, handleGetSortedData, saveOrUpdate: saveOrUpdateSort } = useUserSorts('Webhook') const orderBy = computed>({ @@ -32,13 +30,10 @@ const { createSnapshot, listSnapshots, updateSnapshot, - restoreSnapshot, - deleteSnapshot, cancelNewSnapshot, isUnsavedSnapshotsPending, addNewSnapshot, isCreatingSnapshot, - isRestoringSnapshot, } = useBaseSettings() const columns = [ @@ -63,13 +58,46 @@ const columns = [ onMounted(async () => { await listSnapshots() }) +const deleteSnapshot = (s: SnapshotExtendedType) => { + const isOpen = ref(true) + + const { close } = useDialog(resolveComponent('DlgSnapshotDelete'), { + 'modelValue': isOpen, + 'snapshot': s, + 'onUpdate:modelValue': closeDialog, + 'onDeleted': async () => { + closeDialog() + await listSnapshots() + }, + }) + + function closeDialog() { + isOpen.value = false + close(1000) + } +} + +const restoreSnapshot = (s: SnapshotExtendedType) => { + const isOpen = ref(true) + + const { close } = useDialog(resolveComponent('DlgSnapshotRestore'), { + 'modelValue': isOpen, + 'snapshot': s, + 'onUpdate:modelValue': closeDialog, + 'onRestored': async () => { + closeDialog() + }, + }) + + function closeDialog() { + isOpen.value = false + close(1000) + } +}