signal-desktop/ts/components/WhatsNewModal.tsx

122 lines
2.8 KiB
TypeScript
Raw Normal View History

2023-01-03 19:55:46 +00:00
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
2023-12-14 19:57:03 +00:00
import type { ReactNode } from 'react';
import React from 'react';
import moment from 'moment';
import { Modal } from './Modal';
import { Intl } from './Intl';
import type { LocalizerType } from '../types/Util';
export type PropsType = {
hideWhatsNewModal: () => unknown;
i18n: LocalizerType;
};
type ReleaseNotesType = {
date: Date;
version: string;
features: Array<JSX.Element>;
};
2023-12-14 19:57:03 +00:00
// Exported so it doesn't get marked unused
export function ExternalLink(props: {
href: string;
children: ReactNode;
}): JSX.Element {
return (
<a href={props.href} target="_blank" rel="noreferrer">
{props.children}
</a>
);
}
2022-11-18 00:45:19 +00:00
export function WhatsNewModal({
i18n,
hideWhatsNewModal,
2022-11-18 00:45:19 +00:00
}: PropsType): JSX.Element {
2023-12-14 19:57:03 +00:00
let contentNode: ReactNode;
const releaseNotes: ReleaseNotesType = {
date: new Date(window.getBuildCreation?.() || Date.now()),
version: window.getVersion?.(),
2023-11-08 23:39:44 +00:00
features: [
2023-12-14 19:57:03 +00:00
<Intl i18n={i18n} id="icu:WhatsNew__v6.43--0" />,
2023-11-30 20:07:45 +00:00
<Intl
i18n={i18n}
2023-12-14 19:57:03 +00:00
id="icu:WhatsNew__v6.43--1"
2023-11-30 20:07:45 +00:00
components={{
2023-12-07 01:39:30 +00:00
linkToGithub1: (
2023-12-14 19:57:03 +00:00
<ExternalLink href="https://github.com/MahdiNazemi">
@MahdiNazemi
</ExternalLink>
),
}}
/>,
<Intl
i18n={i18n}
id="icu:WhatsNew__v6.43--2"
components={{
linkToGithub1: (
<ExternalLink href="https://github.com/Shrinks99">
@Shrinks99
</ExternalLink>
),
}}
/>,
<Intl
i18n={i18n}
id="icu:WhatsNew__v6.43--3"
components={{
linkToGithub1: (
<ExternalLink href="https://github.com/NetSysFire">
@NetSysFire
</ExternalLink>
2023-12-07 01:39:30 +00:00
),
linkToGithub2: (
2023-12-14 19:57:03 +00:00
<ExternalLink href="https://github.com/timjamello">
@timjamello
</ExternalLink>
),
linkToGithub3: (
<ExternalLink href="https://github.com/u32i64">
@u32i64
</ExternalLink>
2023-11-30 20:07:45 +00:00
),
}}
/>,
2023-11-08 23:39:44 +00:00
],
};
if (releaseNotes.features.length === 1) {
contentNode = <p>{releaseNotes.features[0]}</p>;
} else {
contentNode = (
<ul>
{releaseNotes.features.map(element => {
return <li key={element.props.id}>{element}</li>;
})}
</ul>
);
}
return (
<Modal
2022-09-27 20:24:21 +00:00
modalName="WhatsNewModal"
hasXButton
i18n={i18n}
onClose={hideWhatsNewModal}
2023-03-30 00:03:25 +00:00
title={i18n('icu:WhatsNew__modal-title')}
>
<>
<span>
{moment(releaseNotes.date).format('LL')} &middot;{' '}
{releaseNotes.version}
</span>
{contentNode}
</>
</Modal>
);
2022-11-18 00:45:19 +00:00
}