payload-plugin-backup-postgres 0.3.3 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -0
- package/dist/backup-dashboard.css +84 -1
- package/dist/collections/BackupNumbers.d.ts +3 -0
- package/dist/collections/BackupNumbers.js +29 -0
- package/dist/collections/BackupNumbers.js.map +1 -0
- package/dist/components/BackupDashboard/BackupCollectionsDetails.client.d.ts +7 -0
- package/dist/components/BackupDashboard/BackupCollectionsDetails.client.js +135 -0
- package/dist/components/BackupDashboard/BackupCollectionsDetails.client.js.map +1 -0
- package/dist/components/BackupDashboard/BackupItemActions.client.d.ts +1 -0
- package/dist/components/BackupDashboard/BackupItemActions.client.js +7 -5
- package/dist/components/BackupDashboard/BackupItemActions.client.js.map +1 -1
- package/dist/components/BackupDashboard/BackupListCollapsible.client.d.ts +1 -0
- package/dist/components/BackupDashboard/BackupListCollapsible.client.js +14 -10
- package/dist/components/BackupDashboard/BackupListCollapsible.client.js.map +1 -1
- package/dist/components/BackupDashboard/backupDashboardInlineCss.js +1 -1
- package/dist/components/BackupDashboard/backupDashboardInlineCss.js.map +1 -1
- package/dist/components/BackupDashboard/index.js +14 -1
- package/dist/components/BackupDashboard/index.js.map +1 -1
- package/dist/core/backup.d.ts +4 -1
- package/dist/core/backup.js +16 -6
- package/dist/core/backup.js.map +1 -1
- package/dist/core/backupNumbers.d.ts +10 -0
- package/dist/core/backupNumbers.js +121 -0
- package/dist/core/backupNumbers.js.map +1 -0
- package/dist/core/restorePreview.d.ts +2 -0
- package/dist/core/restorePreview.js +9 -0
- package/dist/core/restorePreview.js.map +1 -1
- package/dist/plugin.js +3 -1
- package/dist/plugin.js.map +1 -1
- package/docs/screenshots/backup-dashboard.png +0 -0
- package/docs/screenshots/backup-progress.png +0 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -26,6 +26,20 @@ the database engine was rewritten for Payload's Drizzle/Postgres adapter.
|
|
|
26
26
|
|
|
27
27
|
Backups are **not** interchangeable between the two plugins.
|
|
28
28
|
|
|
29
|
+
## Screenshots
|
|
30
|
+
|
|
31
|
+
### Backup dashboard
|
|
32
|
+
|
|
33
|
+

|
|
34
|
+
|
|
35
|
+
The dashboard's **Archives total** is the combined size of the listed backup
|
|
36
|
+
archives only, not the full Vercel Blob store. The listing is limited to 1,000
|
|
37
|
+
objects.
|
|
38
|
+
|
|
39
|
+
### Task progress
|
|
40
|
+
|
|
41
|
+

