Skip to content

Commit 12705b7

Browse files
wip
1 parent 614aa09 commit 12705b7

File tree

8 files changed

+136
-552
lines changed

8 files changed

+136
-552
lines changed

client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@statamic-backup/client",
33
"type": "module",
44
"scripts": {
5-
"dev": "vite build --watch",
5+
"dev": "vite build --watch --mode development",
66
"build": "vite build"
77
},
88
"devDependencies": {

client/src/components/Backup.vue

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,22 @@
22
import { Listing, DropdownItem, Header, Button } from "@statamic/cms/ui";
33
import { requireElevatedSession } from "@statamic/cms"
44
import { useBackupStore } from "../store";
5+
import { ref, useTemplateRef } from "vue";
6+
import { useResumable } from "../resumable";
7+
8+
const props = defineProps(['chunkSize']);
59
610
const backupStore = useBackupStore();
711
12+
const dropZone = useTemplateRef("dropZone");
13+
const browseTarget = ref(null);
14+
15+
const { files } = useResumable({ chunkSize: props.chunkSize ?? 2 * 1024 * 1024, dropZone, browseTarget });
16+
817
backupStore.startPolling();
918
19+
20+
1021
const restoreFrom = async (id) => {
1122
1223
try {
@@ -44,12 +55,40 @@ const queueBackup = async () => {
4455
}
4556
}
4657
58+
const deleteBackup = async (id) => {
59+
try {
60+
await requireElevatedSession();
61+
62+
const { data } = await window.Statamic.$app.config.globalProperties.$axios.delete(cp_url(`api/backups/${id}`));
63+
64+
Statamic.$toast.info(__(data.message));
65+
} catch (e) {
66+
console.error(e);
67+
68+
if (error.response.data.message) {
69+
Statamic.$toast.error(message);
70+
} else {
71+
Statamic.$toast.error(__('statamic-backup::backup.destroy.failed'));
72+
}
73+
}
74+
}
75+
4776
</script>
77+
4878
<template>
4979
<Header :icon="database" :title="__('statamic-backup::backup.title')">
50-
<Button icon="save" variant="primary" v-on:click="queueBackup" :disabled="!backupStore.abilities.backup.isPossible">{{ __("statamic-backup::backup.create") }}</Button>
80+
<Button variant="subtle" ref="browseTarget">{{ __("statamic-backup::backup.upload.label") }}</Button>
81+
<Button variant="primary" v-on:click="queueBackup"
82+
:disabled="!backupStore.abilities.backup.isPossible">{{ __("statamic-backup::backup.create") }}</Button>
5183
</Header>
5284
85+
<p v-for="file in files" :key="file.file.uniqueIdentifier" class="mb-2">
86+
<span>{{ file.file.fileName }}</span>
87+
<span v-if="file.status === 'uploading'"> - {{ Math.round(file.progress * 100) }}%</span>
88+
<span v-if="file.status === 'retrying'"> - {{ __('statamic-backup::backup.upload.retrying') }}</span>
89+
<span v-if="file.status === 'error'" class="text-red-600"> - {{ __('statamic-backup::backup.upload.error') }}</span>
90+
</p>
91+
5392
<Listing :allowSearch="false" :allowCustomizingColumns="false" :url="cp_url('api/backups')">
5493
<template #prepended-row-actions="{ row }">
5594
<DropdownItem v-if="backupStore.abilities.download.isPermitted"
@@ -58,8 +97,8 @@ const queueBackup = async () => {
5897
<DropdownItem v-if="backupStore.abilities.restore.isPermitted"
5998
:disabled="!backupStore.abilities.restore.isPossible" @click="restoreFrom(row.id)"
6099
:text="__('statamic-backup::backup.restore.label')" />
61-
<DropdownItem v-if="backupStore.abilities.destroy.isPermitted" :dangerous="true"
62-
@click="() => console.log(row.id, row.name)" :text="__('statamic-backup::backup.destroy.label')" />
100+
<DropdownItem v-if="backupStore.abilities.destroy.isPermitted" variant="destructive"
101+
@click="deleteBackup(row.id)" :text="__('statamic-backup::backup.destroy.label')" />
63102
</template>
64103
</Listing>
65104
</template>

client/src/components/old/Actions.vue

Lines changed: 0 additions & 88 deletions
This file was deleted.

client/src/components/old/Backup.vue

Lines changed: 0 additions & 55 deletions
This file was deleted.

0 commit comments

Comments
 (0)