Skip to content

Commit

Permalink
[frontend] report route + change props.history to props.navigate
Browse files Browse the repository at this point in the history
  • Loading branch information
jpkha committed Jan 31, 2024
1 parent 121f065 commit 898e00b
Show file tree
Hide file tree
Showing 33 changed files with 92 additions and 100 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { Suspense, lazy } from 'react';
import { Routes, Route, Navigate } from 'react-router-dom';
import { Routes, Route, Navigate, useLocation } from 'react-router-dom';

import { boundaryWrapper } from '@components/Error';
import { useIsHiddenEntity } from '../../../utils/hooks/useEntitySettings';
import Loader from '../../../components/Loader';
Expand Down Expand Up @@ -30,6 +31,7 @@ const Root = () => {
} else {
redirect = 'external_references';
}
console.log('Analyses Root', useLocation());
return (
<Suspense fallback={<Loader />}>
<Routes>
Expand All @@ -42,7 +44,7 @@ const Root = () => {
Component={boundaryWrapper(Reports)}
/>
<Route
path="/reports/:reportId"
path="/reports/:reportId/*"
Component={boundaryWrapper(RootReport)}
/>
<Route
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class GroupingKnowledgeComponent extends Component {
const LOCAL_STORAGE_KEY = `grouping-knowledge-${props.grouping.id}`;
super(props);
const params = buildViewParamsFromUrlAndStorage(
props.history,
props.navigate,
props.location,
LOCAL_STORAGE_KEY,
);
Expand All @@ -112,7 +112,7 @@ class GroupingKnowledgeComponent extends Component {

saveView() {
saveViewParameters(
this.props.history,
this.props.navigate,
this.props.location,
`grouping-knowledge-${this.props.grouping.id}`,
this.state,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ class GroupingKnowledgeCorrelationComponent extends Component {
this.selectedNodes = new Set();
this.selectedLinks = new Set();
const params = buildViewParamsFromUrlAndStorage(
props.history,
props.navigate,
props.location,
LOCAL_STORAGE_KEY,
);
Expand Down Expand Up @@ -350,7 +350,7 @@ class GroupingKnowledgeCorrelationComponent extends Component {
saveParameters(refreshGraphData = false) {
const LOCAL_STORAGE_KEY = `grouping-${this.props.grouping.id}-knowledge-correlation`;
saveViewParameters(
this.props.history,
this.props.navigate,
this.props.location,
LOCAL_STORAGE_KEY,
{ zoom: this.zoom, ...this.state },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ class GroupingKnowledgeGraphComponent extends Component {
this.selectedNodes = new Set();
this.selectedLinks = new Set();
const params = buildViewParamsFromUrlAndStorage(
props.history,
props.navigate,
props.location,
LOCAL_STORAGE_KEY,
);
Expand Down Expand Up @@ -557,7 +557,7 @@ class GroupingKnowledgeGraphComponent extends Component {
saveParameters(refreshGraphData = false) {
const LOCAL_STORAGE_KEY = `grouping-${this.props.grouping.id}-knowledge`;
saveViewParameters(
this.props.history,
this.props.navigate,
this.props.location,
LOCAL_STORAGE_KEY,
{ zoom: this.zoom, ...this.state },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const styles = () => ({
class ReportComponent extends Component {
render() {
const { classes, report } = this.props;
console.log(report);
return (
<>
<Grid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class ReportKnowledgeComponent extends Component {
const LOCAL_STORAGE_KEY = `report-knowledge-${props.report.id}`;
super(props);
const params = buildViewParamsFromUrlAndStorage(
props.history,
props.navigate,
props.location,
LOCAL_STORAGE_KEY,
);
Expand All @@ -124,7 +124,7 @@ class ReportKnowledgeComponent extends Component {
saveView() {
const LOCAL_STORAGE_KEY = `report-knowledge-${this.props.report.id}`;
saveViewParameters(
this.props.history,
this.props.navigate,
this.props.location,
LOCAL_STORAGE_KEY,
this.state,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ class ReportKnowledgeCorrelationComponent extends Component {
this.selectedNodes = new Set();
this.selectedLinks = new Set();
const params = buildViewParamsFromUrlAndStorage(
props.history,
props.navigate,
props.location,
LOCAL_STORAGE_KEY,
);
Expand Down Expand Up @@ -350,7 +350,7 @@ class ReportKnowledgeCorrelationComponent extends Component {
saveParameters(refreshGraphData = false) {
const LOCAL_STORAGE_KEY = `report-${this.props.report.id}-knowledge-correlation`;
saveViewParameters(
this.props.history,
this.props.navigate,
this.props.location,
LOCAL_STORAGE_KEY,
{ zoom: this.zoom, ...this.state },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ class ReportKnowledgeGraphComponent extends Component {
this.selectedNodes = new Set();
this.selectedLinks = new Set();
const params = buildViewParamsFromUrlAndStorage(
props.history,
props.navigate,
props.location,
LOCAL_STORAGE_KEY,
);
Expand Down Expand Up @@ -581,7 +581,7 @@ class ReportKnowledgeGraphComponent extends Component {
saveParameters(refreshGraphData = false) {
const LOCAL_STORAGE_KEY = `report-${this.props.report.id}-knowledge`;
saveViewParameters(
this.props.history,
this.props.navigate,
this.props.location,
LOCAL_STORAGE_KEY,
{ zoom: this.zoom, ...this.state },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { Component } from 'react';
import * as PropTypes from 'prop-types';
import { Link, Routes, Redirect, Route } from 'react-router-dom';
import { Link, Routes, Navigate, Route } from 'react-router-dom';
import { graphql } from 'react-relay';
import * as R from 'ramda';
import Box from '@mui/material/Box';
Expand Down Expand Up @@ -82,10 +82,9 @@ class RootReport extends Component {
const {
t,
location,
match: {
params: { reportId },
},
params: { reportId },
} = this.props;
console.log('report Root');
return (
<>
<QueryRenderer
Expand Down Expand Up @@ -177,75 +176,63 @@ class RootReport extends Component {
</Box>
<Routes>
<Route
exact
path="/dashboard/analyses/reports/:reportId"
render={(routeProps) => (
<Report {...routeProps} report={report} />
)}
path="/"
element={
<Report report={report} />
}
/>
<Route
exact
path="/dashboard/analyses/reports/:reportId/entities"
render={(routeProps) => (
path="/entities"
element={
<ContainerStixDomainObjects
{...routeProps}
container={report}
/>
)}
}
/>
<Route
exact
path="/dashboard/analyses/reports/:reportId/observables"
render={(routeProps) => (
path="/observables"
element={
<ContainerStixCyberObservables
{...routeProps}
container={report}
/>
)}
}
/>
<Route
exact
path="/dashboard/analyses/reports/:reportId/knowledge"
render={() => (
<Redirect
path="/knowledge"
element={() => (
<Navigate
to={`/dashboard/analyses/reports/${reportId}/knowledge/graph`}
/>
)}
/>
<Route
exact
path="/dashboard/analyses/reports/:reportId/content"
render={(routeProps) => (
path="/content"
element={
<StixDomainObjectContent
{...routeProps}
stixDomainObject={report}
/>
)}
}
/>
<Route
exact
path="/dashboard/analyses/reports/:reportId/knowledge/:mode"
render={(routeProps) => (
path="/knowledge/:mode"
element={
<ReportKnowledge
{...routeProps}
report={report}
/>
)}
}
/>
<Route
exact
path="/dashboard/analyses/reports/:reportId/files"
render={(routeProps) => (
path="/files"
element={
<StixCoreObjectFilesAndHistory
{...routeProps}
id={reportId}
connectorsExport={props.connectorsForExport}
connectorsImport={props.connectorsForImport}
entity={report}
withoutRelations={true}
bypassEntityId={true}
/>
)}
}
/>
</Routes>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class IncidentKnowledgeComponent extends Component {
const LOCAL_STORAGE_KEY = `case-incident-knowledge-${props.caseData.id}`;
super(props);
const params = buildViewParamsFromUrlAndStorage(
props.history,
props.navigate,
props.location,
LOCAL_STORAGE_KEY,
);
Expand All @@ -125,7 +125,7 @@ class IncidentKnowledgeComponent extends Component {
saveView() {
const LOCAL_STORAGE_KEY = `case-incident-knowledge-${this.props.caseData.id}`;
saveViewParameters(
this.props.history,
this.props.navigate,
this.props.location,
LOCAL_STORAGE_KEY,
this.state,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ class IncidentKnowledgeCorrelationComponent extends Component {
this.selectedNodes = new Set();
this.selectedLinks = new Set();
const params = buildViewParamsFromUrlAndStorage(
props.history,
props.navigate,
props.location,
LOCAL_STORAGE_KEY,
);
Expand Down Expand Up @@ -350,7 +350,7 @@ class IncidentKnowledgeCorrelationComponent extends Component {
saveParameters(refreshGraphData = false) {
const LOCAL_STORAGE_KEY = `case-incident-${this.props.caseData.id}-knowledge-correlation`;
saveViewParameters(
this.props.history,
this.props.navigate,
this.props.location,
LOCAL_STORAGE_KEY,
{ zoom: this.zoom, ...this.state },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ class IncidentKnowledgeGraphComponent extends Component {
this.selectedNodes = new Set();
this.selectedLinks = new Set();
const params = buildViewParamsFromUrlAndStorage(
props.history,
props.navigate,
props.location,
LOCAL_STORAGE_KEY,
);
Expand Down Expand Up @@ -598,7 +598,7 @@ class IncidentKnowledgeGraphComponent extends Component {
saveParameters(refreshGraphData = false) {
const LOCAL_STORAGE_KEY = `incident-case-${this.props.caseData.id}-knowledge`;
saveViewParameters(
this.props.history,
this.props.navigate,
this.props.location,
LOCAL_STORAGE_KEY,
{ zoom: this.zoom, ...this.state },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class CaseRfiKnowledgeComponent extends Component {
const LOCAL_STORAGE_KEY = `case-rfis-knowledge-${props.caseData.id}`;
super(props);
const params = buildViewParamsFromUrlAndStorage(
props.history,
props.navigate,
props.location,
LOCAL_STORAGE_KEY,
);
Expand All @@ -125,7 +125,7 @@ class CaseRfiKnowledgeComponent extends Component {
saveView() {
const LOCAL_STORAGE_KEY = `case-rfis-knowledge-${this.props.caseData.id}`;
saveViewParameters(
this.props.history,
this.props.navigate,
this.props.location,
LOCAL_STORAGE_KEY,
this.state,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ class CaseRfiKnowledgeCorrelationComponent extends Component {
this.selectedNodes = new Set();
this.selectedLinks = new Set();
const params = buildViewParamsFromUrlAndStorage(
props.history,
props.navigate,
props.location,
LOCAL_STORAGE_KEY,
);
Expand Down Expand Up @@ -350,7 +350,7 @@ class CaseRfiKnowledgeCorrelationComponent extends Component {
saveParameters(refreshGraphData = false) {
const LOCAL_STORAGE_KEY = `case-rfis-${this.props.caseData.id}-knowledge-correlation`;
saveViewParameters(
this.props.history,
this.props.navigate,
this.props.location,
LOCAL_STORAGE_KEY,
{ zoom: this.zoom, ...this.state },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ class CaseRfiKnowledgeGraphComponent extends Component {
this.selectedNodes = new Set();
this.selectedLinks = new Set();
const params = buildViewParamsFromUrlAndStorage(
props.history,
props.navigate,
props.location,
LOCAL_STORAGE_KEY,
);
Expand Down Expand Up @@ -597,7 +597,7 @@ class CaseRfiKnowledgeGraphComponent extends Component {
saveParameters(refreshGraphData = false) {
const LOCAL_STORAGE_KEY = `case-rfi-${this.props.caseData.id}-knowledge`;
saveViewParameters(
this.props.history,
this.props.navigate,
this.props.location,
LOCAL_STORAGE_KEY,
{ zoom: this.zoom, ...this.state },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class CaseRftKnowledgeComponent extends Component {
const LOCAL_STORAGE_KEY = `case-rfts-knowledge-${props.caseData.id}`;
super(props);
const params = buildViewParamsFromUrlAndStorage(
props.history,
props.navigate,
props.location,
LOCAL_STORAGE_KEY,
);
Expand All @@ -124,7 +124,7 @@ class CaseRftKnowledgeComponent extends Component {
saveView() {
const LOCAL_STORAGE_KEY = `case-rfts-knowledge-${this.props.caseData.id}`;
saveViewParameters(
this.props.history,
this.props.navigate,
this.props.location,
LOCAL_STORAGE_KEY,
this.state,
Expand Down

0 comments on commit 898e00b

Please sign in to comment.