Skip to content

Commit d3c2f42

Browse files
committed
1.2.1cleanup: Optimize EdgeEditor render to only display full editor in edit mode. This speeds up render by almost 2 secs.
1 parent df6b338 commit d3c2f42

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

build/app/view/netcreate/components/EdgeEditor.jsx

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -831,18 +831,30 @@ class EdgeEditor extends UNISYS.Component {
831831
// special override to allow editing an edge that has the same parent node for both source and target
832832
let sameSourceAndTarget = (sourceNode.label === this.props.parentNodeLabel) &&
833833
(targetNode.label === this.props.parentNodeLabel);
834+
835+
// Optimize Edge Loading
836+
// If not expanded, just show the button
837+
// Only bother to render the whole EdgeEditor if the Edge is being edited
838+
// This speeds up render times by almost 2 seconds
839+
if (!this.state.isExpanded) {
840+
return (
841+
<div>
842+
<Button
843+
outline
844+
size="sm"
845+
style={{ backgroundColor: "#a9d3ff", borderColor: 'transparent', width: '100%', marginBottom: '3px', textAlign: "left", overflow: "hidden" }}
846+
onClick={this.onButtonClick}
847+
>{parentNodeLabel === sourceNode.label ? me : sourceNode.label}
848+
&nbsp;<span title={formData.relationship}>&#x2794;</span>&nbsp;
849+
{parentNodeLabel === targetNode.label ? me : targetNode.label}
850+
</Button>
851+
</div>
852+
);
853+
}
854+
834855
return (
835856
<div>
836857

837-
<Button
838-
className={this.state.isExpanded?'d-none':''}
839-
outline
840-
size="sm"
841-
style={{backgroundColor:"#a9d3ff",borderColor:'transparent',width:'100%',marginBottom:'3px',textAlign:"left",overflow: "hidden"}}
842-
onClick={this.onButtonClick}
843-
>{parentNodeLabel===sourceNode.label ? me : sourceNode.label}
844-
&nbsp;<span title={formData.relationship}>&#x2794;</span>&nbsp;
845-
{parentNodeLabel===targetNode.label ? me : targetNode.label}</Button>
846858
<div className={this.state.isExpanded?'':'d-none'}>
847859
<Form className="nodeEntry"
848860
style={{backgroundColor:"#C9E1FF",minHeight:'300px',padding:'5px',marginBottom:'10px'}}

0 commit comments

Comments
 (0)