Update local backups visibility
This commit is contained in:
parent
61ab375308
commit
0589e760df
3 changed files with 168 additions and 111 deletions
|
@ -858,6 +858,16 @@ BackupsFree.args = {
|
||||||
mediaIncludedInBackupDurationDays: 30,
|
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({});
|
export const BackupsOff = Template.bind({});
|
||||||
BackupsOff.args = {
|
BackupsOff.args = {
|
||||||
|
@ -873,6 +883,13 @@ BackupsLocalBackups.args = {
|
||||||
backupLocalBackupsEnabled: true,
|
backupLocalBackupsEnabled: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const BackupsRemoteEnabledLocalDisabled = Template.bind({});
|
||||||
|
BackupsRemoteEnabledLocalDisabled.args = {
|
||||||
|
page: SettingsPage.Backups,
|
||||||
|
backupFeatureEnabled: true,
|
||||||
|
backupLocalBackupsEnabled: false,
|
||||||
|
};
|
||||||
|
|
||||||
export const BackupsSubscriptionNotFound = Template.bind({});
|
export const BackupsSubscriptionNotFound = Template.bind({});
|
||||||
BackupsSubscriptionNotFound.args = {
|
BackupsSubscriptionNotFound.args = {
|
||||||
page: SettingsPage.Backups,
|
page: SettingsPage.Backups,
|
||||||
|
|
|
@ -2103,6 +2103,8 @@ export function Preferences({
|
||||||
resumeBackupMediaDownload={resumeBackupMediaDownload}
|
resumeBackupMediaDownload={resumeBackupMediaDownload}
|
||||||
cloudBackupStatus={cloudBackupStatus}
|
cloudBackupStatus={cloudBackupStatus}
|
||||||
i18n={i18n}
|
i18n={i18n}
|
||||||
|
isLocalBackupsEnabled={backupLocalBackupsEnabled}
|
||||||
|
isRemoteBackupsEnabled={backupFeatureEnabled}
|
||||||
locale={resolvedLocale}
|
locale={resolvedLocale}
|
||||||
localBackupFolder={localBackupFolder}
|
localBackupFolder={localBackupFolder}
|
||||||
onBackupKeyViewedChange={onBackupKeyViewedChange}
|
onBackupKeyViewedChange={onBackupKeyViewedChange}
|
||||||
|
|
|
@ -34,12 +34,28 @@ import { BackupMediaDownloadProgressSettings } from './BackupMediaDownloadProgre
|
||||||
export const SIGNAL_BACKUPS_LEARN_MORE_URL =
|
export const SIGNAL_BACKUPS_LEARN_MORE_URL =
|
||||||
'https://support.signal.org/hc/articles/360007059752-Backup-and-Restore-Messages';
|
'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({
|
export function PreferencesBackups({
|
||||||
accountEntropyPool,
|
accountEntropyPool,
|
||||||
backupKeyViewed,
|
backupKeyViewed,
|
||||||
backupSubscriptionStatus,
|
backupSubscriptionStatus,
|
||||||
cloudBackupStatus,
|
cloudBackupStatus,
|
||||||
i18n,
|
i18n,
|
||||||
|
isLocalBackupsEnabled,
|
||||||
|
isRemoteBackupsEnabled,
|
||||||
locale,
|
locale,
|
||||||
localBackupFolder,
|
localBackupFolder,
|
||||||
onBackupKeyViewedChange,
|
onBackupKeyViewedChange,
|
||||||
|
@ -61,6 +77,8 @@ export function PreferencesBackups({
|
||||||
cloudBackupStatus?: BackupStatusType;
|
cloudBackupStatus?: BackupStatusType;
|
||||||
localBackupFolder: string | undefined;
|
localBackupFolder: string | undefined;
|
||||||
i18n: LocalizerType;
|
i18n: LocalizerType;
|
||||||
|
isLocalBackupsEnabled: boolean;
|
||||||
|
isRemoteBackupsEnabled: boolean;
|
||||||
locale: string;
|
locale: string;
|
||||||
onBackupKeyViewedChange: (keyViewed: boolean) => void;
|
onBackupKeyViewedChange: (keyViewed: boolean) => void;
|
||||||
page: PreferencesBackupPage;
|
page: PreferencesBackupPage;
|
||||||
|
@ -90,6 +108,16 @@ export function PreferencesBackups({
|
||||||
}
|
}
|
||||||
}, [page, refreshBackupSubscriptionStatus, refreshCloudBackupStatus]);
|
}, [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 (page === SettingsPage.BackupsDetails) {
|
||||||
if (backupSubscriptionStatus.status === 'off') {
|
if (backupSubscriptionStatus.status === 'off') {
|
||||||
setPage(SettingsPage.Backups);
|
setPage(SettingsPage.Backups);
|
||||||
|
@ -109,12 +137,7 @@ export function PreferencesBackups({
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (isLocalBackupsPage(page)) {
|
||||||
page === SettingsPage.LocalBackups ||
|
|
||||||
page === SettingsPage.LocalBackupsKeyReference ||
|
|
||||||
page === SettingsPage.LocalBackupsSetupFolder ||
|
|
||||||
page === SettingsPage.LocalBackupsSetupKey
|
|
||||||
) {
|
|
||||||
return (
|
return (
|
||||||
<PreferencesLocalBackups
|
<PreferencesLocalBackups
|
||||||
accountEntropyPool={accountEntropyPool}
|
accountEntropyPool={accountEntropyPool}
|
||||||
|
@ -139,14 +162,9 @@ export function PreferencesBackups({
|
||||||
|
|
||||||
const isLocalBackupsSetup = localBackupFolder && backupKeyViewed;
|
const isLocalBackupsSetup = localBackupFolder && backupKeyViewed;
|
||||||
|
|
||||||
|
function renderRemoteBackups() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="Preferences__padding">
|
|
||||||
<div className="Preferences__description Preferences__description--medium">
|
|
||||||
{i18n('icu:Preferences--backup-section-description')}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{backupSubscriptionStatus.status === 'off' ? (
|
{backupSubscriptionStatus.status === 'off' ? (
|
||||||
<SettingsRow className="Preferences--BackupsRow">
|
<SettingsRow className="Preferences--BackupsRow">
|
||||||
<Control
|
<Control
|
||||||
|
@ -202,7 +220,13 @@ export function PreferencesBackups({
|
||||||
</FlowingControl>
|
</FlowingControl>
|
||||||
</SettingsRow>
|
</SettingsRow>
|
||||||
)}
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderLocalBackups() {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
<SettingsRow
|
<SettingsRow
|
||||||
className="Preferences--BackupsRow"
|
className="Preferences--BackupsRow"
|
||||||
title={i18n('icu:Preferences__backup-other-ways')}
|
title={i18n('icu:Preferences__backup-other-ways')}
|
||||||
|
@ -271,6 +295,20 @@ export function PreferencesBackups({
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className="Preferences__padding">
|
||||||
|
<div className="Preferences__description Preferences__description--medium">
|
||||||
|
{i18n('icu:Preferences--backup-section-description')}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{isRemoteBackupsEnabled ? renderRemoteBackups() : null}
|
||||||
|
{isLocalBackupsEnabled ? renderLocalBackups() : null}
|
||||||
|
</>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSubscriptionDetails({
|
function getSubscriptionDetails({
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue