@marinoscar/vault-web 0.0.0-bootstrap → 0.1.0-next.3
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/CHANGELOG.md +32 -0
- package/LICENSE +21 -0
- package/README.md +99 -0
- package/dist/agent/headless/agentActivity.d.ts +53 -0
- package/dist/agent/headless/agentActivity.js +58 -0
- package/dist/agent/headless/index.d.ts +2 -0
- package/dist/agent/headless/index.js +3 -0
- package/dist/agent/headless/useAgentActivity.d.ts +9 -0
- package/dist/agent/headless/useAgentActivity.js +30 -0
- package/dist/agent/ui/components/AgentActivityTable.d.ts +25 -0
- package/dist/agent/ui/components/AgentActivityTable.js +114 -0
- package/dist/agent/ui/index.d.ts +3 -0
- package/dist/agent/ui/index.js +4 -0
- package/dist/agent/ui/pages/AgentAccessSettingsPage.d.ts +7 -0
- package/dist/agent/ui/pages/AgentAccessSettingsPage.js +70 -0
- package/dist/agent/ui/pages/AgentActivityPage.d.ts +6 -0
- package/dist/agent/ui/pages/AgentActivityPage.js +61 -0
- package/dist/backups/headless/backupContents.d.ts +69 -0
- package/dist/backups/headless/backupContents.js +133 -0
- package/dist/backups/headless/backupPassword.d.ts +34 -0
- package/dist/backups/headless/backupPassword.js +80 -0
- package/dist/backups/headless/backupSchedule.d.ts +56 -0
- package/dist/backups/headless/backupSchedule.js +189 -0
- package/dist/backups/headless/index.d.ts +4 -0
- package/dist/backups/headless/index.js +5 -0
- package/dist/backups/headless/useBackupRunHistory.d.ts +36 -0
- package/dist/backups/headless/useBackupRunHistory.js +83 -0
- package/dist/backups/ui/components/AdminBackupDownloadDialog.d.ts +20 -0
- package/dist/backups/ui/components/AdminBackupDownloadDialog.js +65 -0
- package/dist/backups/ui/components/BackupContentsGroup.d.ts +17 -0
- package/dist/backups/ui/components/BackupContentsGroup.js +21 -0
- package/dist/backups/ui/components/BackupPasswordFields.d.ts +18 -0
- package/dist/backups/ui/components/BackupPasswordFields.js +40 -0
- package/dist/backups/ui/components/BackupRunsTable.d.ts +44 -0
- package/dist/backups/ui/components/BackupRunsTable.js +61 -0
- package/dist/backups/ui/components/DataBackup.d.ts +14 -0
- package/dist/backups/ui/components/DataBackup.js +169 -0
- package/dist/backups/ui/components/ScheduledBackups.d.ts +13 -0
- package/dist/backups/ui/components/ScheduledBackups.js +304 -0
- package/dist/backups/ui/index.d.ts +8 -0
- package/dist/backups/ui/index.js +9 -0
- package/dist/backups/ui/pages/BackupSettingsPage.d.ts +8 -0
- package/dist/backups/ui/pages/BackupSettingsPage.js +19 -0
- package/dist/backups/ui/pages/MyBackupsPage.d.ts +8 -0
- package/dist/backups/ui/pages/MyBackupsPage.js +19 -0
- package/dist/brand/BrandLockup.d.ts +14 -0
- package/dist/brand/BrandLockup.js +13 -0
- package/dist/brand/assets/vault-mark.png +0 -0
- package/dist/brand/contrast.d.ts +8 -0
- package/dist/brand/contrast.js +21 -0
- package/dist/brand/index.d.ts +7 -0
- package/dist/brand/index.js +8 -0
- package/dist/brand/mark.d.ts +6 -0
- package/dist/brand/mark.js +7 -0
- package/dist/brand/theme.d.ts +25 -0
- package/dist/brand/theme.js +84 -0
- package/dist/brand/tokens.d.ts +52 -0
- package/dist/brand/tokens.js +54 -0
- package/dist/cards/headless/cardExpiry.d.ts +57 -0
- package/dist/cards/headless/cardExpiry.js +138 -0
- package/dist/cards/headless/cardFormat.d.ts +60 -0
- package/dist/cards/headless/cardFormat.js +135 -0
- package/dist/cards/headless/cardImage.d.ts +293 -0
- package/dist/cards/headless/cardImage.js +518 -0
- package/dist/cards/headless/index.d.ts +6 -0
- package/dist/cards/headless/index.js +7 -0
- package/dist/cards/headless/useCardImport.d.ts +137 -0
- package/dist/cards/headless/useCardImport.js +391 -0
- package/dist/cards/headless/useCardRenewal.d.ts +102 -0
- package/dist/cards/headless/useCardRenewal.js +305 -0
- package/dist/cards/headless/useCards.d.ts +80 -0
- package/dist/cards/headless/useCards.js +114 -0
- package/dist/cards/ui/components/AiEgressNotice.d.ts +13 -0
- package/dist/cards/ui/components/AiEgressNotice.js +18 -0
- package/dist/cards/ui/components/CardCaptureStep.d.ts +59 -0
- package/dist/cards/ui/components/CardCaptureStep.js +96 -0
- package/dist/cards/ui/components/CardCropAdjuster.d.ts +43 -0
- package/dist/cards/ui/components/CardCropAdjuster.js +215 -0
- package/dist/cards/ui/components/CardCropReview.d.ts +51 -0
- package/dist/cards/ui/components/CardCropReview.js +88 -0
- package/dist/cards/ui/components/CardExpiryBadge.d.ts +8 -0
- package/dist/cards/ui/components/CardExpiryBadge.js +43 -0
- package/dist/cards/ui/components/CardFieldDiff.d.ts +37 -0
- package/dist/cards/ui/components/CardFieldDiff.js +66 -0
- package/dist/cards/ui/components/CardFlowStepper.d.ts +24 -0
- package/dist/cards/ui/components/CardFlowStepper.js +23 -0
- package/dist/cards/ui/components/CardReviewForm.d.ts +44 -0
- package/dist/cards/ui/components/CardReviewForm.js +102 -0
- package/dist/cards/ui/components/CardScanModelSection.d.ts +23 -0
- package/dist/cards/ui/components/CardScanModelSection.js +81 -0
- package/dist/cards/ui/components/CardTile.d.ts +40 -0
- package/dist/cards/ui/components/CardTile.js +94 -0
- package/dist/cards/ui/index.d.ts +15 -0
- package/dist/cards/ui/index.js +16 -0
- package/dist/cards/ui/pages/AiSettingsPage.d.ts +12 -0
- package/dist/cards/ui/pages/AiSettingsPage.js +24 -0
- package/dist/cards/ui/pages/CardsPage.d.ts +26 -0
- package/dist/cards/ui/pages/CardsPage.js +160 -0
- package/dist/cards/ui/pages/ImportCardPage.d.ts +24 -0
- package/dist/cards/ui/pages/ImportCardPage.js +343 -0
- package/dist/cards/ui/pages/RenewCardPage.d.ts +35 -0
- package/dist/cards/ui/pages/RenewCardPage.js +350 -0
- package/dist/core/headless/api.d.ts +272 -0
- package/dist/core/headless/api.js +425 -0
- package/dist/core/headless/cardScanAvailability.d.ts +20 -0
- package/dist/core/headless/cardScanAvailability.js +27 -0
- package/dist/core/headless/clipboard.d.ts +60 -0
- package/dist/core/headless/clipboard.js +101 -0
- package/dist/core/headless/http.d.ts +41 -0
- package/dist/core/headless/http.js +50 -0
- package/dist/core/headless/index.d.ts +12 -0
- package/dist/core/headless/index.js +13 -0
- package/dist/core/headless/relativeTime.d.ts +7 -0
- package/dist/core/headless/relativeTime.js +28 -0
- package/dist/core/headless/saveBlob.d.ts +6 -0
- package/dist/core/headless/saveBlob.js +21 -0
- package/dist/core/headless/types.d.ts +441 -0
- package/dist/core/headless/types.js +49 -0
- package/dist/core/headless/useAiStatus.d.ts +41 -0
- package/dist/core/headless/useAiStatus.js +42 -0
- package/dist/core/headless/useCopyToClipboard.d.ts +20 -0
- package/dist/core/headless/useCopyToClipboard.js +52 -0
- package/dist/core/headless/useDashboardResource.d.ts +22 -0
- package/dist/core/headless/useDashboardResource.js +52 -0
- package/dist/core/headless/useSystemSettings.d.ts +17 -0
- package/dist/core/headless/useSystemSettings.js +106 -0
- package/dist/core/headless/useUserSettings.d.ts +13 -0
- package/dist/core/headless/useUserSettings.js +103 -0
- package/dist/core/ui/ErrorBoundary.d.ts +15 -0
- package/dist/core/ui/ErrorBoundary.js +27 -0
- package/dist/core/ui/LoadingSpinner.d.ts +6 -0
- package/dist/core/ui/LoadingSpinner.js +14 -0
- package/dist/core/ui/SettingsPageFrame.d.ts +19 -0
- package/dist/core/ui/SettingsPageFrame.js +12 -0
- package/dist/core/ui/StorageSettingsLink.d.ts +19 -0
- package/dist/core/ui/StorageSettingsLink.js +26 -0
- package/dist/core/ui/index.d.ts +4 -0
- package/dist/core/ui/index.js +5 -0
- package/dist/home/headless/homeLinks.d.ts +24 -0
- package/dist/home/headless/homeLinks.js +24 -0
- package/dist/home/headless/index.d.ts +1 -0
- package/dist/home/headless/index.js +2 -0
- package/dist/home/ui/components/BackupStatusPanel.d.ts +28 -0
- package/dist/home/ui/components/BackupStatusPanel.js +99 -0
- package/dist/home/ui/components/DashboardPanel.d.ts +33 -0
- package/dist/home/ui/components/DashboardPanel.js +21 -0
- package/dist/home/ui/components/ExpiringCardsPanel.d.ts +31 -0
- package/dist/home/ui/components/ExpiringCardsPanel.js +35 -0
- package/dist/home/ui/components/FirstRunPanel.d.ts +7 -0
- package/dist/home/ui/components/FirstRunPanel.js +21 -0
- package/dist/home/ui/components/QuickActions.d.ts +14 -0
- package/dist/home/ui/components/QuickActions.js +40 -0
- package/dist/home/ui/components/RecentSecretsPanel.d.ts +19 -0
- package/dist/home/ui/components/RecentSecretsPanel.js +20 -0
- package/dist/home/ui/components/StatsRow.d.ts +19 -0
- package/dist/home/ui/components/StatsRow.js +46 -0
- package/dist/home/ui/components/WelcomeHeader.d.ts +11 -0
- package/dist/home/ui/components/WelcomeHeader.js +15 -0
- package/dist/home/ui/index.d.ts +9 -0
- package/dist/home/ui/index.js +10 -0
- package/dist/home/ui/pages/HomePage.d.ts +14 -0
- package/dist/home/ui/pages/HomePage.js +121 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/media/headless/index.d.ts +2 -0
- package/dist/media/headless/index.js +3 -0
- package/dist/media/headless/useMediaFiles.d.ts +20 -0
- package/dist/media/headless/useMediaFiles.js +82 -0
- package/dist/media/headless/useMediaFolders.d.ts +22 -0
- package/dist/media/headless/useMediaFolders.js +81 -0
- package/dist/media/ui/components/FolderList.d.ts +19 -0
- package/dist/media/ui/components/FolderList.js +36 -0
- package/dist/media/ui/components/MediaList.d.ts +20 -0
- package/dist/media/ui/components/MediaList.js +55 -0
- package/dist/media/ui/components/MediaPlayer.d.ts +7 -0
- package/dist/media/ui/components/MediaPlayer.js +361 -0
- package/dist/media/ui/index.d.ts +10 -0
- package/dist/media/ui/index.js +11 -0
- package/dist/media/ui/pages/CreateFolderPage.d.ts +1 -0
- package/dist/media/ui/pages/CreateFolderPage.js +39 -0
- package/dist/media/ui/pages/EditFolderPage.d.ts +1 -0
- package/dist/media/ui/pages/EditFolderPage.js +59 -0
- package/dist/media/ui/pages/MediaFolderPage.d.ts +1 -0
- package/dist/media/ui/pages/MediaFolderPage.js +68 -0
- package/dist/media/ui/pages/MediaFoldersPage.d.ts +1 -0
- package/dist/media/ui/pages/MediaFoldersPage.js +58 -0
- package/dist/media/ui/pages/MediaPlayerPage.d.ts +1 -0
- package/dist/media/ui/pages/MediaPlayerPage.js +76 -0
- package/dist/media/ui/pages/MediaUploadPage.d.ts +1 -0
- package/dist/media/ui/pages/MediaUploadPage.js +88 -0
- package/dist/media/ui/pages/RenameMediaFilePage.d.ts +1 -0
- package/dist/media/ui/pages/RenameMediaFilePage.js +63 -0
- package/dist/navigation/destinations.d.ts +50 -0
- package/dist/navigation/destinations.js +109 -0
- package/dist/navigation/index.d.ts +1 -0
- package/dist/navigation/index.js +4 -0
- package/dist/secrets/headless/fieldOptionsValidation.d.ts +45 -0
- package/dist/secrets/headless/fieldOptionsValidation.js +79 -0
- package/dist/secrets/headless/index.d.ts +6 -0
- package/dist/secrets/headless/index.js +7 -0
- package/dist/secrets/headless/secretFields.d.ts +86 -0
- package/dist/secrets/headless/secretFields.js +190 -0
- package/dist/secrets/headless/useSecretDetail.d.ts +33 -0
- package/dist/secrets/headless/useSecretDetail.js +87 -0
- package/dist/secrets/headless/useSecretTypes.d.ts +16 -0
- package/dist/secrets/headless/useSecretTypes.js +62 -0
- package/dist/secrets/headless/useSecrets.d.ts +24 -0
- package/dist/secrets/headless/useSecrets.js +59 -0
- package/dist/secrets/headless/useTotpCode.d.ts +24 -0
- package/dist/secrets/headless/useTotpCode.js +116 -0
- package/dist/secrets/ui/components/CardImages.d.ts +31 -0
- package/dist/secrets/ui/components/CardImages.js +208 -0
- package/dist/secrets/ui/components/DynamicSecretFields.d.ts +10 -0
- package/dist/secrets/ui/components/DynamicSecretFields.js +90 -0
- package/dist/secrets/ui/components/FieldDefinitionBuilder.d.ts +13 -0
- package/dist/secrets/ui/components/FieldDefinitionBuilder.js +114 -0
- package/dist/secrets/ui/components/FieldOptionsEditor.d.ts +15 -0
- package/dist/secrets/ui/components/FieldOptionsEditor.js +45 -0
- package/dist/secrets/ui/components/SecretAttachments.d.ts +15 -0
- package/dist/secrets/ui/components/SecretAttachments.js +106 -0
- package/dist/secrets/ui/components/SecretForm.d.ts +34 -0
- package/dist/secrets/ui/components/SecretForm.js +83 -0
- package/dist/secrets/ui/components/SecretFormDialog.d.ts +15 -0
- package/dist/secrets/ui/components/SecretFormDialog.js +95 -0
- package/dist/secrets/ui/components/SecretTypeFormDialog.d.ts +15 -0
- package/dist/secrets/ui/components/SecretTypeFormDialog.js +92 -0
- package/dist/secrets/ui/components/SecretTypeIcon.d.ts +8 -0
- package/dist/secrets/ui/components/SecretTypeIcon.js +16 -0
- package/dist/secrets/ui/components/SecretTypesList.d.ts +10 -0
- package/dist/secrets/ui/components/SecretTypesList.js +13 -0
- package/dist/secrets/ui/components/SecretValueField.d.ts +20 -0
- package/dist/secrets/ui/components/SecretValueField.js +52 -0
- package/dist/secrets/ui/components/SecretVersionDrawer.d.ts +22 -0
- package/dist/secrets/ui/components/SecretVersionDrawer.js +131 -0
- package/dist/secrets/ui/components/SecretsTable.d.ts +49 -0
- package/dist/secrets/ui/components/SecretsTable.js +174 -0
- package/dist/secrets/ui/components/TotpCodeCard.d.ts +8 -0
- package/dist/secrets/ui/components/TotpCodeCard.js +34 -0
- package/dist/secrets/ui/index.d.ts +20 -0
- package/dist/secrets/ui/index.js +21 -0
- package/dist/secrets/ui/pages/CreateSecretPage.d.ts +2 -0
- package/dist/secrets/ui/pages/CreateSecretPage.js +25 -0
- package/dist/secrets/ui/pages/CreateSecretTypePage.d.ts +1 -0
- package/dist/secrets/ui/pages/CreateSecretTypePage.js +62 -0
- package/dist/secrets/ui/pages/EditSecretPage.d.ts +5 -0
- package/dist/secrets/ui/pages/EditSecretPage.js +55 -0
- package/dist/secrets/ui/pages/EditSecretTypePage.d.ts +1 -0
- package/dist/secrets/ui/pages/EditSecretTypePage.js +88 -0
- package/dist/secrets/ui/pages/SecretDetailPage.d.ts +7 -0
- package/dist/secrets/ui/pages/SecretDetailPage.js +182 -0
- package/dist/secrets/ui/pages/SecretTypesPage.d.ts +1 -0
- package/dist/secrets/ui/pages/SecretTypesPage.js +23 -0
- package/dist/secrets/ui/pages/SecretsPage.d.ts +6 -0
- package/dist/secrets/ui/pages/SecretsPage.js +179 -0
- package/dist/settings/ui/components/FeatureFlagsList.d.ts +7 -0
- package/dist/settings/ui/components/FeatureFlagsList.js +46 -0
- package/dist/settings/ui/components/ImageUpload.d.ts +6 -0
- package/dist/settings/ui/components/ImageUpload.js +61 -0
- package/dist/settings/ui/components/ProfileSettings.d.ts +11 -0
- package/dist/settings/ui/components/ProfileSettings.js +55 -0
- package/dist/settings/ui/components/ThemeSettings.d.ts +7 -0
- package/dist/settings/ui/components/ThemeSettings.js +24 -0
- package/dist/settings/ui/components/UISettings.d.ts +9 -0
- package/dist/settings/ui/components/UISettings.js +25 -0
- package/dist/settings/ui/components/UserProfileCard.d.ts +1 -0
- package/dist/settings/ui/components/UserProfileCard.js +39 -0
- package/dist/settings/ui/components/UserSettingsSection.d.ts +23 -0
- package/dist/settings/ui/components/UserSettingsSection.js +29 -0
- package/dist/settings/ui/index.d.ts +10 -0
- package/dist/settings/ui/index.js +11 -0
- package/dist/settings/ui/pages/AppearanceSettingsPage.d.ts +6 -0
- package/dist/settings/ui/pages/AppearanceSettingsPage.js +11 -0
- package/dist/settings/ui/pages/GeneralSettingsPage.d.ts +9 -0
- package/dist/settings/ui/pages/GeneralSettingsPage.js +41 -0
- package/dist/settings/ui/pages/ProfileSettingsPage.d.ts +6 -0
- package/dist/settings/ui/pages/ProfileSettingsPage.js +11 -0
- package/package.json +146 -1
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
3
|
+
import { Alert, Autocomplete, Box, Button, Card, CardContent, CircularProgress, Divider, FormControl, FormControlLabel, FormHelperText, IconButton, InputAdornment, InputLabel, MenuItem, Select, Stack, Switch, TextField, Tooltip, Typography, } from '@mui/material';
|
|
4
|
+
import Visibility from '@mui/icons-material/Visibility';
|
|
5
|
+
import VisibilityOff from '@mui/icons-material/VisibilityOff';
|
|
6
|
+
import AutoAwesomeIcon from '@mui/icons-material/AutoAwesome';
|
|
7
|
+
import DownloadIcon from '@mui/icons-material/Download';
|
|
8
|
+
import PlayArrowIcon from '@mui/icons-material/PlayArrow';
|
|
9
|
+
import SaveIcon from '@mui/icons-material/Save';
|
|
10
|
+
import RefreshIcon from '@mui/icons-material/Refresh';
|
|
11
|
+
import { usePermissions } from '@marinoscar/platform-web/identity/headless';
|
|
12
|
+
import { StorageSettingsLink } from '../../../core/ui/StorageSettingsLink.js';
|
|
13
|
+
import { deleteBackupRun, getBackupDownloadUrl, getBackupRuns, getBackupSchedule, runBackupNow, updateBackupSchedule, } from '../../../core/headless/api.js';
|
|
14
|
+
import { BACKUP_PASSWORD_MAX_LENGTH, BACKUP_PASSWORD_WARNING, shouldWarnBackupPassword, suggestBackupPassword, validateBackupPassword, } from '../../headless/backupPassword.js';
|
|
15
|
+
import { BACKUP_DAY_OF_MONTH_MAX, BACKUP_FREQUENCY_LABELS, BACKUP_INTERVAL_HOURS, BACKUP_KEEP_MAX, BACKUP_KEEP_MIN, BACKUP_PASSWORD_LOSS_WARNING, WEEKDAY_NAMES, describeBackupSchedule, formatDateTime, getBrowserTimeZone, getTimeZoneOptions, normalizeScheduleFields, scheduleContentSelection, startUrlDownload, validateScheduleFields, withScheduleContents, } from '../../headless/backupSchedule.js';
|
|
16
|
+
import { rawBackupContentFlags } from '../../headless/backupContents.js';
|
|
17
|
+
import { useBackupRunHistory } from '../../headless/useBackupRunHistory.js';
|
|
18
|
+
import { BackupContentsGroup } from './BackupContentsGroup.js';
|
|
19
|
+
import { BackupRunsTable, DeleteBackupDialog } from './BackupRunsTable.js';
|
|
20
|
+
import { AdminBackupDownloadDialog } from './AdminBackupDownloadDialog.js';
|
|
21
|
+
export { BACKUP_POLL_INTERVAL_MS } from '../../headless/useBackupRunHistory.js';
|
|
22
|
+
/** Hourly runs are anchored to local midnight, not to the save time. */
|
|
23
|
+
export const BACKUP_HOURLY_HELPER_TEXT = 'Runs on the hour, counted from midnight';
|
|
24
|
+
export const BACKUP_SCHEDULE_SAVED_MESSAGE = 'Backup schedule saved';
|
|
25
|
+
const FREQUENCIES = ['hourly', 'daily', 'weekly', 'monthly'];
|
|
26
|
+
const DAYS_OF_MONTH = Array.from({ length: BACKUP_DAY_OF_MONTH_MAX }, (_, i) => i + 1);
|
|
27
|
+
function errorMessage(err, fallback) {
|
|
28
|
+
return err instanceof Error && err.message ? err.message : fallback;
|
|
29
|
+
}
|
|
30
|
+
/** The editable part of a schedule response, as the form's draft. */
|
|
31
|
+
function toDraft(schedule) {
|
|
32
|
+
return {
|
|
33
|
+
enabled: schedule.enabled,
|
|
34
|
+
frequency: schedule.frequency,
|
|
35
|
+
intervalHours: schedule.intervalHours,
|
|
36
|
+
timeOfDay: schedule.timeOfDay,
|
|
37
|
+
dayOfWeek: schedule.dayOfWeek,
|
|
38
|
+
dayOfMonth: schedule.dayOfMonth,
|
|
39
|
+
// A schedule that was never saved starts in the admin's own time zone.
|
|
40
|
+
timezone: schedule.updatedAt === null ? getBrowserTimeZone() : schedule.timezone,
|
|
41
|
+
keepCount: schedule.keepCount,
|
|
42
|
+
// Older API responses may lack the newer flags; they take the defaults.
|
|
43
|
+
...rawBackupContentFlags(scheduleContentSelection(schedule)),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function BackupScheduleCard({ schedule, canWrite, onSaved }) {
|
|
47
|
+
const [draft, setDraft] = useState(() => toDraft(schedule));
|
|
48
|
+
const [editingPassword, setEditingPassword] = useState(!schedule.passwordConfigured);
|
|
49
|
+
const [password, setPassword] = useState('');
|
|
50
|
+
const [confirm, setConfirm] = useState('');
|
|
51
|
+
const [showPassword, setShowPassword] = useState(false);
|
|
52
|
+
const [submitted, setSubmitted] = useState(false);
|
|
53
|
+
const [saving, setSaving] = useState(false);
|
|
54
|
+
const [error, setError] = useState(null);
|
|
55
|
+
const [success, setSuccess] = useState(null);
|
|
56
|
+
const timeZones = useMemo(() => getTimeZoneOptions(draft.timezone), [draft.timezone]);
|
|
57
|
+
const readOnly = !canWrite || saving;
|
|
58
|
+
const update = (key, value) => {
|
|
59
|
+
setDraft((d) => ({ ...d, [key]: value }));
|
|
60
|
+
setSuccess(null);
|
|
61
|
+
};
|
|
62
|
+
const changingPassword = editingPassword && (password.length > 0 || confirm.length > 0);
|
|
63
|
+
const passwordValidation = changingPassword ? validateBackupPassword(password, confirm) : null;
|
|
64
|
+
const passwordError = submitted && passwordValidation && passwordValidation !== 'Passwords do not match'
|
|
65
|
+
? passwordValidation
|
|
66
|
+
: null;
|
|
67
|
+
const mismatch = changingPassword && password !== confirm && (confirm.length > 0 || submitted);
|
|
68
|
+
const confirmError = mismatch && !passwordError ? 'Passwords do not match' : null;
|
|
69
|
+
const showWeakWarning = editingPassword && shouldWarnBackupPassword(password);
|
|
70
|
+
const enableBlockedByStorage = !schedule.storageConfigured && !draft.enabled;
|
|
71
|
+
const resetPasswordFields = (stored) => {
|
|
72
|
+
setPassword('');
|
|
73
|
+
setConfirm('');
|
|
74
|
+
setShowPassword(false);
|
|
75
|
+
setEditingPassword(!stored);
|
|
76
|
+
};
|
|
77
|
+
const handleSuggest = () => {
|
|
78
|
+
const suggestion = suggestBackupPassword();
|
|
79
|
+
setPassword(suggestion);
|
|
80
|
+
setConfirm(suggestion);
|
|
81
|
+
setShowPassword(true);
|
|
82
|
+
setSuccess(null);
|
|
83
|
+
};
|
|
84
|
+
const handleSubmit = async (e) => {
|
|
85
|
+
e.preventDefault();
|
|
86
|
+
setSubmitted(true);
|
|
87
|
+
setError(null);
|
|
88
|
+
setSuccess(null);
|
|
89
|
+
const fields = normalizeScheduleFields(draft);
|
|
90
|
+
const fieldError = validateScheduleFields(fields);
|
|
91
|
+
if (fieldError) {
|
|
92
|
+
setError(fieldError);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
if (passwordValidation)
|
|
96
|
+
return;
|
|
97
|
+
if (fields.enabled && !schedule.passwordConfigured && !changingPassword) {
|
|
98
|
+
setError('Set a backup password before turning scheduled backups on.');
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (fields.enabled && !schedule.storageConfigured) {
|
|
102
|
+
setError('Object storage is not configured, so scheduled backups cannot be turned on.');
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const body = { ...fields };
|
|
106
|
+
if (changingPassword)
|
|
107
|
+
body.password = password;
|
|
108
|
+
setSaving(true);
|
|
109
|
+
try {
|
|
110
|
+
const saved = await updateBackupSchedule(body);
|
|
111
|
+
setDraft(toDraft(saved));
|
|
112
|
+
resetPasswordFields(saved.passwordConfigured);
|
|
113
|
+
setSubmitted(false);
|
|
114
|
+
setSuccess(BACKUP_SCHEDULE_SAVED_MESSAGE);
|
|
115
|
+
onSaved(saved);
|
|
116
|
+
}
|
|
117
|
+
catch (err) {
|
|
118
|
+
setError(errorMessage(err, 'Failed to save the backup schedule'));
|
|
119
|
+
}
|
|
120
|
+
finally {
|
|
121
|
+
setSaving(false);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
const visibilityToggle = (_jsx(InputAdornment, { position: "end", children: _jsx(IconButton, { "aria-label": showPassword ? 'Hide password' : 'Show password', onClick: () => setShowPassword((v) => !v), edge: "end", children: showPassword ? _jsx(VisibilityOff, {}) : _jsx(Visibility, {}) }) }));
|
|
125
|
+
const nextRun = formatDateTime(schedule.nextRunAt);
|
|
126
|
+
const lastRun = formatDateTime(schedule.lastRunAt);
|
|
127
|
+
const passwordSetOn = schedule.passwordUpdatedAt
|
|
128
|
+
? new Date(schedule.passwordUpdatedAt).toLocaleDateString()
|
|
129
|
+
: null;
|
|
130
|
+
return (_jsx(Card, { variant: "outlined", children: _jsxs(CardContent, { children: [_jsx(Typography, { variant: "h6", gutterBottom: true, children: "Backup schedule" }), _jsx(Typography, { variant: "body2", sx: {
|
|
131
|
+
color: "text.secondary",
|
|
132
|
+
marginBottom: "16px"
|
|
133
|
+
}, children: "Back up every user's vault data into object storage as one password-protected (AES-256) zip per run. Open a backup with 7-Zip on Windows or Keka on Mac." }), !schedule.storageConfigured && (_jsxs(Alert, { severity: "warning", sx: { mb: 2 }, children: ["Object storage is not configured. Scheduled backups cannot run until it is.", ' ', _jsx(StorageSettingsLink, {})] })), _jsx(Box, { component: "form", noValidate: true, onSubmit: handleSubmit, children: _jsxs(Stack, { spacing: 2, children: [_jsxs(Box, { children: [_jsx(FormControlLabel, { control: _jsx(Switch, { checked: draft.enabled, onChange: (e) => update('enabled', e.target.checked), disabled: readOnly || enableBlockedByStorage }), label: "Scheduled backups enabled" }), _jsx(Typography, { variant: "body2", "data-testid": "backup-summary", sx: {
|
|
134
|
+
color: "text.secondary"
|
|
135
|
+
}, children: describeBackupSchedule(normalizeScheduleFields(draft)) }), _jsxs(Typography, { variant: "body2", sx: {
|
|
136
|
+
color: "text.secondary"
|
|
137
|
+
}, children: [schedule.enabled && nextRun ? `Next run: ${nextRun}` : 'Next run: not scheduled', lastRun ? ` · Last run: ${lastRun}` : ''] })] }), _jsxs(Box, { sx: {
|
|
138
|
+
display: 'grid',
|
|
139
|
+
gridTemplateColumns: { xs: '1fr', sm: '1fr 1fr' },
|
|
140
|
+
gap: 2,
|
|
141
|
+
}, children: [_jsxs(FormControl, { fullWidth: true, disabled: readOnly, children: [_jsx(InputLabel, { id: "backup-frequency-label", children: "Frequency" }), _jsx(Select, { labelId: "backup-frequency-label", label: "Frequency", value: draft.frequency, onChange: (e) => update('frequency', e.target.value), children: FREQUENCIES.map((f) => (_jsx(MenuItem, { value: f, children: BACKUP_FREQUENCY_LABELS[f] }, f))) })] }), draft.frequency === 'hourly' ? (_jsxs(FormControl, { fullWidth: true, disabled: readOnly, children: [_jsx(InputLabel, { id: "backup-interval-label", children: "Every" }), _jsx(Select, { labelId: "backup-interval-label", label: "Every", value: draft.intervalHours ?? 1, onChange: (e) => update('intervalHours', Number(e.target.value)), children: BACKUP_INTERVAL_HOURS.map((h) => (_jsx(MenuItem, { value: h, children: h === 1 ? '1 hour' : `${h} hours` }, h))) }), _jsx(FormHelperText, { children: BACKUP_HOURLY_HELPER_TEXT })] })) : (_jsx(TextField, { label: "Time", type: "time", value: draft.timeOfDay, onChange: (e) => update('timeOfDay', e.target.value), disabled: readOnly, fullWidth: true, slotProps: {
|
|
142
|
+
htmlInput: { step: 60 },
|
|
143
|
+
inputLabel: { shrink: true }
|
|
144
|
+
} })), draft.frequency === 'weekly' && (_jsxs(FormControl, { fullWidth: true, disabled: readOnly, children: [_jsx(InputLabel, { id: "backup-weekday-label", children: "Day of the week" }), _jsx(Select, { labelId: "backup-weekday-label", label: "Day of the week", value: draft.dayOfWeek ?? 1, onChange: (e) => update('dayOfWeek', Number(e.target.value)), children: WEEKDAY_NAMES.map((name, i) => (_jsx(MenuItem, { value: i, children: name }, name))) })] })), draft.frequency === 'monthly' && (_jsxs(FormControl, { fullWidth: true, disabled: readOnly, children: [_jsx(InputLabel, { id: "backup-monthday-label", children: "Day of the month" }), _jsx(Select, { labelId: "backup-monthday-label", label: "Day of the month", value: draft.dayOfMonth ?? 1, onChange: (e) => update('dayOfMonth', Number(e.target.value)), children: DAYS_OF_MONTH.map((d) => (_jsx(MenuItem, { value: d, children: d }, d))) })] })), _jsx(Autocomplete, { options: timeZones, value: draft.timezone, onChange: (_, value) => value && update('timezone', value), disableClearable: true, disabled: readOnly, renderInput: (params) => _jsx(TextField, { ...params, label: "Time zone" }) }), _jsx(TextField, { label: "Keep the last N backups", type: "number", value: Number.isNaN(draft.keepCount) ? '' : draft.keepCount, onChange: (e) => update('keepCount', Number.parseInt(e.target.value, 10)), disabled: readOnly, fullWidth: true, helperText: `Older backups are deleted after a successful run (${BACKUP_KEEP_MIN}-${BACKUP_KEEP_MAX})`, slotProps: {
|
|
145
|
+
htmlInput: { min: BACKUP_KEEP_MIN, max: BACKUP_KEEP_MAX, step: 1 }
|
|
146
|
+
} })] }), _jsx(BackupContentsGroup, { value: scheduleContentSelection(draft), onChange: (next) => {
|
|
147
|
+
setDraft((d) => withScheduleContents(d, next));
|
|
148
|
+
setSuccess(null);
|
|
149
|
+
}, disabled: readOnly, showSystem: true, summaryTestId: "backup-schedule-contents-summary" }), _jsx(Divider, {}), _jsxs(Box, { children: [_jsx(Typography, { variant: "subtitle1", gutterBottom: true, children: "Backup password" }), schedule.passwordConfigured ? (_jsx(Typography, { variant: "body2", gutterBottom: true, sx: {
|
|
150
|
+
color: "text.secondary"
|
|
151
|
+
}, children: passwordSetOn ? `Password set on ${passwordSetOn}` : 'Password set' })) : (_jsx(Typography, { variant: "body2", gutterBottom: true, sx: {
|
|
152
|
+
color: "text.secondary"
|
|
153
|
+
}, children: "No password set yet. Backups cannot run without one." })), _jsx(Alert, { severity: "warning", sx: { my: 1 }, children: BACKUP_PASSWORD_LOSS_WARNING }), !editingPassword ? (canWrite && (_jsx(Button, { variant: "outlined", size: "small", onClick: () => setEditingPassword(true), disabled: saving, children: "Change password" }))) : (_jsxs(_Fragment, { children: [_jsxs(Box, { sx: {
|
|
154
|
+
display: 'flex',
|
|
155
|
+
flexDirection: { xs: 'column', sm: 'row' },
|
|
156
|
+
gap: 2,
|
|
157
|
+
mt: 1,
|
|
158
|
+
mb: 1,
|
|
159
|
+
}, children: [_jsx(TextField, { label: schedule.passwordConfigured ? 'New password' : 'Password', type: showPassword ? 'text' : 'password', value: password, onChange: (e) => {
|
|
160
|
+
setPassword(e.target.value);
|
|
161
|
+
setSuccess(null);
|
|
162
|
+
}, error: !!passwordError, helperText: passwordError ?? 'At least 6 characters', autoComplete: "new-password", fullWidth: true, disabled: readOnly, slotProps: {
|
|
163
|
+
input: { endAdornment: visibilityToggle },
|
|
164
|
+
htmlInput: { maxLength: BACKUP_PASSWORD_MAX_LENGTH }
|
|
165
|
+
} }), _jsx(TextField, { label: "Confirm password", type: showPassword ? 'text' : 'password', value: confirm, onChange: (e) => setConfirm(e.target.value), error: !!confirmError, helperText: confirmError ?? ' ', autoComplete: "new-password", fullWidth: true, disabled: readOnly, slotProps: {
|
|
166
|
+
htmlInput: { maxLength: BACKUP_PASSWORD_MAX_LENGTH }
|
|
167
|
+
} })] }), _jsxs(Stack, { direction: "row", spacing: 1, useFlexGap: true, sx: {
|
|
168
|
+
flexWrap: "wrap"
|
|
169
|
+
}, children: [_jsx(Button, { variant: "text", size: "small", startIcon: _jsx(AutoAwesomeIcon, {}), onClick: handleSuggest, disabled: readOnly, children: "Suggest one for me" }), schedule.passwordConfigured && (_jsx(Button, { variant: "text", size: "small", onClick: () => resetPasswordFields(true), disabled: saving, children: "Keep current password" }))] }), showWeakWarning && (_jsx(Alert, { severity: "warning", sx: { mt: 1 }, children: BACKUP_PASSWORD_WARNING }))] }))] }), error && (_jsx(Alert, { severity: "error", onClose: () => setError(null), children: error })), success && (_jsx(Alert, { severity: "success", onClose: () => setSuccess(null), children: success })), canWrite && (_jsx(Box, { children: _jsx(Button, { type: "submit", variant: "contained", startIcon: saving ? _jsx(CircularProgress, { size: 18, color: "inherit" }) : _jsx(SaveIcon, {}), disabled: saving, "aria-busy": saving, children: saving ? 'Saving…' : 'Save schedule' }) }))] }) })] }) }));
|
|
170
|
+
}
|
|
171
|
+
// =============================================================================
|
|
172
|
+
// Tab root
|
|
173
|
+
// =============================================================================
|
|
174
|
+
/**
|
|
175
|
+
* Backups card of the Console (/admin/settings/backups): the scheduled-backup configuration,
|
|
176
|
+
* "Run backup now (save to storage)", "Download a backup now" (streamed,
|
|
177
|
+
* nothing stored) and the run history (system backups only; users' saved
|
|
178
|
+
* backups are never listed here). Reading needs system_settings:read
|
|
179
|
+
* (enforced by the page); every change, run, download and delete needs
|
|
180
|
+
* system_settings:write, matching the API.
|
|
181
|
+
*/
|
|
182
|
+
export function ScheduledBackups() {
|
|
183
|
+
const { hasPermission } = usePermissions();
|
|
184
|
+
const canWrite = hasPermission('system_settings:write');
|
|
185
|
+
const [schedule, setSchedule] = useState(null);
|
|
186
|
+
const [scheduleLoading, setScheduleLoading] = useState(true);
|
|
187
|
+
const [scheduleError, setScheduleError] = useState(null);
|
|
188
|
+
/** Bumped to remount the form with a freshly loaded schedule. */
|
|
189
|
+
const [formKey, setFormKey] = useState(0);
|
|
190
|
+
const [starting, setStarting] = useState(false);
|
|
191
|
+
const [actionError, setActionError] = useState(null);
|
|
192
|
+
const [actionInfo, setActionInfo] = useState(null);
|
|
193
|
+
const [busyId, setBusyId] = useState(null);
|
|
194
|
+
const [deleteTarget, setDeleteTarget] = useState(null);
|
|
195
|
+
const [deleting, setDeleting] = useState(false);
|
|
196
|
+
const [downloadOpen, setDownloadOpen] = useState(false);
|
|
197
|
+
/** Bumped each time the download dialog opens so it starts clean. */
|
|
198
|
+
const [downloadKey, setDownloadKey] = useState(0);
|
|
199
|
+
const loadSchedule = useCallback(async (resetForm) => {
|
|
200
|
+
try {
|
|
201
|
+
const next = await getBackupSchedule();
|
|
202
|
+
setSchedule(next);
|
|
203
|
+
setScheduleError(null);
|
|
204
|
+
if (resetForm)
|
|
205
|
+
setFormKey((k) => k + 1);
|
|
206
|
+
}
|
|
207
|
+
catch (err) {
|
|
208
|
+
setScheduleError(errorMessage(err, 'Failed to load the backup schedule'));
|
|
209
|
+
}
|
|
210
|
+
finally {
|
|
211
|
+
setScheduleLoading(false);
|
|
212
|
+
}
|
|
213
|
+
}, []);
|
|
214
|
+
useEffect(() => {
|
|
215
|
+
void loadSchedule(true);
|
|
216
|
+
}, [loadSchedule]);
|
|
217
|
+
// Polls while a run is in progress; when it settles, refresh the schedule's
|
|
218
|
+
// last/next run times without discarding unsaved form edits.
|
|
219
|
+
const history = useBackupRunHistory(getBackupRuns, {
|
|
220
|
+
onRunSettled: () => void loadSchedule(false),
|
|
221
|
+
});
|
|
222
|
+
const { hasRunning, reload: loadRuns } = history;
|
|
223
|
+
const handleRunNow = async () => {
|
|
224
|
+
setStarting(true);
|
|
225
|
+
setActionError(null);
|
|
226
|
+
setActionInfo(null);
|
|
227
|
+
try {
|
|
228
|
+
await runBackupNow();
|
|
229
|
+
setActionInfo('Backup started.');
|
|
230
|
+
await history.showNewest();
|
|
231
|
+
}
|
|
232
|
+
catch (err) {
|
|
233
|
+
setActionError(errorMessage(err, 'Failed to start the backup'));
|
|
234
|
+
await loadRuns();
|
|
235
|
+
}
|
|
236
|
+
finally {
|
|
237
|
+
setStarting(false);
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
const handleDownload = async (run) => {
|
|
241
|
+
setBusyId(run.id);
|
|
242
|
+
setActionError(null);
|
|
243
|
+
try {
|
|
244
|
+
const link = await getBackupDownloadUrl(run.id);
|
|
245
|
+
startUrlDownload(link.url, link.fileName);
|
|
246
|
+
}
|
|
247
|
+
catch (err) {
|
|
248
|
+
setActionError(errorMessage(err, 'Failed to get the download link'));
|
|
249
|
+
}
|
|
250
|
+
finally {
|
|
251
|
+
setBusyId(null);
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
const handleConfirmDelete = async () => {
|
|
255
|
+
if (!deleteTarget)
|
|
256
|
+
return;
|
|
257
|
+
setDeleting(true);
|
|
258
|
+
setActionError(null);
|
|
259
|
+
try {
|
|
260
|
+
await deleteBackupRun(deleteTarget.id);
|
|
261
|
+
setActionInfo('Backup deleted.');
|
|
262
|
+
setDeleteTarget(null);
|
|
263
|
+
await loadRuns();
|
|
264
|
+
}
|
|
265
|
+
catch (err) {
|
|
266
|
+
setActionError(errorMessage(err, 'Failed to delete the backup'));
|
|
267
|
+
setDeleteTarget(null);
|
|
268
|
+
}
|
|
269
|
+
finally {
|
|
270
|
+
setDeleting(false);
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
if (scheduleLoading) {
|
|
274
|
+
return (_jsx(Box, { sx: { display: 'flex', justifyContent: 'center', p: 4 }, children: _jsx(CircularProgress, {}) }));
|
|
275
|
+
}
|
|
276
|
+
if (!schedule) {
|
|
277
|
+
return (_jsx(Alert, { severity: "error", action: _jsx(Button, { color: "inherit", size: "small", onClick: () => void loadSchedule(true), children: "Retry" }), children: scheduleError ?? 'Failed to load the backup schedule' }));
|
|
278
|
+
}
|
|
279
|
+
const runDisabledReason = !schedule.storageConfigured
|
|
280
|
+
? 'Object storage is not configured.'
|
|
281
|
+
: !schedule.passwordConfigured
|
|
282
|
+
? 'Save a backup password first.'
|
|
283
|
+
: null;
|
|
284
|
+
return (_jsxs(Stack, { spacing: 3, children: [!canWrite && (_jsx(Alert, { severity: "info", children: "You can view backups but not change the schedule, run, download or delete them." })), _jsx(BackupScheduleCard, { schedule: schedule, canWrite: canWrite, onSaved: setSchedule }, formKey), _jsx(Card, { variant: "outlined", children: _jsxs(CardContent, { children: [_jsxs(Box, { sx: {
|
|
285
|
+
display: 'flex',
|
|
286
|
+
flexDirection: { xs: 'column', sm: 'row' },
|
|
287
|
+
alignItems: { xs: 'stretch', sm: 'center' },
|
|
288
|
+
justifyContent: 'space-between',
|
|
289
|
+
gap: 2,
|
|
290
|
+
mb: 2,
|
|
291
|
+
}, children: [_jsx(Typography, { variant: "h6", children: "Backup history" }), _jsxs(Stack, { direction: "row", spacing: 1, useFlexGap: true, sx: {
|
|
292
|
+
justifyContent: "flex-end",
|
|
293
|
+
flexWrap: "wrap"
|
|
294
|
+
}, children: [_jsx(Tooltip, { title: "Refresh", children: _jsx(IconButton, { "aria-label": "Refresh history", onClick: () => void loadRuns(), children: _jsx(RefreshIcon, {}) }) }), canWrite && (_jsx(Button, { variant: "outlined", startIcon: _jsx(DownloadIcon, {}), onClick: () => {
|
|
295
|
+
setDownloadKey((k) => k + 1);
|
|
296
|
+
setDownloadOpen(true);
|
|
297
|
+
}, children: "Download a backup now" })), canWrite && (_jsx(Button, { variant: "contained", startIcon: starting || hasRunning ? (_jsx(CircularProgress, { size: 18, color: "inherit" })) : (_jsx(PlayArrowIcon, {})), onClick: () => void handleRunNow(), disabled: starting || hasRunning || runDisabledReason !== null, "aria-busy": starting || hasRunning, children: hasRunning ? 'Backup running…' : 'Run backup now (save to storage)' }))] })] }), canWrite && runDisabledReason && (_jsx(Typography, { variant: "body2", sx: {
|
|
298
|
+
color: "text.secondary",
|
|
299
|
+
mb: 2
|
|
300
|
+
}, children: runDisabledReason })), actionError && (_jsx(Alert, { severity: "error", sx: { mb: 2 }, onClose: () => setActionError(null), children: actionError })), actionInfo && (_jsx(Alert, { severity: "success", sx: { mb: 2 }, onClose: () => setActionInfo(null), children: actionInfo })), history.error && (_jsx(Alert, { severity: "error", sx: { mb: 2 }, children: history.error })), _jsx(BackupRunsTable, { runs: history.runs, total: history.total, page: history.page, rowsPerPage: history.rowsPerPage, loading: history.loading, showActions: canWrite, busyId: busyId, onPageChange: history.setPage, onRowsPerPageChange: history.setRowsPerPage, onDownload: (run) => void handleDownload(run), onDelete: setDeleteTarget, ariaLabel: "Backup history", emptyText: "No backups yet.", showAdminColumns: true })] }) }), _jsx(DeleteBackupDialog, { target: deleteTarget, deleting: deleting, onCancel: () => setDeleteTarget(null), onConfirm: () => void handleConfirmDelete() }), canWrite && (_jsx(AdminBackupDownloadDialog, { open: downloadOpen, onClose: () => setDownloadOpen(false), onDownloaded: (message) => {
|
|
301
|
+
setActionError(null);
|
|
302
|
+
setActionInfo(message);
|
|
303
|
+
}, passwordConfigured: schedule.passwordConfigured, initialContents: scheduleContentSelection(schedule) }, downloadKey))] }));
|
|
304
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './components/AdminBackupDownloadDialog.js';
|
|
2
|
+
export * from './components/BackupContentsGroup.js';
|
|
3
|
+
export * from './components/BackupPasswordFields.js';
|
|
4
|
+
export * from './components/BackupRunsTable.js';
|
|
5
|
+
export * from './components/DataBackup.js';
|
|
6
|
+
export * from './components/ScheduledBackups.js';
|
|
7
|
+
export { default as BackupSettingsPage } from './pages/BackupSettingsPage.js';
|
|
8
|
+
export { default as MyBackupsPage } from './pages/MyBackupsPage.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Backups: the scheduled (admin) and personal backup components and the two settings pages.
|
|
2
|
+
export * from './components/AdminBackupDownloadDialog.js';
|
|
3
|
+
export * from './components/BackupContentsGroup.js';
|
|
4
|
+
export * from './components/BackupPasswordFields.js';
|
|
5
|
+
export * from './components/BackupRunsTable.js';
|
|
6
|
+
export * from './components/DataBackup.js';
|
|
7
|
+
export * from './components/ScheduledBackups.js';
|
|
8
|
+
export { default as BackupSettingsPage } from './pages/BackupSettingsPage.js';
|
|
9
|
+
export { default as MyBackupsPage } from './pages/MyBackupsPage.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `Backups` card of the Console (`/admin/settings/backups`, E10.3 #94):
|
|
3
|
+
* the old "Backups" tab, unchanged. `ScheduledBackups` loads and saves its own
|
|
4
|
+
* data (the schedule and the run history live in `/api/admin/backups`, not in
|
|
5
|
+
* the system settings object) and reads write access itself; the page only
|
|
6
|
+
* gates the read on `system_settings:read`.
|
|
7
|
+
*/
|
|
8
|
+
export default function BackupSettingsPage(): import("react").JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Navigate } from 'react-router-dom';
|
|
3
|
+
import { usePermissions } from '@marinoscar/platform-web/identity/headless';
|
|
4
|
+
import { SettingsPageFrame } from '../../../core/ui/SettingsPageFrame.js';
|
|
5
|
+
import { ScheduledBackups } from '../components/ScheduledBackups.js';
|
|
6
|
+
/**
|
|
7
|
+
* The `Backups` card of the Console (`/admin/settings/backups`, E10.3 #94):
|
|
8
|
+
* the old "Backups" tab, unchanged. `ScheduledBackups` loads and saves its own
|
|
9
|
+
* data (the schedule and the run history live in `/api/admin/backups`, not in
|
|
10
|
+
* the system settings object) and reads write access itself; the page only
|
|
11
|
+
* gates the read on `system_settings:read`.
|
|
12
|
+
*/
|
|
13
|
+
export default function BackupSettingsPage() {
|
|
14
|
+
const { hasPermission } = usePermissions();
|
|
15
|
+
if (!hasPermission('system_settings:read')) {
|
|
16
|
+
return _jsx(Navigate, { to: "/", replace: true });
|
|
17
|
+
}
|
|
18
|
+
return (_jsx(SettingsPageFrame, { title: "Backups", description: "Scheduled encrypted backups of the whole vault, kept in object storage", maxWidth: "lg", children: _jsx(ScheduledBackups, {}) }));
|
|
19
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `My backups` card of `/settings` (`/settings/backups`, E10.3 #94): the
|
|
3
|
+
* "Back up my data" section (download, save to storage, the saved list),
|
|
4
|
+
* unchanged. `my-backups.controller.ts` and `POST /api/secrets/export` need
|
|
5
|
+
* `secrets:read` (never `secrets:read_any` alone). The password stays in
|
|
6
|
+
* component state only.
|
|
7
|
+
*/
|
|
8
|
+
export default function MyBackupsPage(): import("react").JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Navigate } from 'react-router-dom';
|
|
3
|
+
import { usePermissions } from '@marinoscar/platform-web/identity/headless';
|
|
4
|
+
import { DataBackup } from '../components/DataBackup.js';
|
|
5
|
+
import { SettingsPageFrame } from '../../../core/ui/SettingsPageFrame.js';
|
|
6
|
+
/**
|
|
7
|
+
* The `My backups` card of `/settings` (`/settings/backups`, E10.3 #94): the
|
|
8
|
+
* "Back up my data" section (download, save to storage, the saved list),
|
|
9
|
+
* unchanged. `my-backups.controller.ts` and `POST /api/secrets/export` need
|
|
10
|
+
* `secrets:read` (never `secrets:read_any` alone). The password stays in
|
|
11
|
+
* component state only.
|
|
12
|
+
*/
|
|
13
|
+
export default function MyBackupsPage() {
|
|
14
|
+
const { hasPermission } = usePermissions();
|
|
15
|
+
if (!hasPermission('secrets:read')) {
|
|
16
|
+
return _jsx(Navigate, { to: "/settings", replace: true });
|
|
17
|
+
}
|
|
18
|
+
return (_jsx(SettingsPageFrame, { title: "My backups", description: "Encrypted backups of the secrets you own", maxWidth: "lg", children: _jsx(DataBackup, {}) }));
|
|
19
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
export interface BrandLockupProps {
|
|
3
|
+
/** Side of the mark in CSS pixels. Default 32. */
|
|
4
|
+
size?: number;
|
|
5
|
+
/** Draw the product name beside the mark. Default true. */
|
|
6
|
+
showName?: boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The Vault mark (generated from `media/app_logo.png`, tinted to the teal
|
|
10
|
+
* primary; 128px source, so it stays crisp at 32px on a 4x screen) and the
|
|
11
|
+
* product name. A plain inline row: the app bar wraps it in its home button.
|
|
12
|
+
* With the name shown the mark is decorative, so the name is announced once.
|
|
13
|
+
*/
|
|
14
|
+
export declare function BrandLockup({ size, showName }?: BrandLockupProps): ReactElement;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import Box from '@mui/material/Box';
|
|
3
|
+
import markUrl from './assets/vault-mark.png';
|
|
4
|
+
import { PRODUCT_NAME } from './tokens.js';
|
|
5
|
+
/**
|
|
6
|
+
* The Vault mark (generated from `media/app_logo.png`, tinted to the teal
|
|
7
|
+
* primary; 128px source, so it stays crisp at 32px on a 4x screen) and the
|
|
8
|
+
* product name. A plain inline row: the app bar wraps it in its home button.
|
|
9
|
+
* With the name shown the mark is decorative, so the name is announced once.
|
|
10
|
+
*/
|
|
11
|
+
export function BrandLockup({ size = 32, showName = true } = {}) {
|
|
12
|
+
return (_jsxs(Box, { component: "span", sx: { display: 'inline-flex', alignItems: 'center', gap: 1.25 }, children: [_jsx(Box, { component: "img", src: markUrl, alt: showName ? '' : PRODUCT_NAME, width: size, height: size, sx: { display: 'block', borderRadius: '22%', flexShrink: 0 } }), showName && (_jsx(Box, { component: "span", sx: { fontWeight: 700, letterSpacing: '-0.01em', color: 'text.primary' }, children: PRODUCT_NAME }))] }));
|
|
13
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WCAG 2.x contrast (relative luminance), used to prove the brand tokens
|
|
3
|
+
* (`theme/tokens.ts`) meet the ratios recorded in docs/specs/ux-refresh.md §5.
|
|
4
|
+
*/
|
|
5
|
+
/** Relative luminance of a `#RRGGBB` colour. */
|
|
6
|
+
export declare function relativeLuminance(hex: string): number;
|
|
7
|
+
/** The contrast ratio of two `#RRGGBB` colours, from 1 to 21. */
|
|
8
|
+
export declare function contrastRatio(a: string, b: string): number;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WCAG 2.x contrast (relative luminance), used to prove the brand tokens
|
|
3
|
+
* (`theme/tokens.ts`) meet the ratios recorded in docs/specs/ux-refresh.md §5.
|
|
4
|
+
*/
|
|
5
|
+
function channel(value) {
|
|
6
|
+
const c = value / 255;
|
|
7
|
+
return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
|
|
8
|
+
}
|
|
9
|
+
/** Relative luminance of a `#RRGGBB` colour. */
|
|
10
|
+
export function relativeLuminance(hex) {
|
|
11
|
+
const match = /^#([0-9a-f]{6})$/i.exec(hex);
|
|
12
|
+
if (!match)
|
|
13
|
+
throw new Error(`relativeLuminance: "${hex}" is not #RRGGBB`);
|
|
14
|
+
const n = parseInt(match[1], 16);
|
|
15
|
+
return 0.2126 * channel((n >> 16) & 0xff) + 0.7152 * channel((n >> 8) & 0xff) + 0.0722 * channel(n & 0xff);
|
|
16
|
+
}
|
|
17
|
+
/** The contrast ratio of two `#RRGGBB` colours, from 1 to 21. */
|
|
18
|
+
export function contrastRatio(a, b) {
|
|
19
|
+
const [hi, lo] = [relativeLuminance(a), relativeLuminance(b)].sort((x, y) => y - x);
|
|
20
|
+
return (hi + 0.05) / (lo + 0.05);
|
|
21
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './tokens.js';
|
|
2
|
+
export { VAULT_THEMES, vaultDarkTheme, vaultLightTheme } from './theme.js';
|
|
3
|
+
export type { ThemeMode } from './theme.js';
|
|
4
|
+
export { contrastRatio, relativeLuminance } from './contrast.js';
|
|
5
|
+
export { VAULT_MARK_URL } from './mark.js';
|
|
6
|
+
export { BrandLockup } from './BrandLockup.js';
|
|
7
|
+
export type { BrandLockupProps } from './BrandLockup.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// The Vault brand: the token map both themes are built from, the two themes
|
|
2
|
+
// `ShellRoot` takes, the contrast helpers the token tests use, the mark and the
|
|
3
|
+
// lockup. Colours live only in `tokens.ts`.
|
|
4
|
+
export * from './tokens.js';
|
|
5
|
+
export { VAULT_THEMES, vaultDarkTheme, vaultLightTheme } from './theme.js';
|
|
6
|
+
export { contrastRatio, relativeLuminance } from './contrast.js';
|
|
7
|
+
export { VAULT_MARK_URL } from './mark.js';
|
|
8
|
+
export { BrandLockup } from './BrandLockup.js';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import vaultMark from './assets/vault-mark.png';
|
|
2
|
+
/**
|
|
3
|
+
* The Vault mark (the padlock tile), as the URL the bundler gives the image.
|
|
4
|
+
* The host's login page and any other surface that needs the bare mark use it;
|
|
5
|
+
* `BrandLockup` pairs it with the wordmark.
|
|
6
|
+
*/
|
|
7
|
+
export const VAULT_MARK_URL = vaultMark;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The two Vault themes (E10.1, issue #92): the platform shell's base
|
|
3
|
+
* (`createShellTheme`: Inter, 600-weight headings, 8px radius, no-uppercase
|
|
4
|
+
* buttons, flat AppBar) with the Vault palette from `tokens.ts` and a few
|
|
5
|
+
* component overrides that read the tokens instead of the shell's neutral
|
|
6
|
+
* greys.
|
|
7
|
+
*
|
|
8
|
+
* The viewer's light / dark / system choice is held by the shell's `ShellRoot`
|
|
9
|
+
* (App.tsx), persisted in this browser and synced from the `theme` user
|
|
10
|
+
* setting by `useUserSettings`. This file only builds the two themes, once.
|
|
11
|
+
*/
|
|
12
|
+
import type { Theme } from '@mui/material/styles';
|
|
13
|
+
export { BRAND_TOKENS, BRAND_THEME_COLOR, PRODUCT_NAME } from './tokens.js';
|
|
14
|
+
export type { BrandMode, BrandModeTokens } from './tokens.js';
|
|
15
|
+
/** The modes the Appearance setting offers. */
|
|
16
|
+
export type ThemeMode = 'light' | 'dark' | 'system';
|
|
17
|
+
/** The Vault light theme, built once. */
|
|
18
|
+
export declare const vaultLightTheme: Theme;
|
|
19
|
+
/** The Vault dark theme, built once. */
|
|
20
|
+
export declare const vaultDarkTheme: Theme;
|
|
21
|
+
/** The themes `ShellRoot` takes. */
|
|
22
|
+
export declare const VAULT_THEMES: {
|
|
23
|
+
readonly light: Theme;
|
|
24
|
+
readonly dark: Theme;
|
|
25
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The two Vault themes (E10.1, issue #92): the platform shell's base
|
|
3
|
+
* (`createShellTheme`: Inter, 600-weight headings, 8px radius, no-uppercase
|
|
4
|
+
* buttons, flat AppBar) with the Vault palette from `tokens.ts` and a few
|
|
5
|
+
* component overrides that read the tokens instead of the shell's neutral
|
|
6
|
+
* greys.
|
|
7
|
+
*
|
|
8
|
+
* The viewer's light / dark / system choice is held by the shell's `ShellRoot`
|
|
9
|
+
* (App.tsx), persisted in this browser and synced from the `theme` user
|
|
10
|
+
* setting by `useUserSettings`. This file only builds the two themes, once.
|
|
11
|
+
*/
|
|
12
|
+
import { alpha, createTheme } from '@mui/material/styles';
|
|
13
|
+
import { withTelemetryTokens } from '@marinoscar/platform-web/telemetry/headless';
|
|
14
|
+
import { createShellTheme } from '@marinoscar/platform-web/shell/headless';
|
|
15
|
+
import { BRAND_TOKENS } from './tokens.js';
|
|
16
|
+
export { BRAND_TOKENS, BRAND_THEME_COLOR, PRODUCT_NAME } from './tokens.js';
|
|
17
|
+
function createVaultTheme(mode) {
|
|
18
|
+
const t = BRAND_TOKENS[mode];
|
|
19
|
+
// The telemetry pages read `palette.status.*` and `palette.chart.series` (E9.2, #90); the tokens the
|
|
20
|
+
// theme does not set are filled from its own palette.
|
|
21
|
+
return withTelemetryTokens(createShellTheme(mode, {
|
|
22
|
+
palette: {
|
|
23
|
+
primary: { main: t.primary, light: t.primaryLight, dark: t.primaryDark, contrastText: t.onPrimary },
|
|
24
|
+
secondary: { main: t.accent, contrastText: t.onAccent },
|
|
25
|
+
error: { main: t.error },
|
|
26
|
+
background: { default: t.background, paper: t.paper },
|
|
27
|
+
text: { primary: t.textPrimary, secondary: t.textSecondary },
|
|
28
|
+
divider: t.divider,
|
|
29
|
+
},
|
|
30
|
+
extend: (base) => createTheme(base, {
|
|
31
|
+
components: {
|
|
32
|
+
MuiCssBaseline: {
|
|
33
|
+
styleOverrides: {
|
|
34
|
+
body: { WebkitFontSmoothing: 'antialiased', MozOsxFontSmoothing: 'grayscale' },
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
MuiAppBar: {
|
|
38
|
+
styleOverrides: {
|
|
39
|
+
root: { boxShadow: 'none', borderBottom: `1px solid ${t.divider}`, backgroundImage: 'none' },
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
MuiPaper: {
|
|
43
|
+
styleOverrides: { root: { backgroundImage: 'none' } },
|
|
44
|
+
},
|
|
45
|
+
MuiCard: {
|
|
46
|
+
styleOverrides: {
|
|
47
|
+
root: {
|
|
48
|
+
border: `1px solid ${t.divider}`,
|
|
49
|
+
boxShadow: mode === 'light' ? '0 1px 2px rgba(15, 23, 42, 0.06)' : 'none',
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
MuiListItemButton: {
|
|
54
|
+
styleOverrides: {
|
|
55
|
+
root: {
|
|
56
|
+
'&.Mui-selected': {
|
|
57
|
+
backgroundColor: alpha(t.primary, mode === 'light' ? 0.1 : 0.16),
|
|
58
|
+
'&:hover': { backgroundColor: alpha(t.primary, mode === 'light' ? 0.14 : 0.22) },
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
MuiAvatar: {
|
|
64
|
+
styleOverrides: {
|
|
65
|
+
// The user menu's initials avatar: a tonal primary chip, not MUI's grey.
|
|
66
|
+
colorDefault: { backgroundColor: alpha(t.primary, mode === 'light' ? 0.12 : 0.2), color: t.primary, fontWeight: 600 },
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
MuiBottomNavigation: {
|
|
70
|
+
styleOverrides: { root: { borderTop: `1px solid ${t.divider}` } },
|
|
71
|
+
},
|
|
72
|
+
MuiBottomNavigationAction: {
|
|
73
|
+
styleOverrides: { root: { color: t.textSecondary, '&.Mui-selected': { color: t.primary } } },
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
}),
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
79
|
+
/** The Vault light theme, built once. */
|
|
80
|
+
export const vaultLightTheme = createVaultTheme('light');
|
|
81
|
+
/** The Vault dark theme, built once. */
|
|
82
|
+
export const vaultDarkTheme = createVaultTheme('dark');
|
|
83
|
+
/** The themes `ShellRoot` takes. */
|
|
84
|
+
export const VAULT_THEMES = { light: vaultLightTheme, dark: vaultDarkTheme };
|