Skip to content

Commit

Permalink
fix(topology): delete action should be available for custom targets
Browse files Browse the repository at this point in the history
  • Loading branch information
tthvo authored and andrewazores committed Apr 24, 2024
1 parent 35303e7 commit 8d80dfb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
5 changes: 2 additions & 3 deletions src/app/Topology/Actions/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -73,8 +72,8 @@ export interface NodeAction {
readonly title?: React.ReactNode;
readonly isSeparator?: boolean;
readonly isDisabled?: (element: GraphElement | ListElement, actionUtils: ActionUtils) => Observable<boolean>;
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 = {
Expand Down
11 changes: 8 additions & 3 deletions src/app/Topology/Actions/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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))
);
});

Expand Down

0 comments on commit 8d80dfb

Please sign in to comment.