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:
parent
082a03afd7
commit
e09b839ac0
@ -12,11 +12,13 @@ import { ActionCell } from 'component/common/Table/cells/ActionCell/ActionCell';
|
|||||||
interface IContextActionsCellProps {
|
interface IContextActionsCellProps {
|
||||||
name: string;
|
name: string;
|
||||||
onDelete: () => void;
|
onDelete: () => void;
|
||||||
|
allowDelete: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ContextActionsCell: VFC<IContextActionsCellProps> = ({
|
export const ContextActionsCell: VFC<IContextActionsCellProps> = ({
|
||||||
name,
|
name,
|
||||||
onDelete,
|
onDelete,
|
||||||
|
allowDelete,
|
||||||
}) => {
|
}) => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
@ -37,6 +39,7 @@ export const ContextActionsCell: VFC<IContextActionsCellProps> = ({
|
|||||||
permission={DELETE_CONTEXT_FIELD}
|
permission={DELETE_CONTEXT_FIELD}
|
||||||
onClick={onDelete}
|
onClick={onDelete}
|
||||||
data-loading
|
data-loading
|
||||||
|
disabled={!allowDelete}
|
||||||
aria-label='delete'
|
aria-label='delete'
|
||||||
tooltipProps={{
|
tooltipProps={{
|
||||||
title: 'Delete context field',
|
title: 'Delete context field',
|
||||||
|
@ -97,7 +97,7 @@ const ContextList: VFC = () => {
|
|||||||
align: 'center',
|
align: 'center',
|
||||||
Cell: ({
|
Cell: ({
|
||||||
row: {
|
row: {
|
||||||
original: { name },
|
original: { name, usedInFeatures },
|
||||||
},
|
},
|
||||||
}: any) => (
|
}: any) => (
|
||||||
<ContextActionsCell
|
<ContextActionsCell
|
||||||
@ -106,6 +106,7 @@ const ContextList: VFC = () => {
|
|||||||
setName(name);
|
setName(name);
|
||||||
setShowDelDialogue(true);
|
setShowDelDialogue(true);
|
||||||
}}
|
}}
|
||||||
|
allowDelete={usedInFeatures === 0}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
width: 150,
|
width: 150,
|
||||||
|
Loading…
Reference in New Issue
Block a user