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
client/options/backup: correct line widths
Adorian Doran22ddbc5a9f4b
diff --git a/apps/client/src/widgets/react/Card.tsx b/apps/client/src/widgets/react/Card.tsxindex d0b52217a7..7ce92eb584 100644--- a/apps/client/src/widgets/react/Card.tsx+++ b/apps/client/src/widgets/react/Card.tsx@@ -107,7 +107,8 @@ export interface CardOptionProps extends CardSectionProps {* A card section built as one setting: what it is on the leading edge, what changes it on the* trailing one, with the sentence explaining it below the label.*/-export function CardOption({label, description, name, children, className, ...rest}: CardOptionProps) {+export function CardOption(props: CardOptionProps) {+ const {label, description, name, children, className, ...rest} = props;const id = useUniqueName(name);const bound = !!name && isValidElement(children);diff --git a/apps/client/src/widgets/type_widgets/options/advanced.tsx b/apps/client/src/widgets/type_widgets/options/advanced.tsxindex 765f0199ca..89a869d755 100644--- a/apps/client/src/widgets/type_widgets/options/advanced.tsx+++ b/apps/client/src/widgets/type_widgets/options/advanced.tsx@@ -168,7 +168,9 @@ function ExistingAnonymizedDatabases({ databases, anonymizedFolderPath }: { datatitle={t("database_anonymization.existing_anonymized_databases")}description={anonymizedFolderPath && (<span className="selectable-text">- {t("database_anonymization.anonymized_databases_location", { anonymizedFolder: anonymizedFolderPath })}+ {t("database_anonymization.anonymized_databases_location", {+ anonymizedFolder: anonymizedFolderPath+ })}</span>)}files={databases}diff --git a/apps/client/src/widgets/type_widgets/options/backup.tsx b/apps/client/src/widgets/type_widgets/options/backup.tsxindex b743f2c87f..716421c1f7 100644--- a/apps/client/src/widgets/type_widgets/options/backup.tsx+++ b/apps/client/src/widgets/type_widgets/options/backup.tsx@@ -1,6 +1,12 @@import "./backup.css";-import { BackupDatabaseNowResponse, BackupPassphraseStatus, DatabaseBackup, dayjs, ExistingBackupsResponse } from "@triliumnext/commons";+import {+ BackupDatabaseNowResponse,+ BackupPassphraseStatus,+ DatabaseBackup,+ dayjs,+ ExistingBackupsResponse+} from "@triliumnext/commons";import { useCallback, useEffect, useRef, useState } from "preact/hooks";import dialogService from "../../../services/dialog";@@ -36,7 +42,9 @@ export default function BackupSettings() {return (<>- <OptionsPageHeader below={<BackupStatus backups={backups} refreshCallback={refreshBackups} />} />+ <OptionsPageHeader+ below={<BackupStatus backups={backups} refreshCallback={refreshBackups} />}+ /><BackupList backups={backups} backupFolderPath={backupFolderPath} />{/* Absent where there is no user-accessible location at all, e.g. backups kept in OPFS. */}{backupFolderPath && <BackupLocation backupFolderPath={backupFolderPath} refreshCallback={refreshBackups} />}@@ -47,12 +55,17 @@ export default function BackupSettings() {);}+interface BackupStatusProps {+ backups: DatabaseBackup[];+ refreshCallback: () => void;+}+/**- * How the backups stand, and the one action that makes one now rather than on a schedule. Part of the- * page's own header rather than of the list below it: the list card answers for what it holds, which- * is not the same as what the page is for.+ * How the backups stand, and the one action that makes one now rather than on a schedule. Part+ * of the page's own header rather than of the list below it: the list card answers for what it+ * holds, which is not the same as what the page is for.*/-function BackupStatus({ backups, refreshCallback }: { backups: DatabaseBackup[]; refreshCallback: () => void }) {+function BackupStatus({ backups, refreshCallback }: BackupStatusProps) {const [backupInProgress, setBackupInProgress] = useState(false);return (@@ -67,8 +80,14 @@ function BackupStatus({ backups, refreshCallback }: { backups: DatabaseBackup[];onClick={async () => {setBackupInProgress(true);try {- const { backupFile } = await server.post<BackupDatabaseNowResponse>("database/backup-database");- toast.showMessage(t("backup.database_backed_up_to", { backupFilePath: backupFile }), 10000);+ const { backupFile } = await server.post<BackupDatabaseNowResponse>(+ "database/backup-database"+ );++ toast.showMessage(+ t("backup.database_backed_up_to", { backupFilePath: backupFile }),+ 10000+ );refreshCallback();} finally {setBackupInProgress(false);@@ -80,18 +99,23 @@ function BackupStatus({ backups, refreshCallback }: { backups: DatabaseBackup[];}/**- * How many backups there are and how long ago the last one was made — the two things the list itself- * only answers by being read through. Nothing is said while there are none: the list stands empty- * right below, which states it more plainly than a sentence could.+ * How many backups there are and how long ago the last one was made — the two things the list+ * itself only answers by being read through. Nothing is said while there are none: the list+ * stands empty right below, which states it more plainly than a sentence could.*/function summarizeBackups(backups: DatabaseBackup[]) {if (!backups.length) {return null;}- const mostRecent = backups.reduce((latest, backup) => (backup.mtime > latest.mtime ? backup : latest));+ const mostRecent = backups.reduce((latest, backup) => (+ backup.mtime > latest.mtime ? backup : latest+ ));- return t("backup.backups_summary", { count: backups.length, age: dayjs(mostRecent.mtime).fromNow(true) });+ return t("backup.backups_summary", {+ count: backups.length,+ age: dayjs(mostRecent.mtime).fromNow(true)+ });}export function BackupConfiguration() {@@ -106,15 +130,24 @@ export function BackupConfiguration() {description={t("backup.automatic_backups_description")}><CardOption name="daily-backup-enabled" label={t("backup.enable_daily_backup")}>- <FormToggle currentValue={dailyBackupEnabled} onChange={setDailyBackupEnabled} />+ <FormToggle+ currentValue={dailyBackupEnabled}+ onChange={setDailyBackupEnabled}+ /></CardOption><CardOption name="weekly-backup-enabled" label={t("backup.enable_weekly_backup")}>- <FormToggle currentValue={weeklyBackupEnabled} onChange={setWeeklyBackupEnabled} />+ <FormToggle+ currentValue={weeklyBackupEnabled}+ onChange={setWeeklyBackupEnabled}+ /></CardOption><CardOption name="monthly-backup-enabled" label={t("backup.enable_monthly_backup")}>- <FormToggle currentValue={monthlyBackupEnabled} onChange={setMonthlyBackupEnabled} />+ <FormToggle+ currentValue={monthlyBackupEnabled}+ onChange={setMonthlyBackupEnabled}+ /></CardOption></Card></div>@@ -258,7 +291,9 @@ export function BackupOptions() {<Card heading={t("backup.options_title")}><CardOptionlabel={t("backup.enable_encryption")}- description={passphrase.available ? t("backup.enable_encryption_description") : t("backup.no_keyring")}+ description={passphrase.available+ ? t("backup.enable_encryption_description")+ : t("backup.no_keyring")}>{passphrase.set ? (<>@@ -289,7 +324,10 @@ export function BackupOptions() {label={t("backup.enable_compression")}description={t("backup.enable_compression_description")}>- <FormToggle currentValue={compressionEnabled} onChange={setCompressionEnabled} />+ <FormToggle+ currentValue={compressionEnabled}+ onChange={setCompressionEnabled}+ /></CardOption></Card>@@ -327,7 +365,12 @@ function BackupPasswordModal({ show, onHidden, onSave }: { show: boolean; onHidd);}-export function BackupList({ backups, backupFolderPath }: { backups: DatabaseBackup[]; backupFolderPath: string | null }) {+interface BackupListProps {+ backups: DatabaseBackup[];+ backupFolderPath: string | null;+}++export function BackupList({ backups, backupFolderPath }: BackupListProps) {const [customDir] = useTriliumOption("customDbBackupDir");// What a row cannot say for itself: the format it was written in, and — with a custom location indiff --git a/apps/client/src/widgets/type_widgets/options/components/DatabaseFileList.tsx b/apps/client/src/widgets/type_widgets/options/components/DatabaseFileList.tsxindex c58ed1bc75..de40ac57f0 100644--- a/apps/client/src/widgets/type_widgets/options/components/DatabaseFileList.tsx+++ b/apps/client/src/widgets/type_widgets/options/components/DatabaseFileList.tsx@@ -42,7 +42,10 @@ interface DatabaseFileListProps<T extends DatabaseFile> {children?: ComponentChildren;}-export default function DatabaseFileList<T extends DatabaseFile>({ title, description, files, downloadEndpoint, downloadText, emptyIcon, emptyText, fileBadges, children }: DatabaseFileListProps<T>) {+export default function DatabaseFileList<T extends DatabaseFile>(props: DatabaseFileListProps<T>) {+ const { title, description, files, downloadEndpoint, downloadText } = props;+ const { emptyIcon, emptyText, fileBadges, children } = props;+const sortedFiles = useMemo(() => [...files].sort((a, b) => {if (a.mtime < b.mtime) return 1;if (a.mtime > b.mtime) return -1;@@ -60,7 +63,12 @@ export default function DatabaseFileList<T extends DatabaseFile>({ title, descri<span className="database-file-label"><span className="selectable-text">{file.fileName}</span>{fileBadges?.(file).map((badge) => (- <Badge key={badge} className="database-file-badge" text={badge} outline />+ <Badge+ key={badge}+ className="database-file-badge"+ text={badge}+ outline+ />))}</span>}@@ -69,7 +77,7 @@ export default function DatabaseFileList<T extends DatabaseFile>({ title, descri<ActionButtonicon="bx bx-download"text={downloadText}- onClick={() => open.download(open.getUrlForDownload(`${downloadEndpoint}?filePath=${encodeURIComponent(file.filePath)}`))}+ onClick={() => downloadFile(downloadEndpoint, file.filePath)}/></CardOption>))@@ -85,6 +93,12 @@ export default function DatabaseFileList<T extends DatabaseFile>({ title, descri);}+function downloadFile(downloadEndpoint: string, filePath: string) {+ const url = `${downloadEndpoint}?filePath=${encodeURIComponent(filePath)}`;++ open.download(open.getUrlForDownload(url));+}+/*** When the file was written, and how big it is. A file made from a database larger than itself states* both, so what compressing it saved is visible rather than having to be worked out.