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.
32 lines
989 B
32 lines
989 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
|
|
||
7 years ago
|
export default class ColumnBackButtonSlim 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 = () => {
|
||
7 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 (
|
||
8 years ago
|
<div className='column-back-button--slim'>
|
||
8 years ago
|
<div role='button' tabIndex='0' onClick={this.handleClick} className='column-back-button column-back-button--slim-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' />
|
||
|
</div>
|
||
|
</div>
|
||
|
);
|
||
|
}
|
||
8 years ago
|
|
||
8 years ago
|
}
|