From 3bb1ca7825a0381ddd8dbe7f44f7dcf4a788b165 Mon Sep 17 00:00:00 2001 From: André Oliveira <37463445+SpecialAro@users.noreply.github.com> Date: Tue, 19 Jul 2022 12:52:31 +0100 Subject: Feature: Add Release Notes (#491) Co-authored-by: Vijay A Co-authored-by: Ricardo Cino --- src/containers/auth/AuthLayoutContainer.tsx | 1 + src/containers/auth/AuthReleaseNotesScreen.tsx | 107 +++++++++++++++++++++++++ 2 files changed, 108 insertions(+) create mode 100644 src/containers/auth/AuthReleaseNotesScreen.tsx (limited to 'src/containers/auth') diff --git a/src/containers/auth/AuthLayoutContainer.tsx b/src/containers/auth/AuthLayoutContainer.tsx index 8d31cfb48..6fc6713f1 100644 --- a/src/containers/auth/AuthLayoutContainer.tsx +++ b/src/containers/auth/AuthLayoutContainer.tsx @@ -49,6 +49,7 @@ class AuthLayoutContainer extends Component { appUpdateIsDownloaded={ app.updateStatus === app.updateStatusTypes.DOWNLOADED } + updateVersion={app.updateVersion} > diff --git a/src/containers/auth/AuthReleaseNotesScreen.tsx b/src/containers/auth/AuthReleaseNotesScreen.tsx new file mode 100644 index 000000000..c717529fa --- /dev/null +++ b/src/containers/auth/AuthReleaseNotesScreen.tsx @@ -0,0 +1,107 @@ +import { Component } from 'react'; +import { inject, observer } from 'mobx-react'; + +import { defineMessages, injectIntl } from 'react-intl'; +import Markdown from 'markdown-to-jsx'; +import { mdiArrowLeftCircle } from '@mdi/js'; +import { openExternalUrl } from '../../helpers/url-helpers'; +import Icon from '../../components/ui/icon'; +import { ferdiumVersion } from '../../environment-remote'; +import { + getFerdiumVersion, + getUpdateInfoFromGH, +} from '../../helpers/update-helpers'; + +const messages = defineMessages({ + headline: { + id: 'settings.releasenotes.headline', + defaultMessage: 'Release Notes', + }, +}); + +interface IProps { + intl: any; +} + +class AuthReleaseNotesScreen extends Component { + state = { + data: '', + }; + + constructor(props) { + super(props); + + this.state = { data: '' }; + } + + async componentDidMount() { + const { intl } = this.props; + + const data = await getUpdateInfoFromGH( + window.location.href, + ferdiumVersion, + intl, + ); + + this.setState({ + data, + }); + + for (const link of document.querySelectorAll('.releasenotes__body a')) { + link.addEventListener('click', this.handleClick.bind(this), false); + } + } + + handleClick(e) { + e.preventDefault(); + openExternalUrl(e.target.href); + } + + componentWillUnmount() { + document.removeEventListener( + 'click', + // eslint-disable-next-line unicorn/no-invalid-remove-event-listener + this.handleClick.bind(this), + false, + ); + } + + render() { + const { intl } = this.props; + + const { data } = this.state; + return ( +
+
+
+ + Ferdium {getFerdiumVersion(window.location.href, ferdiumVersion)}{' '} + {' | '} + + + {intl.formatMessage(messages.headline)} + +
+
+ {data} +
+
+ +
+
+
+ ); + } +} + +export default injectIntl<'intl', IProps>( + inject('stores', 'actions')(observer(AuthReleaseNotesScreen)), +); -- cgit v1.2.3-70-g09d2