1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-06-27 01:19:00 +02:00

chore: disable delete button if a context field has usage (#10002)

Blocks deletion of context fields from the UI if the context field has
any usage.

<img width="1399" alt="image"
src="https://github.com/user-attachments/assets/e6c26671-761b-4e54-9850-c505ba7b42f3"
/>
This commit is contained in:
Thomas Heartman 2025-05-15 13:55:56 +02:00 committed by GitHub
parent 082a03afd7
commit e09b839ac0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View File

@ -12,11 +12,13 @@ import { ActionCell } from 'component/common/Table/cells/ActionCell/ActionCell';
interface IContextActionsCellProps {
name: string;
onDelete: () => void;
allowDelete: boolean;
}
export const ContextActionsCell: VFC<IContextActionsCellProps> = ({
name,
onDelete,
allowDelete,
}) => {
const navigate = useNavigate();
@ -37,6 +39,7 @@ export const ContextActionsCell: VFC<IContextActionsCellProps> = ({
permission={DELETE_CONTEXT_FIELD}
onClick={onDelete}
data-loading
disabled={!allowDelete}
aria-label='delete'
tooltipProps={{
title: 'Delete context field',

View File

@ -97,7 +97,7 @@ const ContextList: VFC = () => {
align: 'center',
Cell: ({
row: {
original: { name },
original: { name, usedInFeatures },
},
}: any) => (
<ContextActionsCell
@ -106,6 +106,7 @@ const ContextList: VFC = () => {
setName(name);
setShowDelDialogue(true);
}}
allowDelete={usedInFeatures === 0}
/>
),
width: 150,