mirror of https://github.com/nocodb/nocodb
DarkPhoenix2704
3 days ago
5 changed files with 191 additions and 22 deletions
@ -0,0 +1,51 @@
|
||||
<script lang="ts" setup> |
||||
interface Props { |
||||
modelValue: boolean |
||||
snapshot: SnapshotExtendedType |
||||
} |
||||
|
||||
interface Emits { |
||||
(event: 'update:modelValue', data: boolean): void |
||||
(event: 'deleted'): void |
||||
} |
||||
|
||||
const props = defineProps<Props>() |
||||
|
||||
const emits = defineEmits<Emits>() |
||||
|
||||
const { snapshot } = props |
||||
|
||||
const vModel = useVModel(props, 'modelValue', emits) |
||||
|
||||
const { deleteSnapshot } = useBaseSettings() |
||||
|
||||
async function onDelete() { |
||||
if (!snapshot.id) return |
||||
|
||||
try { |
||||
await deleteSnapshot(snapshot) |
||||
|
||||
vModel.value = false |
||||
emits('deleted') |
||||
} catch (e: any) { |
||||
message.error(await extractSdkResponseErrorMsg(e)) |
||||
} |
||||
} |
||||
</script> |
||||
|
||||
<template> |
||||
<GeneralDeleteModal v-model:visible="vModel" :entity-name="$t('general.snapshot')" :on-delete="onDelete"> |
||||
<template #entity-preview> |
||||
<div class="flex flex-row items-center py-2 px-3 bg-gray-50 rounded-lg text-gray-700"> |
||||
<div |
||||
class="capitalize text-ellipsis overflow-hidden select-none w-full pl-3" |
||||
:style="{ wordBreak: 'keep-all', whiteSpace: 'nowrap', display: 'inline' }" |
||||
> |
||||
<span> |
||||
{{ snapshot.title }} |
||||
</span> |
||||
</div> |
||||
</div> |
||||
</template> |
||||
</GeneralDeleteModal> |
||||
</template> |
@ -0,0 +1,70 @@
|
||||
<script lang="ts" setup> |
||||
interface Props { |
||||
modelValue: boolean |
||||
snapshot: SnapshotExtendedType |
||||
} |
||||
|
||||
interface Emits { |
||||
(event: 'update:modelValue', data: boolean): void |
||||
(event: 'restored'): void |
||||
} |
||||
|
||||
const props = defineProps<Props>() |
||||
|
||||
const emits = defineEmits<Emits>() |
||||
|
||||
const { snapshot } = props |
||||
|
||||
const vModel = useVModel(props, 'modelValue', emits) |
||||
|
||||
const { restoreSnapshot, isRestoringSnapshot } = useBaseSettings() |
||||
</script> |
||||
|
||||
<template> |
||||
<NcModal |
||||
v-model:visible="vModel" |
||||
:mask-closable="!isRestoringSnapshot" |
||||
size="xs" |
||||
height="auto" |
||||
:show-separator="false" |
||||
nc-modal-class-name="!p-6" |
||||
> |
||||
<div class="text-nc-content-gray-emphasis font-semibold text-lg">Confirm Snapshot Restore</div> |
||||
|
||||
<div class="text-nc-content-gray-subtle2 my-2 leading-5">Are you sure you want to restore this base snapshot.</div> |
||||
|
||||
<div class="leading-5 text-nc-content-gray-subtle">Note:</div> |
||||
|
||||
<ul class="list-disc leading-5 text-nc-content-gray-subtle pl-4 !mb-0"> |
||||
<li>Restoring this snapshot will not affect the existing base.</li> |
||||
<li> |
||||
On restore, a new base |
||||
|
||||
<span class="font-semibold"> |
||||
{{ snapshot.title }} |
||||
</span> |
||||
will be created in the same workspace. |
||||
</li> |
||||
</ul> |
||||
|
||||
<div class="my-5 px-4 py-2 bg-nc-bg-gray-light rounded-lg"> |
||||
{{ snapshot.title }} |
||||
</div> |
||||
|
||||
<div class="flex items-center gap-2 justify-end"> |
||||
<NcButton :disabled="isRestoringSnapshot" type="secondary" size="small" @click="vModel = false"> |
||||
{{ $t('general.cancel') }} |
||||
</NcButton> |
||||
|
||||
<NcButton |
||||
:disabled="isRestoringSnapshot" |
||||
type="primary" |
||||
size="small" |
||||
:loading="isRestoringSnapshot" |
||||
@click="restoreSnapshot(snapshot)" |
||||
> |
||||
{{ isRestoringSnapshot ? 'Restoring Snapshot' : $t('labels.confirmRestore') }} |
||||
</NcButton> |
||||
</div> |
||||
</NcModal> |
||||
</template> |
Loading…
Reference in new issue