|
|
42
|
+
|
|
29
43
|
## Requirements
|
|
30
44
|
|
|
31
45
|
- Payload `^3`, Next.js 15/16, React 19, Node `>=20.9`
|
|
@@ -192,6 +206,11 @@ After the first login as an admin user, the backup dashboard is available at
|
|
|
192
206
|
`/admin/db-backups`. Day-to-day tasks — create, download, restore, delete,
|
|
193
207
|
schedule — are managed on this dedicated page.
|
|
194
208
|
|
|
209
|
+
Backups receive sequential numbers starting at **#1**. Existing archives are
|
|
210
|
+
numbered oldest first, and a number is never reused after its backup is deleted.
|
|
211
|
+
Each Payload database has its own counter, kept in the database and excluded
|
|
212
|
+
from backup restores.
|
|
213
|
+
|
|
195
214
|
**Who can see it?** The visibility rules, in precedence order:
|
|
196
215
|
|
|
197
216
|
1. If the plugin is registered with an `access` function, it wins (see
|
|
@@ -253,6 +253,63 @@
|
|
|
253
253
|
align-items: center;
|
|
254
254
|
gap: 6px;
|
|
255
255
|
}
|
|
256
|
+
.backup-dashboard .backup-item__collections {
|
|
257
|
+
display: flex;
|
|
258
|
+
flex-direction: column;
|
|
259
|
+
align-items: flex-start;
|
|
260
|
+
gap: 7px;
|
|
261
|
+
}
|
|
262
|
+
.backup-dashboard .backup-item__collections-trigger {
|
|
263
|
+
appearance: none;
|
|
264
|
+
cursor: pointer;
|
|
265
|
+
font: inherit;
|
|
266
|
+
}
|
|
267
|
+
.backup-dashboard .backup-item__collections-trigger:hover {
|
|
268
|
+
border-color: var(--theme-elevation-300);
|
|
269
|
+
}
|
|
270
|
+
.backup-dashboard .backup-item__collections-trigger:focus-visible {
|
|
271
|
+
outline: 2px solid var(--theme-elevation-400);
|
|
272
|
+
outline-offset: 2px;
|
|
273
|
+
}
|
|
274
|
+
.backup-dashboard .backup-item__collections-arrow {
|
|
275
|
+
display: inline-block;
|
|
276
|
+
font-size: 15px;
|
|
277
|
+
line-height: 1;
|
|
278
|
+
transition: transform 150ms ease;
|
|
279
|
+
}
|
|
280
|
+
.backup-dashboard .backup-item__collections-arrow--expanded {
|
|
281
|
+
transform: rotate(90deg);
|
|
282
|
+
}
|
|
283
|
+
.backup-dashboard .backup-item__collections-list {
|
|
284
|
+
display: flex;
|
|
285
|
+
flex-wrap: wrap;
|
|
286
|
+
gap: 6px;
|
|
287
|
+
margin: 0;
|
|
288
|
+
padding: 0;
|
|
289
|
+
list-style: none;
|
|
290
|
+
}
|
|
291
|
+
.backup-dashboard .backup-item__collections-name {
|
|
292
|
+
padding: 3px 8px;
|
|
293
|
+
border: 1px solid var(--theme-elevation-150);
|
|
294
|
+
border-radius: 999px;
|
|
295
|
+
background: var(--theme-elevation-50, #f5f5f5);
|
|
296
|
+
color: var(--theme-elevation-800);
|
|
297
|
+
font-size: 12px;
|
|
298
|
+
line-height: 1.35;
|
|
299
|
+
}
|
|
300
|
+
.backup-dashboard .backup-item__collections-status {
|
|
301
|
+
margin: 0;
|
|
302
|
+
color: var(--theme-elevation-600);
|
|
303
|
+
font-size: 12px;
|
|
304
|
+
}
|
|
305
|
+
.backup-dashboard .backup-item__collections-error {
|
|
306
|
+
display: flex;
|
|
307
|
+
flex-wrap: wrap;
|
|
308
|
+
align-items: center;
|
|
309
|
+
gap: 10px;
|
|
310
|
+
color: var(--theme-error-600, #c0392b);
|
|
311
|
+
font-size: 12px;
|
|
312
|
+
}
|
|
256
313
|
.backup-dashboard .backup-item__pill {
|
|
257
314
|
display: inline-flex;
|
|
258
315
|
flex-direction: row;
|
|
@@ -301,6 +358,13 @@
|
|
|
301
358
|
border-color: var(--theme-elevation-150);
|
|
302
359
|
font-variant-numeric: tabular-nums;
|
|
303
360
|
}
|
|
361
|
+
.backup-dashboard .backup-item__pill--number {
|
|
362
|
+
background: var(--theme-elevation-0, #fff);
|
|
363
|
+
border-color: var(--theme-elevation-250, var(--theme-elevation-200));
|
|
364
|
+
color: var(--theme-elevation-900);
|
|
365
|
+
font-weight: 700;
|
|
366
|
+
font-variant-numeric: tabular-nums;
|
|
367
|
+
}
|
|
304
368
|
.backup-dashboard .backup-item__pill--label {
|
|
305
369
|
background: rgba(124, 58, 237, 0.1);
|
|
306
370
|
color: var(--theme-elevation-900);
|
|
@@ -380,10 +444,18 @@
|
|
|
380
444
|
max-width: 440px;
|
|
381
445
|
background: var(--theme-elevation-0);
|
|
382
446
|
}
|
|
383
|
-
.backup-confirm-dialog--restore, .backup-confirm-dialog--manual, .backup-confirm-dialog--settings, .backup-confirm-dialog--backup-list-filters {
|
|
447
|
+
.backup-confirm-dialog--restore, .backup-confirm-dialog--manual, .backup-confirm-dialog--settings, .backup-confirm-dialog--backup-list-filters, .backup-confirm-dialog--collections {
|
|
384
448
|
min-width: 360px;
|
|
385
449
|
max-width: min(560px, 96vw);
|
|
386
450
|
}
|
|
451
|
+
.backup-confirm-dialog--collections .backup-item__collections-body {
|
|
452
|
+
max-height: min(100dvh - 13rem, 520px);
|
|
453
|
+
overflow: auto;
|
|
454
|
+
}
|
|
455
|
+
.backup-confirm-dialog--collections .backup-item__collections-list {
|
|
456
|
+
margin: 0;
|
|
457
|
+
padding: 0;
|
|
458
|
+
}
|
|
387
459
|
.backup-confirm-dialog--settings .backup-confirm-dialog__body.restore-preview {
|
|
388
460
|
/* ~120px taller than default; cap keeps full dialog under the viewport */
|
|
389
461
|
max-height: min(100dvh - 10rem, 660px);
|
|
@@ -435,6 +507,17 @@
|
|
|
435
507
|
background-color: var(--theme-error-700, #a93226);
|
|
436
508
|
border-color: var(--theme-error-700, #a93226);
|
|
437
509
|
}
|
|
510
|
+
.backup-confirm-dialog--delete-backup .backup-confirm-dialog__actions {
|
|
511
|
+
display: grid;
|
|
512
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
513
|
+
}
|
|
514
|
+
.backup-confirm-dialog--delete-backup .backup-task-action,
|
|
515
|
+
.backup-confirm-dialog--delete-backup .backup-confirm-dialog__not-now-button {
|
|
516
|
+
width: 100%;
|
|
517
|
+
}
|
|
518
|
+
.backup-confirm-dialog--delete-backup .backup-confirm-dialog__delete-button {
|
|
519
|
+
width: 100%;
|
|
520
|
+
}
|
|
438
521
|
.backup-confirm-dialog::backdrop {
|
|
439
522
|
background: rgba(0, 0, 0, 0.35);
|
|
440
523
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** Persistent, non-reusable numbers assigned to backup archive pathnames. */ export const BackupNumbersCollection = {
|
|
2
|
+
slug: 'backup-numbers',
|
|
3
|
+
access: {
|
|
4
|
+
create: ()=>false,
|
|
5
|
+
delete: ()=>false,
|
|
6
|
+
read: ()=>false,
|
|
7
|
+
update: ()=>false
|
|
8
|
+
},
|
|
9
|
+
admin: {
|
|
10
|
+
hidden: true
|
|
11
|
+
},
|
|
12
|
+
fields: [
|
|
13
|
+
{
|
|
14
|
+
name: 'number',
|
|
15
|
+
type: 'number',
|
|
16
|
+
required: true,
|
|
17
|
+
unique: true
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: 'pathname',
|
|
21
|
+
type: 'text',
|
|
22
|
+
required: true,
|
|
23
|
+
unique: true
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
timestamps: false
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=BackupNumbers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/collections/BackupNumbers.ts"],"sourcesContent":["import type { CollectionConfig } from 'payload'\n\n/** Persistent, non-reusable numbers assigned to backup archive pathnames. */\nexport const BackupNumbersCollection: CollectionConfig = {\n slug: 'backup-numbers',\n access: {\n create: () => false,\n delete: () => false,\n read: () => false,\n update: () => false,\n },\n admin: {\n hidden: true,\n },\n fields: [\n {\n name: 'number',\n type: 'number',\n required: true,\n unique: true,\n },\n {\n name: 'pathname',\n type: 'text',\n required: true,\n unique: true,\n },\n ],\n timestamps: false,\n}\n"],"names":["BackupNumbersCollection","slug","access","create","delete","read","update","admin","hidden","fields","name","type","required","unique","timestamps"],"mappings":"AAEA,2EAA2E,GAC3E,OAAO,MAAMA,0BAA4C;IACvDC,MAAM;IACNC,QAAQ;QACNC,QAAQ,IAAM;QACdC,QAAQ,IAAM;QACdC,MAAM,IAAM;QACZC,QAAQ,IAAM;IAChB;IACAC,OAAO;QACLC,QAAQ;IACV;IACAC,QAAQ;QACN;YACEC,MAAM;YACNC,MAAM;YACNC,UAAU;YACVC,QAAQ;QACV;QACA;YACEH,MAAM;YACNC,MAAM;YACNC,UAAU;YACVC,QAAQ;QACV;KACD;IACDC,YAAY;AACd,EAAC"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Button } from '@payloadcms/ui';
|
|
4
|
+
import { useCallback, useId, useRef, useState } from 'react';
|
|
5
|
+
import { backupPluginPublicApiPaths } from '../../publicApiPaths.js';
|
|
6
|
+
import { closeNativeDialogOnBackdropPointer } from '../../utils/dialogBackdrop.js';
|
|
7
|
+
export const BackupCollectionsDetails = ({ collectionCount, downloadUrl, pathname })=>{
|
|
8
|
+
const id = useId();
|
|
9
|
+
const dialogRef = useRef(null);
|
|
10
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
11
|
+
const [collections, setCollections] = useState([]);
|
|
12
|
+
const [phase, setPhase] = useState('idle');
|
|
13
|
+
const [errorMessage, setErrorMessage] = useState(null);
|
|
14
|
+
const loadCollections = useCallback(async ()=>{
|
|
15
|
+
setPhase('loading');
|
|
16
|
+
setErrorMessage(null);
|
|
17
|
+
try {
|
|
18
|
+
const locale = typeof document !== 'undefined' ? (document.documentElement.lang || 'en').slice(0, 2) : 'en';
|
|
19
|
+
const response = await fetch(backupPluginPublicApiPaths.adminRestorePreview, {
|
|
20
|
+
body: JSON.stringify({
|
|
21
|
+
locale,
|
|
22
|
+
pathname,
|
|
23
|
+
url: downloadUrl
|
|
24
|
+
}),
|
|
25
|
+
headers: {
|
|
26
|
+
'Content-Type': 'application/json'
|
|
27
|
+
},
|
|
28
|
+
method: 'POST'
|
|
29
|
+
});
|
|
30
|
+
const data = await response.json();
|
|
31
|
+
if (!response.ok) {
|
|
32
|
+
throw new Error(data.error || 'Could not load backup collections');
|
|
33
|
+
}
|
|
34
|
+
setCollections(data.backupCollections);
|
|
35
|
+
setPhase('ready');
|
|
36
|
+
} catch (error) {
|
|
37
|
+
setPhase('error');
|
|
38
|
+
setErrorMessage(error instanceof Error ? error.message : 'Could not load backup collections');
|
|
39
|
+
}
|
|
40
|
+
}, [
|
|
41
|
+
downloadUrl,
|
|
42
|
+
pathname
|
|
43
|
+
]);
|
|
44
|
+
const openDetails = ()=>{
|
|
45
|
+
setIsOpen(true);
|
|
46
|
+
dialogRef.current?.showModal();
|
|
47
|
+
if (phase === 'idle') {
|
|
48
|
+
void loadCollections();
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const displayCount = phase === 'ready' ? collections.length : collectionCount;
|
|
52
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
53
|
+
className: "backup-item__collections",
|
|
54
|
+
children: [
|
|
55
|
+
/*#__PURE__*/ _jsxs("button", {
|
|
56
|
+
"aria-controls": id,
|
|
57
|
+
"aria-expanded": isOpen,
|
|
58
|
+
"aria-haspopup": "dialog",
|
|
59
|
+
className: "backup-item__pill backup-item__pill--collections backup-item__collections-trigger",
|
|
60
|
+
onClick: openDetails,
|
|
61
|
+
type: "button",
|
|
62
|
+
children: [
|
|
63
|
+
displayCount === undefined ? 'Collections' : `${displayCount} collection${displayCount === 1 ? '' : 's'}`,
|
|
64
|
+
/*#__PURE__*/ _jsx("span", {
|
|
65
|
+
"aria-hidden": "true",
|
|
66
|
+
className: `backup-item__collections-arrow${isOpen ? ' backup-item__collections-arrow--expanded' : ''}`,
|
|
67
|
+
children: '>'
|
|
68
|
+
})
|
|
69
|
+
]
|
|
70
|
+
}),
|
|
71
|
+
/*#__PURE__*/ _jsxs("dialog", {
|
|
72
|
+
"aria-labelledby": `${id}-title`,
|
|
73
|
+
className: "backup-confirm-dialog backup-confirm-dialog--collections",
|
|
74
|
+
id: id,
|
|
75
|
+
onClose: ()=>setIsOpen(false),
|
|
76
|
+
onPointerDown: (event)=>closeNativeDialogOnBackdropPointer(event, dialogRef),
|
|
77
|
+
ref: dialogRef,
|
|
78
|
+
children: [
|
|
79
|
+
/*#__PURE__*/ _jsx("h3", {
|
|
80
|
+
className: "backup-confirm-dialog__title",
|
|
81
|
+
id: `${id}-title`,
|
|
82
|
+
children: "Collections in backup"
|
|
83
|
+
}),
|
|
84
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
85
|
+
className: "backup-confirm-dialog__body backup-item__collections-body",
|
|
86
|
+
children: [
|
|
87
|
+
phase === 'loading' && /*#__PURE__*/ _jsx("p", {
|
|
88
|
+
"aria-live": "polite",
|
|
89
|
+
className: "backup-item__collections-status",
|
|
90
|
+
children: "Loading collection names…"
|
|
91
|
+
}),
|
|
92
|
+
phase === 'error' && /*#__PURE__*/ _jsxs("div", {
|
|
93
|
+
className: "backup-item__collections-error",
|
|
94
|
+
role: "alert",
|
|
95
|
+
children: [
|
|
96
|
+
/*#__PURE__*/ _jsx("span", {
|
|
97
|
+
children: errorMessage
|
|
98
|
+
}),
|
|
99
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
100
|
+
buttonStyle: "secondary",
|
|
101
|
+
onClick: ()=>void loadCollections(),
|
|
102
|
+
size: "small",
|
|
103
|
+
children: "Retry"
|
|
104
|
+
})
|
|
105
|
+
]
|
|
106
|
+
}),
|
|
107
|
+
phase === 'ready' && (collections.length > 0 ? /*#__PURE__*/ _jsx("ul", {
|
|
108
|
+
"aria-label": "Collections in backup",
|
|
109
|
+
className: "backup-item__collections-list",
|
|
110
|
+
children: collections.map((collection)=>/*#__PURE__*/ _jsx("li", {
|
|
111
|
+
className: "backup-item__collections-name",
|
|
112
|
+
children: collection
|
|
113
|
+
}, collection))
|
|
114
|
+
}) : /*#__PURE__*/ _jsx("p", {
|
|
115
|
+
className: "backup-item__collections-status",
|
|
116
|
+
children: "No collections in this backup."
|
|
117
|
+
}))
|
|
118
|
+
]
|
|
119
|
+
}),
|
|
120
|
+
/*#__PURE__*/ _jsx("div", {
|
|
121
|
+
className: "backup-confirm-dialog__actions",
|
|
122
|
+
children: /*#__PURE__*/ _jsx(Button, {
|
|
123
|
+
buttonStyle: "secondary",
|
|
124
|
+
onClick: ()=>dialogRef.current?.close(),
|
|
125
|
+
type: "button",
|
|
126
|
+
children: "Close"
|
|
127
|
+
})
|
|
128
|
+
})
|
|
129
|
+
]
|
|
130
|
+
})
|
|
131
|
+
]
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
//# sourceMappingURL=BackupCollectionsDetails.client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/BackupDashboard/BackupCollectionsDetails.client.tsx"],"sourcesContent":["'use client'\n\nimport { Button } from '@payloadcms/ui'\nimport { useCallback, useId, useRef, useState } from 'react'\n\nimport type { RestorePreviewResponse } from '../../core/restorePreview'\n\nimport { backupPluginPublicApiPaths } from '../../publicApiPaths'\nimport { closeNativeDialogOnBackdropPointer } from '../../utils/dialogBackdrop'\n\ntype BackupCollectionsDetailsProps = {\n collectionCount?: number\n downloadUrl: string\n pathname: string\n}\n\ntype BackupCollectionsResponse = {\n error?: string\n} & Pick<RestorePreviewResponse, 'backupCollections'>\n\nexport const BackupCollectionsDetails: React.FC<BackupCollectionsDetailsProps> = ({\n collectionCount,\n downloadUrl,\n pathname,\n}) => {\n const id = useId()\n const dialogRef = useRef<HTMLDialogElement>(null)\n const [isOpen, setIsOpen] = useState(false)\n const [collections, setCollections] = useState<string[]>([])\n const [phase, setPhase] = useState<'error' | 'idle' | 'loading' | 'ready'>('idle')\n const [errorMessage, setErrorMessage] = useState<null | string>(null)\n\n const loadCollections = useCallback(async () => {\n setPhase('loading')\n setErrorMessage(null)\n try {\n const locale =\n typeof document !== 'undefined' ? (document.documentElement.lang || 'en').slice(0, 2) : 'en'\n const response = await fetch(backupPluginPublicApiPaths.adminRestorePreview, {\n body: JSON.stringify({ locale, pathname, url: downloadUrl }),\n headers: { 'Content-Type': 'application/json' },\n method: 'POST',\n })\n const data = (await response.json()) as BackupCollectionsResponse\n if (!response.ok) {\n throw new Error(data.error || 'Could not load backup collections')\n }\n setCollections(data.backupCollections)\n setPhase('ready')\n } catch (error) {\n setPhase('error')\n setErrorMessage(\n error instanceof Error ? error.message : 'Could not load backup collections',\n )\n }\n }, [downloadUrl, pathname])\n\n const openDetails = () => {\n setIsOpen(true)\n dialogRef.current?.showModal()\n if (phase === 'idle') {\n void loadCollections()\n }\n }\n\n const displayCount = phase === 'ready' ? collections.length : collectionCount\n\n return (\n <div className=\"backup-item__collections\">\n <button\n aria-controls={id}\n aria-expanded={isOpen}\n aria-haspopup=\"dialog\"\n className=\"backup-item__pill backup-item__pill--collections backup-item__collections-trigger\"\n onClick={openDetails}\n type=\"button\"\n >\n {displayCount === undefined ?\n 'Collections'\n : `${displayCount} collection${displayCount === 1 ? '' : 's'}`}\n <span\n aria-hidden=\"true\"\n className={`backup-item__collections-arrow${isOpen ? ' backup-item__collections-arrow--expanded' : ''}`}\n >\n {'>'}\n </span>\n </button>\n\n <dialog\n aria-labelledby={`${id}-title`}\n className=\"backup-confirm-dialog backup-confirm-dialog--collections\"\n id={id}\n onClose={() => setIsOpen(false)}\n onPointerDown={(event) => closeNativeDialogOnBackdropPointer(event, dialogRef)}\n ref={dialogRef}\n >\n <h3 className=\"backup-confirm-dialog__title\" id={`${id}-title`}>\n Collections in backup\n </h3>\n <div className=\"backup-confirm-dialog__body backup-item__collections-body\">\n {phase === 'loading' && (\n <p aria-live=\"polite\" className=\"backup-item__collections-status\">\n Loading collection names…\n </p>\n )}\n {phase === 'error' && (\n <div className=\"backup-item__collections-error\" role=\"alert\">\n <span>{errorMessage}</span>\n <Button buttonStyle=\"secondary\" onClick={() => void loadCollections()} size=\"small\">\n Retry\n </Button>\n </div>\n )}\n {phase === 'ready' &&\n (collections.length > 0 ?\n <ul aria-label=\"Collections in backup\" className=\"backup-item__collections-list\">\n {collections.map((collection) => (\n <li className=\"backup-item__collections-name\" key={collection}>\n {collection}\n </li>\n ))}\n </ul>\n : <p className=\"backup-item__collections-status\">No collections in this backup.</p>)}\n </div>\n <div className=\"backup-confirm-dialog__actions\">\n <Button buttonStyle=\"secondary\" onClick={() => dialogRef.current?.close()} type=\"button\">\n Close\n </Button>\n </div>\n </dialog>\n </div>\n )\n}\n"],"names":["Button","useCallback","useId","useRef","useState","backupPluginPublicApiPaths","closeNativeDialogOnBackdropPointer","BackupCollectionsDetails","collectionCount","downloadUrl","pathname","id","dialogRef","isOpen","setIsOpen","collections","setCollections","phase","setPhase","errorMessage","setErrorMessage","loadCollections","locale","document","documentElement","lang","slice","response","fetch","adminRestorePreview","body","JSON","stringify","url","headers","method","data","json","ok","Error","error","backupCollections","message","openDetails","current","showModal","displayCount","length","div","className","button","aria-controls","aria-expanded","aria-haspopup","onClick","type","undefined","span","aria-hidden","dialog","aria-labelledby","onClose","onPointerDown","event","ref","h3","p","aria-live","role","buttonStyle","size","ul","aria-label","map","collection","li","close"],"mappings":"AAAA;;AAEA,SAASA,MAAM,QAAQ,iBAAgB;AACvC,SAASC,WAAW,EAAEC,KAAK,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AAI5D,SAASC,0BAA0B,QAAQ,uBAAsB;AACjE,SAASC,kCAAkC,QAAQ,6BAA4B;AAY/E,OAAO,MAAMC,2BAAoE,CAAC,EAChFC,eAAe,EACfC,WAAW,EACXC,QAAQ,EACT;IACC,MAAMC,KAAKT;IACX,MAAMU,YAAYT,OAA0B;IAC5C,MAAM,CAACU,QAAQC,UAAU,GAAGV,SAAS;IACrC,MAAM,CAACW,aAAaC,eAAe,GAAGZ,SAAmB,EAAE;IAC3D,MAAM,CAACa,OAAOC,SAAS,GAAGd,SAAiD;IAC3E,MAAM,CAACe,cAAcC,gBAAgB,GAAGhB,SAAwB;IAEhE,MAAMiB,kBAAkBpB,YAAY;QAClCiB,SAAS;QACTE,gBAAgB;QAChB,IAAI;YACF,MAAME,SACJ,OAAOC,aAAa,cAAc,AAACA,CAAAA,SAASC,eAAe,CAACC,IAAI,IAAI,IAAG,EAAGC,KAAK,CAAC,GAAG,KAAK;YAC1F,MAAMC,WAAW,MAAMC,MAAMvB,2BAA2BwB,mBAAmB,EAAE;gBAC3EC,MAAMC,KAAKC,SAAS,CAAC;oBAAEV;oBAAQZ;oBAAUuB,KAAKxB;gBAAY;gBAC1DyB,SAAS;oBAAE,gBAAgB;gBAAmB;gBAC9CC,QAAQ;YACV;YACA,MAAMC,OAAQ,MAAMT,SAASU,IAAI;YACjC,IAAI,CAACV,SAASW,EAAE,EAAE;gBAChB,MAAM,IAAIC,MAAMH,KAAKI,KAAK,IAAI;YAChC;YACAxB,eAAeoB,KAAKK,iBAAiB;YACrCvB,SAAS;QACX,EAAE,OAAOsB,OAAO;YACdtB,SAAS;YACTE,gBACEoB,iBAAiBD,QAAQC,MAAME,OAAO,GAAG;QAE7C;IACF,GAAG;QAACjC;QAAaC;KAAS;IAE1B,MAAMiC,cAAc;QAClB7B,UAAU;QACVF,UAAUgC,OAAO,EAAEC;QACnB,IAAI5B,UAAU,QAAQ;YACpB,KAAKI;QACP;IACF;IAEA,MAAMyB,eAAe7B,UAAU,UAAUF,YAAYgC,MAAM,GAAGvC;IAE9D,qBACE,MAACwC;QAAIC,WAAU;;0BACb,MAACC;gBACCC,iBAAexC;gBACfyC,iBAAevC;gBACfwC,iBAAc;gBACdJ,WAAU;gBACVK,SAASX;gBACTY,MAAK;;oBAEJT,iBAAiBU,YAChB,gBACA,GAAGV,aAAa,WAAW,EAAEA,iBAAiB,IAAI,KAAK,KAAK;kCAC9D,KAACW;wBACCC,eAAY;wBACZT,WAAW,CAAC,8BAA8B,EAAEpC,SAAS,8CAA8C,IAAI;kCAEtG;;;;0BAIL,MAAC8C;gBACCC,mBAAiB,GAAGjD,GAAG,MAAM,CAAC;gBAC9BsC,WAAU;gBACVtC,IAAIA;gBACJkD,SAAS,IAAM/C,UAAU;gBACzBgD,eAAe,CAACC,QAAUzD,mCAAmCyD,OAAOnD;gBACpEoD,KAAKpD;;kCAEL,KAACqD;wBAAGhB,WAAU;wBAA+BtC,IAAI,GAAGA,GAAG,MAAM,CAAC;kCAAE;;kCAGhE,MAACqC;wBAAIC,WAAU;;4BACZhC,UAAU,2BACT,KAACiD;gCAAEC,aAAU;gCAASlB,WAAU;0CAAkC;;4BAInEhC,UAAU,yBACT,MAAC+B;gCAAIC,WAAU;gCAAiCmB,MAAK;;kDACnD,KAACX;kDAAMtC;;kDACP,KAACnB;wCAAOqE,aAAY;wCAAYf,SAAS,IAAM,KAAKjC;wCAAmBiD,MAAK;kDAAQ;;;;4BAKvFrD,UAAU,WACRF,CAAAA,YAAYgC,MAAM,GAAG,kBACpB,KAACwB;gCAAGC,cAAW;gCAAwBvB,WAAU;0CAC9ClC,YAAY0D,GAAG,CAAC,CAACC,2BAChB,KAACC;wCAAG1B,WAAU;kDACXyB;uCADgDA;+CAKvD,KAACR;gCAAEjB,WAAU;0CAAkC;8BAAiC;;;kCAEtF,KAACD;wBAAIC,WAAU;kCACb,cAAA,KAACjD;4BAAOqE,aAAY;4BAAYf,SAAS,IAAM1C,UAAUgC,OAAO,EAAEgC;4BAASrB,MAAK;sCAAS;;;;;;;AAOnG,EAAC"}
|
|
@@ -6,7 +6,7 @@ import { backupPluginPublicApiPaths } from '../../publicApiPaths.js';
|
|
|
6
6
|
import { closeNativeDialogOnBackdropPointer } from '../../utils/dialogBackdrop.js';
|
|
7
7
|
import { RestoreBackupDialog } from './RestoreBackupDialog.client.js';
|
|
8
8
|
import { TaskActionButton } from './TaskActionButton.client.js';
|
|
9
|
-
export const BackupItemActions = ({ downloadUrl, pathname, url })=>{
|
|
9
|
+
export const BackupItemActions = ({ backupNumber, downloadUrl, pathname, url })=>{
|
|
10
10
|
const downloadParams = new URLSearchParams({
|
|
11
11
|
pathname
|
|
12
12
|
});
|
|
@@ -45,13 +45,13 @@ export const BackupItemActions = ({ downloadUrl, pathname, url })=>{
|
|
|
45
45
|
]
|
|
46
46
|
}),
|
|
47
47
|
/*#__PURE__*/ _jsxs("dialog", {
|
|
48
|
-
className: "backup-confirm-dialog",
|
|
48
|
+
className: "backup-confirm-dialog backup-confirm-dialog--delete-backup",
|
|
49
49
|
onMouseDown: (e)=>closeNativeDialogOnBackdropPointer(e, deleteDialogRef),
|
|
50
50
|
ref: deleteDialogRef,
|
|
51
51
|
children: [
|
|
52
52
|
/*#__PURE__*/ _jsx("p", {
|
|
53
53
|
className: "backup-confirm-dialog__title",
|
|
54
|
-
children:
|
|
54
|
+
children: backupNumber === undefined ? 'Delete this backup?' : `Delete backup #${backupNumber} ?`
|
|
55
55
|
}),
|
|
56
56
|
/*#__PURE__*/ _jsx("p", {
|
|
57
57
|
className: "backup-confirm-dialog__body",
|
|
@@ -66,6 +66,7 @@ export const BackupItemActions = ({ downloadUrl, pathname, url })=>{
|
|
|
66
66
|
url
|
|
67
67
|
},
|
|
68
68
|
buttonStyle: "error",
|
|
69
|
+
className: "backup-confirm-dialog__delete-button",
|
|
69
70
|
completeLabel: "Deleted",
|
|
70
71
|
endpoint: backupPluginPublicApiPaths.adminDelete,
|
|
71
72
|
idleLabel: "Yes, delete",
|
|
@@ -77,9 +78,10 @@ export const BackupItemActions = ({ downloadUrl, pathname, url })=>{
|
|
|
77
78
|
}),
|
|
78
79
|
/*#__PURE__*/ _jsx(Button, {
|
|
79
80
|
buttonStyle: "secondary",
|
|
81
|
+
className: "backup-confirm-dialog__not-now-button",
|
|
80
82
|
onClick: ()=>deleteDialogRef.current?.close(),
|
|
81
|
-
size: "
|
|
82
|
-
children: "
|
|
83
|
+
size: "medium",
|
|
84
|
+
children: "Not now"
|
|
83
85
|
})
|
|
84
86
|
]
|
|
85
87
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/BackupDashboard/BackupItemActions.client.tsx"],"sourcesContent":["'use client'\n\nimport { Button } from '@payloadcms/ui'\nimport { useRef } from 'react'\n\nimport { backupPluginPublicApiPaths } from '../../publicApiPaths'\nimport { closeNativeDialogOnBackdropPointer } from '../../utils/dialogBackdrop'\nimport { RestoreBackupDialog } from './RestoreBackupDialog.client'\nimport { TaskActionButton } from './TaskActionButton.client'\n\ntype BackupItemActionsProps = {\n downloadUrl: string\n pathname: string\n url: string\n}\n\nexport const BackupItemActions: React.FC<BackupItemActionsProps> = ({\n downloadUrl,\n pathname,\n url,\n}) => {\n const downloadParams = new URLSearchParams({ pathname })\n if (url) {\n downloadParams.set('url', url)\n }\n if (downloadUrl) {\n downloadParams.set('downloadUrl', downloadUrl)\n }\n const downloadHref = `${backupPluginPublicApiPaths.adminBackupDownload}?${downloadParams.toString()}`\n const deleteDialogRef = useRef<HTMLDialogElement>(null)\n\n return (\n <div className=\"backup-item-actions\">\n <div className=\"backup-item-actions__buttons\">\n <Button buttonStyle=\"secondary\" el=\"anchor\" newTab size=\"small\" url={downloadHref}>\n Download\n </Button>\n <RestoreBackupDialog downloadUrl={downloadUrl} pathname={pathname} />\n <Button\n buttonStyle=\"secondary\"\n onClick={() => deleteDialogRef.current?.showModal()}\n size=\"small\"\n >\n Delete\n </Button>\n </div>\n\n {/* Native <dialog>: backdrop dismiss; element not in jsx-a11y interactive list */}\n {/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */}\n <dialog\n className=\"backup-confirm-dialog\"\n onMouseDown={(e) => closeNativeDialogOnBackdropPointer(e, deleteDialogRef)}\n ref={deleteDialogRef}\n >\n <p className=\"backup-confirm-dialog__title\"
|
|
1
|
+
{"version":3,"sources":["../../../src/components/BackupDashboard/BackupItemActions.client.tsx"],"sourcesContent":["'use client'\n\nimport { Button } from '@payloadcms/ui'\nimport { useRef } from 'react'\n\nimport { backupPluginPublicApiPaths } from '../../publicApiPaths'\nimport { closeNativeDialogOnBackdropPointer } from '../../utils/dialogBackdrop'\nimport { RestoreBackupDialog } from './RestoreBackupDialog.client'\nimport { TaskActionButton } from './TaskActionButton.client'\n\ntype BackupItemActionsProps = {\n backupNumber?: number\n downloadUrl: string\n pathname: string\n url: string\n}\n\nexport const BackupItemActions: React.FC<BackupItemActionsProps> = ({\n backupNumber,\n downloadUrl,\n pathname,\n url,\n}) => {\n const downloadParams = new URLSearchParams({ pathname })\n if (url) {\n downloadParams.set('url', url)\n }\n if (downloadUrl) {\n downloadParams.set('downloadUrl', downloadUrl)\n }\n const downloadHref = `${backupPluginPublicApiPaths.adminBackupDownload}?${downloadParams.toString()}`\n const deleteDialogRef = useRef<HTMLDialogElement>(null)\n\n return (\n <div className=\"backup-item-actions\">\n <div className=\"backup-item-actions__buttons\">\n <Button buttonStyle=\"secondary\" el=\"anchor\" newTab size=\"small\" url={downloadHref}>\n Download\n </Button>\n <RestoreBackupDialog downloadUrl={downloadUrl} pathname={pathname} />\n <Button\n buttonStyle=\"secondary\"\n onClick={() => deleteDialogRef.current?.showModal()}\n size=\"small\"\n >\n Delete\n </Button>\n </div>\n\n {/* Native <dialog>: backdrop dismiss; element not in jsx-a11y interactive list */}\n {/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */}\n <dialog\n className=\"backup-confirm-dialog backup-confirm-dialog--delete-backup\"\n onMouseDown={(e) => closeNativeDialogOnBackdropPointer(e, deleteDialogRef)}\n ref={deleteDialogRef}\n >\n <p className=\"backup-confirm-dialog__title\">\n {backupNumber === undefined ? 'Delete this backup?' : `Delete backup #${backupNumber} ?`}\n </p>\n <p className=\"backup-confirm-dialog__body\">This action cannot be undone.</p>\n <div className=\"backup-confirm-dialog__actions\">\n <TaskActionButton\n body={{ pathname, url }}\n buttonStyle=\"error\"\n className=\"backup-confirm-dialog__delete-button\"\n completeLabel=\"Deleted\"\n endpoint={backupPluginPublicApiPaths.adminDelete}\n idleLabel=\"Yes, delete\"\n kind=\"delete\"\n onComplete={() => deleteDialogRef.current?.close()}\n onFailure={() => deleteDialogRef.current?.close()}\n pendingLabel=\"Deleting...\"\n refreshOnComplete={true}\n />\n <Button\n buttonStyle=\"secondary\"\n className=\"backup-confirm-dialog__not-now-button\"\n onClick={() => deleteDialogRef.current?.close()}\n size=\"medium\"\n >\n Not now\n </Button>\n </div>\n </dialog>\n </div>\n )\n}\n"],"names":["Button","useRef","backupPluginPublicApiPaths","closeNativeDialogOnBackdropPointer","RestoreBackupDialog","TaskActionButton","BackupItemActions","backupNumber","downloadUrl","pathname","url","downloadParams","URLSearchParams","set","downloadHref","adminBackupDownload","toString","deleteDialogRef","div","className","buttonStyle","el","newTab","size","onClick","current","showModal","dialog","onMouseDown","e","ref","p","undefined","body","completeLabel","endpoint","adminDelete","idleLabel","kind","onComplete","close","onFailure","pendingLabel","refreshOnComplete"],"mappings":"AAAA;;AAEA,SAASA,MAAM,QAAQ,iBAAgB;AACvC,SAASC,MAAM,QAAQ,QAAO;AAE9B,SAASC,0BAA0B,QAAQ,uBAAsB;AACjE,SAASC,kCAAkC,QAAQ,6BAA4B;AAC/E,SAASC,mBAAmB,QAAQ,+BAA8B;AAClE,SAASC,gBAAgB,QAAQ,4BAA2B;AAS5D,OAAO,MAAMC,oBAAsD,CAAC,EAClEC,YAAY,EACZC,WAAW,EACXC,QAAQ,EACRC,GAAG,EACJ;IACC,MAAMC,iBAAiB,IAAIC,gBAAgB;QAAEH;IAAS;IACtD,IAAIC,KAAK;QACPC,eAAeE,GAAG,CAAC,OAAOH;IAC5B;IACA,IAAIF,aAAa;QACfG,eAAeE,GAAG,CAAC,eAAeL;IACpC;IACA,MAAMM,eAAe,GAAGZ,2BAA2Ba,mBAAmB,CAAC,CAAC,EAAEJ,eAAeK,QAAQ,IAAI;IACrG,MAAMC,kBAAkBhB,OAA0B;IAElD,qBACE,MAACiB;QAAIC,WAAU;;0BACb,MAACD;gBAAIC,WAAU;;kCACb,KAACnB;wBAAOoB,aAAY;wBAAYC,IAAG;wBAASC,MAAM;wBAACC,MAAK;wBAAQb,KAAKI;kCAAc;;kCAGnF,KAACV;wBAAoBI,aAAaA;wBAAaC,UAAUA;;kCACzD,KAACT;wBACCoB,aAAY;wBACZI,SAAS,IAAMP,gBAAgBQ,OAAO,EAAEC;wBACxCH,MAAK;kCACN;;;;0BAOH,MAACI;gBACCR,WAAU;gBACVS,aAAa,CAACC,IAAM1B,mCAAmC0B,GAAGZ;gBAC1Da,KAAKb;;kCAEL,KAACc;wBAAEZ,WAAU;kCACVZ,iBAAiByB,YAAY,wBAAwB,CAAC,eAAe,EAAEzB,aAAa,EAAE,CAAC;;kCAE1F,KAACwB;wBAAEZ,WAAU;kCAA8B;;kCAC3C,MAACD;wBAAIC,WAAU;;0CACb,KAACd;gCACC4B,MAAM;oCAAExB;oCAAUC;gCAAI;gCACtBU,aAAY;gCACZD,WAAU;gCACVe,eAAc;gCACdC,UAAUjC,2BAA2BkC,WAAW;gCAChDC,WAAU;gCACVC,MAAK;gCACLC,YAAY,IAAMtB,gBAAgBQ,OAAO,EAAEe;gCAC3CC,WAAW,IAAMxB,gBAAgBQ,OAAO,EAAEe;gCAC1CE,cAAa;gCACbC,mBAAmB;;0CAErB,KAAC3C;gCACCoB,aAAY;gCACZD,WAAU;gCACVK,SAAS,IAAMP,gBAAgBQ,OAAO,EAAEe;gCACxCjB,MAAK;0CACN;;;;;;;;AAOX,EAAC"}
|
|
@@ -4,6 +4,7 @@ import { Button } from '@payloadcms/ui';
|
|
|
4
4
|
import { useCallback, useId, useMemo, useRef, useState } from 'react';
|
|
5
5
|
import { closeNativeDialogOnBackdropPointer } from '../../utils/dialogBackdrop.js';
|
|
6
6
|
import { formatBytes, getBackupSortTimeMs, transformBlobName } from '../../utils/index.js';
|
|
7
|
+
import { BackupCollectionsDetails } from './BackupCollectionsDetails.client.js';
|
|
7
8
|
import { BackupItemActions } from './BackupItemActions.client.js';
|
|
8
9
|
const defaultFilterState = {
|
|
9
10
|
dateFrom: '',
|
|
@@ -162,6 +163,13 @@ export const BackupListCollapsible = ({ blobs, countOtherDb, countOtherHostname,
|
|
|
162
163
|
/*#__PURE__*/ _jsxs("div", {
|
|
163
164
|
className: "backup-item__primary",
|
|
164
165
|
children: [
|
|
166
|
+
typeof blob.backupNumber === 'number' ? /*#__PURE__*/ _jsxs("span", {
|
|
167
|
+
className: "backup-item__pill backup-item__pill--number",
|
|
168
|
+
children: [
|
|
169
|
+
"#",
|
|
170
|
+
blob.backupNumber
|
|
171
|
+
]
|
|
172
|
+
}) : null,
|
|
165
173
|
/*#__PURE__*/ _jsx("time", {
|
|
166
174
|
className: "backup-item__time",
|
|
167
175
|
dateTime: displayAt.toISOString(),
|
|
@@ -208,16 +216,11 @@ export const BackupListCollapsible = ({ blobs, countOtherDb, countOtherHostname,
|
|
|
208
216
|
hostname || 'Unknown'
|
|
209
217
|
]
|
|
210
218
|
}),
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
children: "Collections"
|
|
217
|
-
}),
|
|
218
|
-
collectionCount
|
|
219
|
-
]
|
|
220
|
-
}) : null,
|
|
219
|
+
/*#__PURE__*/ _jsx(BackupCollectionsDetails, {
|
|
220
|
+
collectionCount: collectionCount,
|
|
221
|
+
downloadUrl: blob.downloadUrl,
|
|
222
|
+
pathname: blob.pathname
|
|
223
|
+
}),
|
|
221
224
|
fileType === 'tar.gz' ? /*#__PURE__*/ _jsx("span", {
|
|
222
225
|
className: "backup-item__pill backup-item__pill--media",
|
|
223
226
|
children: "With media"
|
|
@@ -244,6 +247,7 @@ export const BackupListCollapsible = ({ blobs, countOtherDb, countOtherHostname,
|
|
|
244
247
|
]
|
|
245
248
|
}),
|
|
246
249
|
/*#__PURE__*/ _jsx(BackupItemActions, {
|
|
250
|
+
backupNumber: blob.backupNumber,
|
|
247
251
|
downloadUrl: blob.downloadUrl,
|
|
248
252
|
pathname: blob.pathname,
|
|
249
253
|
url: blob.url
|