[feature] Add logout button to sidebar (#48)
This one should probably be scrutinized a little more than my previous two. For example, I don't know why I needed to do this: https://codeberg.org/prplecake/masto-fe-standalone/src/commit/1a1f48ceaa544650a8b8f50f8fa4e8c7cdc44c12/app/javascript/flavours/glitch/features/ui/index.jsx#L152 ~~But, it appears to work.~~ It's live at https://masto-fe.compostintraining.club if you want to test it out. ~~Edit: it breaks stuff. Images don't load anymore...~~ Maybe that was just a network glitch... Fixes #21. Reviewed-on: https://codeberg.org/superseriousbusiness/masto-fe-standalone/pulls/48 Co-authored-by: prplecake <me@prplecake.com> Co-committed-by: prplecake <me@prplecake.com>
This commit is contained in:
@@ -1,14 +1,22 @@
|
||||
import { defineMessages, injectIntl } from 'react-intl';
|
||||
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import { openModal } from 'flavours/glitch/actions/modal';
|
||||
import { logOut } from 'flavours/glitch/utils/log_out';
|
||||
|
||||
import ColumnsArea from '../components/columns_area';
|
||||
|
||||
const messages = defineMessages({
|
||||
logoutMessage: { id: 'confirmations.logout.message', defaultMessage: 'Are you sure you want to log out?' },
|
||||
logoutConfirm: { id: 'confirmations.logout.confirm', defaultMessage: 'Log out' },
|
||||
});
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
columns: state.getIn(['settings', 'columns']),
|
||||
});
|
||||
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
const mapDispatchToProps = (dispatch, { intl }) => ({
|
||||
openSettings (e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
@@ -17,6 +25,17 @@ const mapDispatchToProps = dispatch => ({
|
||||
modalProps: {},
|
||||
}));
|
||||
},
|
||||
onLogout () {
|
||||
dispatch(openModal({
|
||||
modalType: 'CONFIRM',
|
||||
modalProps: {
|
||||
message: intl.formatMessage(messages.logoutMessage),
|
||||
confirm: intl.formatMessage(messages.logoutConfirm),
|
||||
closeWhenConfirm: false,
|
||||
onConfirm: () => logOut(),
|
||||
},
|
||||
}));
|
||||
},
|
||||
});
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps, null, { forwardRef: true })(ColumnsArea);
|
||||
export default injectIntl(connect(mapStateToProps, mapDispatchToProps, null, { forwardRef: true })(ColumnsArea));
|
||||
|
||||
Reference in New Issue
Block a user