Skip to content

Commit

Permalink
[frontend] stored data updated to roll back with creation (#3167)
Browse files Browse the repository at this point in the history
  • Loading branch information
ValentinBouzinFiligran committed Apr 5, 2024
1 parent d365802 commit 51c6e0b
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 52 deletions.
5 changes: 2 additions & 3 deletions opencti-platform/opencti-front/lang/front/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -2675,9 +2675,7 @@
"Public dashboard": "Öffentliches Dashboard",
"Restore the state of the graphic before the last expansion": "Wiederherstellung des Zustands der Grafik vor der letzten Erweiterung",
"Revert to Pre-Expansion State": "Zurückkehren zum Zustand vor der Erweiterung",
"All actions after the last expansion will be lost": "Alle Aktionen nach der letzten Erweiterung gehen verloren",
"Last expansion": "Letzte Erweiterung",
"All actions after the last expansion will be lost.": "Alle Aktionen nach der letzten Erweiterung gehen verloren.",
"Show left navigation submenu icons": "Symbole des linken Navigations-Untermenüs anzeigen",
"Unless specific groups are selected, user will be created with default groups only.": "Wenn keine spezifischen Gruppen ausgewählt werden, wird der Benutzer nur mit den Standardgruppen erstellt.",
"By enabling the OpenCTI Enterprise Edition, you (and your organization) agrees to the OpenCTI Enterprise Edition (EE) supplemental license terms and conditions of usage:": "Mit der Aktivierung der OpenCTI Enterprise Edition erklären Sie (und Ihre Organisation) sich mit den zusätzlichen Lizenz- und Nutzungsbedingungen der OpenCTI Enterprise Edition (EE) einverstanden:",
Expand All @@ -2688,5 +2686,6 @@
"All other filters": "Alle anderen Filter",
"Testing csv mapper": "Testen des csv-Mappers",
"This operations will only apply on labels or markings added in the context of this playbook such as enrichment or other knowledge manipulations but not if the labels or markings are already written in the platform.": "Diese Operationen gelten nur für Labels oder Markierungen, die im Kontext dieses Playbooks hinzugefügt werden, wie z. B. Anreicherung oder andere Wissensmanipulationen, nicht aber, wenn die Labels oder Markierungen bereits in der Plattform geschrieben sind.",
"Auto collapse submenus in left navigation": "Untermenüs in der linken Navigation automatisch einklappen"
"Auto collapse submenus in left navigation": "Untermenüs in der linken Navigation automatisch einklappen",
"All add or remove actions done on the graph after the last expansion will be lost.": "Alle Hinzufügungs- oder Entfernungsaktionen, die nach der letzten Erweiterung am Diagramm vorgenommen wurden, gehen verloren."
}
3 changes: 1 addition & 2 deletions opencti-platform/opencti-front/lang/front/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1853,7 +1853,6 @@
"Restore the state of the graphic before the last expansion": "Restore the state of the graphic before the last expansion",
"Revert to Pre-Expansion State": "Revert to Pre-Expansion State",
"Last expansion": "Last expansion",
"All actions after the last expansion will be lost": "All actions after the last expansion will be lost",
"Add a widget": "Add a widget",
"Update a widget": "Update a widget",
"Update an artifact": "Update an artifact",
Expand Down Expand Up @@ -2677,7 +2676,7 @@
"Operational": "Operational",
"Strategic": "Strategic",
"Link created": "Link created",
"All actions after the last expansion will be lost.": "All actions after the last expansion will be lost.",
"All add or remove actions done on the graph after the last expansion will be lost.": "All add or remove actions done on the graph after the last expansion will be lost.",
"Show left navigation submenu icons": "Show left navigation submenu icons",
"Auto collapse submenus in left navigation": "Auto collapse submenus in left navigation",
"Public dashboard": "Public dashboard",
Expand Down
2 changes: 0 additions & 2 deletions opencti-platform/opencti-front/lang/front/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -2675,9 +2675,7 @@
"Public dashboard": "Cuadro de mandos público",
"Restore the state of the graphic before the last expansion": "Restaurar el estado del gráfico antes de la última ampliación",
"Revert to Pre-Expansion State": "Volver al estado anterior a la expansión",
"All actions after the last expansion will be lost": "Todas las acciones posteriores a la última expansión se perderán",
"Last expansion": "Última expansión",
"All actions after the last expansion will be lost.": "Todas las acciones posteriores a la última expansión se perderán.",
"Show left navigation submenu icons": "Mostrar iconos del submenú de navegación izquierdo",
"Auto collapse submenus in left navigation": "Submenús contraídos automáticamente en la navegación izquierda",
"Unless specific groups are selected, user will be created with default groups only.": "A menos que se seleccionen grupos específicos, el usuario se creará sólo con los grupos por defecto.",
Expand Down
5 changes: 2 additions & 3 deletions opencti-platform/opencti-front/lang/front/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -2675,9 +2675,7 @@
"Public dashboard": "Tableau de bord public",
"Restore the state of the graphic before the last expansion": "Rétablir l'état du graphique avant la dernière expansion",
"Revert to Pre-Expansion State": "Retour à l'état antérieur à l'expansion",
"All actions after the last expansion will be lost": "Toutes les actions postérieures à la dernière expansion seront perdues",
"Last expansion": "Dernière extension",
"All actions after the last expansion will be lost.": "Toutes les actions effectuées après la dernière expansion seront perdues.",
"Show left navigation submenu icons": "Afficher les icônes des sous-menus de la navigation de gauche",
"Auto collapse submenus in left navigation": "Fermer automatiquement les sous-menus de la navigation de gauche",
"Unless specific groups are selected, user will be created with default groups only.": "À moins que des groupes spécifiques ne soient sélectionnés, l'utilisateur sera créé avec les groupes par défaut uniquement.",
Expand All @@ -2688,5 +2686,6 @@
"Most used filters": "Filtres les plus utilisés",
"All other filters": "Tous les autres filtres",
"Testing csv mapper": "Test du mappeur csv",
"This operations will only apply on labels or markings added in the context of this playbook such as enrichment or other knowledge manipulations but not if the labels or markings are already written in the platform.": "Ces opérations ne s'appliqueront qu'aux étiquettes ou marquages ajoutés dans le contexte de ce playbook, comme l'enrichissement ou d'autres manipulations de connaissances, mais pas si les étiquettes ou marquages sont déjà écrits dans la plateforme."
"This operations will only apply on labels or markings added in the context of this playbook such as enrichment or other knowledge manipulations but not if the labels or markings are already written in the platform.": "Ces opérations ne s'appliqueront qu'aux étiquettes ou marquages ajoutés dans le contexte de ce playbook, comme l'enrichissement ou d'autres manipulations de connaissances, mais pas si les étiquettes ou marquages sont déjà écrits dans la plateforme.",
"All add or remove actions done on the graph after the last expansion will be lost.": "Toutes les actions d'ajout ou de suppression effectuées sur le graphique après la dernière expansion seront perdues."
}
5 changes: 2 additions & 3 deletions opencti-platform/opencti-front/lang/front/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -2675,9 +2675,7 @@
"Public dashboard": "公開ダッシュボード",
"Restore the state of the graphic before the last expansion": "最後の拡張前のグラフィックの状態を復元する。",
"Revert to Pre-Expansion State": "拡張前の状態に戻す",
"All actions after the last expansion will be lost": "最後の拡張以降のすべてのアクションが失われる",
"Last expansion": "最後の拡張",
"All actions after the last expansion will be lost.": "最後の拡張以降のアクションはすべて失われます。",
"Show left navigation submenu icons": "左側のナビゲーション サブメニュー アイコンを表示する",
"Auto collapse submenus in left navigation": "左側のナビゲーションのサブメニューを自動的に折りたたむ",
"Unless specific groups are selected, user will be created with default groups only.": "特定のグループを選択しない限り、ユーザーはデフォルトのグループのみで作成されます。",
Expand All @@ -2688,5 +2686,6 @@
"Most used filters": "最も使用されるフィルター",
"All other filters": "その他のフィルター",
"Testing csv mapper": "csvマッパーのテスト",
"This operations will only apply on labels or markings added in the context of this playbook such as enrichment or other knowledge manipulations but not if the labels or markings are already written in the platform.": "この操作は、エンリッチメントやその他の知識操作など、このプレイブックのコンテキストで追加されたラベルやマーキングに対してのみ適用されます。"
"This operations will only apply on labels or markings added in the context of this playbook such as enrichment or other knowledge manipulations but not if the labels or markings are already written in the platform.": "この操作は、エンリッチメントやその他の知識操作など、このプレイブックのコンテキストで追加されたラベルやマーキングに対してのみ適用されます。",
"All add or remove actions done on the graph after the last expansion will be lost.": "最後の拡張以降にグラフ上で行われた追加や削除の操作はすべて失われる。"
}
5 changes: 2 additions & 3 deletions opencti-platform/opencti-front/lang/front/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -2675,9 +2675,7 @@
"Public dashboard": "公共仪表板",
"Restore the state of the graphic before the last expansion": "恢复上次扩展前的图形状态",
"Revert to Pre-Expansion State": "恢复到扩展前状态",
"All actions after the last expansion will be lost": "上次扩展后的所有操作都将丢失",
"Last expansion": "最后扩",
"All actions after the last expansion will be lost.": "最后一次扩展后的所有操作都将丢失。",
"Show left navigation submenu icons": "显示左侧导航子菜单图标",
"Unless specific groups are selected, user will be created with default groups only.": "除非选择了特定组,否则创建的用户将只包含默认组。",
"By enabling the OpenCTI Enterprise Edition, you (and your organization) agrees to the OpenCTI Enterprise Edition (EE) supplemental license terms and conditions of usage:": "启用 OpenCTI 企业版,即表示您(和您的组织)同意 OpenCTI 企业版 (EE) 补充许可条款和使用条件:",
Expand All @@ -2688,5 +2686,6 @@
"All other filters": "所有其他筛选器",
"Testing csv mapper": "测试 csv 映射器",
"This operations will only apply on labels or markings added in the context of this playbook such as enrichment or other knowledge manipulations but not if the labels or markings are already written in the platform.": "此操作仅适用于在此播放列表中添加的标签或标记,如充实或其他知识操作,但不适用于平台中已写入的标签或标记。",
"Auto collapse submenus in left navigation": "自动折叠左侧导航中的子菜单"
"Auto collapse submenus in left navigation": "自动折叠左侧导航中的子菜单",
"All add or remove actions done on the graph after the last expansion will be lost.": "上次扩展后在图形上进行的所有添加或删除操作都将丢失。"
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const InvestigationRollBackExpandDialog = ({ closeDialog, handleRollBackToPreExp
<DialogTitle>{t_i18n('Revert to Pre-Expansion State')}</DialogTitle>
<DialogContent>
<p>{t_i18n('Last expansion')}: {getLastRollBackExpandDate()}</p>
<p>{t_i18n('All actions after the last expansion will be lost.')}</p>
<p>{t_i18n('All add or remove actions done on the graph after the last expansion will be lost.')}</p>
</DialogContent>
<DialogActions>
<Button onClick={closeDialog}>{t_i18n('Cancel')}</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import ForceGraph2D from 'react-force-graph-2d';
import ForceGraph3D from 'react-force-graph-3d';
import RectangleSelection from 'react-rectangle-selection';
import { createFragmentContainer, graphql } from 'react-relay';
import { withRouter } from 'react-router-dom';
import { Subject, timer } from 'rxjs';
import { debounce } from 'rxjs/operators';
import SpriteText from 'three-spritetext';
Expand All @@ -18,7 +17,7 @@ import InvestigationExpandForm from './InvestigationExpandForm';
import inject18n from '../../../../components/i18n';
import { commitMutation, fetchQuery, MESSAGING$ } from '../../../../relay/environment';
import { hexToRGB } from '../../../../utils/Colors';
import setStackDataInSessionStorage from '../../../../utils/sessionStorage/setStackDataInSessionStorage/setStackDataInSessionStorage';
import setStackDataInSessionStorage from './utils/setStackDataInSessionStorage/setStackDataInSessionStorage';
import {
applyFilters,
buildGraphData,
Expand Down Expand Up @@ -1806,12 +1805,11 @@ class InvestigationGraphComponent extends Component {
return;
}

const investigatedEntitiesIdsList = this.graphObjects.map(({ id }) => id);
setStackDataInSessionStorage(
investigationPreExpansionStateListStorageKey,
{
dateTime: new Date().getTime(),
investigatedEntitiesIdsList,
investigatedEntitiesList: this.graphObjects,
},
10,
);
Expand Down Expand Up @@ -1896,49 +1894,45 @@ class InvestigationGraphComponent extends Component {
const storedPreExpansion = getPreExpansionStateList();
if (storedPreExpansion) {
const currentStoredPreExpansion = JSON.parse(storedPreExpansion);
const { investigatedEntitiesIdsList } = currentStoredPreExpansion[0];
const { investigatedEntitiesList } = currentStoredPreExpansion[0];

const graphObjectsToRestore = this.graphObjects.filter((graphObject) => investigatedEntitiesList.find((investigatedEntity) => investigatedEntity.id === graphObject.id));
const graphObjectsToAdd = investigatedEntitiesList.filter((investigatedEntities) => !this.graphObjects.find((graphObject) => graphObject.id === investigatedEntities.id));

const { graphObjectToRestore, graphObjectIdsToRemove } = this.graphObjects.reduce((acc, graphObject) => {
if (investigatedEntitiesIdsList.includes(graphObject.id)) {
acc.graphObjectToRestore = [...acc.graphObjectToRestore, graphObject];
} else {
acc.graphObjectIdsToRemove = [...acc.graphObjectIdsToRemove, graphObject.id];
}
return acc;
}, { graphObjectToRestore: [], graphObjectIdsToRemove: [] });
commitMutation({
mutation: investigationAddStixCoreObjectsLinesRelationsDeleteMutation,
variables: {
id: this.props.workspace.id,
input: {
key: 'investigated_entities_ids',
value: graphObjectIdsToRemove,
operation: 'remove',
value: [
...graphObjectsToRestore.map((graphObjectToRestore) => graphObjectToRestore.id),
...graphObjectsToAdd.map((graphObjectToAdd) => graphObjectToAdd.id),
],
operation: 'replace',
},
},
onCompleted: () => {
this.graphObjects = graphObjectToRestore;

this.graphData = buildGraphData(
graphObjectToRestore,
decodeGraphData(this.props.workspace.graph_data),
this.props.t,
);
});

this.setState({
graphData: applyFilters(
this.graphData,
this.state.stixCoreObjectsTypes,
this.state.markedBy,
this.state.createdBy,
[],
this.state.selectedTimeRangeInterval,
),
});
this.graphObjects = [...graphObjectsToRestore, ...graphObjectsToAdd];
this.graphData = buildGraphData(
[...graphObjectsToRestore, ...graphObjectsToAdd],
decodeGraphData(this.props.workspace.graph_data),
this.props.t,
);

updatePreExpansionStateList(currentStoredPreExpansion);
},
this.setState({
graphData: applyFilters(
this.graphData,
this.state.stixCoreObjectsTypes,
this.state.markedBy,
this.state.createdBy,
[],
this.state.selectedTimeRangeInterval,
),
});

updatePreExpansionStateList(currentStoredPreExpansion);
}
}

Expand Down

0 comments on commit 51c6e0b

Please sign in to comment.