2023-01-03 19:55:46 +00:00
|
|
|
// Copyright 2020 Signal Messenger, LLC
|
2021-08-19 22:56:29 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
import formatFileSize from 'filesize';
|
|
|
|
|
2021-11-11 22:46:16 +00:00
|
|
|
import { isBeta } from '../util/version';
|
2021-08-19 22:56:29 +00:00
|
|
|
import { DialogType } from '../types/Dialogs';
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { LocalizerType } from '../types/Util';
|
2023-03-20 20:42:00 +00:00
|
|
|
import { PRODUCTION_DOWNLOAD_URL, BETA_DOWNLOAD_URL } from '../types/support';
|
2021-09-17 22:20:49 +00:00
|
|
|
import { Intl } from './Intl';
|
|
|
|
import { LeftPaneDialog } from './LeftPaneDialog';
|
2021-10-12 23:59:08 +00:00
|
|
|
import type { WidthBreakpoint } from './_util';
|
2021-08-19 22:56:29 +00:00
|
|
|
|
|
|
|
export type PropsType = {
|
2021-10-12 23:59:08 +00:00
|
|
|
containerWidthBreakpoint: WidthBreakpoint;
|
2021-08-19 22:56:29 +00:00
|
|
|
dialogType: DialogType;
|
|
|
|
dismissDialog: () => void;
|
|
|
|
downloadSize?: number;
|
|
|
|
downloadedSize?: number;
|
|
|
|
i18n: LocalizerType;
|
|
|
|
snoozeUpdate: () => void;
|
|
|
|
startUpdate: () => void;
|
|
|
|
version?: string;
|
2021-11-11 22:46:16 +00:00
|
|
|
currentVersion: string;
|
2021-08-19 22:56:29 +00:00
|
|
|
};
|
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function DialogUpdate({
|
2021-10-12 23:59:08 +00:00
|
|
|
containerWidthBreakpoint,
|
2021-08-19 22:56:29 +00:00
|
|
|
dialogType,
|
|
|
|
dismissDialog,
|
|
|
|
downloadSize,
|
|
|
|
downloadedSize,
|
|
|
|
i18n,
|
|
|
|
snoozeUpdate,
|
|
|
|
startUpdate,
|
|
|
|
version,
|
2021-11-11 22:46:16 +00:00
|
|
|
currentVersion,
|
2022-11-18 00:45:19 +00:00
|
|
|
}: PropsType): JSX.Element | null {
|
2021-08-19 22:56:29 +00:00
|
|
|
if (dialogType === DialogType.Cannot_Update) {
|
2021-11-11 22:46:16 +00:00
|
|
|
const url = isBeta(currentVersion)
|
|
|
|
? BETA_DOWNLOAD_URL
|
|
|
|
: PRODUCTION_DOWNLOAD_URL;
|
2021-08-19 22:56:29 +00:00
|
|
|
return (
|
2021-10-12 23:59:08 +00:00
|
|
|
<LeftPaneDialog
|
|
|
|
containerWidthBreakpoint={containerWidthBreakpoint}
|
|
|
|
type="warning"
|
2023-03-30 00:03:25 +00:00
|
|
|
title={i18n('icu:cannotUpdate')}
|
2021-10-12 23:59:08 +00:00
|
|
|
>
|
2021-09-17 22:20:49 +00:00
|
|
|
<span>
|
|
|
|
<Intl
|
2022-02-02 21:13:56 +00:00
|
|
|
components={{
|
|
|
|
retry: (
|
|
|
|
<button
|
|
|
|
className="LeftPaneDialog__retry"
|
|
|
|
key="signal-retry"
|
|
|
|
onClick={startUpdate}
|
|
|
|
type="button"
|
|
|
|
>
|
2023-03-30 00:03:25 +00:00
|
|
|
{i18n('icu:autoUpdateRetry')}
|
2022-02-02 21:13:56 +00:00
|
|
|
</button>
|
|
|
|
),
|
|
|
|
url: (
|
|
|
|
<a
|
|
|
|
key="signal-download"
|
|
|
|
href={url}
|
|
|
|
rel="noreferrer"
|
|
|
|
target="_blank"
|
|
|
|
>
|
|
|
|
{url}
|
|
|
|
</a>
|
|
|
|
),
|
|
|
|
support: (
|
|
|
|
<a
|
|
|
|
key="signal-support"
|
|
|
|
href="https://support.signal.org/hc/en-us/requests/new?desktop"
|
|
|
|
rel="noreferrer"
|
|
|
|
target="_blank"
|
|
|
|
>
|
2023-03-30 00:03:25 +00:00
|
|
|
{i18n('icu:autoUpdateContactSupport')}
|
2022-02-02 21:13:56 +00:00
|
|
|
</a>
|
|
|
|
),
|
|
|
|
}}
|
2021-09-17 22:20:49 +00:00
|
|
|
i18n={i18n}
|
2023-03-30 00:03:25 +00:00
|
|
|
id="icu:cannotUpdateDetail"
|
2021-09-17 22:20:49 +00:00
|
|
|
/>
|
|
|
|
</span>
|
|
|
|
</LeftPaneDialog>
|
2021-08-19 22:56:29 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-04-06 18:27:17 +00:00
|
|
|
if (dialogType === DialogType.Cannot_Update_Require_Manual) {
|
|
|
|
const url = isBeta(currentVersion)
|
|
|
|
? BETA_DOWNLOAD_URL
|
|
|
|
: PRODUCTION_DOWNLOAD_URL;
|
|
|
|
return (
|
|
|
|
<LeftPaneDialog
|
|
|
|
containerWidthBreakpoint={containerWidthBreakpoint}
|
|
|
|
type="warning"
|
2023-03-30 00:03:25 +00:00
|
|
|
title={i18n('icu:cannotUpdate')}
|
2022-04-06 18:27:17 +00:00
|
|
|
>
|
|
|
|
<span>
|
|
|
|
<Intl
|
|
|
|
components={{
|
|
|
|
url: (
|
|
|
|
<a
|
|
|
|
key="signal-download"
|
|
|
|
href={url}
|
|
|
|
rel="noreferrer"
|
|
|
|
target="_blank"
|
|
|
|
>
|
|
|
|
{url}
|
|
|
|
</a>
|
|
|
|
),
|
|
|
|
support: (
|
|
|
|
<a
|
|
|
|
key="signal-support"
|
|
|
|
href="https://support.signal.org/hc/en-us/requests/new?desktop"
|
|
|
|
rel="noreferrer"
|
|
|
|
target="_blank"
|
|
|
|
>
|
2023-03-30 00:03:25 +00:00
|
|
|
{i18n('icu:autoUpdateContactSupport')}
|
2022-04-06 18:27:17 +00:00
|
|
|
</a>
|
|
|
|
),
|
|
|
|
}}
|
|
|
|
i18n={i18n}
|
2023-03-30 00:03:25 +00:00
|
|
|
id="icu:cannotUpdateRequireManualDetail"
|
2022-04-06 18:27:17 +00:00
|
|
|
/>
|
|
|
|
</span>
|
|
|
|
</LeftPaneDialog>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-08-19 22:56:29 +00:00
|
|
|
if (dialogType === DialogType.MacOS_Read_Only) {
|
|
|
|
return (
|
2021-09-17 22:20:49 +00:00
|
|
|
<LeftPaneDialog
|
2023-03-30 00:03:25 +00:00
|
|
|
closeLabel={i18n('icu:close')}
|
2021-10-12 23:59:08 +00:00
|
|
|
containerWidthBreakpoint={containerWidthBreakpoint}
|
2021-09-17 22:20:49 +00:00
|
|
|
hasXButton
|
|
|
|
onClose={dismissDialog}
|
2023-03-30 00:03:25 +00:00
|
|
|
title={i18n('icu:cannotUpdate')}
|
2022-02-02 21:13:56 +00:00
|
|
|
type="warning"
|
2021-09-17 22:20:49 +00:00
|
|
|
>
|
|
|
|
<span>
|
|
|
|
<Intl
|
|
|
|
components={{
|
|
|
|
app: <strong key="app">Signal.app</strong>,
|
|
|
|
folder: <strong key="folder">/Applications</strong>,
|
|
|
|
}}
|
|
|
|
i18n={i18n}
|
2023-03-30 00:03:25 +00:00
|
|
|
id="icu:readOnlyVolume"
|
2021-08-19 22:56:29 +00:00
|
|
|
/>
|
2021-09-17 22:20:49 +00:00
|
|
|
</span>
|
|
|
|
</LeftPaneDialog>
|
2021-08-19 22:56:29 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-01-18 23:31:10 +00:00
|
|
|
if (dialogType === DialogType.UnsupportedOS) {
|
|
|
|
// Displayed as UnsupportedOSDialog in LeftPane
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2021-09-17 22:20:49 +00:00
|
|
|
const versionTitle = version
|
2023-03-30 00:03:25 +00:00
|
|
|
? i18n('icu:DialogUpdate--version-available', {
|
2023-03-27 23:37:39 +00:00
|
|
|
version,
|
|
|
|
})
|
2021-09-17 22:20:49 +00:00
|
|
|
: undefined;
|
|
|
|
|
|
|
|
if (dialogType === DialogType.Downloading) {
|
2021-08-19 22:56:29 +00:00
|
|
|
const width = Math.ceil(
|
|
|
|
((downloadedSize || 1) / (downloadSize || 1)) * 100
|
|
|
|
);
|
|
|
|
|
2021-09-17 22:20:49 +00:00
|
|
|
return (
|
2021-10-12 23:59:08 +00:00
|
|
|
<LeftPaneDialog
|
|
|
|
containerWidthBreakpoint={containerWidthBreakpoint}
|
|
|
|
icon="update"
|
2023-03-15 16:57:27 +00:00
|
|
|
title={i18n('icu:DialogUpdate__downloading')}
|
2021-10-12 23:59:08 +00:00
|
|
|
hoverText={versionTitle}
|
|
|
|
>
|
2021-09-17 22:20:49 +00:00
|
|
|
<div className="LeftPaneDialog__progress--container">
|
|
|
|
<div
|
|
|
|
className="LeftPaneDialog__progress--bar"
|
2022-11-23 20:13:13 +00:00
|
|
|
style={{ transform: `translateX(${width - 100}%)` }}
|
2021-09-17 22:20:49 +00:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</LeftPaneDialog>
|
2021-08-19 22:56:29 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-03-30 00:03:25 +00:00
|
|
|
let title = i18n('icu:autoUpdateNewVersionTitle');
|
2023-03-15 16:57:27 +00:00
|
|
|
|
|
|
|
if (
|
|
|
|
downloadSize &&
|
|
|
|
(dialogType === DialogType.DownloadReady ||
|
|
|
|
dialogType === DialogType.FullDownloadReady)
|
|
|
|
) {
|
|
|
|
title += ` (${formatFileSize(downloadSize, { round: 0 })})`;
|
|
|
|
}
|
|
|
|
|
2023-03-30 00:03:25 +00:00
|
|
|
let clickLabel = i18n('icu:autoUpdateNewVersionMessage');
|
2022-02-25 18:44:03 +00:00
|
|
|
let type: 'warning' | undefined;
|
2021-09-17 22:20:49 +00:00
|
|
|
if (dialogType === DialogType.DownloadReady) {
|
2023-03-30 00:03:25 +00:00
|
|
|
clickLabel = i18n('icu:downloadNewVersionMessage');
|
2022-02-25 18:44:03 +00:00
|
|
|
} else if (dialogType === DialogType.FullDownloadReady) {
|
2023-03-30 00:03:25 +00:00
|
|
|
clickLabel = i18n('icu:downloadFullNewVersionMessage');
|
2022-02-25 18:44:03 +00:00
|
|
|
type = 'warning';
|
2023-03-15 16:57:27 +00:00
|
|
|
} else if (dialogType === DialogType.DownloadedUpdate) {
|
|
|
|
title = i18n('icu:DialogUpdate__downloaded');
|
2021-09-17 22:20:49 +00:00
|
|
|
}
|
2021-08-19 22:56:29 +00:00
|
|
|
|
|
|
|
return (
|
2021-09-17 22:20:49 +00:00
|
|
|
<LeftPaneDialog
|
2021-10-12 23:59:08 +00:00
|
|
|
containerWidthBreakpoint={containerWidthBreakpoint}
|
2021-09-17 22:20:49 +00:00
|
|
|
icon="update"
|
2022-02-25 18:44:03 +00:00
|
|
|
type={type}
|
2021-09-17 22:20:49 +00:00
|
|
|
title={title}
|
|
|
|
hoverText={versionTitle}
|
|
|
|
hasAction
|
|
|
|
onClick={startUpdate}
|
|
|
|
clickLabel={clickLabel}
|
|
|
|
hasXButton
|
|
|
|
onClose={snoozeUpdate}
|
2023-03-30 00:03:25 +00:00
|
|
|
closeLabel={i18n('icu:autoUpdateIgnoreButtonLabel')}
|
2021-09-17 22:20:49 +00:00
|
|
|
/>
|
2021-08-19 22:56:29 +00:00
|
|
|
);
|
2022-11-18 00:45:19 +00:00
|
|
|
}
|