Skip to content

Commit ba899d5

Browse files
wip
1 parent e9c5168 commit ba899d5

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

client/src/components/Backup.vue

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,21 @@
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";
5+
import { ref } from "vue";
66
import { useResumable } from "../resumable";
77
88
const props = defineProps(['chunkSize']);
99
1010
const backupStore = useBackupStore();
1111
12-
const dropZone = useTemplateRef("dropZone");
12+
const listing = ref(null);
13+
14+
const dropZone = ref(null);
1315
const browseTarget = ref(null);
1416
15-
const { files } = useResumable({ chunkSize: props.chunkSize ?? 2 * 1024 * 1024, dropZone, browseTarget });
17+
const { files } = useResumable({ chunkSize: props.chunkSize ?? 2 * 1024 * 1024, dropZone, browseTarget, onFileUploaded: (file) => {
18+
listing.value.refresh();
19+
}});
1620
1721
backupStore.startPolling();
1822
@@ -44,6 +48,7 @@ const queueBackup = async () => {
4448
const { data } = await window.Statamic.$app.config.globalProperties.$axios.post(cp_url("api/backups"));
4549
4650
Statamic.$toast.info(__(data.message));
51+
listing.value.refresh();
4752
} catch (e) {
4853
console.error(e);
4954
@@ -62,6 +67,7 @@ const deleteBackup = async (id) => {
6267
const { data } = await window.Statamic.$app.config.globalProperties.$axios.delete(cp_url(`api/backups/${id}`));
6368
6469
Statamic.$toast.info(__(data.message));
70+
listing.value.refresh();
6571
} catch (e) {
6672
console.error(e);
6773
@@ -89,7 +95,7 @@ const deleteBackup = async (id) => {
8995
<span v-if="file.status === 'error'" class="text-red-600"> - {{ __('statamic-backup::backup.upload.error') }}</span>
9096
</p>
9197
92-
<Listing :allowSearch="false" :allowCustomizingColumns="false" :url="cp_url('api/backups')">
98+
<Listing ref="listing" :allowSearch="false" :allowCustomizingColumns="false" :url="cp_url('api/backups')">
9399
<template #prepended-row-actions="{ row }">
94100
<DropdownItem v-if="backupStore.abilities.download.isPermitted"
95101
:text="__('statamic-backup::backup.download.label')"

client/src/resumable.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,17 @@ import { reactive, ref, watch } from "vue";
44
/**
55
* @param {{
66
* chunkSize: number,
7-
* dropZone: import("vue").Ref<HTMLElement>
8-
* browseTarget: import("vue").Ref<HTMLElement>
7+
* dropZone: import("vue").Ref<HTMLElement>,
8+
* browseTarget: import("vue").Ref<HTMLElement>,
9+
* onFileUploaded: (file: File) => void
910
* }}
1011
*/
11-
export const useResumable = ({ chunkSize, dropZone, browseTarget }) => {
12+
export const useResumable = ({
13+
chunkSize,
14+
dropZone,
15+
browseTarget,
16+
onFileUploaded,
17+
}) => {
1218
const files = ref([]);
1319

1420
const findFile = (file) =>
@@ -69,6 +75,8 @@ export const useResumable = ({ chunkSize, dropZone, browseTarget }) => {
6975

7076
window.Statamic.$toast.success(data.message);
7177

78+
onFileUploaded?.(findFile(file));
79+
7280
files.value = files.value.filter(
7381
(item) => item.file.uniqueIdentifier !== file.uniqueIdentifier
7482
);

0 commit comments

Comments
 (0)