Skip to content

Commit

Permalink
[frontend] Fix the display of a relationship after it has been created (
Browse files Browse the repository at this point in the history
  • Loading branch information
Gwendoline-FAVRE-FELIX committed Nov 19, 2024
1 parent 5087c95 commit 09120d6
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 09120d6

Please sign in to comment.