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,48 +162,84 @@ export function PreferencesBackups({
|
||||||
|
|
||||||
const isLocalBackupsSetup = localBackupFolder && backupKeyViewed;
|
const isLocalBackupsSetup = localBackupFolder && backupKeyViewed;
|
||||||
|
|
||||||
return (
|
function renderRemoteBackups() {
|
||||||
<>
|
return (
|
||||||
<div className="Preferences__padding">
|
<>
|
||||||
<div className="Preferences__description Preferences__description--medium">
|
{backupSubscriptionStatus.status === 'off' ? (
|
||||||
{i18n('icu:Preferences--backup-section-description')}
|
<SettingsRow className="Preferences--BackupsRow">
|
||||||
</div>
|
<Control
|
||||||
</div>
|
icon="Preferences__BackupsIcon"
|
||||||
|
left={
|
||||||
{backupSubscriptionStatus.status === 'off' ? (
|
|
||||||
<SettingsRow className="Preferences--BackupsRow">
|
|
||||||
<Control
|
|
||||||
icon="Preferences__BackupsIcon"
|
|
||||||
left={
|
|
||||||
<label>
|
|
||||||
{i18n('icu:Preferences--signal-backups')}{' '}
|
|
||||||
<div className="Preferences--backup-details__value">
|
|
||||||
<I18n
|
|
||||||
id="icu:Preferences--signal-backups-off-description"
|
|
||||||
i18n={i18n}
|
|
||||||
components={{
|
|
||||||
learnMoreLink,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</label>
|
|
||||||
}
|
|
||||||
right={null}
|
|
||||||
/>
|
|
||||||
</SettingsRow>
|
|
||||||
) : (
|
|
||||||
<SettingsRow className="Preferences--BackupsRow">
|
|
||||||
<FlowingControl>
|
|
||||||
<div className="Preferences__two-thirds-flow">
|
|
||||||
<LightIconLabel icon="Preferences__BackupsIcon">
|
|
||||||
<label>
|
<label>
|
||||||
{i18n('icu:Preferences--signal-backups')}{' '}
|
{i18n('icu:Preferences--signal-backups')}{' '}
|
||||||
|
<div className="Preferences--backup-details__value">
|
||||||
|
<I18n
|
||||||
|
id="icu:Preferences--signal-backups-off-description"
|
||||||
|
i18n={i18n}
|
||||||
|
components={{
|
||||||
|
learnMoreLink,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</label>
|
||||||
|
}
|
||||||
|
right={null}
|
||||||
|
/>
|
||||||
|
</SettingsRow>
|
||||||
|
) : (
|
||||||
|
<SettingsRow className="Preferences--BackupsRow">
|
||||||
|
<FlowingControl>
|
||||||
|
<div className="Preferences__two-thirds-flow">
|
||||||
|
<LightIconLabel icon="Preferences__BackupsIcon">
|
||||||
|
<label>
|
||||||
|
{i18n('icu:Preferences--signal-backups')}{' '}
|
||||||
|
<div className="Preferences__description">
|
||||||
|
{renderBackupsSubscriptionSummary({
|
||||||
|
subscriptionStatus: backupSubscriptionStatus,
|
||||||
|
i18n,
|
||||||
|
locale,
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</label>
|
||||||
|
</LightIconLabel>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className={classNames(
|
||||||
|
'Preferences__flow-button',
|
||||||
|
'Preferences__one-third-flow',
|
||||||
|
'Preferences__one-third-flow--align-right'
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
onClick={() => setPage(SettingsPage.BackupsDetails)}
|
||||||
|
variant={ButtonVariant.Secondary}
|
||||||
|
>
|
||||||
|
{i18n('icu:Preferences__button--manage')}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</FlowingControl>
|
||||||
|
</SettingsRow>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderLocalBackups() {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<SettingsRow
|
||||||
|
className="Preferences--BackupsRow"
|
||||||
|
title={i18n('icu:Preferences__backup-other-ways')}
|
||||||
|
>
|
||||||
|
<FlowingControl>
|
||||||
|
<div className="Preferences__two-thirds-flow">
|
||||||
|
<LightIconLabel icon="Preferences__LocalBackupsIcon">
|
||||||
|
<label>
|
||||||
|
{i18n('icu:Preferences__local-backups')}{' '}
|
||||||
<div className="Preferences__description">
|
<div className="Preferences__description">
|
||||||
{renderBackupsSubscriptionSummary({
|
{isLocalBackupsSetup
|
||||||
subscriptionStatus: backupSubscriptionStatus,
|
? null
|
||||||
i18n,
|
: i18n('icu:Preferences--local-backups-off-description')}
|
||||||
locale,
|
|
||||||
})}
|
|
||||||
</div>
|
</div>
|
||||||
</label>
|
</label>
|
||||||
</LightIconLabel>
|
</LightIconLabel>
|
||||||
|
@ -193,82 +252,61 @@ export function PreferencesBackups({
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<Button
|
<Button
|
||||||
onClick={() => setPage(SettingsPage.BackupsDetails)}
|
className="Preferences--BackupsAuthButton"
|
||||||
|
disabled={isAuthPending}
|
||||||
|
onClick={async () => {
|
||||||
|
setAuthError(undefined);
|
||||||
|
|
||||||
|
if (!isLocalBackupsSetup) {
|
||||||
|
try {
|
||||||
|
setIsAuthPending(true);
|
||||||
|
const result = await promptOSAuth('enable-backups');
|
||||||
|
if (result !== 'success' && result !== 'unsupported') {
|
||||||
|
setAuthError(result);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
setIsAuthPending(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setPage(SettingsPage.LocalBackups);
|
||||||
|
}}
|
||||||
variant={ButtonVariant.Secondary}
|
variant={ButtonVariant.Secondary}
|
||||||
>
|
>
|
||||||
{i18n('icu:Preferences__button--manage')}
|
{isLocalBackupsSetup
|
||||||
|
? i18n('icu:Preferences__button--manage')
|
||||||
|
: i18n('icu:Preferences__button--set-up')}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</FlowingControl>
|
</FlowingControl>
|
||||||
</SettingsRow>
|
</SettingsRow>
|
||||||
)}
|
|
||||||
|
|
||||||
<SettingsRow
|
{authError && (
|
||||||
className="Preferences--BackupsRow"
|
<ConfirmationDialog
|
||||||
title={i18n('icu:Preferences__backup-other-ways')}
|
i18n={i18n}
|
||||||
>
|
dialogName="PreferencesLocalBackups--ErrorDialog"
|
||||||
<FlowingControl>
|
onClose={() => setAuthError(undefined)}
|
||||||
<div className="Preferences__two-thirds-flow">
|
cancelButtonVariant={ButtonVariant.Secondary}
|
||||||
<LightIconLabel icon="Preferences__LocalBackupsIcon">
|
cancelText={i18n('icu:ok')}
|
||||||
<label>
|
|
||||||
{i18n('icu:Preferences__local-backups')}{' '}
|
|
||||||
<div className="Preferences__description">
|
|
||||||
{isLocalBackupsSetup
|
|
||||||
? null
|
|
||||||
: i18n('icu:Preferences--local-backups-off-description')}
|
|
||||||
</div>
|
|
||||||
</label>
|
|
||||||
</LightIconLabel>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
className={classNames(
|
|
||||||
'Preferences__flow-button',
|
|
||||||
'Preferences__one-third-flow',
|
|
||||||
'Preferences__one-third-flow--align-right'
|
|
||||||
)}
|
|
||||||
>
|
>
|
||||||
<Button
|
{getOSAuthErrorString(authError) ?? i18n('icu:error')}
|
||||||
className="Preferences--BackupsAuthButton"
|
</ConfirmationDialog>
|
||||||
disabled={isAuthPending}
|
)}
|
||||||
onClick={async () => {
|
</>
|
||||||
setAuthError(undefined);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (!isLocalBackupsSetup) {
|
return (
|
||||||
try {
|
<>
|
||||||
setIsAuthPending(true);
|
<div className="Preferences__padding">
|
||||||
const result = await promptOSAuth('enable-backups');
|
<div className="Preferences__description Preferences__description--medium">
|
||||||
if (result !== 'success' && result !== 'unsupported') {
|
{i18n('icu:Preferences--backup-section-description')}
|
||||||
setAuthError(result);
|
</div>
|
||||||
return;
|
</div>
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
setIsAuthPending(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
setPage(SettingsPage.LocalBackups);
|
{isRemoteBackupsEnabled ? renderRemoteBackups() : null}
|
||||||
}}
|
{isLocalBackupsEnabled ? renderLocalBackups() : null}
|
||||||
variant={ButtonVariant.Secondary}
|
|
||||||
>
|
|
||||||
{isLocalBackupsSetup
|
|
||||||
? i18n('icu:Preferences__button--manage')
|
|
||||||
: i18n('icu:Preferences__button--set-up')}
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</FlowingControl>
|
|
||||||
</SettingsRow>
|
|
||||||
|
|
||||||
{authError && (
|
|
||||||
<ConfirmationDialog
|
|
||||||
i18n={i18n}
|
|
||||||
dialogName="PreferencesLocalBackups--ErrorDialog"
|
|
||||||
onClose={() => setAuthError(undefined)}
|
|
||||||
cancelButtonVariant={ButtonVariant.Secondary}
|
|
||||||
cancelText={i18n('icu:ok')}
|
|
||||||
>
|
|
||||||
{getOSAuthErrorString(authError) ?? i18n('icu:error')}
|
|
||||||
</ConfirmationDialog>
|
|
||||||
)}
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue