Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Cloud Posture] track findings pages #144822

Merged
merged 2 commits into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,16 @@ export const findingsNavigation = {
findings_default: {
name: NAV_ITEMS_NAMES.FINDINGS,
path: `${CLOUD_SECURITY_POSTURE_BASE_PATH}/findings/default`,
id: 'cloud_security_posture-findings-default',
},
findings_by_resource: {
name: NAV_ITEMS_NAMES.FINDINGS,
path: `${CLOUD_SECURITY_POSTURE_BASE_PATH}/findings/resource`,
id: 'cloud_security_posture-findings-resource',
},
resource_findings: {
name: NAV_ITEMS_NAMES.FINDINGS,
path: `${CLOUD_SECURITY_POSTURE_BASE_PATH}/findings/resource/:resourceId`,
id: 'cloud_security_posture-findings-resourceId',
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import React from 'react';
import type { UseQueryResult } from '@tanstack/react-query';
import { Redirect, Switch, Route, useLocation } from 'react-router-dom';
import { TrackApplicationView } from '@kbn/usage-collection-plugin/public';
import { useCspSetupStatusApi } from '../../common/api/use_setup_status_api';
import { NoFindingsStates } from '../../components/no_findings_states';
import { CloudPosturePage } from '../../components/cloud_posture_page';
Expand Down Expand Up @@ -57,7 +58,11 @@ export const Findings = () => {
/>
<Route
path={findingsNavigation.findings_default.path}
render={() => <LatestFindingsContainer dataView={dataViewQuery.data!} />}
render={() => (
<TrackApplicationView viewId={findingsNavigation.findings_default.id}>
<LatestFindingsContainer dataView={dataViewQuery.data!} />
</TrackApplicationView>
)}
/>
<Route
path={findingsNavigation.findings_by_resource.path}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { Route, Switch } from 'react-router-dom';
import { EuiFlexGroup, EuiFlexItem, EuiSpacer } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import useLocalStorage from 'react-use/lib/useLocalStorage';
import { TrackApplicationView } from '@kbn/usage-collection-plugin/public';
import type { Evaluation } from '../../../../common/types';
import { CloudPosturePageTitle } from '../../../components/cloud_posture_page_title';
import { FindingsSearchBar } from '../layout/findings_search_bar';
Expand Down Expand Up @@ -49,11 +50,19 @@ export const FindingsByResourceContainer = ({ dataView }: FindingsBaseProps) =>
<Route
exact
path={findingsNavigation.findings_by_resource.path}
render={() => <LatestFindingsByResource dataView={dataView} />}
render={() => (
<TrackApplicationView viewId={findingsNavigation.findings_by_resource.id}>
<LatestFindingsByResource dataView={dataView} />
</TrackApplicationView>
Comment on lines +54 to +56
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could remove the inner routes, and combine findingsNavigation with cloudPosturePages, like we did for benchmarks/rules.

this way we could remove the above code and the initial root-routes wrapper would work.

not critical for now imo tho

)}
/>
<Route
path={findingsNavigation.resource_findings.path}
render={() => <ResourceFindings dataView={dataView} />}
render={() => (
<TrackApplicationView viewId={findingsNavigation.resource_findings.id}>
<ResourceFindings dataView={dataView} />
</TrackApplicationView>
)}
/>
</Switch>
);
Expand Down