PLT-6987 User access token UI (#7007)
* Add user access token UI * Fix enter press and update mattermost-redux * Updating UI for access token stuff (#7066) * Revert segment key
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
4ef844298f
Коммит
5da5c0bbfb
24
webapp/components/admin_console/revoke_token_button/index.js
Обычный файл
24
webapp/components/admin_console/revoke_token_button/index.js
Обычный файл
@@ -0,0 +1,24 @@
|
||||
// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import {connect} from 'react-redux';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import {revokeUserAccessToken} from 'mattermost-redux/actions/users';
|
||||
|
||||
import RevokeTokenButton from './revoke_token_button.jsx';
|
||||
|
||||
function mapStateToProps(state, ownProps) {
|
||||
return {
|
||||
...ownProps
|
||||
};
|
||||
}
|
||||
|
||||
function mapDispatchToProps(dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators({
|
||||
revokeUserAccessToken
|
||||
}, dispatch)
|
||||
};
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(RevokeTokenButton);
|
||||
@@ -0,0 +1,56 @@
|
||||
// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import {FormattedMessage} from 'react-intl';
|
||||
|
||||
import {trackEvent} from 'actions/diagnostics_actions.jsx';
|
||||
|
||||
export default class RevokeTokenButton extends React.PureComponent {
|
||||
static propTypes = {
|
||||
|
||||
/*
|
||||
* Token id to revoke
|
||||
*/
|
||||
tokenId: PropTypes.string.isRequired,
|
||||
|
||||
/*
|
||||
* Function to call on error
|
||||
*/
|
||||
onError: PropTypes.func.isRequired,
|
||||
|
||||
actions: PropTypes.shape({
|
||||
|
||||
/**
|
||||
* Function to revoke a user access token
|
||||
*/
|
||||
revokeUserAccessToken: PropTypes.func.isRequired
|
||||
}).isRequired
|
||||
};
|
||||
|
||||
handleClick = async (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
const {error} = await this.props.actions.revokeUserAccessToken(this.props.tokenId);
|
||||
trackEvent('system_console', 'revoke_user_access_token');
|
||||
|
||||
if (error) {
|
||||
this.props.onError(error.message);
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<button
|
||||
className='btn btn-danger'
|
||||
onClick={this.handleClick}
|
||||
>
|
||||
<FormattedMessage
|
||||
id='admin.revoke_token_button.delete'
|
||||
defaultMessage='Delete'
|
||||
/>
|
||||
</button>
|
||||
);
|
||||
}
|
||||
}
|
||||
Ссылка в новой задаче
Block a user