Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(options/backup): disable "Backup now" while ongoing
Elian Doran4168e7bea78e
diff --git a/apps/client/src/widgets/type_widgets/options/backup.tsx b/apps/client/src/widgets/type_widgets/options/backup.tsxindex 1619f35ffb..12749e9f63 100644--- a/apps/client/src/widgets/type_widgets/options/backup.tsx+++ b/apps/client/src/widgets/type_widgets/options/backup.tsx@@ -45,6 +45,7 @@ export function BackupConfiguration({ refreshCallback }: { refreshCallback: () =const [dailyBackupEnabled, setDailyBackupEnabled] = useTriliumOptionBool("dailyBackupEnabled");const [weeklyBackupEnabled, setWeeklyBackupEnabled] = useTriliumOptionBool("weeklyBackupEnabled");const [monthlyBackupEnabled, setMonthlyBackupEnabled] = useTriliumOptionBool("monthlyBackupEnabled");+ const [backupInProgress, setBackupInProgress] = useState(false);return (<OptionsSection title={t("backup.title")}>@@ -77,10 +78,16 @@ export function BackupConfiguration({ refreshCallback }: { refreshCallback: () =<OptionsRowWithButtonlabel={t("backup.backup_database_now")}+ disabled={backupInProgress}onClick={async () => {- const { backupFile } = await server.post<BackupDatabaseNowResponse>("database/backup-database");- toast.showMessage(t("backup.database_backed_up_to", { backupFilePath: backupFile }), 10000);- refreshCallback();+ setBackupInProgress(true);+ try {+ const { backupFile } = await server.post<BackupDatabaseNowResponse>("database/backup-database");+ toast.showMessage(t("backup.database_backed_up_to", { backupFilePath: backupFile }), 10000);+ refreshCallback();+ } finally {+ setBackupInProgress(false);+ }}}/></OptionsSection>diff --git a/apps/client/src/widgets/type_widgets/options/components/OptionsRow.css b/apps/client/src/widgets/type_widgets/options/components/OptionsRow.cssindex 48091eec69..f17f1fb64f 100644--- a/apps/client/src/widgets/type_widgets/options/components/OptionsRow.css+++ b/apps/client/src/widgets/type_widgets/options/components/OptionsRow.css@@ -94,6 +94,11 @@ button.option-row-link:last-child {border-bottom: none;}+button.option-row-link:disabled {+ opacity: 0.6;+ pointer-events: none;+}+.search-engine-templates {--badge-radius: 12px;display: flex;diff --git a/apps/client/src/widgets/type_widgets/options/components/OptionsRow.tsx b/apps/client/src/widgets/type_widgets/options/components/OptionsRow.tsxindex 5a165f292f..620c4d876e 100644--- a/apps/client/src/widgets/type_widgets/options/components/OptionsRow.tsx+++ b/apps/client/src/widgets/type_widgets/options/components/OptionsRow.tsx@@ -92,15 +92,17 @@ interface OptionsRowWithButtonProps {label: string;description?: string;icon?: string;+ disabled?: boolean;onClick: () => void;}-export function OptionsRowWithButton({ label, description, icon, onClick }: OptionsRowWithButtonProps) {+export function OptionsRowWithButton({ label, description, icon, disabled, onClick }: OptionsRowWithButtonProps) {return (<buttontype="button"className="option-row option-row-link"onClick={onClick}+ disabled={disabled}aria-label={label}><div className="option-row-label">