-
Notifications
You must be signed in to change notification settings - Fork 993
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<div class="tab-pane" id="jwt_tokens"> | ||
<%= react_component('JwtTokens', { | ||
userId: @user.id, | ||
}) %> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import React, { Fragment } from 'react'; | ||
import { Button } from '@patternfly/react-core'; | ||
import { KeyIcon } from '@patternfly/react-icons'; | ||
import { useDispatch } from 'react-redux'; | ||
import PropTypes from 'prop-types'; | ||
import { useAPI } from '../../../common/hooks/API/APIHooks'; | ||
import { openConfirmModal } from '../../ConfirmModal'; | ||
import { APIActions } from '../../../redux/API'; | ||
Check failure on line 8 in webpack/assets/javascripts/react_app/components/users/JwtTokens/JwtTokens.js GitHub Actions / test (13, 3.0, 18)
Check failure on line 8 in webpack/assets/javascripts/react_app/components/users/JwtTokens/JwtTokens.js GitHub Actions / test (13, 3.0, 14)
Check failure on line 8 in webpack/assets/javascripts/react_app/components/users/JwtTokens/JwtTokens.js GitHub Actions / test (13, 2.7, 18)
|
||
import { translate as __ } from '../../../common/I18n'; | ||
|
||
const JwtTokens = ({ userId }) => { | ||
const dispatch = useDispatch(); | ||
return ( | ||
<Fragment> | ||
<table className="table table-bordered table-striped table-hover table-fixed"> | ||
<tbody> | ||
<tr> | ||
<td className="blank-slate-pf"> | ||
<div className="blank-slate-pf-icon"> | ||
<KeyIcon type="fa" name="key" color="#9c9c9c" /> | ||
</div> | ||
<h1>{__('JWT Tokens')}</h1> | ||
<p> | ||
{__( | ||
'By invalidating your JSON Web Tokens (JWTs), you will no longer be able to register hosts by using your existing JWTs.' | ||
)} | ||
</p> | ||
<Button | ||
ouiaId="invalidate-jwt-token-button" | ||
variant="primary" | ||
isSmall | ||
onClick={() => | ||
dispatch( | ||
openConfirmModal({ | ||
isWarning: true, | ||
title: __('Invalidate tokens for self?'), | ||
confirmButtonText: __('Confirm'), | ||
onConfirm: () => | ||
useAPI('patch', `/users/${userId}/invalidate_jwt`, { | ||
Check failure on line 39 in webpack/assets/javascripts/react_app/components/users/JwtTokens/JwtTokens.js GitHub Actions / test (13, 3.0, 18)
Check failure on line 39 in webpack/assets/javascripts/react_app/components/users/JwtTokens/JwtTokens.js GitHub Actions / test (13, 3.0, 14)
Check failure on line 39 in webpack/assets/javascripts/react_app/components/users/JwtTokens/JwtTokens.js GitHub Actions / test (13, 2.7, 18)
Check failure on line 39 in webpack/assets/javascripts/react_app/components/users/JwtTokens/JwtTokens.js GitHub Actions / test (13, 2.7, 14)
|
||
successToast: () => | ||
__('Successfully Invalidated JWTs'), | ||
}), | ||
}) | ||
) | ||
} | ||
> | ||
{__('Invalidate JWTs')} | ||
</Button> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</Fragment> | ||
); | ||
}; | ||
|
||
JwtTokens.propTypes = { | ||
userId: PropTypes.string.isRequired, | ||
}; | ||
|
||
export default JwtTokens; |