chore(i18n): components.settings.backup.*
This commit is contained in:
@@ -84,22 +84,42 @@ export const BackupConfigViewer = memo(
|
||||
|
||||
if (!url) {
|
||||
urlRef.current?.focus();
|
||||
showNotice("error", t("WebDAV URL Required"));
|
||||
throw new Error(t("WebDAV URL Required"));
|
||||
showNotice(
|
||||
"error",
|
||||
t("components.settings.backup.messages.webdavUrlRequired"),
|
||||
);
|
||||
throw new Error(
|
||||
t("components.settings.backup.messages.webdavUrlRequired"),
|
||||
);
|
||||
} else if (!isValidUrl(url)) {
|
||||
urlRef.current?.focus();
|
||||
showNotice("error", t("Invalid WebDAV URL"));
|
||||
throw new Error(t("Invalid WebDAV URL"));
|
||||
showNotice(
|
||||
"error",
|
||||
t("components.settings.backup.messages.invalidWebdavUrl"),
|
||||
);
|
||||
throw new Error(
|
||||
t("components.settings.backup.messages.invalidWebdavUrl"),
|
||||
);
|
||||
}
|
||||
if (!username) {
|
||||
usernameRef.current?.focus();
|
||||
showNotice("error", t("WebDAV URL Required"));
|
||||
throw new Error(t("Username Required"));
|
||||
showNotice(
|
||||
"error",
|
||||
t("components.settings.backup.messages.usernameRequired"),
|
||||
);
|
||||
throw new Error(
|
||||
t("components.settings.backup.messages.usernameRequired"),
|
||||
);
|
||||
}
|
||||
if (!password) {
|
||||
passwordRef.current?.focus();
|
||||
showNotice("error", t("WebDAV URL Required"));
|
||||
throw new Error(t("Password Required"));
|
||||
showNotice(
|
||||
"error",
|
||||
t("components.settings.backup.messages.passwordRequired"),
|
||||
);
|
||||
throw new Error(
|
||||
t("components.settings.backup.messages.passwordRequired"),
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -112,11 +132,20 @@ export const BackupConfigViewer = memo(
|
||||
data.username.trim(),
|
||||
data.password,
|
||||
).then(() => {
|
||||
showNotice("success", t("WebDAV Config Saved"));
|
||||
showNotice(
|
||||
"success",
|
||||
t("components.settings.backup.messages.webdavConfigSaved"),
|
||||
);
|
||||
onSaveSuccess();
|
||||
});
|
||||
} catch (error) {
|
||||
showNotice("error", t("WebDAV Config Save Failed", { error }), 3000);
|
||||
showNotice(
|
||||
"error",
|
||||
t("components.settings.backup.messages.webdavConfigSaveFailed", {
|
||||
error,
|
||||
}),
|
||||
3000,
|
||||
);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -127,11 +156,17 @@ export const BackupConfigViewer = memo(
|
||||
try {
|
||||
setLoading(true);
|
||||
await createWebdavBackup().then(async () => {
|
||||
showNotice("success", t("Backup Created"));
|
||||
showNotice(
|
||||
"success",
|
||||
t("components.settings.backup.messages.backupCreated"),
|
||||
);
|
||||
await onBackupSuccess();
|
||||
});
|
||||
} catch (error) {
|
||||
showNotice("error", t("Backup Failed", { error }));
|
||||
showNotice(
|
||||
"error",
|
||||
t("components.settings.backup.messages.backupFailed", { error }),
|
||||
);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -145,7 +180,7 @@ export const BackupConfigViewer = memo(
|
||||
<Grid size={{ xs: 12 }}>
|
||||
<TextField
|
||||
fullWidth
|
||||
label={t("WebDAV Server URL")}
|
||||
label={t("components.settings.backup.fields.webdavUrl")}
|
||||
variant="outlined"
|
||||
size="small"
|
||||
{...register("url")}
|
||||
@@ -157,7 +192,7 @@ export const BackupConfigViewer = memo(
|
||||
</Grid>
|
||||
<Grid size={{ xs: 6 }}>
|
||||
<TextField
|
||||
label={t("Username")}
|
||||
label={t("components.settings.backup.fields.username")}
|
||||
variant="outlined"
|
||||
size="small"
|
||||
{...register("username")}
|
||||
@@ -169,7 +204,7 @@ export const BackupConfigViewer = memo(
|
||||
</Grid>
|
||||
<Grid size={{ xs: 6 }}>
|
||||
<TextField
|
||||
label={t("Password")}
|
||||
label={t("components.settings.backup.fields.password")}
|
||||
type={showPassword ? "text" : "password"}
|
||||
variant="outlined"
|
||||
size="small"
|
||||
@@ -214,7 +249,7 @@ export const BackupConfigViewer = memo(
|
||||
type="button"
|
||||
onClick={handleSubmit(save)}
|
||||
>
|
||||
{t("Save")}
|
||||
{t("components.settings.backup.actions.save")}
|
||||
</Button>
|
||||
) : (
|
||||
<>
|
||||
@@ -225,7 +260,7 @@ export const BackupConfigViewer = memo(
|
||||
type="button"
|
||||
size="large"
|
||||
>
|
||||
{t("Backup")}
|
||||
{t("components.settings.backup.actions.backup")}
|
||||
</Button>
|
||||
<Button
|
||||
variant="outlined"
|
||||
@@ -233,7 +268,7 @@ export const BackupConfigViewer = memo(
|
||||
type="button"
|
||||
size="large"
|
||||
>
|
||||
{t("Refresh")}
|
||||
{t("components.settings.backup.actions.refresh")}
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
|
||||
@@ -75,7 +75,10 @@ export const BackupTableViewer = memo(
|
||||
|
||||
const handleRestore = useLockFn(async (filename: string) => {
|
||||
await onRestore(filename).then(() => {
|
||||
showNotice("success", t("Restore Success, App will restart in 1s"));
|
||||
showNotice(
|
||||
"success",
|
||||
t("components.settings.backup.messages.restoreSuccess"),
|
||||
);
|
||||
});
|
||||
await restartApp();
|
||||
});
|
||||
@@ -92,10 +95,16 @@ export const BackupTableViewer = memo(
|
||||
return;
|
||||
}
|
||||
await onExport(filename, savePath);
|
||||
showNotice("success", t("Local Backup Exported"));
|
||||
showNotice(
|
||||
"success",
|
||||
t("components.settings.backup.messages.localBackupExported"),
|
||||
);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
showNotice("error", t("Local Backup Export Failed"));
|
||||
showNotice(
|
||||
"error",
|
||||
t("components.settings.backup.messages.localBackupExportFailed"),
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -104,9 +113,15 @@ export const BackupTableViewer = memo(
|
||||
<Table>
|
||||
<TableHead>
|
||||
<TableRow>
|
||||
<TableCell>{t("Filename")}</TableCell>
|
||||
<TableCell>{t("Backup Time")}</TableCell>
|
||||
<TableCell align="right">{t("Actions")}</TableCell>
|
||||
<TableCell>
|
||||
{t("components.settings.backup.table.filename")}
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
{t("components.settings.backup.table.backupTime")}
|
||||
</TableCell>
|
||||
<TableCell align="right">
|
||||
{t("components.settings.backup.table.actions")}
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
</TableHead>
|
||||
<TableBody>
|
||||
@@ -140,9 +155,13 @@ export const BackupTableViewer = memo(
|
||||
<>
|
||||
<IconButton
|
||||
color="primary"
|
||||
aria-label={t("Export")}
|
||||
aria-label={t(
|
||||
"components.settings.backup.actions.export",
|
||||
)}
|
||||
size="small"
|
||||
title={t("Export Backup")}
|
||||
title={t(
|
||||
"components.settings.backup.actions.exportBackup",
|
||||
)}
|
||||
onClick={async (e: React.MouseEvent) => {
|
||||
e.preventDefault();
|
||||
await handleExport(file.filename);
|
||||
@@ -159,13 +178,19 @@ export const BackupTableViewer = memo(
|
||||
)}
|
||||
<IconButton
|
||||
color="secondary"
|
||||
aria-label={t("Delete")}
|
||||
aria-label={t(
|
||||
"components.settings.backup.actions.delete",
|
||||
)}
|
||||
size="small"
|
||||
title={t("Delete Backup")}
|
||||
title={t(
|
||||
"components.settings.backup.actions.deleteBackup",
|
||||
)}
|
||||
onClick={async (e: React.MouseEvent) => {
|
||||
e.preventDefault();
|
||||
const confirmed = await confirmAsync(
|
||||
t("Confirm to delete this backup file?"),
|
||||
t(
|
||||
"components.settings.backup.messages.confirmDelete",
|
||||
),
|
||||
);
|
||||
if (confirmed) {
|
||||
await handleDelete(file.filename);
|
||||
@@ -181,14 +206,20 @@ export const BackupTableViewer = memo(
|
||||
/>
|
||||
<IconButton
|
||||
color="primary"
|
||||
aria-label={t("Restore")}
|
||||
aria-label={t(
|
||||
"components.settings.backup.actions.restore",
|
||||
)}
|
||||
size="small"
|
||||
title={t("Restore Backup")}
|
||||
title={t(
|
||||
"components.settings.backup.actions.restoreBackup",
|
||||
)}
|
||||
disabled={!file.allow_apply}
|
||||
onClick={async (e: React.MouseEvent) => {
|
||||
e.preventDefault();
|
||||
const confirmed = await confirmAsync(
|
||||
t("Confirm to restore this backup file?"),
|
||||
t(
|
||||
"components.settings.backup.messages.confirmRestore",
|
||||
),
|
||||
);
|
||||
if (confirmed) {
|
||||
await handleRestore(file.filename);
|
||||
@@ -219,7 +250,7 @@ export const BackupTableViewer = memo(
|
||||
color="textSecondary"
|
||||
align="center"
|
||||
>
|
||||
{t("No Backups")}
|
||||
{t("components.settings.backup.table.noBackups")}
|
||||
</Typography>
|
||||
</Box>
|
||||
</TableCell>
|
||||
@@ -234,7 +265,7 @@ export const BackupTableViewer = memo(
|
||||
rowsPerPage={DEFAULT_ROWS_PER_PAGE}
|
||||
page={page}
|
||||
onPageChange={onPageChange}
|
||||
labelRowsPerPage={t("Rows per page")}
|
||||
labelRowsPerPage={t("components.settings.backup.table.rowsPerPage")}
|
||||
/>
|
||||
</TableContainer>
|
||||
);
|
||||
|
||||
@@ -247,7 +247,7 @@ export function BackupViewer({ ref }: { ref?: Ref<DialogRef> }) {
|
||||
return (
|
||||
<BaseDialog
|
||||
open={open}
|
||||
title={t("Backup Setting")}
|
||||
title={t("components.settings.backup.title")}
|
||||
contentSx={{
|
||||
minWidth: { xs: 320, sm: 620 },
|
||||
maxWidth: "unset",
|
||||
@@ -278,11 +278,17 @@ export function BackupViewer({ ref }: { ref?: Ref<DialogRef> }) {
|
||||
<Tabs
|
||||
value={source}
|
||||
onChange={handleChangeSource}
|
||||
aria-label={t("Select Backup Target")}
|
||||
aria-label={t("components.settings.backup.actions.selectTarget")}
|
||||
sx={{ mb: 2 }}
|
||||
>
|
||||
<Tab value="local" label={t("Local Backup")} />
|
||||
<Tab value="webdav" label={t("WebDAV Backup")} />
|
||||
<Tab
|
||||
value="local"
|
||||
label={t("components.settings.backup.tabs.local")}
|
||||
/>
|
||||
<Tab
|
||||
value="webdav"
|
||||
label={t("components.settings.backup.tabs.webdav")}
|
||||
/>
|
||||
</Tabs>
|
||||
{source === "local" ? (
|
||||
<LocalBackupActions
|
||||
|
||||
@@ -20,11 +20,17 @@ export const LocalBackupActions = memo(
|
||||
try {
|
||||
setLoading(true);
|
||||
await createLocalBackup();
|
||||
showNotice("success", t("Local Backup Created"));
|
||||
showNotice(
|
||||
"success",
|
||||
t("components.settings.backup.messages.localBackupCreated"),
|
||||
);
|
||||
await onBackupSuccess();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
showNotice("error", t("Local Backup Failed"));
|
||||
showNotice(
|
||||
"error",
|
||||
t("components.settings.backup.messages.localBackupFailed"),
|
||||
);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -43,7 +49,7 @@ export const LocalBackupActions = memo(
|
||||
<Grid container spacing={2}>
|
||||
<Grid size={{ xs: 12, sm: 9 }}>
|
||||
<Typography variant="body2" color="text.secondary">
|
||||
{t("Local Backup Info")}
|
||||
{t("components.settings.backup.fields.info")}
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid size={{ xs: 12, sm: 3 }}>
|
||||
@@ -60,7 +66,7 @@ export const LocalBackupActions = memo(
|
||||
type="button"
|
||||
size="large"
|
||||
>
|
||||
{t("Backup")}
|
||||
{t("components.settings.backup.actions.backup")}
|
||||
</Button>
|
||||
<Button
|
||||
variant="outlined"
|
||||
@@ -68,7 +74,7 @@ export const LocalBackupActions = memo(
|
||||
type="button"
|
||||
size="large"
|
||||
>
|
||||
{t("Refresh")}
|
||||
{t("components.settings.backup.actions.refresh")}
|
||||
</Button>
|
||||
</Stack>
|
||||
</Grid>
|
||||
|
||||
Reference in New Issue
Block a user