Skip to content

Commit

Permalink
feat(context menu): add prop to hide the context menu kebab
Browse files Browse the repository at this point in the history
  • Loading branch information
jenny-s51 committed Nov 8, 2024
1 parent 2a1b615 commit 9830873
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/module/src/behavior/withContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type Reference = React.ComponentProps<typeof ContextMenu>['reference'];
export interface WithContextMenuProps {
onContextMenu?: (e: React.MouseEvent) => void;
contextMenuOpen?: boolean;
hideContextMenuKebab?: boolean;
}

export const withContextMenu =
Expand Down
6 changes: 5 additions & 1 deletion packages/module/src/components/nodes/DefaultNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ interface DefaultNodeProps {
onContextMenu?: (e: React.MouseEvent) => void;
/** Flag indicating that the context menu for the node is currently open */
contextMenuOpen?: boolean;
/** Hide context menu kebab for the node */
hideContextMenuKebab?: boolean;
}

const SCALE_UP_TIME = 200;
Expand Down Expand Up @@ -166,7 +168,8 @@ const DefaultNodeInner: React.FunctionComponent<DefaultNodeInnerProps> = observe
onHideCreateConnector,
onShowCreateConnector,
onContextMenu,
contextMenuOpen
contextMenuOpen,
hideContextMenuKebab
}) => {
const [hovered, hoverRef] = useHover();
const status = nodeStatus || element.getNodeStatus();
Expand Down Expand Up @@ -379,6 +382,7 @@ const DefaultNodeInner: React.FunctionComponent<DefaultNodeInnerProps> = observe
badgeLocation={badgeLocation}
onContextMenu={onContextMenu}
contextMenuOpen={contextMenuOpen}
hideContextMenuKebab={hideContextMenuKebab}
hover={isHover}
labelIconClass={labelIconClass}
labelIcon={labelIcon}
Expand Down
3 changes: 2 additions & 1 deletion packages/module/src/components/nodes/labels/NodeLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ const NodeLabel: React.FunctionComponent<NodeLabelProps> = ({
dropTarget,
onContextMenu,
contextMenuOpen,
hideContextMenuKebab,
actionIcon,
actionIconClassName,
onActionIconClick,
Expand Down Expand Up @@ -291,7 +292,7 @@ const NodeLabel: React.FunctionComponent<NodeLabelProps> = ({
/>
</>
)}
{textSize && onContextMenu && (
{textSize && onContextMenu && !hideContextMenuKebab && (
<>
<line
className={css(styles.topologyNodeSeparator)}
Expand Down
2 changes: 2 additions & 0 deletions packages/module/src/pipelines/components/nodes/TaskNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ export interface TaskNodeProps {
onContextMenu?: (e: React.MouseEvent) => void;
/** Flag indicating that the context menu for the node is currently open */
contextMenuOpen?: boolean;
/** Hide context menu kebab for the node */
hideContextMenuKebab?: boolean;
/** Number of shadowed pills to show */
shadowCount?: number;
/** Offset for each shadow */
Expand Down
3 changes: 2 additions & 1 deletion packages/module/src/pipelines/components/nodes/TaskPill.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ const TaskPill: React.FC<TaskPillProps> = observer(
hasWhenExpression = false,
onContextMenu,
contextMenuOpen,
hideContextMenuKebab,
actionIcon,
actionIconClassName,
onActionIconClick,
Expand Down Expand Up @@ -429,7 +430,7 @@ const TaskPill: React.FC<TaskPillProps> = observer(
/>
</>
)}
{textSize && onContextMenu && (
{textSize && onContextMenu && !hideContextMenuKebab && (
<>
<line
className={css(topologyStyles.topologyNodeSeparator)}
Expand Down

0 comments on commit 9830873

Please sign in to comment.