Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(demo): fix for nested levels in package demo #164

Merged
merged 1 commit into from
Mar 25, 2024
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
20 changes: 5 additions & 15 deletions packages/demo-app-ts/src/demos/topologyPackageDemo/DemoContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ export class DemoModel {
showTags: false,
terminalTypes: false,
};
protected nestedLevelP: number = 0;
protected creationCountsP: { numNodes: number; numEdges: number; numGroups: number } = {
protected creationCountsP: { numNodes: number; numEdges: number; numGroups: number, nestedLevel: number } = {
numNodes: 6,
numEdges: 2,
numGroups: 1,
nestedLevel: 0
};
protected layoutP: string = 'ColaNoForce';
protected medScaleP: number = 0.5;
Expand All @@ -38,29 +38,25 @@ export class DemoModel {
DemoModel,
| 'nodeOptionsP'
| 'edgeOptionsP'
| 'nestedLevelP'
| 'creationCountsP'
| 'layoutP'
| 'medScaleP'
| 'lowScaleP'
| 'setNodeOptions'
| 'setEdgeOptions'
| 'setNestedLevel'
| 'setCreationCounts'
| 'setLayout'
| 'setMedScale'
| 'setLowScale'
>(this, {
nodeOptionsP: observable.ref,
edgeOptionsP: observable.shallow,
nestedLevelP: observable,
creationCountsP: observable.shallow,
layoutP: observable,
medScaleP: observable,
lowScaleP: observable,
setNodeOptions: action,
setEdgeOptions: action,
setNestedLevel: action,
setCreationCounts: action,
setLayout: action,
setMedScale: action,
Expand All @@ -82,17 +78,11 @@ export class DemoModel {
this.edgeOptionsP = options;
}

public get nestedLevel(): number {
return this.nestedLevelP;
}
public setNestedLevel = (show: number): void => {
this.nestedLevelP = show;
}

public get creationCounts(): { numNodes: number; numEdges: number; numGroups: number } {
public get creationCounts(): { numNodes: number; numEdges: number; numGroups: number, nestedLevel: number } {
return this.creationCountsP;
}
public setCreationCounts = (counts: { numNodes: number; numEdges: number; numGroups: number }): void => {

public setCreationCounts = (counts: { numNodes: number; numEdges: number; numGroups: number, nestedLevel: number }): void => {
this.creationCountsP = counts;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const OptionsContextBar: React.FC = observer(() => {
const [numNodes, setNumNodes] = React.useState<number>(options.creationCounts.numNodes);
const [numEdges, setNumEdges] = React.useState<number>(options.creationCounts.numEdges);
const [numGroups, setNumGroups] = React.useState<number>(options.creationCounts.numGroups);
const [nestedLevel, setNestedLevel] = React.useState<number>(options.nestedLevel);
const [nestedLevel, setNestedLevel] = React.useState<number>(options.creationCounts.nestedLevel);

const renderNodeOptionsDropdown = () => {
const nodeOptionsToggle = (toggleRef: React.Ref<MenuToggleElement>) => (
Expand Down Expand Up @@ -268,7 +268,7 @@ const OptionsContextBar: React.FC = observer(() => {
<Button
variant="link"
isDisabled={numNodes === undefined || numNodes < 1 || numEdges === undefined || numGroups === undefined}
onClick={() => options.setCreationCounts({ numNodes, numEdges, numGroups })}
onClick={() => options.setCreationCounts({ numNodes, numEdges, numGroups, nestedLevel })}
>
Apply
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const TopologyViewComponent: React.FunctionComponent<TopologyViewComponentProps>
options.creationCounts.numNodes,
options.creationCounts.numGroups,
options.creationCounts.numEdges,
options.nestedLevel,
options.creationCounts.nestedLevel,
);

const model = {
Expand All @@ -54,7 +54,7 @@ const TopologyViewComponent: React.FunctionComponent<TopologyViewComponentProps>
};

controller.fromModel(model, true);
}, [controller, options.creationCounts, options.layout, options.nestedLevel]);
}, [controller, options.creationCounts, options.layout]);

useEventListener<SelectionEventListener>(SELECTION_EVENT, ids => {
setSelectedIds(ids);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export const generateDataModel = (
type: 'group',
group: true,
label: id,
style: { padding: 15 },
style: { padding: 45 },
data: {
objectType: 'GN',
}
Expand Down
Loading