Developers: add "Leave developers" button
This commit is contained in:
parent
3af8313b42
commit
ef49cf911c
1 changed files with 31 additions and 1 deletions
|
@ -1,19 +1,39 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
import { connect } from 'react-redux';
|
||||||
import { FormattedMessage, injectIntl, defineMessages } from 'react-intl';
|
import { FormattedMessage, injectIntl, defineMessages } from 'react-intl';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import Column from '../ui/components/column';
|
import Column from '../ui/components/column';
|
||||||
import Icon from 'soapbox/components/icon';
|
import Icon from 'soapbox/components/icon';
|
||||||
|
import { changeSetting } from 'soapbox/actions/settings';
|
||||||
|
import snackbar from 'soapbox/actions/snackbar';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
heading: { id: 'column.developers', defaultMessage: 'Developers' },
|
heading: { id: 'column.developers', defaultMessage: 'Developers' },
|
||||||
|
leave: { id: 'developers.leave', defaultMessage: 'You have left developers' },
|
||||||
});
|
});
|
||||||
|
|
||||||
export default @injectIntl
|
export default @connect()
|
||||||
|
@injectIntl
|
||||||
class DevelopersMenu extends React.Component {
|
class DevelopersMenu extends React.Component {
|
||||||
|
|
||||||
|
static contextTypes = {
|
||||||
|
router: PropTypes.object,
|
||||||
|
};
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
intl: PropTypes.object.isRequired,
|
intl: PropTypes.object.isRequired,
|
||||||
|
dispatch: PropTypes.func.isRequired,
|
||||||
|
}
|
||||||
|
|
||||||
|
leaveDevelopers = e => {
|
||||||
|
const { intl, dispatch } = this.props;
|
||||||
|
|
||||||
|
dispatch(changeSetting(['isDeveloper'], false));
|
||||||
|
dispatch(snackbar.success(intl.formatMessage(messages.leave)));
|
||||||
|
|
||||||
|
this.context.router.history.push('/');
|
||||||
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@ -52,6 +72,16 @@ class DevelopersMenu extends React.Component {
|
||||||
</div>
|
</div>
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
|
<div className='dashcounter'>
|
||||||
|
<a href='#' onClick={this.leaveDevelopers}>
|
||||||
|
<div className='dashcounter__icon'>
|
||||||
|
<Icon src={require('@tabler/icons/icons/logout.svg')} />
|
||||||
|
</div>
|
||||||
|
<div className='dashcounter__label'>
|
||||||
|
<FormattedMessage id='developers.navigation.leave_developers_label' defaultMessage='Leave developers' />
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Column>
|
</Column>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue