mirror of
https://github.com/strapi/strapi.git
synced 2025-12-29 08:04:51 +00:00
add tokenType to the willDeleteToken event inside the DeleteButton in ApiTokens and TransferTokens
This commit is contained in:
parent
3182bba15c
commit
5c2cd8c938
@ -6,7 +6,7 @@ import { stopPropagation, useTracking } from '@strapi/helper-plugin';
|
||||
import { useIntl } from 'react-intl';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
const DeleteButton = ({ tokenName, onClickDelete }) => {
|
||||
const DeleteButton = ({ tokenName, onClickDelete, tokenType }) => {
|
||||
const { formatMessage } = useIntl();
|
||||
const { trackUsage } = useTracking(); // TODO: Track different types of tokens
|
||||
|
||||
@ -14,7 +14,9 @@ const DeleteButton = ({ tokenName, onClickDelete }) => {
|
||||
<Box paddingLeft={1} {...stopPropagation}>
|
||||
<IconButton
|
||||
onClick={() => {
|
||||
trackUsage('willDeleteToken');
|
||||
trackUsage('willDeleteToken', {
|
||||
tokenType,
|
||||
});
|
||||
onClickDelete();
|
||||
}}
|
||||
label={formatMessage(
|
||||
@ -35,6 +37,7 @@ const DeleteButton = ({ tokenName, onClickDelete }) => {
|
||||
DeleteButton.propTypes = {
|
||||
tokenName: PropTypes.string.isRequired,
|
||||
onClickDelete: PropTypes.func.isRequired,
|
||||
tokenType: PropTypes.string.isRequired,
|
||||
};
|
||||
|
||||
export default DeleteButton;
|
||||
|
||||
@ -16,7 +16,15 @@ import DeleteButton from './DeleteButton';
|
||||
import UpdateButton from './UpdateButton';
|
||||
import ReadButton from './ReadButton';
|
||||
|
||||
const Table = ({ permissions, headers, contentType, isLoading, tokens, onConfirmDelete }) => {
|
||||
const Table = ({
|
||||
permissions,
|
||||
headers,
|
||||
contentType,
|
||||
isLoading,
|
||||
tokens,
|
||||
onConfirmDelete,
|
||||
tokenType,
|
||||
}) => {
|
||||
const { canDelete, canUpdate, canRead } = permissions;
|
||||
const withBulkActions = canDelete || canUpdate || canRead;
|
||||
const [{ query }] = useQueryParams();
|
||||
@ -89,6 +97,7 @@ const Table = ({ permissions, headers, contentType, isLoading, tokens, onConfirm
|
||||
<DeleteButton
|
||||
tokenName={token.name}
|
||||
onClickDelete={() => onConfirmDelete(token.id)}
|
||||
tokenType={tokenType}
|
||||
/>
|
||||
)}
|
||||
</Flex>
|
||||
@ -123,6 +132,7 @@ Table.propTypes = {
|
||||
contentType: PropTypes.string.isRequired,
|
||||
isLoading: PropTypes.bool,
|
||||
onConfirmDelete: PropTypes.func,
|
||||
tokenType: PropTypes.string.isRequired,
|
||||
};
|
||||
|
||||
Table.defaultProps = {
|
||||
|
||||
@ -24,6 +24,7 @@ import Plus from '@strapi/icons/Plus';
|
||||
import adminPermissions from '../../../../../permissions';
|
||||
import tableHeaders from './utils/tableHeaders';
|
||||
import Table from '../../../components/Tokens/Table';
|
||||
import { API_TOKEN_TYPE } from '../../../components/Tokens/constants';
|
||||
|
||||
const ApiTokenListView = () => {
|
||||
useFocusWhenNavigate();
|
||||
@ -151,6 +152,7 @@ const ApiTokenListView = () => {
|
||||
isLoading={isLoading}
|
||||
onConfirmDelete={(id) => deleteMutation.mutateAsync(id)}
|
||||
tokens={apiTokens}
|
||||
tokenType={API_TOKEN_TYPE}
|
||||
/>
|
||||
)}
|
||||
{shouldDisplayNoContentWithCreationButton && (
|
||||
|
||||
@ -23,6 +23,7 @@ import Plus from '@strapi/icons/Plus';
|
||||
import adminPermissions from '../../../../../permissions';
|
||||
import tableHeaders from './utils/tableHeaders';
|
||||
import Table from '../../../components/Tokens/Table';
|
||||
import { TRANSFER_TOKEN_TYPE } from '../../../components/Tokens/constants';
|
||||
|
||||
const TransferTokenListView = () => {
|
||||
useFocusWhenNavigate();
|
||||
@ -148,6 +149,7 @@ const TransferTokenListView = () => {
|
||||
isLoading={isLoading}
|
||||
onConfirmDelete={(id) => deleteMutation.mutateAsync(id)}
|
||||
tokens={transferTokens}
|
||||
tokenType={TRANSFER_TOKEN_TYPE}
|
||||
/>
|
||||
)}
|
||||
{shouldDisplayNoContentWithCreationButton && (
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user