You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
862 B
30 lines
862 B
8 years ago
|
import React from 'react';
|
||
8 years ago
|
import { FormattedMessage } from 'react-intl';
|
||
8 years ago
|
import PropTypes from 'prop-types';
|
||
8 years ago
|
|
||
8 years ago
|
export default class ColumnBackButton extends React.PureComponent {
|
||
8 years ago
|
|
||
8 years ago
|
static contextTypes = {
|
||
8 years ago
|
router: PropTypes.object,
|
||
8 years ago
|
};
|
||
8 years ago
|
|
||
8 years ago
|
handleClick = () => {
|
||
8 years ago
|
// if history is exhausted, or we would leave mastodon, just go to root.
|
||
|
if (window.history && (window.history.length === 1 || window.history.length === window._mastoInitialHistoryLen)) {
|
||
|
this.context.router.history.push('/');
|
||
|
} else {
|
||
|
this.context.router.history.goBack();
|
||
|
}
|
||
8 years ago
|
}
|
||
8 years ago
|
|
||
|
render () {
|
||
|
return (
|
||
7 years ago
|
<button onClick={this.handleClick} className='column-back-button'>
|
||
8 years ago
|
<i className='fa fa-fw fa-chevron-left column-back-button__icon' />
|
||
8 years ago
|
<FormattedMessage id='column_back_button.label' defaultMessage='Back' />
|
||
7 years ago
|
</button>
|
||
8 years ago
|
);
|
||
|
}
|
||
|
|
||
8 years ago
|
}
|