Skip to content

Commit

Permalink
[frontend] In Investigation, fix the display of a relationship after …
Browse files Browse the repository at this point in the history
…it has been created (#9022)
  • Loading branch information
Gwendoline-FAVRE-FELIX authored Nov 20, 2024
1 parent ea72d44 commit a0a5121
Showing 1 changed file with 37 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1476,57 +1476,45 @@ class InvestigationGraphComponent extends Component {

async handleAddRelation(stixCoreRelationship, skipReload = false) {
if (R.map((n) => n.id, this.graphObjects).includes(stixCoreRelationship.id)) return;
this.graphObjects = [...this.graphObjects, stixCoreRelationship];
if (!skipReload) {
this.graphData = buildGraphData(
this.graphObjects,
decodeGraphData(this.props.workspace.graph_data),
this.props.t,
);
await this.resetAllFilters();
const selectedTimeRangeInterval = computeTimeRangeInterval(
this.graphObjects,
);
this.setState(
{
selectedTimeRangeInterval,
graphData: applyFilters(
this.graphData,
this.state.stixCoreObjectsTypes,
this.state.markedBy,
this.state.createdBy,
[],
selectedTimeRangeInterval,
),
commitMutation({
mutation: investigationGraphRelationsAddMutation,
variables: {
id: this.props.workspace.id,
input: {
key: 'investigated_entities_ids',
operation: 'add',
value: [stixCoreRelationship.id],
},
() => {
commitMutation({
mutation: investigationGraphRelationsAddMutation,
variables: {
id: this.props.workspace.id,
input: {
key: 'investigated_entities_ids',
operation: 'add',
value: [stixCoreRelationship.id],
},
},
onCompleted: async () => {
this.graphObjects = [...this.graphObjects, stixCoreRelationship];
if (!skipReload) {
this.graphData = buildGraphData(
this.graphObjects,
decodeGraphData(this.props.workspace.graph_data),
this.props.t,
);
await this.resetAllFilters();
const selectedTimeRangeInterval = computeTimeRangeInterval(this.graphObjects);
this.setState(
{
selectedTimeRangeInterval,
graphData: applyFilters(
this.graphData,
this.state.stixCoreObjectsTypes,
this.state.markedBy,
this.state.createdBy,
[],
selectedTimeRangeInterval,
),
},
});
setTimeout(() => this.handleZoomToFit(), 1500);
},
);
} else {
commitMutation({
mutation: investigationGraphRelationsAddMutation,
variables: {
id: this.props.workspace.id,
input: {
key: 'investigated_entities_ids',
operation: 'add',
value: [stixCoreRelationship.id],
},
},
});
}
() => {
setTimeout(() => this.handleZoomToFit(), 1500);
},
);
}
},
});
}

handleDelete(stixCoreObject) {
Expand Down

0 comments on commit a0a5121

Please sign in to comment.