Skip to content

Commit

Permalink
[frontend] Relationship creation graph
Browse files Browse the repository at this point in the history
  • Loading branch information
Kedae committed Jan 10, 2024
1 parent 76ccb83 commit 0266121
Show file tree
Hide file tree
Showing 14 changed files with 346 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import { hexToRGB } from '../../../../utils/Colors';
import { UserContext } from '../../../../utils/hooks/useAuth';
import investigationAddFromContainer from '../../../../utils/InvestigationUtils';
import { isNotEmptyField } from '../../../../utils/utils';
import RelationSelection from '../../../../utils/graph/RelationSelection';

const ignoredStixCoreObjectsTypes = ['Note', 'Opinion'];

Expand Down Expand Up @@ -516,6 +517,7 @@ class GroupingKnowledgeGraphComponent extends Component {
zoomed: false,
keyword: '',
navOpen: localStorage.getItem('navOpen') === 'true',
openCreatedRelation: false,
};
}

Expand Down Expand Up @@ -1414,6 +1416,8 @@ class GroupingKnowledgeGraphComponent extends Component {
handleSearch={this.handleSearch.bind(this)}
navOpen={navOpen}
resetAllFilters={this.resetAllFilters.bind(this)}
openCreatedRelation={this.state.openCreatedRelation}
handleCloseRelationCreation={() => this.setState({ openCreatedRelation: false })}
/>
{selectedEntities.length > 0 && (
<EntitiesDetailsRightsBar
Expand Down Expand Up @@ -1529,6 +1533,18 @@ class GroupingKnowledgeGraphComponent extends Component {
this.setState({ numberOfSelectedNodes: nodes.size });
}}
/>
<RelationSelection
activated={!(selectModeFree && selectModeFreeReady) && !selectRectangleModeFree}
width={graphWidth}
height={graphHeight}
graphDataNodes={graphData.nodes}
graph={this.graph}
setSelectedNodes={(nodes) => {
this.selectedNodes.clear();
Array.from(nodes).forEach((n) => this.selectedNodes.add(n));
this.setState({ numberOfSelectedNodes: this.selectedNodes.size, openCreatedRelation: true });
}}
/>
<RectangleSelection
onSelect={(e, coords) => {
this.handleRectSelectMove(e, coords);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ class GroupingKnowledgeGraphBar extends Component {
};
}

componentDidUpdate(prevProps) {
if (prevProps.openCreatedRelation === false && this.props.openCreatedRelation) {
this.setState({ openCreatedRelation: true });
}
}

handleOpenRemove() {
this.setState({ displayRemove: true });
}
Expand Down Expand Up @@ -166,6 +172,7 @@ class GroupingKnowledgeGraphBar extends Component {

handleCloseCreateRelationship() {
this.setState({ openCreatedRelation: false });
this.props.handleCloseRelationCreation();
}

handleReverseRelation() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import ReportPopover from './ReportPopover';
import { UserContext } from '../../../../utils/hooks/useAuth';
import investigationAddFromContainer from '../../../../utils/InvestigationUtils';
import { isNotEmptyField } from '../../../../utils/utils';
import RelationSelection from '../../../../utils/graph/RelationSelection';

const ignoredStixCoreObjectsTypes = ['Note', 'Opinion'];

Expand Down Expand Up @@ -539,6 +540,7 @@ class ReportKnowledgeGraphComponent extends Component {
zoomed: false,
keyword: '',
navOpen: localStorage.getItem('navOpen') === 'true',
openCreatedRelation: false,
};
this.canvas = null;
}
Expand Down Expand Up @@ -1463,6 +1465,8 @@ class ReportKnowledgeGraphComponent extends Component {
handleSearch={this.handleSearch.bind(this)}
navOpen={navOpen}
resetAllFilters={this.resetAllFilters.bind(this)}
openCreatedRelation={this.state.openCreatedRelation}
handleCloseRelationCreation={() => this.setState({ openCreatedRelation: false })}
/>
{selectedEntities.length > 0 && (
<EntitiesDetailsRightsBar
Expand Down Expand Up @@ -1582,6 +1586,18 @@ class ReportKnowledgeGraphComponent extends Component {
this.setState({ numberOfSelectedNodes: nodes.size });
}}
/>
<RelationSelection
activated={!(selectModeFree && selectModeFreeReady) && !selectRectangleModeFree}
width={graphWidth}
height={graphHeight}
graphDataNodes={graphData.nodes}
graph={this.graph}
setSelectedNodes={(nodes) => {
this.selectedNodes.clear();
Array.from(nodes).forEach((n) => this.selectedNodes.add(n));
this.setState({ numberOfSelectedNodes: this.selectedNodes.size, openCreatedRelation: true });
}}
/>
<RectangleSelection
onSelect={(e, coords) => {
this.handleRectSelectMove(e, coords);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ class ReportKnowledgeGraphBar extends Component {
};
}

componentDidUpdate(prevProps) {
if (prevProps.openCreatedRelation === false && this.props.openCreatedRelation) {
this.setState({ openCreatedRelation: true });
}
}

handleOpenRemove() {
this.setState({ displayRemove: true });
}
Expand Down Expand Up @@ -175,6 +181,7 @@ class ReportKnowledgeGraphBar extends Component {

handleCloseCreateRelationship() {
this.setState({ openCreatedRelation: false });
this.props.handleCloseRelationCreation();
}

handleReverseRelation() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import {
import { UserContext } from '../../../../utils/hooks/useAuth';
import investigationAddFromContainer from '../../../../utils/InvestigationUtils';
import { isNotEmptyField } from '../../../../utils/utils';
import RelationSelection from '../../../../utils/graph/RelationSelection';

const ignoredStixCoreObjectsTypes = ['Note', 'Opinion'];

Expand Down Expand Up @@ -556,6 +557,7 @@ class IncidentKnowledgeGraphComponent extends Component {
zoomed: false,
keyword: '',
navOpen: localStorage.getItem('navOpen') === 'true',
openCreatedRelation: false,
};
this.canvas = null;
}
Expand Down Expand Up @@ -1481,6 +1483,8 @@ class IncidentKnowledgeGraphComponent extends Component {
handleSearch={this.handleSearch.bind(this)}
navOpen={navOpen}
resetAllFilters={this.resetAllFilters.bind(this)}
openCreatedRelation={this.state.openCreatedRelation}
handleCloseRelationCreation={() => this.setState({ openCreatedRelation: false })}
/>
{selectedEntities.length > 0 && (
<EntitiesDetailsRightsBar
Expand Down Expand Up @@ -1600,6 +1604,18 @@ class IncidentKnowledgeGraphComponent extends Component {
this.setState({ numberOfSelectedNodes: nodes.size });
}}
/>
<RelationSelection
activated={!(selectModeFree && selectModeFreeReady) && !selectRectangleModeFree}
width={graphWidth}
height={graphHeight}
graphDataNodes={graphData.nodes}
graph={this.graph}
setSelectedNodes={(nodes) => {
this.selectedNodes.clear();
Array.from(nodes).forEach((n) => this.selectedNodes.add(n));
this.setState({ numberOfSelectedNodes: this.selectedNodes.size, openCreatedRelation: true });
}}
/>
<RectangleSelection
onSelect={(e, coords) => {
this.handleRectSelectMove(e, coords);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ class IncidentKnowledgeGraphBar extends Component {
};
}

componentDidUpdate(prevProps) {
if (prevProps.openCreatedRelation === false && this.props.openCreatedRelation) {
this.setState({ openCreatedRelation: true });
}
}

handleOpenRemove() {
this.setState({ displayRemove: true });
}
Expand Down Expand Up @@ -175,6 +181,7 @@ class IncidentKnowledgeGraphBar extends Component {

handleCloseCreateRelationship() {
this.setState({ openCreatedRelation: false });
this.props.handleCloseRelationCreation();
}

handleReverseRelation() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import CaseRfiPopover from './CaseRfiPopover';
import { UserContext } from '../../../../utils/hooks/useAuth';
import investigationAddFromContainer from '../../../../utils/InvestigationUtils';
import { isNotEmptyField } from '../../../../utils/utils';
import RelationSelection from '../../../../utils/graph/RelationSelection';

const ignoredStixCoreObjectsTypes = ['Note', 'Opinion'];

Expand Down Expand Up @@ -555,6 +556,7 @@ class CaseRfiKnowledgeGraphComponent extends Component {
zoomed: false,
keyword: '',
navOpen: localStorage.getItem('navOpen') === 'true',
openCreatedRelation: false,
};
this.canvas = null;
}
Expand Down Expand Up @@ -1480,6 +1482,8 @@ class CaseRfiKnowledgeGraphComponent extends Component {
handleSearch={this.handleSearch.bind(this)}
navOpen={navOpen}
resetAllFilters={this.resetAllFilters.bind(this)}
openCreatedRelation={this.state.openCreatedRelation}
handleCloseRelationCreation={() => this.setState({ openCreatedRelation: false })}
/>
{selectedEntities.length > 0 && (
<EntitiesDetailsRightsBar
Expand Down Expand Up @@ -1599,6 +1603,18 @@ class CaseRfiKnowledgeGraphComponent extends Component {
this.setState({ numberOfSelectedNodes: nodes.size });
}}
/>
<RelationSelection
activated={!(selectModeFree && selectModeFreeReady) && !selectRectangleModeFree}
width={graphWidth}
height={graphHeight}
graphDataNodes={graphData.nodes}
graph={this.graph}
setSelectedNodes={(nodes) => {
this.selectedNodes.clear();
Array.from(nodes).forEach((n) => this.selectedNodes.add(n));
this.setState({ numberOfSelectedNodes: this.selectedNodes.size, openCreatedRelation: true });
}}
/>
<RectangleSelection
onSelect={(e, coords) => {
this.handleRectSelectMove(e, coords);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ class CaseRfiKnowledgeGraphBar extends Component {
};
}

componentDidUpdate(prevProps) {
if (prevProps.openCreatedRelation === false && this.props.openCreatedRelation) {
this.setState({ openCreatedRelation: true });
}
}

handleOpenRemove() {
this.setState({ displayRemove: true });
}
Expand Down Expand Up @@ -174,6 +180,7 @@ class CaseRfiKnowledgeGraphBar extends Component {

handleCloseCreateRelationship() {
this.setState({ openCreatedRelation: false });
this.props.handleCloseRelationCreation();
}

handleReverseRelation() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import CaseRftPopover from './CaseRftPopover';
import { UserContext } from '../../../../utils/hooks/useAuth';
import investigationAddFromContainer from '../../../../utils/InvestigationUtils';
import { isNotEmptyField } from '../../../../utils/utils';
import RelationSelection from '../../../../utils/graph/RelationSelection';

const ignoredStixCoreObjectsTypes = ['Note', 'Opinion'];

Expand Down Expand Up @@ -555,6 +556,7 @@ class CaseRftKnowledgeGraphComponent extends Component {
zoomed: false,
keyword: '',
navOpen: localStorage.getItem('navOpen') === 'true',
openCreatedRelation: false,
};
this.canvas = null;
}
Expand Down Expand Up @@ -1480,6 +1482,8 @@ class CaseRftKnowledgeGraphComponent extends Component {
handleSearch={this.handleSearch.bind(this)}
navOpen={navOpen}
resetAllFilters={this.resetAllFilters.bind(this)}
openCreatedRelation={this.state.openCreatedRelation}
handleCloseRelationCreation={() => this.setState({ openCreatedRelation: false })}
/>
{selectedEntities.length > 0 && (
<EntitiesDetailsRightsBar
Expand Down Expand Up @@ -1599,6 +1603,18 @@ class CaseRftKnowledgeGraphComponent extends Component {
this.setState({ numberOfSelectedNodes: nodes.size });
}}
/>
<RelationSelection
activated={!(selectModeFree && selectModeFreeReady) && !selectRectangleModeFree}
width={graphWidth}
height={graphHeight}
graphDataNodes={graphData.nodes}
graph={this.graph}
setSelectedNodes={(nodes) => {
this.selectedNodes.clear();
Array.from(nodes).forEach((n) => this.selectedNodes.add(n));
this.setState({ numberOfSelectedNodes: this.selectedNodes.size, openCreatedRelation: true });
}}
/>
<RectangleSelection
onSelect={(e, coords) => {
this.handleRectSelectMove(e, coords);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ class CaseRftKnowledgeGraphBar extends Component {
};
}

componentDidUpdate(prevProps) {
if (prevProps.openCreatedRelation === false && this.props.openCreatedRelation) {
this.setState({ openCreatedRelation: true });
}
}

handleOpenRemove() {
this.setState({ displayRemove: true });
}
Expand Down Expand Up @@ -174,6 +180,7 @@ class CaseRftKnowledgeGraphBar extends Component {

handleCloseCreateRelationship() {
this.setState({ openCreatedRelation: false });
this.props.handleCloseRelationCreation();
}

handleReverseRelation() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import InvestigationGraphBar from './InvestigationGraphBar';
import { UserContext } from '../../../../utils/hooks/useAuth';
import { investigationAddStixCoreObjectsLinesRelationsDeleteMutation } from './InvestigationAddStixCoreObjectsLines';
import { isNotEmptyField } from '../../../../utils/utils';
import RelationSelection from '../../../../utils/graph/RelationSelection';

const PARAMETERS$ = new Subject().pipe(debounce(() => timer(2000)));
const POSITIONS$ = new Subject().pipe(debounce(() => timer(2000)));
Expand Down Expand Up @@ -999,6 +1000,7 @@ class InvestigationGraphComponent extends Component {
keyword: '',
prevClick: null,
navOpen: localStorage.getItem('navOpen') === 'true',
openCreatedRelation: false,
};
this.canvas = null;
}
Expand Down Expand Up @@ -2113,6 +2115,8 @@ class InvestigationGraphComponent extends Component {
handleSearch={this.handleSearch.bind(this)}
navOpen={navOpen}
resetAllFilters={this.resetAllFilters.bind(this, false)}
openCreatedRelation={this.state.openCreatedRelation}
handleCloseRelationCreation={() => this.setState({ openCreatedRelation: false })}
/>
{selectedEntities.length > 0 && (
<EntitiesDetailsRightsBar selectedEntities={selectedEntities} />
Expand Down Expand Up @@ -2223,6 +2227,18 @@ class InvestigationGraphComponent extends Component {
this.setState({ numberOfSelectedNodes: nodes.size });
}}
/>
<RelationSelection
activated={!(selectModeFree && selectModeFreeReady) && !selectRectangleModeFree}
width={graphWidth}
height={graphHeight}
graphDataNodes={graphData.nodes}
graph={this.graph}
setSelectedNodes={(nodes) => {
this.selectedNodes.clear();
Array.from(nodes).forEach((n) => this.selectedNodes.add(n));
this.setState({ numberOfSelectedNodes: this.selectedNodes.size, openCreatedRelation: true });
}}
/>
<RectangleSelection
onSelect={(e, coords) => {
this.handleRectSelectMove(e, coords);
Expand Down
Loading

0 comments on commit 0266121

Please sign in to comment.