2019-04-09 11:05:20 +00:00
|
|
|
// @flow
|
2017-10-02 23:08:07 +00:00
|
|
|
|
2017-03-09 00:16:53 +00:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
|
2020-06-04 14:09:13 +00:00
|
|
|
import { reloadNow } from '../../../app/actions';
|
2019-04-09 11:05:20 +00:00
|
|
|
import { translate } from '../../../base/i18n';
|
|
|
|
import { connect } from '../../../base/redux';
|
2017-03-09 00:16:53 +00:00
|
|
|
|
|
|
|
/**
|
2018-10-30 05:02:23 +00:00
|
|
|
* The type of the React {@code Component} props of {@link ReloadButton}.
|
2017-03-09 00:16:53 +00:00
|
|
|
*/
|
2018-10-30 05:02:23 +00:00
|
|
|
type Props = {
|
|
|
|
|
2017-03-09 00:16:53 +00:00
|
|
|
/**
|
2018-10-30 05:02:23 +00:00
|
|
|
* Reloads the page.
|
2017-03-09 00:16:53 +00:00
|
|
|
*/
|
2018-10-30 05:02:23 +00:00
|
|
|
_reloadNow: Function,
|
2017-05-31 05:31:00 +00:00
|
|
|
|
2018-10-30 05:02:23 +00:00
|
|
|
/**
|
|
|
|
* The function to translate human-readable text.
|
|
|
|
*/
|
|
|
|
t: Function,
|
2017-03-09 00:16:53 +00:00
|
|
|
|
2018-10-30 05:02:23 +00:00
|
|
|
/**
|
|
|
|
* The translation key for the text in the button.
|
|
|
|
*/
|
|
|
|
textKey: string
|
|
|
|
};
|
2017-03-09 00:16:53 +00:00
|
|
|
|
2018-10-30 05:02:23 +00:00
|
|
|
/**
|
|
|
|
* Implements a React Component for button for the overlays that will reload
|
|
|
|
* the page.
|
|
|
|
*/
|
|
|
|
class ReloadButton extends Component<Props> {
|
2017-03-09 00:16:53 +00:00
|
|
|
/**
|
|
|
|
* Renders the button for relaod the page if necessary.
|
|
|
|
*
|
|
|
|
* @private
|
2017-05-31 05:24:34 +00:00
|
|
|
* @returns {ReactElement}
|
2017-03-09 00:16:53 +00:00
|
|
|
*/
|
|
|
|
render() {
|
|
|
|
const className
|
|
|
|
= 'button-control button-control_overlay button-control_center';
|
|
|
|
|
|
|
|
/* eslint-disable react/jsx-handler-names */
|
|
|
|
|
|
|
|
return (
|
|
|
|
<button
|
|
|
|
className = { className }
|
2017-05-31 05:31:00 +00:00
|
|
|
onClick = { this.props._reloadNow }>
|
|
|
|
{ this.props.t(this.props.textKey) }
|
2017-03-09 00:16:53 +00:00
|
|
|
</button>
|
|
|
|
);
|
|
|
|
|
|
|
|
/* eslint-enable react/jsx-handler-names */
|
|
|
|
}
|
2017-05-31 05:24:34 +00:00
|
|
|
}
|
2017-03-09 00:16:53 +00:00
|
|
|
|
2017-05-31 05:31:00 +00:00
|
|
|
/**
|
|
|
|
* Maps part of redux actions to component's props.
|
|
|
|
*
|
|
|
|
* @param {Function} dispatch - Redux's {@code dispatch} function.
|
|
|
|
* @private
|
|
|
|
* @returns {Object}
|
|
|
|
*/
|
|
|
|
function _mapDispatchToProps(dispatch: Function): Object {
|
|
|
|
return {
|
|
|
|
/**
|
|
|
|
* Dispatches the redux action to reload the page.
|
|
|
|
*
|
|
|
|
* @protected
|
|
|
|
* @returns {Object} Dispatched action.
|
|
|
|
*/
|
|
|
|
_reloadNow() {
|
2018-07-02 21:22:51 +00:00
|
|
|
dispatch(reloadNow());
|
2017-05-31 05:31:00 +00:00
|
|
|
}
|
|
|
|
};
|
2017-03-09 00:16:53 +00:00
|
|
|
}
|
|
|
|
|
2017-05-31 05:31:00 +00:00
|
|
|
export default translate(connect(undefined, _mapDispatchToProps)(ReloadButton));
|