Skip to content

Commit

Permalink
feat(update): cherry pick v5 updates onto main (#265)
Browse files Browse the repository at this point in the history
* feat(context menu): Add the hideContextMenuKebab option to groups (#261)

add feature to topology package demo

* feat(group): Add support for custom classname on group labels
  • Loading branch information
jenny-s51 authored Jan 6, 2025
1 parent ccaeee0 commit 99f505b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ const DemoGroup: React.FunctionComponent<DemoGroupProps> = ({ element, onContext
return (
<DefaultGroup
{...rest}
onContextMenu={data.showContextMenu ? onContextMenu : undefined}
onContextMenu={options.contextMenus ? onContextMenu : undefined}
hideContextMenuKebab={options.hideKebabMenu}
element={element}
collapsible
collapsedWidth={DEFAULT_NODE_SIZE}
Expand Down
5 changes: 1 addition & 4 deletions packages/module/release.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
module.exports = {
branches: [
'do-not-delete',
{ name: 'main', channel: 'prerelease', prerelease: 'prerelease' },
],
branches: ['do-not-delete', { name: 'main', channel: 'prerelease', prerelease: 'prerelease' }],
analyzeCommits: {
preset: 'angular'
},
Expand Down
4 changes: 4 additions & 0 deletions packages/module/src/components/groups/DefaultGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ interface DefaultGroupProps {
secondaryLabel?: string;
/** Flag to show the label */
showLabel?: boolean; // Defaults to true
/** Additional classes to add to the label */
labelClassName?: string;
/** Flag to show the label when hovering (effects expanded only) */
showLabelOnHover?: boolean;
/** Position of the label, top or bottom. Defaults to element.getLabelPosition() or bottom */
Expand Down Expand Up @@ -82,6 +84,8 @@ interface DefaultGroupProps {
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 group */
hideContextMenuKebab?: boolean;
/** Flag indicating whether to use hull layout or rect layout for expanded groups. Defaults to hull (true) */
hulledOutline?: boolean;
/** Border radius for rectangular groups when expanded. Defaults to 16px */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type DefaultGroupCollapsedProps = {
label?: string; // Defaults to element.getLabel()
secondaryLabel?: string;
showLabel?: boolean; // Defaults to true
hideContextMenuKebab?: boolean;
labelPosition?: LabelPosition; // Defaults to bottom
truncateLength?: number; // Defaults to 13
labelIconClass?: string; // Icon to show in label
Expand All @@ -43,6 +44,7 @@ type DefaultGroupCollapsedProps = {
badgeBorderColor?: string;
badgeClassName?: string;
badgeLocation?: BadgeLocation;
labelClassName?: string;
} & CollapsibleGroupProps &
WithDragNodeProps &
WithSelectionProps &
Expand Down Expand Up @@ -72,6 +74,7 @@ const DefaultGroupCollapsed: React.FunctionComponent<DefaultGroupCollapsedProps>
dropTarget,
onContextMenu,
contextMenuOpen,
hideContextMenuKebab,
dragging,
labelPosition,
badge,
Expand All @@ -82,7 +85,8 @@ const DefaultGroupCollapsed: React.FunctionComponent<DefaultGroupCollapsedProps>
badgeLocation,
labelIconClass,
labelIcon,
labelIconPadding
labelIconPadding,
labelClassName
}) => {
const [hovered, hoverRef] = useHover();
const [labelHover, labelHoverRef] = useHover();
Expand Down Expand Up @@ -154,7 +158,7 @@ const DefaultGroupCollapsed: React.FunctionComponent<DefaultGroupCollapsedProps>
)}
{showLabel && (
<NodeLabel
className={styles.topologyGroupLabel}
className={css(styles.topologyGroupLabel, labelClassName)}
x={collapsedWidth / 2}
y={labelPosition === LabelPosition.top ? collapsedHeight / 2 - collapsedHeight : collapsedHeight + 6}
paddingX={8}
Expand All @@ -174,6 +178,7 @@ const DefaultGroupCollapsed: React.FunctionComponent<DefaultGroupCollapsedProps>
labelIconPadding={labelIconPadding}
onContextMenu={onContextMenu}
contextMenuOpen={contextMenuOpen}
hideContextMenuKebab={hideContextMenuKebab}
hover={isHover || labelHover}
actionIcon={collapsible ? <ExpandIcon /> : undefined}
onActionIconClick={() => onCollapseChange(element, false)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@ type DefaultGroupExpandedProps = {
secondaryLabel?: string;
showLabel?: boolean; // Defaults to true
showLabelOnHover?: boolean;
hideContextMenuKebab?: boolean;
truncateLength?: number; // Defaults to 13
badge?: string;
badgeColor?: string;
badgeTextColor?: string;
badgeBorderColor?: string;
badgeClassName?: string;
badgeLocation?: BadgeLocation;
labelClassName?: string;
labelIconClass?: string; // Icon to show in label
labelIcon?: string;
labelPosition?: LabelPosition;
Expand Down Expand Up @@ -129,6 +131,7 @@ const DefaultGroupExpanded: React.FunctionComponent<DefaultGroupExpandedProps> =
dropTarget,
onContextMenu,
contextMenuOpen,
hideContextMenuKebab,
dragging,
dragNodeRef,
badge,
Expand All @@ -137,6 +140,7 @@ const DefaultGroupExpanded: React.FunctionComponent<DefaultGroupExpandedProps> =
badgeBorderColor,
badgeClassName,
badgeLocation,
labelClassName,
labelIconClass,
labelIcon,
labelPosition,
Expand Down Expand Up @@ -252,7 +256,7 @@ const DefaultGroupExpanded: React.FunctionComponent<DefaultGroupExpandedProps> =
(showLabel || (showLabelOnHover && isHover)) && (label || element.getLabel()) ? (
<g ref={labelHoverRef} transform={isHover ? `scale(${labelScale})` : undefined}>
<NodeLabel
className={styles.topologyGroupLabel}
className={css(styles.topologyGroupLabel, labelClassName)}
x={startX * labelPositionScale}
y={startY * labelPositionScale}
paddingX={8}
Expand All @@ -272,6 +276,7 @@ const DefaultGroupExpanded: React.FunctionComponent<DefaultGroupExpandedProps> =
labelIconPadding={labelIconPadding}
onContextMenu={onContextMenu}
contextMenuOpen={contextMenuOpen}
hideContextMenuKebab={hideContextMenuKebab}
hover={isHover || labelHover}
actionIcon={collapsible ? <CollapseIcon /> : undefined}
onActionIconClick={() => onCollapseChange(element, true)}
Expand Down

0 comments on commit 99f505b

Please sign in to comment.