aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/AppUpdateInfoBar.js
blob: 47b730bde2e9b7960e8b99fb88ef92e1cfee71aa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { defineMessages, injectIntl } from 'react-intl';

import InfoBar from './ui/InfoBar';
import { GITHUB_FERDI_URL } from '../config';
import { openExternalUrl } from '../helpers/url-helpers';

const messages = defineMessages({
  updateAvailable: {
    id: 'infobar.updateAvailable',
    defaultMessage: 'A new update for Ferdi is available.',
  },
  changelog: {
    id: 'infobar.buttonChangelog',
    defaultMessage: 'What is new?',
  },
  buttonInstallUpdate: {
    id: 'infobar.buttonInstallUpdate',
    defaultMessage: 'Restart & install update',
  },
});

class AppUpdateInfoBar extends Component {
  static propTypes = {
    onInstallUpdate: PropTypes.func.isRequired,
    onHide: PropTypes.func.isRequired,
  };

  render() {
    const { intl } = this.props;
    const { onInstallUpdate, onHide } = this.props;

    return (
      <InfoBar
        type="primary"
        ctaLabel={intl.formatMessage(messages.buttonInstallUpdate)}
        onClick={onInstallUpdate}
        onHide={onHide}
      >
        <span className="mdi mdi-information" />
        {intl.formatMessage(messages.updateAvailable)}{' '}
        <button
          className="info-bar__inline-button"
          type="button"
          onClick={() =>
            openExternalUrl(
              `${GITHUB_FERDI_URL}/ferdi/blob/develop/CHANGELOG.md`,
              true,
            )
          }
        >
          <u>{intl.formatMessage(messages.changelog)}</u>
        </button>
      </InfoBar>
    );
  }
}

export default injectIntl(AppUpdateInfoBar);