aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/AppUpdateInfoBar.js
blob: 4fb3a8b714f485243fcd980a7d249949ddca7595 (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
61
62
63
64
65
66
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { defineMessages, intlShape } from 'react-intl';

import { announcementActions } from '../features/announcements/actions';
import InfoBar from './ui/InfoBar';

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

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

  static defaultProps = {
    nextAppReleaseVersion: null,
  };

  static contextTypes = {
    intl: intlShape,
  };

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

    return (
      <InfoBar
        type="primary"
        ctaLabel={intl.formatMessage(messages.buttonInstallUpdate)}
        onClick={onInstallUpdate}
        sticky
      >
        <span className="mdi mdi-information" />
        {intl.formatMessage(messages.updateAvailable)}
        {' '}
        <button
          className="info-bar__inline-button"
          type="button"
          onClick={() => announcementActions.show({ targetVersion: nextAppReleaseVersion })}
        >
          <u>{intl.formatMessage(messages.changelog)}</u>
        </button>
      </InfoBar>
    );
  }
}

export default AppUpdateInfoBar;