Skip to content

Commit

Permalink
[frontend] Add content mapping in content tab (#5651)
Browse files Browse the repository at this point in the history
Co-authored-by: Jeremy Cloarec <[email protected]>
  • Loading branch information
2 people authored and helene-nguyen committed Jun 14, 2024
1 parent 833c6e0 commit c4d9409
Show file tree
Hide file tree
Showing 56 changed files with 644 additions and 951 deletions.
1 change: 1 addition & 0 deletions opencti-platform/opencti-front/lang/front/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@
"Content": "Inhalt",
"Content mapping view": "Ansicht des Content Mappings",
"Content max marking definition levels": "Maximale Markierungsdefinitionsstufen für Inhalte",
"Content view": "Ansicht des Inhalts",
"contest": "Flüchtige Gruppierung",
"Context": "Kontext",
"context": "Kontext",
Expand Down
1 change: 1 addition & 0 deletions opencti-platform/opencti-front/lang/front/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@
"Content": "Content",
"Content mapping view": "Content mapping view",
"Content max marking definition levels": "Content max marking definition levels",
"Content view": "Content view",
"contest": "Ephemeral groupment",
"Context": "Context",
"context": "Context",
Expand Down
1 change: 1 addition & 0 deletions opencti-platform/opencti-front/lang/front/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@
"Content": "Contenido",
"Content mapping view": "Vista de mapeo de contenidos",
"Content max marking definition levels": "Niveles de definición de marcado máximo de contenido",
"Content view": "Vista del contenido",
"contest": "Movimiento espontáneo",
"context": "Contexto",
"Context": "Contexto",
Expand Down
1 change: 1 addition & 0 deletions opencti-platform/opencti-front/lang/front/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@
"Content": "Contenu",
"Content mapping view": "Vue de la cartographie du contenu",
"Content max marking definition levels": "Niveaux de marquage maximum du contenu",
"Content view": "Vue du contenu",
"contest": "Mouvement spontané",
"context": "Contexte",
"Context": "Contexte",
Expand Down
1 change: 1 addition & 0 deletions opencti-platform/opencti-front/lang/front/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@
"Content": "内容",
"Content mapping view": "コンテンツマッピングビュー",
"Content max marking definition levels": "コンテンツの最大マーキング定義レベル",
"Content view": "コンテンツビュー",
"contest": "一時的なグループ",
"context": "コンテキスト",
"Context": "コンテキスト",
Expand Down
1 change: 1 addition & 0 deletions opencti-platform/opencti-front/lang/front/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@
"Content": "内容",
"Content mapping view": "内容映射视图",
"Content max marking definition levels": "内容最大标记定义级别",
"Content view": "内容视图",
"contest": "比赛",
"context": "关联",
"Context": "上下文",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ export const GroupingCreationForm: FunctionComponent<GroupingFormProps> = ({
const classes = useStyles();
const { t_i18n } = useFormatter();
const navigate = useNavigate();
const { isFeatureEnable } = useHelper();
const contentMappingFeatureFlag = isFeatureEnable('CONTENT_MAPPING');
const [mapAfter, setMapAfter] = useState<boolean>(false);
const basicShape = {
name: Yup.string().trim().min(2).required(t_i18n('This field is required')),
Expand Down Expand Up @@ -149,9 +151,15 @@ export const GroupingCreationForm: FunctionComponent<GroupingFormProps> = ({
onClose();
}
if (mapAfter) {
navigate(
`/dashboard/analyses/groupings/${response.groupingAdd?.id}/knowledge/content`,
);
if (contentMappingFeatureFlag) {
navigate(
`/dashboard/analyses/groupings/${response.groupingAdd?.id}/content/mapping`,
);
} else {
navigate(
`/dashboard/analyses/groupings/${response.groupingAdd?.id}/knowledge/content`,
);
}
}
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import Loader, { LoaderVariant } from '../../../../components/Loader';
import GroupingPopover from './GroupingPopover';
import AttackPatternsMatrix from '../../techniques/attack_patterns/AttackPatternsMatrix';
import { buildViewParamsFromUrlAndStorage, saveViewParameters } from '../../../../utils/ListParameters';
import ContainerContent, { containerContentQuery } from '../../common/containers/ContainerContent';
import investigationAddFromContainer from '../../../../utils/InvestigationUtils';
import ContainerContent, { containerContentQuery } from '../../common/containers/ContainerContent';
import withRouter from '../../../../utils/compat-router/withRouter';

const styles = () => ({
Expand Down Expand Up @@ -210,7 +210,7 @@ class GroupingKnowledgeComponent extends Component {
);
}}
/>
}
}
/>
<Route
path="/correlation"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Tab from '@mui/material/Tab';
import { GraphQLSubscriptionConfig } from 'relay-runtime';
import { RootReportSubscription } from '@components/analyses/reports/__generated__/RootReportSubscription.graphql';
import StixCoreObjectSimulationResult from '@components/common/stix_core_objects/StixCoreObjectSimulationResult';
import StixCoreObjectContent from '../../common/stix_core_objects/StixCoreObjectContent';
import StixCoreObjectContentRoot from '@components/common/stix_core_objects/StixCoreObjectContentRoot';
import { QueryRenderer } from '../../../../relay/environment';
import Grouping from './Grouping';
import GroupingPopover from './GroupingPopover';
Expand All @@ -26,6 +26,7 @@ import { useFormatter } from '../../../../components/i18n';
import Breadcrumbs from '../../../../components/Breadcrumbs';
import { useIsEnforceReference } from '../../../../utils/hooks/useEntitySettings';
import useGranted, { BYPASSREFERENCE } from '../../../../utils/hooks/useGranted';
import { getCurrentTab, getPaddingRight } from '../../../../utils/utils';

const subscription = graphql`
subscription RootGroupingSubscription($id: ID!) {
Expand Down Expand Up @@ -87,6 +88,7 @@ const RootGrouping = () => {
const enableReferences = useIsEnforceReference('Grouping') && !useGranted([BYPASSREFERENCE]);
const { t_i18n } = useFormatter();
useSubscription(subConfig);

return (
<>
<QueryRenderer
Expand All @@ -96,25 +98,8 @@ const RootGrouping = () => {
if (props) {
if (props.grouping) {
const { grouping } = props;
let paddingRight = 0;
const isOverview = location.pathname === `/dashboard/analyses/groupings/${grouping.id}`;
if (
location.pathname.includes(
`/dashboard/analyses/groupings/${grouping.id}/entities`,
)
|| location.pathname.includes(
`/dashboard/analyses/groupings/${grouping.id}/observables`,
)
) {
paddingRight = 250;
}
if (
location.pathname.includes(
`/dashboard/analyses/groupings/${grouping.id}/content`,
)
) {
paddingRight = 350;
}
const paddingRight = getPaddingRight(location.pathname, grouping.id, '/dashboard/analyses/groupings', false);
return (
<div style={{ paddingRight }}>
<Breadcrumbs variant="object" elements={[
Expand All @@ -139,13 +124,7 @@ const RootGrouping = () => {
}}
>
<Tabs
value={
location.pathname.includes(
`/dashboard/analyses/groupings/${grouping.id}/knowledge`,
)
? `/dashboard/analyses/groupings/${grouping.id}/knowledge`
: location.pathname
}
value={getCurrentTab(location.pathname, grouping.id, '/dashboard/analyses/groupings')}
>
<Tab
component={Link}
Expand Down Expand Up @@ -214,10 +193,11 @@ const RootGrouping = () => {
}
/>
<Route
path="/content"
path="/content/*"
element={
<StixCoreObjectContent
<StixCoreObjectContentRoot
stixCoreObject={grouping}
isContainer={true}
/>
}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { GraphQLSubscriptionConfig } from 'relay-runtime';
import Box from '@mui/material/Box';
import Tabs from '@mui/material/Tabs';
import Tab from '@mui/material/Tab';
import StixCoreObjectContentRoot from '@components/common/stix_core_objects/StixCoreObjectContentRoot';
import { QueryRenderer } from '../../../../relay/environment';
import ErrorNotFound from '../../../../components/ErrorNotFound';
import Loader from '../../../../components/Loader';
Expand All @@ -24,6 +25,7 @@ import StixCoreRelationship from '../../common/stix_core_relationships/StixCoreR
import { useFormatter } from '../../../../components/i18n';
import Breadcrumbs from '../../../../components/Breadcrumbs';
import { getMainRepresentative } from '../../../../utils/defaultRepresentatives';
import { getCurrentTab, getPaddingRight } from '../../../../utils/utils';

const subscription = graphql`
subscription RootMalwareAnalysisSubscription($id: ID!) {
Expand Down Expand Up @@ -86,8 +88,9 @@ const RootMalwareAnalysis = () => {
if (props) {
if (props.malwareAnalysis) {
const { malwareAnalysis } = props;
const paddingRight = getPaddingRight(location.pathname, malwareAnalysis.id, '/dashboard/analyses/malware_analyses', false);
return (
<>
<div style={{ paddingRight }}>
<Breadcrumbs variant="object" elements={[
{ label: t_i18n('Analyses') },
{ label: t_i18n('Malware analyses'), link: '/dashboard/analyses/malware_analyses' },
Expand All @@ -98,8 +101,8 @@ const RootMalwareAnalysis = () => {
entityType={'Malware-Analysis'}
stixDomainObject={malwareAnalysis}
PopoverComponent={
<MalwareAnalysisPopover id={malwareAnalysisId} />
}
<MalwareAnalysisPopover id={malwareAnalysisId}/>
}
noAliases={true}
/>
<Box
Expand All @@ -110,13 +113,7 @@ const RootMalwareAnalysis = () => {
}}
>
<Tabs
value={
location.pathname.includes(
`/dashboard/analyses/malware_analyses/${malwareAnalysis.id}/knowledge`,
)
? `/dashboard/analyses/malware_analyses/${malwareAnalysis.id}/knowledge`
: location.pathname
}
value={getCurrentTab(location.pathname, malwareAnalysis.id, '/dashboard/analyses/malware_analyses')}
>
<Tab
component={Link}
Expand All @@ -130,6 +127,12 @@ const RootMalwareAnalysis = () => {
value={`/dashboard/analyses/malware_analyses/${malwareAnalysis.id}/knowledge`}
label={t_i18n('Knowledge')}
/>
<Tab
component={Link}
to={`/dashboard/analyses/malware_analyses/${malwareAnalysis.id}/content`}
value={`/dashboard/analyses/malware_analyses/${malwareAnalysis.id}/content`}
label={t_i18n('Content')}
/>
<Tab
component={Link}
to={`/dashboard/analyses/malware_analyses/${malwareAnalysis.id}/files`}
Expand Down Expand Up @@ -180,6 +183,14 @@ const RootMalwareAnalysis = () => {
entityId={malwareAnalysisId}
/>}
/>
<Route
path="/content/*"
element={
<StixCoreObjectContentRoot
stixCoreObject={malwareAnalysis}
/>
}
/>
<Route
path="/files"
element={
Expand All @@ -198,10 +209,10 @@ const RootMalwareAnalysis = () => {
/>}
/>
</Routes>
</>
</div>
);
}
return <ErrorNotFound />;
return <ErrorNotFound/>;
}
return <Loader />;
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ export const ReportCreationForm: FunctionComponent<ReportFormProps> = ({
const classes = useStyles();
const { t_i18n } = useFormatter();
const navigate = useNavigate();
const { isFeatureEnable } = useHelper();
const contentMappingFeatureFlag = isFeatureEnable('CONTENT_MAPPING');
const [mapAfter, setMapAfter] = useState<boolean>(false);
const basicShape = {
name: Yup.string().trim().min(2, t_i18n('Name must be at least 2 characters')).required(t_i18n('This field is required')),
Expand Down Expand Up @@ -163,9 +165,15 @@ export const ReportCreationForm: FunctionComponent<ReportFormProps> = ({
onClose();
}
if (mapAfter) {
navigate(
`/dashboard/analyses/reports/${response.reportAdd?.id}/knowledge/content`,
);
if (contentMappingFeatureFlag) {
navigate(
`/dashboard/analyses/reports/${response.reportAdd?.id}/content/mapping`,
);
} else {
navigate(
`/dashboard/analyses/reports/${response.reportAdd?.id}/knowledge/content`,
);
}
}
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ class ReportKnowledgeComponent extends Component {
);
}}
/>
)}
)}
/>
<Route
path="/timeline"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { GraphQLSubscriptionConfig } from 'relay-runtime';
import Box from '@mui/material/Box';
import Tabs from '@mui/material/Tabs';
import Tab from '@mui/material/Tab';
import StixCoreObjectContentRoot from '@components/common/stix_core_objects/StixCoreObjectContentRoot';
import StixCoreObjectSimulationResult from '../../common/stix_core_objects/StixCoreObjectSimulationResult';
import { QueryRenderer } from '../../../../relay/environment';
import Report from './Report';
Expand All @@ -22,11 +23,11 @@ import ContainerStixDomainObjects from '../../common/containers/ContainerStixDom
import ContainerStixCyberObservables from '../../common/containers/ContainerStixCyberObservables';
import ErrorNotFound from '../../../../components/ErrorNotFound';
import StixCoreObjectFilesAndHistory from '../../common/stix_core_objects/StixCoreObjectFilesAndHistory';
import StixCoreObjectContent from '../../common/stix_core_objects/StixCoreObjectContent';
import Breadcrumbs from '../../../../components/Breadcrumbs';
import { useFormatter } from '../../../../components/i18n';
import { useIsEnforceReference } from '../../../../utils/hooks/useEntitySettings';
import useGranted, { BYPASSREFERENCE } from '../../../../utils/hooks/useGranted';
import { getCurrentTab, getPaddingRight } from '../../../../utils/utils';

const subscription = graphql`
subscription RootReportSubscription($id: ID!) {
Expand Down Expand Up @@ -86,6 +87,7 @@ const RootReport = () => {
const enableReferences = useIsEnforceReference('Report') && !useGranted([BYPASSREFERENCE]);
const { t_i18n } = useFormatter();
useSubscription(subConfig);

return (
<>
<QueryRenderer
Expand All @@ -95,25 +97,8 @@ const RootReport = () => {
if (props) {
if (props.report) {
const { report } = props;
let paddingRight = 0;
const isOverview = location.pathname === `/dashboard/analyses/reports/${report.id}`;
if (
location.pathname.includes(
`/dashboard/analyses/reports/${report.id}/entities`,
)
|| location.pathname.includes(
`/dashboard/analyses/reports/${report.id}/observables`,
)
) {
paddingRight = 250;
}
if (
location.pathname.includes(
`/dashboard/analyses/reports/${report.id}/content`,
)
) {
paddingRight = 350;
}
const paddingRight = getPaddingRight(location.pathname, reportId, '/dashboard/analyses/reports', false);
return (
<div style={{ paddingRight }} data-testid="report-details-page">
<Breadcrumbs variant="object" elements={[
Expand Down Expand Up @@ -141,13 +126,7 @@ const RootReport = () => {
}}
>
<Tabs
value={
location.pathname.includes(
`/dashboard/analyses/reports/${report.id}/knowledge`,
)
? `/dashboard/analyses/reports/${report.id}/knowledge`
: location.pathname
}
value={getCurrentTab(location.pathname, report.id, '/dashboard/analyses/reports')}
>
<Tab
component={Link}
Expand Down Expand Up @@ -225,10 +204,11 @@ const RootReport = () => {
)}
/>
<Route
path="/content"
path="/content/*"
element={
<StixCoreObjectContent
<StixCoreObjectContentRoot
stixCoreObject={report}
isContainer={true}
/>
}
/>
Expand Down
Loading

0 comments on commit c4d9409

Please sign in to comment.