1+ import React from "react" ;
2+ import { useMatch , useNavigate } from "react-router-dom" ;
3+
4+ import {
5+ Divider ,
6+ PageSection ,
7+ PageSectionVariants ,
8+ Text ,
9+ TextContent ,
10+ Toolbar ,
11+ ToolbarContent ,
12+ ToolbarItem ,
13+ } from "@patternfly/react-core" ;
14+
15+ import { ALL_APPLICATIONS_ID } from "@app/Constants" ;
16+ import { Context , SimpleContextSelector } from "@app/context/simple-context" ;
17+ import { ViolationsTable } from "@app/shared/components/violations-table" ;
18+
19+ export const InsightsList : React . FC = ( ) => {
20+ const matchInsightsPage = useMatch ( "/insights" ) ;
21+ const matchAllApplicationsPage = useMatch ( "/insights/applications" ) ;
22+ const matchSingleApplicationPage = useMatch (
23+ "/insights/applications/:applicationId"
24+ ) ;
25+
26+ const applicationId = matchInsightsPage
27+ ? undefined
28+ : matchAllApplicationsPage
29+ ? ALL_APPLICATIONS_ID
30+ : matchSingleApplicationPage ?. params . applicationId ;
31+
32+ const navigate = useNavigate ( ) ;
33+
34+ const onContextChange = ( context : Context ) => {
35+ navigate ( "/insights/applications/" + context . key ) ;
36+ } ;
37+
38+ return (
39+ < >
40+ < PageSection padding = { { default : "noPadding" } } >
41+ < Toolbar >
42+ < ToolbarContent >
43+ < ToolbarItem > Application:</ ToolbarItem >
44+ < ToolbarItem >
45+ < SimpleContextSelector
46+ contextKeyFromURL = { applicationId }
47+ onChange = { onContextChange }
48+ />
49+ </ ToolbarItem >
50+ </ ToolbarContent >
51+ </ Toolbar >
52+ </ PageSection >
53+ < Divider />
54+ < PageSection variant = { PageSectionVariants . light } >
55+ < TextContent >
56+ < Text component = "h1" > Insights</ Text >
57+ < Text component = "small" >
58+ This report provides a concise summary of all insights identified - issues with zero effort.
59+ </ Text >
60+ </ TextContent >
61+ </ PageSection >
62+ < PageSection variant = { PageSectionVariants . default } >
63+ < ViolationsTable applicationId = { applicationId } insightsMode = { true } />
64+ </ PageSection >
65+ </ >
66+ ) ;
67+ } ;
0 commit comments