Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions packages/demo-app-ts/src/data/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export interface GeneratorNodeOptions {
nodeIcons?: boolean;
smallNodes?: boolean;
contextMenus?: boolean;
hulledOutline?: boolean;
}

export interface GeneratorEdgeOptions {
Expand All @@ -53,7 +54,8 @@ export const DefaultNodeOptions: GeneratorNodeOptions = {
nodeBadges: false,
nodeIcons: false,
smallNodes: false,
contextMenus: false
contextMenus: false,
hulledOutline: true
};

export const DefaultEdgeOptions: GeneratorEdgeOptions = {
Expand All @@ -76,6 +78,7 @@ export const getNodeOptions = (
showStatusDecorator?: boolean;
showDecorators?: boolean;
showContextMenu?: boolean;
hulledOutline?: boolean;
labelIconClass?: string;
labelIcon?: React.ComponentClass<SVGIconProps>;
} => {
Expand All @@ -91,6 +94,7 @@ export const getNodeOptions = (
showStatusDecorator: nodeCreationOptions.statusDecorators,
showDecorators: nodeCreationOptions.showDecorators,
showContextMenu: nodeCreationOptions.contextMenus,
hulledOutline: nodeCreationOptions.hulledOutline,
labelIconClass,
labelIcon
};
Expand Down Expand Up @@ -129,6 +133,23 @@ export const generateEdge = (
tagStatus: options.edgeStatuses[index % options.edgeStatuses.length]
});

export const updateGroup = (group: NodeModel, nodeCreationOptions: GeneratorNodeOptions): NodeModel => {
return {
...group,
data: {
badge: nodeCreationOptions.nodeBadges ? 'GN' : undefined,
badgeColor: '#F2F0FC',
badgeTextColor: '#5752d1',
badgeBorderColor: '#CBC1FF',
collapsedWidth: 75,
collapsedHeight: 75,
showContextMenu: nodeCreationOptions.contextMenus,
collapsible: true,
hulledOutline: nodeCreationOptions.hulledOutline
}
};
};

export const generateDataModel = (
numNodes: number,
numGroups: number,
Expand Down Expand Up @@ -167,7 +188,8 @@ export const generateDataModel = (
collapsedWidth: 75,
collapsedHeight: 75,
showContextMenu: nodeCreationOptions.contextMenus,
collapsible: true
collapsible: true,
hulledOutline: nodeOptions.hulledOutline
}
};
if (level === groupDepth) {
Expand Down
4 changes: 2 additions & 2 deletions packages/demo-app-ts/src/demos/TopologyPackage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
import stylesComponentFactory from '../components/stylesComponentFactory';
import defaultLayoutFactory from '../layouts/defaultLayoutFactory';
import defaultComponentFactory from '../components/defaultComponentFactory';
import { generateDataModel, generateEdge, generateNode } from '../data/generator';
import { generateDataModel, generateEdge, generateNode, updateGroup } from '../data/generator';
import { useTopologyOptions } from '../utils/useTopologyOptions';
import { Tab, Tabs, TabTitleText } from '@patternfly/react-core';

Expand Down Expand Up @@ -157,7 +157,7 @@ const TopologyViewComponent: React.FunctionComponent<TopologyViewComponentProps>
if (nodes.length) {
const updatedNodes: NodeModel[] = nodes.map((node, index) => {
if (node.group) {
return node;
return updateGroup(node, nodeOptions);
}
return {
...node,
Expand Down
8 changes: 8 additions & 0 deletions packages/demo-app-ts/src/utils/useTopologyOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,14 @@ export const useTopologyOptions = (
>
Context Menus
</SelectOption>
<SelectOption
hasCheckbox
value="Rectangle Groups"
isSelected={!nodeOptions.hulledOutline}
onClick={() => setNodeOptions((prev) => ({ ...prev, hulledOutline: !prev.hulledOutline }))}
>
Rectangle Groups
</SelectOption>
</SelectList>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ const DefaultGroupExpanded: React.FunctionComponent<DefaultGroupExpandedProps> =
const padding = maxPadding(element.getStyle<NodeStyle>().padding ?? 17);
const hullPadding = (point: PointWithSize | PointTuple) => (point[2] || 0) + padding;

if (!droppable || !pathRef.current || !labelLocation.current) {
if (!droppable || (hulledOutline && !pathRef.current) || (!hulledOutline && !boxRef.current) || !labelLocation.current) {
const children = element.getNodes().filter(c => c.isVisible());
if (children.length === 0) {
return null;
Expand Down