Skip to content

Commit

Permalink
[frontend] import and translation fixed, session storage logic remove…
Browse files Browse the repository at this point in the history
…d from component (#3167)
  • Loading branch information
ValentinBouzinFiligran committed Apr 5, 2024
1 parent 1d30c15 commit 98c21bc
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 12 deletions.
2 changes: 1 addition & 1 deletion opencti-platform/opencti-front/lang/back/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -630,5 +630,5 @@
"Entity ID": "ID de l'entité",
"Source connector": "Connecteur source",
"Malware analysis operating System": "Système d'exploitation pour l'analyse des logiciels malveillants",
"Allowed markings": "Marques autorisées"
"Allowed markings": "Marquages autorisés"
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import DialogTitle from '@mui/material/DialogTitle';
import DialogContent from '@mui/material/DialogContent';
import DialogActions from '@mui/material/DialogActions';
import Button from '@mui/material/Button';
import { useFormatter } from 'src/components/i18n';
import { getPreExpansionStateList } from '../utils/investigationStorage';
import { useFormatter } from '../../../../../components/i18n';

type InvestigationRollBackExpandDialogProps = {
closeDialog: () => void;
Expand All @@ -21,7 +22,7 @@ const InvestigationRollBackExpandDialog = ({ closeDialog, handleRollBackToPreExp
};

const getLastRollBackExpandDate = () => {
const storedPreExpansion = sessionStorage.getItem('preExpansionStateList');
const storedPreExpansion = getPreExpansionStateList();
if (storedPreExpansion) {
return fldt(JSON.parse(storedPreExpansion)[0].dateTime);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { withRouter } from 'react-router-dom';
import { Subject, timer } from 'rxjs';
import { debounce } from 'rxjs/operators';
import SpriteText from 'three-spritetext';
import { getPreExpansionStateList, investigationPreExpansionStateListStorageKey, updatePreExpansionStateList } from './utils/investigationStorage';
import InvestigationRollBackExpandDialog from './Dialog/InvestigationRollBackExpandDialog';
import withRouter from '../../../../utils/compat-router/withRouter';
import InvestigationExpandForm from './InvestigationExpandForm';
Expand Down Expand Up @@ -1838,7 +1839,7 @@ class InvestigationGraphComponent extends Component {
}
if (newElementsIds.length > 0) {
setStackDataInSessionStorage(
'preExpansionStateList',
investigationPreExpansionStateListStorageKey,
{
dateTime: new Date().getTime(),
investigatedEntitiesIdsList: newElementsIds,
Expand Down Expand Up @@ -1891,7 +1892,7 @@ class InvestigationGraphComponent extends Component {
}

handleRollBackToPreExpansionState() {
const storedPreExpansion = sessionStorage.getItem('preExpansionStateList');
const storedPreExpansion = getPreExpansionStateList();
if (storedPreExpansion) {
const currentStoredPreExpansion = JSON.parse(storedPreExpansion);
const { investigatedEntitiesIdsList } = currentStoredPreExpansion[0];
Expand Down Expand Up @@ -1928,12 +1929,7 @@ class InvestigationGraphComponent extends Component {
),
});

currentStoredPreExpansion.shift();
if (currentStoredPreExpansion.length === 0) {
sessionStorage.removeItem('preExpansionStateList');
} else {
sessionStorage.setItem('preExpansionStateList', JSON.stringify(currentStoredPreExpansion));
}
updatePreExpansionStateList(currentStoredPreExpansion);
},
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import * as R from 'ramda';
import React, { Component } from 'react';
import TimeRange from 'react-timeline-range-slider';
import { ResponsiveContainer, Scatter, ScatterChart, YAxis, ZAxis } from 'recharts';
import { getPreExpansionStateList } from './utils/investigationStorage';
import InvestigationAddStixCoreObjects from './InvestigationAddStixCoreObjects';
import inject18n from '../../../../components/i18n';
import SearchInput from '../../../../components/SearchInput';
Expand Down Expand Up @@ -355,7 +356,7 @@ class InvestigationGraphBar extends Component {
}
const stixCoreObjectOrRelationshipId = (selectedNodes[0]?.id ?? null) || (selectedLinks[0]?.id ?? null);

const isRollBackToLastPreExpansionStateEnabled = !sessionStorage.getItem('preExpansionStateList');
const isRollBackToLastPreExpansionStateEnabled = !getPreExpansionStateList();

return (
<UserContext.Consumer>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export const investigationPreExpansionStateListStorageKey = 'preExpansionStateList';

type UpdatePreExpansionStateParamsType = Array<{
dateTime: number;
investigatedEntitiesIdsList: string[];
}>;
export const getPreExpansionStateList = () => sessionStorage.getItem(investigationPreExpansionStateListStorageKey);

export const updatePreExpansionStateList = (preExpansionStateList: UpdatePreExpansionStateParamsType) => {
preExpansionStateList.shift();
if (preExpansionStateList.length === 0) {
sessionStorage.removeItem(investigationPreExpansionStateListStorageKey);
} else {
sessionStorage.setItem(investigationPreExpansionStateListStorageKey, JSON.stringify(preExpansionStateList));
}
};

0 comments on commit 98c21bc

Please sign in to comment.