2018-04-25 03:29:34 +00:00
|
|
|
import React from 'react';
|
|
|
|
import translate, { translateRaw } from 'translations';
|
|
|
|
import Modal, { IButton } from 'components/ui/Modal';
|
2018-05-14 17:06:04 +00:00
|
|
|
import { getLatestElectronRelease } from 'utils/versioning';
|
|
|
|
import { VERSION } from 'config/data';
|
2018-04-25 03:29:34 +00:00
|
|
|
|
|
|
|
interface State {
|
|
|
|
isOpen: boolean;
|
2018-05-14 17:06:04 +00:00
|
|
|
newRelease?: string;
|
2018-04-25 03:29:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export default class NewAppReleaseModal extends React.Component<{}, State> {
|
|
|
|
public state: State = {
|
|
|
|
isOpen: false
|
|
|
|
};
|
|
|
|
|
|
|
|
public async componentDidMount() {
|
|
|
|
try {
|
2018-05-14 17:06:04 +00:00
|
|
|
const newRelease = await getLatestElectronRelease();
|
|
|
|
if (newRelease) {
|
|
|
|
this.setState({ isOpen: true, newRelease });
|
2018-04-25 03:29:34 +00:00
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
console.error('Failed to fetch latest release from GitHub:', err);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public render() {
|
|
|
|
const { isOpen } = this.state;
|
|
|
|
const buttons: IButton[] = [
|
|
|
|
{
|
|
|
|
text: translate('APP_UPDATE_CONFIRM'),
|
|
|
|
type: 'primary',
|
|
|
|
onClick: this.openRelease
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: translate('APP_UPDATE_CANCEL'),
|
|
|
|
type: 'default',
|
|
|
|
onClick: this.close
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Modal
|
|
|
|
title={translateRaw('APP_UPDATE_TITLE')}
|
|
|
|
isOpen={isOpen}
|
|
|
|
buttons={buttons}
|
|
|
|
handleClose={this.close}
|
|
|
|
maxWidth={520}
|
|
|
|
>
|
2018-05-14 17:06:04 +00:00
|
|
|
<h4>
|
|
|
|
{translateRaw('APP_UPDATE_BODY')} {this.versionCompareStr()}
|
|
|
|
</h4>
|
2018-04-25 03:29:34 +00:00
|
|
|
</Modal>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-05-14 17:06:04 +00:00
|
|
|
private versionCompareStr() {
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<h5>Current Version: {VERSION}</h5>
|
|
|
|
<h5>New Version: {this.state.newRelease}</h5>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-04-25 03:29:34 +00:00
|
|
|
private close = () => {
|
|
|
|
this.setState({ isOpen: false });
|
|
|
|
};
|
|
|
|
|
|
|
|
private openRelease() {
|
|
|
|
window.open('https://github.com/MyCryptoHQ/MyCrypto/releases/latest');
|
|
|
|
}
|
|
|
|
}
|