From 0589e760dff6fa02bf6e5e88f8abc0083ef5d2af Mon Sep 17 00:00:00 2001 From: trevor-signal <131492920+trevor-signal@users.noreply.github.com> Date: Thu, 11 Sep 2025 13:15:48 -0400 Subject: [PATCH] Update local backups visibility --- ts/components/Preferences.stories.tsx | 17 ++ ts/components/Preferences.tsx | 2 + ts/components/PreferencesBackups.tsx | 260 +++++++++++++++----------- 3 files changed, 168 insertions(+), 111 deletions(-) diff --git a/ts/components/Preferences.stories.tsx b/ts/components/Preferences.stories.tsx index 8fea92242c6..936cbd468ff 100644 --- a/ts/components/Preferences.stories.tsx +++ b/ts/components/Preferences.stories.tsx @@ -858,6 +858,16 @@ BackupsFree.args = { mediaIncludedInBackupDurationDays: 30, }, }; +export const BackupsFreeNoLocal = Template.bind({}); +BackupsFreeNoLocal.args = { + page: SettingsPage.Backups, + backupFeatureEnabled: true, + backupLocalBackupsEnabled: false, + backupSubscriptionStatus: { + status: 'free', + mediaIncludedInBackupDurationDays: 30, + }, +}; export const BackupsOff = Template.bind({}); BackupsOff.args = { @@ -873,6 +883,13 @@ BackupsLocalBackups.args = { backupLocalBackupsEnabled: true, }; +export const BackupsRemoteEnabledLocalDisabled = Template.bind({}); +BackupsRemoteEnabledLocalDisabled.args = { + page: SettingsPage.Backups, + backupFeatureEnabled: true, + backupLocalBackupsEnabled: false, +}; + export const BackupsSubscriptionNotFound = Template.bind({}); BackupsSubscriptionNotFound.args = { page: SettingsPage.Backups, diff --git a/ts/components/Preferences.tsx b/ts/components/Preferences.tsx index 8868d008086..bb8733dd363 100644 --- a/ts/components/Preferences.tsx +++ b/ts/components/Preferences.tsx @@ -2103,6 +2103,8 @@ export function Preferences({ resumeBackupMediaDownload={resumeBackupMediaDownload} cloudBackupStatus={cloudBackupStatus} i18n={i18n} + isLocalBackupsEnabled={backupLocalBackupsEnabled} + isRemoteBackupsEnabled={backupFeatureEnabled} locale={resolvedLocale} localBackupFolder={localBackupFolder} onBackupKeyViewedChange={onBackupKeyViewedChange} diff --git a/ts/components/PreferencesBackups.tsx b/ts/components/PreferencesBackups.tsx index 6eab611c69b..fcad5975ee6 100644 --- a/ts/components/PreferencesBackups.tsx +++ b/ts/components/PreferencesBackups.tsx @@ -34,12 +34,28 @@ import { BackupMediaDownloadProgressSettings } from './BackupMediaDownloadProgre export const SIGNAL_BACKUPS_LEARN_MORE_URL = 'https://support.signal.org/hc/articles/360007059752-Backup-and-Restore-Messages'; +const LOCAL_BACKUPS_PAGES = new Set([ + SettingsPage.LocalBackups, + SettingsPage.LocalBackupsKeyReference, + SettingsPage.LocalBackupsSetupFolder, + SettingsPage.LocalBackupsSetupKey, +]); +const REMOTE_BACKUPS_PAGES = new Set([SettingsPage.BackupsDetails]); + +function isLocalBackupsPage(page: SettingsPage) { + return LOCAL_BACKUPS_PAGES.has(page); +} +function isRemoteBackupsPage(page: SettingsPage) { + return REMOTE_BACKUPS_PAGES.has(page); +} export function PreferencesBackups({ accountEntropyPool, backupKeyViewed, backupSubscriptionStatus, cloudBackupStatus, i18n, + isLocalBackupsEnabled, + isRemoteBackupsEnabled, locale, localBackupFolder, onBackupKeyViewedChange, @@ -61,6 +77,8 @@ export function PreferencesBackups({ cloudBackupStatus?: BackupStatusType; localBackupFolder: string | undefined; i18n: LocalizerType; + isLocalBackupsEnabled: boolean; + isRemoteBackupsEnabled: boolean; locale: string; onBackupKeyViewedChange: (keyViewed: boolean) => void; page: PreferencesBackupPage; @@ -90,6 +108,16 @@ export function PreferencesBackups({ } }, [page, refreshBackupSubscriptionStatus, refreshCloudBackupStatus]); + if (!isRemoteBackupsEnabled && isRemoteBackupsPage(page)) { + setPage(SettingsPage.Backups); + return null; + } + + if (!isLocalBackupsEnabled && isLocalBackupsPage(page)) { + setPage(SettingsPage.Backups); + return null; + } + if (page === SettingsPage.BackupsDetails) { if (backupSubscriptionStatus.status === 'off') { setPage(SettingsPage.Backups); @@ -109,12 +137,7 @@ export function PreferencesBackups({ ); } - if ( - page === SettingsPage.LocalBackups || - page === SettingsPage.LocalBackupsKeyReference || - page === SettingsPage.LocalBackupsSetupFolder || - page === SettingsPage.LocalBackupsSetupKey - ) { + if (isLocalBackupsPage(page)) { return ( -
-
- {i18n('icu:Preferences--backup-section-description')} -
-
- - {backupSubscriptionStatus.status === 'off' ? ( - - - {i18n('icu:Preferences--signal-backups')}{' '} -
- -
- - } - right={null} - /> -
- ) : ( - - -
- + function renderRemoteBackups() { + return ( + <> + {backupSubscriptionStatus.status === 'off' ? ( + + {i18n('icu:Preferences--signal-backups')}{' '} +
+ +
+ + } + right={null} + /> +
+ ) : ( + + +
+ + + +
+
+ +
+
+
+ )} + + ); + } + + function renderLocalBackups() { + return ( + <> + + +
+ + @@ -193,82 +252,61 @@ export function PreferencesBackups({ )} >
- )} - - -
- - - -
-
setAuthError(undefined)} + cancelButtonVariant={ButtonVariant.Secondary} + cancelText={i18n('icu:ok')} > - -
-
-
- - {authError && ( - setAuthError(undefined)} - cancelButtonVariant={ButtonVariant.Secondary} - cancelText={i18n('icu:ok')} - > - {getOSAuthErrorString(authError) ?? i18n('icu:error')} - - )} + {isRemoteBackupsEnabled ? renderRemoteBackups() : null} + {isLocalBackupsEnabled ? renderLocalBackups() : null} ); }