diff --git a/src/app/Topology/Actions/types.ts b/src/app/Topology/Actions/types.ts index e5f37fc57..9ad81989d 100644 --- a/src/app/Topology/Actions/types.ts +++ b/src/app/Topology/Actions/types.ts @@ -14,7 +14,6 @@ * limitations under the License. */ -import type { NodeType } from '@app/Shared/Services/api.types'; import { NotificationService } from '@app/Shared/Services/Notifications.service'; import type { FeatureLevel } from '@app/Shared/Services/service.types'; import { Services } from '@app/Shared/Services/Services'; @@ -73,8 +72,8 @@ export interface NodeAction { readonly title?: React.ReactNode; readonly isSeparator?: boolean; readonly isDisabled?: (element: GraphElement | ListElement, actionUtils: ActionUtils) => Observable; - readonly includeList?: NodeType[]; // Empty means all - readonly blockList?: NodeType[]; // Empty means none + readonly allowed?: (element: GraphElement | ListElement) => boolean; // Undefined means allowing all + readonly blocked?: (element: GraphElement | ListElement) => boolean; // Undefined means blocking none } export type GroupActionResponse = { diff --git a/src/app/Topology/Actions/utils.tsx b/src/app/Topology/Actions/utils.tsx index f7f358a16..7f58c29a1 100644 --- a/src/app/Topology/Actions/utils.tsx +++ b/src/app/Topology/Actions/utils.tsx @@ -111,7 +111,12 @@ export const nodeActions: NodeAction[] = [ services.api.deleteTarget(targetNode.target).subscribe(() => undefined); }, title: 'Delete Target', - includeList: [NodeType.CUSTOM_TARGET], + allowed: (element) => { + const targetNode: TargetNode = element.getData(); + const realm = targetNode.target.annotations.cryostat.find((label) => label.key === 'REALM')?.value; + + return targetNode.nodeType === NodeType.JVM && realm === 'Custom Targets'; + }, }, { key: 'GROUP_START_RECORDING', @@ -342,8 +347,8 @@ export const actionFactory = ( return ( actionFilter(action) && (action.isGroup || false) === isGroup && - (!action.includeList || action.includeList.includes(data.nodeType)) && - (!action.blockList || !action.blockList.includes(data.nodeType)) + (!action.allowed || action.allowed(element)) && + (!action.blocked || !action.blocked(element)) ); });