@kyverno/backstage-plugin-policy-reporter 2.9.0 → 2.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +39 -0
- package/dist/alpha/components/PolicyReporterPoliciesSubPage/PolicyReporterPoliciesSubPage.esm.js +38 -0
- package/dist/alpha/components/PolicyReporterPoliciesSubPage/PolicyReporterPoliciesSubPage.esm.js.map +1 -0
- package/dist/alpha/components/PolicyReporterPoliciesSubPage/index.esm.js +6 -0
- package/dist/alpha/components/PolicyReporterPoliciesSubPage/index.esm.js.map +1 -0
- package/dist/alpha/plugin.esm.js +51 -8
- package/dist/alpha/plugin.esm.js.map +1 -1
- package/dist/alpha.d.ts +25 -0
- package/dist/components/EntityCustomPoliciesContent/EntityCustomPoliciesContent.esm.js +1 -0
- package/dist/components/EntityCustomPoliciesContent/EntityCustomPoliciesContent.esm.js.map +1 -1
- package/dist/components/EntityKyvernoPoliciesContent/EntityKyvernoPoliciesContent.esm.js +1 -0
- package/dist/components/EntityKyvernoPoliciesContent/EntityKyvernoPoliciesContent.esm.js.map +1 -1
- package/dist/components/MissingKubernetesCluster/MissingKubernetesCluster.esm.js +27 -0
- package/dist/components/MissingKubernetesCluster/MissingKubernetesCluster.esm.js.map +1 -0
- package/dist/components/PolicyReportsPage/PolicyReportsPage.esm.js +18 -25
- package/dist/components/PolicyReportsPage/PolicyReportsPage.esm.js.map +1 -1
- package/dist/components/PolicyReportsTable/PolicyReportsTable.esm.js +22 -10
- package/dist/components/PolicyReportsTable/PolicyReportsTable.esm.js.map +1 -1
- package/dist/components/SelectCategory/SelectCategory.esm.js +84 -0
- package/dist/components/SelectCategory/SelectCategory.esm.js.map +1 -0
- package/dist/components/SelectKind/SelectKind.esm.js +84 -0
- package/dist/components/SelectKind/SelectKind.esm.js.map +1 -0
- package/dist/components/SelectNamespace/SelectNamespace.esm.js +52 -8
- package/dist/components/SelectNamespace/SelectNamespace.esm.js.map +1 -1
- package/dist/components/SelectPolicy/SelectPolicy.esm.js +84 -0
- package/dist/components/SelectPolicy/SelectPolicy.esm.js.map +1 -0
- package/dist/components/SelectSource/SelectSource.esm.js +84 -0
- package/dist/components/SelectSource/SelectSource.esm.js.map +1 -0
- package/dist/hooks/usePolicyReportsFilters.esm.js +11 -7
- package/dist/hooks/usePolicyReportsFilters.esm.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/package.json.esm.js +1 -1
- package/package.json +13 -13
- package/dist/hooks/useNamespaces.esm.js +0 -28
- package/dist/hooks/useNamespaces.esm.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
# @kyverno/backstage-plugin-policy-reporter
|
|
2
2
|
|
|
3
|
+
## 2.11.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 32f327e: Add cluster-scoped source, kind, category and policy filters.
|
|
8
|
+
- 32f327e: NFS (/alpha): Add a new subpage for viewing cluster-scoped policies.
|
|
9
|
+
- 32f327e: Backstage verion bump to v1.55.3
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [32f327e]
|
|
14
|
+
- Updated dependencies [32f327e]
|
|
15
|
+
- Updated dependencies [32f327e]
|
|
16
|
+
- @kyverno/backstage-plugin-policy-reporter-common@2.6.0
|
|
17
|
+
|
|
18
|
+
## 2.10.0
|
|
19
|
+
|
|
20
|
+
### Minor Changes
|
|
21
|
+
|
|
22
|
+
- 256fb9a: Added source filtering to the PolicyReportsPage. Users can now filter the list of policy reports by selecting one or more sources from the selected cluster.
|
|
23
|
+
- 2f4ac45: Added policy filtering to the PolicyReportsPage. Users can now filter the list of policy reports by selecting one or more policies from the selected cluster.
|
|
24
|
+
- d598ade: Added category filtering to the PolicyReportsPage. Users can now filter the list of policy reports by selecting one or more categories from the selected cluster.
|
|
25
|
+
- a664d0c: Added kind filtering to the PolicyReportsPage. Users can now filter the list of policy reports by selecting one or more kinds from the selected cluster.
|
|
26
|
+
- a1d0f51: Updated components that make use of the Policy Reporter Backend API to create toast whenever there are any requests errors.
|
|
27
|
+
- 880eecc: Backstage version bump to v1.51.1
|
|
28
|
+
- 44c5238: Backstage version bump to v1.52.0
|
|
29
|
+
|
|
30
|
+
### Patch Changes
|
|
31
|
+
|
|
32
|
+
- d803dd4: Fixed namespace, kind, sources and category filters being cleared when the responsive filter layout remounts. Cleanup now skips while option lists are loading or temporarily empty.
|
|
33
|
+
- dbc7557: Fixed a bug where switching environments would retain the previously selected namespace, even if it didn't exist in the new environment.
|
|
34
|
+
- Updated dependencies [256fb9a]
|
|
35
|
+
- Updated dependencies [2f4ac45]
|
|
36
|
+
- Updated dependencies [d598ade]
|
|
37
|
+
- Updated dependencies [a664d0c]
|
|
38
|
+
- Updated dependencies [880eecc]
|
|
39
|
+
- Updated dependencies [44c5238]
|
|
40
|
+
- @kyverno/backstage-plugin-policy-reporter-common@2.5.0
|
|
41
|
+
|
|
3
42
|
## 2.9.0
|
|
4
43
|
|
|
5
44
|
### Minor Changes
|
package/dist/alpha/components/PolicyReporterPoliciesSubPage/PolicyReporterPoliciesSubPage.esm.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { Progress } from '@backstage/core-components';
|
|
3
|
+
import { Flex } from '@backstage/ui';
|
|
4
|
+
import { useEnvironments } from '../../../hooks/useEnvironments.esm.js';
|
|
5
|
+
import { SelectEnvironment } from '../../../components/SelectEnvironment/SelectEnvironment.esm.js';
|
|
6
|
+
import { PolicyReportsTable } from '../../../components/PolicyReportsTable/PolicyReportsTable.esm.js';
|
|
7
|
+
import { SearchField } from '../../../components/SearchField/SearchField.esm.js';
|
|
8
|
+
import { PolicyReportsFiltersProvider } from '../../../hooks/usePolicyReportsFilters.esm.js';
|
|
9
|
+
import { FilterLayout } from '../../../components/FilterLayout/FilterLayout.esm.js';
|
|
10
|
+
import { MissingKubernetesCluster } from '../../../components/MissingKubernetesCluster/MissingKubernetesCluster.esm.js';
|
|
11
|
+
|
|
12
|
+
const PolicyReporterPoliciesSubPage = (props) => {
|
|
13
|
+
const { initiallySelectedFilter, filters, context } = props;
|
|
14
|
+
const { environments, environmentsLoading } = useEnvironments();
|
|
15
|
+
if (environmentsLoading) return /* @__PURE__ */ jsx(Progress, {});
|
|
16
|
+
if (!environments?.length) return /* @__PURE__ */ jsx(MissingKubernetesCluster, {});
|
|
17
|
+
return /* @__PURE__ */ jsx(
|
|
18
|
+
PolicyReportsFiltersProvider,
|
|
19
|
+
{
|
|
20
|
+
defaultEnvironment: environments[0].entityRef,
|
|
21
|
+
context,
|
|
22
|
+
defaultFilters: initiallySelectedFilter,
|
|
23
|
+
children: /* @__PURE__ */ jsxs(FilterLayout, { children: [
|
|
24
|
+
/* @__PURE__ */ jsxs(FilterLayout.Filters, { children: [
|
|
25
|
+
/* @__PURE__ */ jsx(SelectEnvironment, { environments }),
|
|
26
|
+
filters
|
|
27
|
+
] }),
|
|
28
|
+
/* @__PURE__ */ jsx(FilterLayout.Content, { children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: "4", children: [
|
|
29
|
+
/* @__PURE__ */ jsx(SearchField, {}),
|
|
30
|
+
/* @__PURE__ */ jsx(PolicyReportsTable, { emptyContentText: "No policies found" })
|
|
31
|
+
] }) })
|
|
32
|
+
] })
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export { PolicyReporterPoliciesSubPage };
|
|
38
|
+
//# sourceMappingURL=PolicyReporterPoliciesSubPage.esm.js.map
|
package/dist/alpha/components/PolicyReporterPoliciesSubPage/PolicyReporterPoliciesSubPage.esm.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PolicyReporterPoliciesSubPage.esm.js","sources":["../../../../src/alpha/components/PolicyReporterPoliciesSubPage/PolicyReporterPoliciesSubPage.tsx"],"sourcesContent":["import { Progress } from '@backstage/core-components';\nimport { Flex } from '@backstage/ui';\nimport { useEnvironments } from '../../../hooks/useEnvironments';\nimport { SelectEnvironment } from '../../../components/SelectEnvironment';\nimport { PolicyReportsTable } from '../../../components/PolicyReportsTable';\nimport { SearchField } from '../../../components/SearchField';\nimport { PolicyReportsFiltersProvider } from '../../../hooks/usePolicyReportsFilters';\nimport { FilterLayout } from '../../../components/FilterLayout';\nimport { MissingKubernetesCluster } from '../../../components/MissingKubernetesCluster';\nimport { Filter } from '@kyverno/backstage-plugin-policy-reporter-common';\nimport { ReactNode } from 'react';\n\nexport interface PolicyReporterPoliciesSubPageProps {\n // This naming aligns with the current Backstage catalog page\n initiallySelectedFilter?: Filter;\n // TODO: Could we implement something like this ?\n // columns?: TableColumn<CatalogTableRow>[] | CatalogTableColumnsFunc;\n filters?: ReactNode;\n context: 'namespaced' | 'cluster';\n}\n\nexport const PolicyReporterPoliciesSubPage = (\n props: PolicyReporterPoliciesSubPageProps,\n) => {\n const { initiallySelectedFilter, filters, context } = props;\n const { environments, environmentsLoading } = useEnvironments();\n\n // Loading environments\n if (environmentsLoading) return <Progress />;\n\n // Environment missing\n if (!environments?.length) return <MissingKubernetesCluster />;\n\n return (\n <PolicyReportsFiltersProvider\n defaultEnvironment={environments[0].entityRef}\n context={context}\n defaultFilters={initiallySelectedFilter}\n >\n <FilterLayout>\n <FilterLayout.Filters>\n <SelectEnvironment environments={environments} />\n {filters}\n </FilterLayout.Filters>\n <FilterLayout.Content>\n <Flex direction=\"column\" gap=\"4\">\n <SearchField />\n <PolicyReportsTable emptyContentText=\"No policies found\" />\n </Flex>\n </FilterLayout.Content>\n </FilterLayout>\n </PolicyReportsFiltersProvider>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;AAqBO,MAAM,6BAAA,GAAgC,CAC3C,KAAA,KACG;AACH,EAAA,MAAM,EAAE,uBAAA,EAAyB,OAAA,EAAS,OAAA,EAAQ,GAAI,KAAA;AACtD,EAAA,MAAM,EAAE,YAAA,EAAc,mBAAA,EAAoB,GAAI,eAAA,EAAgB;AAG9D,EAAA,IAAI,mBAAA,EAAqB,uBAAO,GAAA,CAAC,QAAA,EAAA,EAAS,CAAA;AAG1C,EAAA,IAAI,CAAC,YAAA,EAAc,MAAA,EAAQ,2BAAQ,wBAAA,EAAA,EAAyB,CAAA;AAE5D,EAAA,uBACE,GAAA;AAAA,IAAC,4BAAA;AAAA,IAAA;AAAA,MACC,kBAAA,EAAoB,YAAA,CAAa,CAAC,CAAA,CAAE,SAAA;AAAA,MACpC,OAAA;AAAA,MACA,cAAA,EAAgB,uBAAA;AAAA,MAEhB,+BAAC,YAAA,EAAA,EACC,QAAA,EAAA;AAAA,wBAAA,IAAA,CAAC,YAAA,CAAa,SAAb,EACC,QAAA,EAAA;AAAA,0BAAA,GAAA,CAAC,qBAAkB,YAAA,EAA4B,CAAA;AAAA,UAC9C;AAAA,SAAA,EACH,CAAA;AAAA,wBACA,GAAA,CAAC,aAAa,OAAA,EAAb,EACC,+BAAC,IAAA,EAAA,EAAK,SAAA,EAAU,QAAA,EAAS,GAAA,EAAI,GAAA,EAC3B,QAAA,EAAA;AAAA,0BAAA,GAAA,CAAC,WAAA,EAAA,EAAY,CAAA;AAAA,0BACb,GAAA,CAAC,kBAAA,EAAA,EAAmB,gBAAA,EAAiB,mBAAA,EAAoB;AAAA,SAAA,EAC3D,CAAA,EACF;AAAA,OAAA,EACF;AAAA;AAAA,GACF;AAEJ;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
package/dist/alpha/plugin.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { ApiBlueprint, fetchApiRef, discoveryApiRef, PageBlueprint, SubPageBlueprint, createRouteRef, createFrontendPlugin } from '@backstage/frontend-plugin-api';
|
|
3
3
|
import { rootRouteRef } from '../routes.esm.js';
|
|
4
4
|
import { policyReporterApiRef } from '../api/PolicyReporterClient.esm.js';
|
|
@@ -6,6 +6,14 @@ import { DefaultApiClient } from '@kyverno/backstage-plugin-policy-reporter-comm
|
|
|
6
6
|
import { EntityContentBlueprint } from '@backstage/plugin-catalog-react/alpha';
|
|
7
7
|
import { isPolicyReporterAvailable } from '../utils/annotations.esm.js';
|
|
8
8
|
import PolicyIcon from '@material-ui/icons/Policy';
|
|
9
|
+
import { Container } from '@backstage/ui';
|
|
10
|
+
import { SelectStatus } from '../components/SelectStatus/SelectStatus.esm.js';
|
|
11
|
+
import { SelectSeverity } from '../components/SelectSeverity/SelectSeverity.esm.js';
|
|
12
|
+
import { SelectNamespace } from '../components/SelectNamespace/SelectNamespace.esm.js';
|
|
13
|
+
import { SelectSource } from '../components/SelectSource/SelectSource.esm.js';
|
|
14
|
+
import { SelectKind } from '../components/SelectKind/SelectKind.esm.js';
|
|
15
|
+
import { SelectCategory } from '../components/SelectCategory/SelectCategory.esm.js';
|
|
16
|
+
import { SelectPolicy } from '../components/SelectPolicy/SelectPolicy.esm.js';
|
|
9
17
|
|
|
10
18
|
const policyReporterApi = ApiBlueprint.make({
|
|
11
19
|
params: (defineParams) => defineParams({
|
|
@@ -25,17 +33,51 @@ const policyReporterPage = PageBlueprint.make({
|
|
|
25
33
|
icon: /* @__PURE__ */ jsx(PolicyIcon, {})
|
|
26
34
|
}
|
|
27
35
|
});
|
|
28
|
-
const
|
|
36
|
+
const policyReporterClusterPoliciesSubPage = SubPageBlueprint.make({
|
|
37
|
+
name: "cluster-policy",
|
|
38
|
+
params: {
|
|
39
|
+
path: "cluster-policies",
|
|
40
|
+
routeRef: createRouteRef(),
|
|
41
|
+
title: "Cluster Policies",
|
|
42
|
+
loader: () => import('./components/PolicyReporterPoliciesSubPage/index.esm.js').then((m) => /* @__PURE__ */ jsx(Container, { children: /* @__PURE__ */ jsx(
|
|
43
|
+
m.PolicyReporterPoliciesSubPage,
|
|
44
|
+
{
|
|
45
|
+
initiallySelectedFilter: { status: ["fail"] },
|
|
46
|
+
context: "cluster",
|
|
47
|
+
filters: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
48
|
+
/* @__PURE__ */ jsx(SelectStatus, {}),
|
|
49
|
+
/* @__PURE__ */ jsx(SelectSeverity, {}),
|
|
50
|
+
/* @__PURE__ */ jsx(SelectSource, {}),
|
|
51
|
+
/* @__PURE__ */ jsx(SelectKind, {}),
|
|
52
|
+
/* @__PURE__ */ jsx(SelectCategory, {}),
|
|
53
|
+
/* @__PURE__ */ jsx(SelectPolicy, {})
|
|
54
|
+
] })
|
|
55
|
+
}
|
|
56
|
+
) }))
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
const policyReporterNamespacedPoliciesSubPage = SubPageBlueprint.make({
|
|
29
60
|
name: "namespaced-policy",
|
|
30
61
|
params: {
|
|
31
62
|
path: "namespaced-policies",
|
|
32
63
|
routeRef: createRouteRef(),
|
|
33
|
-
// TODO: Support configuration of the actual component
|
|
34
64
|
title: "Namespaced Policies",
|
|
35
|
-
loader: () => (
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
65
|
+
loader: () => import('./components/PolicyReporterPoliciesSubPage/index.esm.js').then((m) => /* @__PURE__ */ jsx(Container, { children: /* @__PURE__ */ jsx(
|
|
66
|
+
m.PolicyReporterPoliciesSubPage,
|
|
67
|
+
{
|
|
68
|
+
initiallySelectedFilter: { status: ["fail"] },
|
|
69
|
+
context: "namespaced",
|
|
70
|
+
filters: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
71
|
+
/* @__PURE__ */ jsx(SelectStatus, {}),
|
|
72
|
+
/* @__PURE__ */ jsx(SelectSeverity, {}),
|
|
73
|
+
/* @__PURE__ */ jsx(SelectNamespace, {}),
|
|
74
|
+
/* @__PURE__ */ jsx(SelectSource, {}),
|
|
75
|
+
/* @__PURE__ */ jsx(SelectKind, {}),
|
|
76
|
+
/* @__PURE__ */ jsx(SelectCategory, {}),
|
|
77
|
+
/* @__PURE__ */ jsx(SelectPolicy, {})
|
|
78
|
+
] })
|
|
79
|
+
}
|
|
80
|
+
) }))
|
|
39
81
|
}
|
|
40
82
|
});
|
|
41
83
|
const policyReporterEntityContent = EntityContentBlueprint.make({
|
|
@@ -62,7 +104,8 @@ var plugin = createFrontendPlugin({
|
|
|
62
104
|
policyReporterApi,
|
|
63
105
|
policyReporterEntityContent,
|
|
64
106
|
policyReporterPage,
|
|
65
|
-
|
|
107
|
+
policyReporterNamespacedPoliciesSubPage,
|
|
108
|
+
policyReporterClusterPoliciesSubPage
|
|
66
109
|
]
|
|
67
110
|
});
|
|
68
111
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.esm.js","sources":["../../src/alpha/plugin.tsx"],"sourcesContent":["import {\n ApiBlueprint,\n createFrontendPlugin,\n createRouteRef,\n discoveryApiRef,\n fetchApiRef,\n PageBlueprint,\n SubPageBlueprint,\n} from '@backstage/frontend-plugin-api';\n\nimport { rootRouteRef } from '../routes';\nimport { policyReporterApiRef } from '../api';\nimport { DefaultApiClient } from '@kyverno/backstage-plugin-policy-reporter-common';\
|
|
1
|
+
{"version":3,"file":"plugin.esm.js","sources":["../../src/alpha/plugin.tsx"],"sourcesContent":["import {\n ApiBlueprint,\n createFrontendPlugin,\n createRouteRef,\n discoveryApiRef,\n fetchApiRef,\n PageBlueprint,\n SubPageBlueprint,\n} from '@backstage/frontend-plugin-api';\n\nimport { rootRouteRef } from '../routes';\nimport { policyReporterApiRef } from '../api';\nimport { DefaultApiClient } from '@kyverno/backstage-plugin-policy-reporter-common';\nimport { EntityContentBlueprint } from '@backstage/plugin-catalog-react/alpha';\nimport { isPolicyReporterAvailable } from '../utils/annotations';\nimport PolicyIcon from '@material-ui/icons/Policy';\nimport { Container } from '@backstage/ui';\nimport { SelectStatus } from '../components/SelectStatus';\nimport { SelectSeverity } from '../components/SelectSeverity';\nimport { SelectNamespace } from '../components/SelectNamespace';\nimport { SelectSource } from '../components/SelectSource';\nimport { SelectKind } from '../components/SelectKind';\nimport { SelectCategory } from '../components/SelectCategory';\nimport { SelectPolicy } from '../components/SelectPolicy';\n\n/** @alpha */\nexport const policyReporterApi = ApiBlueprint.make({\n params: defineParams =>\n defineParams({\n api: policyReporterApiRef,\n deps: {\n discoveryApi: discoveryApiRef,\n fetchApi: fetchApiRef,\n },\n factory: ({ discoveryApi, fetchApi }) =>\n new DefaultApiClient({ discoveryApi, fetchApi }),\n }),\n});\n\n/** @alpha */\nconst policyReporterPage = PageBlueprint.make({\n params: {\n path: '/policy-reporter',\n routeRef: rootRouteRef,\n title: 'Policy Reporter',\n icon: <PolicyIcon />,\n },\n});\n\n/** @alpha */\nconst policyReporterClusterPoliciesSubPage = SubPageBlueprint.make({\n name: 'cluster-policy',\n params: {\n path: 'cluster-policies',\n routeRef: createRouteRef(),\n title: 'Cluster Policies',\n loader: () =>\n import('./components/PolicyReporterPoliciesSubPage').then(m => (\n <Container>\n <m.PolicyReporterPoliciesSubPage\n // TODO: Add support for configuring initiallySelectedFilter using NFS\n initiallySelectedFilter={{ status: ['fail'] }}\n context=\"cluster\"\n // TODO: Add support for configuring filters using NFS blueprint/extension\n filters={\n <>\n <SelectStatus />\n <SelectSeverity />\n <SelectSource />\n <SelectKind />\n <SelectCategory />\n <SelectPolicy />\n </>\n }\n />\n </Container>\n )),\n },\n});\n\n/** @alpha */\nconst policyReporterNamespacedPoliciesSubPage = SubPageBlueprint.make({\n name: 'namespaced-policy',\n params: {\n path: 'namespaced-policies',\n routeRef: createRouteRef(),\n title: 'Namespaced Policies',\n loader: () =>\n import('./components/PolicyReporterPoliciesSubPage').then(m => (\n <Container>\n <m.PolicyReporterPoliciesSubPage\n // TODO: Add support for configuring initiallySelectedFilter using NFS\n initiallySelectedFilter={{ status: ['fail'] }}\n context=\"namespaced\"\n // TODO: Add support for configuring filters using NFS blueprint/extension\n filters={\n <>\n <SelectStatus />\n <SelectSeverity />\n <SelectNamespace />\n <SelectSource />\n <SelectKind />\n <SelectCategory />\n <SelectPolicy />\n </>\n }\n />\n </Container>\n )),\n },\n});\n\n/** @alpha */\nconst policyReporterEntityContent = EntityContentBlueprint.make({\n name: 'policy-reporter',\n params: {\n path: '/policy-reporter',\n title: 'Policy Reporter',\n // TODO: Support configuration of the actual component\n filter: isPolicyReporterAvailable,\n loader: () =>\n // TODO: Create dedicated EntityPolicyReporterContent component as replacement for Kyverno and Custom content components\n import('../components/EntityKyvernoPoliciesContent/').then(m => (\n <m.EntityKyvernoPoliciesContent />\n )),\n },\n});\n\n/** @alpha */\nexport default createFrontendPlugin({\n pluginId: 'policy-reporter',\n title: 'Policy Reporter',\n info: { packageJson: () => import('../../package.json') },\n routes: {\n root: rootRouteRef,\n },\n extensions: [\n policyReporterApi,\n policyReporterEntityContent,\n policyReporterPage,\n policyReporterNamespacedPoliciesSubPage,\n policyReporterClusterPoliciesSubPage,\n ],\n});\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AA0BO,MAAM,iBAAA,GAAoB,aAAa,IAAA,CAAK;AAAA,EACjD,MAAA,EAAQ,kBACN,YAAA,CAAa;AAAA,IACX,GAAA,EAAK,oBAAA;AAAA,IACL,IAAA,EAAM;AAAA,MACJ,YAAA,EAAc,eAAA;AAAA,MACd,QAAA,EAAU;AAAA,KACZ;AAAA,IACA,OAAA,EAAS,CAAC,EAAE,YAAA,EAAc,QAAA,EAAS,KACjC,IAAI,gBAAA,CAAiB,EAAE,YAAA,EAAc,QAAA,EAAU;AAAA,GAClD;AACL,CAAC;AAGD,MAAM,kBAAA,GAAqB,cAAc,IAAA,CAAK;AAAA,EAC5C,MAAA,EAAQ;AAAA,IACN,IAAA,EAAM,kBAAA;AAAA,IACN,QAAA,EAAU,YAAA;AAAA,IACV,KAAA,EAAO,iBAAA;AAAA,IACP,IAAA,sBAAO,UAAA,EAAA,EAAW;AAAA;AAEtB,CAAC,CAAA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99
|
noHeader?: boolean;
|
|
100
100
|
};
|
|
101
101
|
}>;
|
|
102
|
+
"sub-page:policy-reporter/cluster-policy": _backstage_frontend_plugin_api.OverridableExtensionDefinition<{
|
|
103
|
+
kind: "sub-page";
|
|
104
|
+
name: "cluster-policy";
|
|
105
|
+
config: {
|
|
106
|
+
path: string | undefined;
|
|
107
|
+
title: string | undefined;
|
|
108
|
+
};
|
|
109
|
+
configInput: {
|
|
110
|
+
path?: string | undefined;
|
|
111
|
+
title?: string | undefined;
|
|
112
|
+
};
|
|
113
|
+
output: _backstage_frontend_plugin_api.ExtensionDataRef<string, "core.routing.path", {}> | _backstage_frontend_plugin_api.ExtensionDataRef<react.JSX.Element, "core.reactElement", {}> | _backstage_frontend_plugin_api.ExtensionDataRef<_backstage_frontend_plugin_api.RouteRef<_backstage_frontend_plugin_api.AnyRouteRefParams>, "core.routing.ref", {
|
|
114
|
+
optional: true;
|
|
115
|
+
}> | _backstage_frontend_plugin_api.ExtensionDataRef<string, "core.title", {}> | _backstage_frontend_plugin_api.ExtensionDataRef<_backstage_frontend_plugin_api.IconElement, "core.icon", {
|
|
116
|
+
optional: true;
|
|
117
|
+
}>;
|
|
118
|
+
inputs: {};
|
|
119
|
+
params: {
|
|
120
|
+
path: string;
|
|
121
|
+
title: string;
|
|
122
|
+
icon?: _backstage_frontend_plugin_api.IconElement;
|
|
123
|
+
loader: () => Promise<JSX.Element>;
|
|
124
|
+
routeRef?: _backstage_frontend_plugin_api.RouteRef;
|
|
125
|
+
};
|
|
126
|
+
}>;
|
|
102
127
|
"sub-page:policy-reporter/namespaced-policy": _backstage_frontend_plugin_api.OverridableExtensionDefinition<{
|
|
103
128
|
kind: "sub-page";
|
|
104
129
|
name: "namespaced-policy";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityCustomPoliciesContent.esm.js","sources":["../../../src/components/EntityCustomPoliciesContent/EntityCustomPoliciesContent.tsx"],"sourcesContent":["import { Content, Progress } from '@backstage/core-components';\nimport {\n MissingAnnotationEmptyState,\n useEntity,\n} from '@backstage/plugin-catalog-react';\nimport { Container, Header } from '@backstage/ui';\nimport { PolicyReportsTable } from '../PolicyReportsTable';\nimport { SelectEnvironment } from '../SelectEnvironment';\nimport {\n getKinds,\n getNamespaces,\n getResourceName,\n isPolicyReporterAvailable,\n} from '../../utils/annotations';\nimport { MissingEnvironmentsEmptyState } from '../MissingEnvironmentsEmptyState';\nimport { useEntityEnvironment } from '../../hooks/useEntityEnvironment';\nimport { PolicyReportsFiltersProvider } from '../../hooks/usePolicyReportsFilters';\nimport { KYVERNO_RESOURCE_NAME_ANNOTATION } from '@kyverno/backstage-plugin-policy-reporter-common';\nimport { SelectStatus } from '../SelectStatus';\nimport { SelectSeverity } from '../SelectSeverity';\nimport { FilterLayout } from '../FilterLayout';\n\ntype EntityCustomPoliciesContentProps = {\n annotationsDocumentationUrl?: string;\n policyDocumentationUrl?: string;\n sources: string[];\n title: string;\n};\n\nexport const EntityCustomPoliciesContent = ({\n annotationsDocumentationUrl,\n policyDocumentationUrl,\n sources,\n title,\n}: EntityCustomPoliciesContentProps) => {\n const { entity } = useEntity();\n const annotations = entity.metadata.annotations;\n\n const annotationsState = isPolicyReporterAvailable(entity);\n\n const { environments, environmentsLoading } = useEntityEnvironment(\n entity,\n annotationsState,\n );\n\n // Annotations missing\n if (!annotationsState)\n return (\n <Container>\n <Content>\n <MissingAnnotationEmptyState\n readMoreUrl={annotationsDocumentationUrl}\n annotation={KYVERNO_RESOURCE_NAME_ANNOTATION}\n />\n </Content>\n </Container>\n );\n\n // Fetching environments\n if (environmentsLoading) return <Progress />;\n\n // Environments missing\n if (!environments?.length)\n return (\n <Container>\n <Content>\n <MissingEnvironmentsEmptyState entity={entity} />\n </Content>\n </Container>\n );\n\n return (\n <PolicyReportsFiltersProvider\n defaultFilters={{\n namespaces: getNamespaces(annotations),\n kinds: getKinds(annotations),\n sources: sources,\n search: getResourceName(annotations),\n }}\n defaultEnvironment={environments[0].entityRef}\n >\n <Container>\n <Header\n title={title}\n customActions={<SelectEnvironment environments={environments} />}\n />\n <Content>\n <FilterLayout>\n <FilterLayout.Filters>\n <SelectStatus />\n <SelectSeverity />\n </FilterLayout.Filters>\n <FilterLayout.Content>\n <PolicyReportsTable\n emptyContentText=\"No policies\"\n policyDocumentationUrl={policyDocumentationUrl}\n />\n </FilterLayout.Content>\n </FilterLayout>\n </Content>\n </Container>\n </PolicyReportsFiltersProvider>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AA6BO,MAAM,8BAA8B,CAAC;AAAA,EAC1C,2BAAA;AAAA,EACA,sBAAA;AAAA,EACA,OAAA;AAAA,EACA;AACF,CAAA,KAAwC;AACtC,EAAA,MAAM,EAAE,MAAA,EAAO,GAAI,SAAA,EAAU;AAC7B,EAAA,MAAM,WAAA,GAAc,OAAO,QAAA,CAAS,WAAA;AAEpC,EAAA,MAAM,gBAAA,GAAmB,0BAA0B,MAAM,CAAA;AAEzD,EAAA,MAAM,EAAE,YAAA,EAAc,mBAAA,EAAoB,GAAI,oBAAA;AAAA,IAC5C,MAAA;AAAA,IACA;AAAA,GACF;AAGA,EAAA,IAAI,CAAC,gBAAA;AACH,IAAA,uBACE,GAAA,CAAC,SAAA,EAAA,EACC,QAAA,kBAAA,GAAA,CAAC,OAAA,EAAA,EACC,QAAA,kBAAA,GAAA;AAAA,MAAC,2BAAA;AAAA,MAAA;AAAA,QACC,WAAA,EAAa,2BAAA;AAAA,QACb,UAAA,EAAY;AAAA;AAAA,OAEhB,CAAA,EACF,CAAA;AAIJ,EAAA,IAAI,mBAAA,EAAqB,uBAAO,GAAA,CAAC,QAAA,EAAA,EAAS,CAAA;AAG1C,EAAA,IAAI,CAAC,YAAA,EAAc,MAAA;AACjB,IAAA,uBACE,GAAA,CAAC,aACC,QAAA,kBAAA,GAAA,CAAC,OAAA,EAAA,EACC,8BAAC,6BAAA,EAAA,EAA8B,MAAA,EAAgB,GACjD,CAAA,EACF,CAAA;AAGJ,EAAA,uBACE,GAAA;AAAA,IAAC,4BAAA;AAAA,IAAA;AAAA,MACC,cAAA,EAAgB;AAAA,QACd,UAAA,EAAY,cAAc,WAAW,CAAA;AAAA,QACrC,KAAA,EAAO,SAAS,WAAW,CAAA;AAAA,QAC3B,OAAA;AAAA,QACA,MAAA,EAAQ,gBAAgB,WAAW;AAAA,OACrC;AAAA,MACA,kBAAA,EAAoB,YAAA,CAAa,CAAC,CAAA,CAAE,SAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"EntityCustomPoliciesContent.esm.js","sources":["../../../src/components/EntityCustomPoliciesContent/EntityCustomPoliciesContent.tsx"],"sourcesContent":["import { Content, Progress } from '@backstage/core-components';\nimport {\n MissingAnnotationEmptyState,\n useEntity,\n} from '@backstage/plugin-catalog-react';\nimport { Container, Header } from '@backstage/ui';\nimport { PolicyReportsTable } from '../PolicyReportsTable';\nimport { SelectEnvironment } from '../SelectEnvironment';\nimport {\n getKinds,\n getNamespaces,\n getResourceName,\n isPolicyReporterAvailable,\n} from '../../utils/annotations';\nimport { MissingEnvironmentsEmptyState } from '../MissingEnvironmentsEmptyState';\nimport { useEntityEnvironment } from '../../hooks/useEntityEnvironment';\nimport { PolicyReportsFiltersProvider } from '../../hooks/usePolicyReportsFilters';\nimport { KYVERNO_RESOURCE_NAME_ANNOTATION } from '@kyverno/backstage-plugin-policy-reporter-common';\nimport { SelectStatus } from '../SelectStatus';\nimport { SelectSeverity } from '../SelectSeverity';\nimport { FilterLayout } from '../FilterLayout';\n\ntype EntityCustomPoliciesContentProps = {\n annotationsDocumentationUrl?: string;\n policyDocumentationUrl?: string;\n sources: string[];\n title: string;\n};\n\nexport const EntityCustomPoliciesContent = ({\n annotationsDocumentationUrl,\n policyDocumentationUrl,\n sources,\n title,\n}: EntityCustomPoliciesContentProps) => {\n const { entity } = useEntity();\n const annotations = entity.metadata.annotations;\n\n const annotationsState = isPolicyReporterAvailable(entity);\n\n const { environments, environmentsLoading } = useEntityEnvironment(\n entity,\n annotationsState,\n );\n\n // Annotations missing\n if (!annotationsState)\n return (\n <Container>\n <Content>\n <MissingAnnotationEmptyState\n readMoreUrl={annotationsDocumentationUrl}\n annotation={KYVERNO_RESOURCE_NAME_ANNOTATION}\n />\n </Content>\n </Container>\n );\n\n // Fetching environments\n if (environmentsLoading) return <Progress />;\n\n // Environments missing\n if (!environments?.length)\n return (\n <Container>\n <Content>\n <MissingEnvironmentsEmptyState entity={entity} />\n </Content>\n </Container>\n );\n\n return (\n <PolicyReportsFiltersProvider\n defaultFilters={{\n namespaces: getNamespaces(annotations),\n kinds: getKinds(annotations),\n sources: sources,\n search: getResourceName(annotations),\n }}\n defaultEnvironment={environments[0].entityRef}\n context=\"namespaced\"\n >\n <Container>\n <Header\n title={title}\n customActions={<SelectEnvironment environments={environments} />}\n />\n <Content>\n <FilterLayout>\n <FilterLayout.Filters>\n <SelectStatus />\n <SelectSeverity />\n </FilterLayout.Filters>\n <FilterLayout.Content>\n <PolicyReportsTable\n emptyContentText=\"No policies\"\n policyDocumentationUrl={policyDocumentationUrl}\n />\n </FilterLayout.Content>\n </FilterLayout>\n </Content>\n </Container>\n </PolicyReportsFiltersProvider>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AA6BO,MAAM,8BAA8B,CAAC;AAAA,EAC1C,2BAAA;AAAA,EACA,sBAAA;AAAA,EACA,OAAA;AAAA,EACA;AACF,CAAA,KAAwC;AACtC,EAAA,MAAM,EAAE,MAAA,EAAO,GAAI,SAAA,EAAU;AAC7B,EAAA,MAAM,WAAA,GAAc,OAAO,QAAA,CAAS,WAAA;AAEpC,EAAA,MAAM,gBAAA,GAAmB,0BAA0B,MAAM,CAAA;AAEzD,EAAA,MAAM,EAAE,YAAA,EAAc,mBAAA,EAAoB,GAAI,oBAAA;AAAA,IAC5C,MAAA;AAAA,IACA;AAAA,GACF;AAGA,EAAA,IAAI,CAAC,gBAAA;AACH,IAAA,uBACE,GAAA,CAAC,SAAA,EAAA,EACC,QAAA,kBAAA,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,CAAC,YAAA,CAAa,OAAA,EAAb,EACC,QAAA,kBAAA,GAAA;AAAA,YAAC,kBAAA;AAAA,YAAA;AAAA,cACC,gBAAA,EAAiB,aAAA;AAAA,cACjB;AAAA;AAAA,WACF,EACF;AAAA,SAAA,EACF,CAAA,EACF;AAAA,OAAA,EACF;AAAA;AAAA,GACF;AAEJ;;;;"}
|
package/dist/components/EntityKyvernoPoliciesContent/EntityKyvernoPoliciesContent.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityKyvernoPoliciesContent.esm.js","sources":["../../../src/components/EntityKyvernoPoliciesContent/EntityKyvernoPoliciesContent.tsx"],"sourcesContent":["import { Content, Progress } from '@backstage/core-components';\nimport {\n MissingAnnotationEmptyState,\n useEntity,\n} from '@backstage/plugin-catalog-react';\nimport { Container, Header } from '@backstage/ui';\nimport { PolicyReportsTable } from '../PolicyReportsTable';\nimport { SelectEnvironment } from '../SelectEnvironment';\nimport {\n getKinds,\n getNamespaces,\n getResourceName,\n isPolicyReporterAvailable,\n} from '../../utils/annotations';\nimport { MissingEnvironmentsEmptyState } from '../MissingEnvironmentsEmptyState';\nimport { useEntityEnvironment } from '../../hooks/useEntityEnvironment';\nimport { PolicyReportsFiltersProvider } from '../../hooks/usePolicyReportsFilters';\nimport { KYVERNO_RESOURCE_NAME_ANNOTATION } from '@kyverno/backstage-plugin-policy-reporter-common';\nimport { SelectSeverity } from '../SelectSeverity';\nimport { SelectStatus } from '../SelectStatus';\nimport { FilterLayout } from '../FilterLayout';\n\ntype KyvernoPoliciesContentProps = {\n annotationsDocumentationUrl?: string;\n policyDocumentationUrl?: string;\n};\n\nexport const EntityKyvernoPoliciesContent = ({\n annotationsDocumentationUrl,\n policyDocumentationUrl,\n}: KyvernoPoliciesContentProps) => {\n const { entity } = useEntity();\n const annotations = entity.metadata.annotations;\n\n const annotationsState = isPolicyReporterAvailable(entity);\n\n const { environments, environmentsLoading } = useEntityEnvironment(\n entity,\n annotationsState,\n );\n\n // Annotations missing\n if (!annotationsState)\n return (\n <Container>\n <Content>\n <MissingAnnotationEmptyState\n readMoreUrl={annotationsDocumentationUrl}\n annotation={KYVERNO_RESOURCE_NAME_ANNOTATION}\n />\n </Content>\n </Container>\n );\n\n // Fetching environments\n if (environmentsLoading) return <Progress />;\n\n // Environments missing\n if (!environments?.length)\n return (\n <Container>\n <Content>\n <MissingEnvironmentsEmptyState entity={entity} />\n </Content>\n </Container>\n );\n\n return (\n <PolicyReportsFiltersProvider\n defaultFilters={{\n namespaces: getNamespaces(annotations),\n kinds: getKinds(annotations),\n sources: ['kyverno'],\n search: getResourceName(annotations),\n }}\n defaultEnvironment={environments[0].entityRef}\n >\n <Container>\n <Header\n title=\"Kyverno Policy Reports\"\n customActions={<SelectEnvironment environments={environments} />}\n />\n <Content>\n <FilterLayout>\n <FilterLayout.Filters>\n <SelectStatus />\n <SelectSeverity />\n </FilterLayout.Filters>\n <FilterLayout.Content>\n <PolicyReportsTable\n emptyContentText=\"No policies found\"\n policyDocumentationUrl={policyDocumentationUrl}\n />\n </FilterLayout.Content>\n </FilterLayout>\n </Content>\n </Container>\n </PolicyReportsFiltersProvider>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AA2BO,MAAM,+BAA+B,CAAC;AAAA,EAC3C,2BAAA;AAAA,EACA;AACF,CAAA,KAAmC;AACjC,EAAA,MAAM,EAAE,MAAA,EAAO,GAAI,SAAA,EAAU;AAC7B,EAAA,MAAM,WAAA,GAAc,OAAO,QAAA,CAAS,WAAA;AAEpC,EAAA,MAAM,gBAAA,GAAmB,0BAA0B,MAAM,CAAA;AAEzD,EAAA,MAAM,EAAE,YAAA,EAAc,mBAAA,EAAoB,GAAI,oBAAA;AAAA,IAC5C,MAAA;AAAA,IACA;AAAA,GACF;AAGA,EAAA,IAAI,CAAC,gBAAA;AACH,IAAA,uBACE,GAAA,CAAC,SAAA,EAAA,EACC,QAAA,kBAAA,GAAA,CAAC,OAAA,EAAA,EACC,QAAA,kBAAA,GAAA;AAAA,MAAC,2BAAA;AAAA,MAAA;AAAA,QACC,WAAA,EAAa,2BAAA;AAAA,QACb,UAAA,EAAY;AAAA;AAAA,OAEhB,CAAA,EACF,CAAA;AAIJ,EAAA,IAAI,mBAAA,EAAqB,uBAAO,GAAA,CAAC,QAAA,EAAA,EAAS,CAAA;AAG1C,EAAA,IAAI,CAAC,YAAA,EAAc,MAAA;AACjB,IAAA,uBACE,GAAA,CAAC,aACC,QAAA,kBAAA,GAAA,CAAC,OAAA,EAAA,EACC,8BAAC,6BAAA,EAAA,EAA8B,MAAA,EAAgB,GACjD,CAAA,EACF,CAAA;AAGJ,EAAA,uBACE,GAAA;AAAA,IAAC,4BAAA;AAAA,IAAA;AAAA,MACC,cAAA,EAAgB;AAAA,QACd,UAAA,EAAY,cAAc,WAAW,CAAA;AAAA,QACrC,KAAA,EAAO,SAAS,WAAW,CAAA;AAAA,QAC3B,OAAA,EAAS,CAAC,SAAS,CAAA;AAAA,QACnB,MAAA,EAAQ,gBAAgB,WAAW;AAAA,OACrC;AAAA,MACA,kBAAA,EAAoB,YAAA,CAAa,CAAC,CAAA,CAAE,SAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"EntityKyvernoPoliciesContent.esm.js","sources":["../../../src/components/EntityKyvernoPoliciesContent/EntityKyvernoPoliciesContent.tsx"],"sourcesContent":["import { Content, Progress } from '@backstage/core-components';\nimport {\n MissingAnnotationEmptyState,\n useEntity,\n} from '@backstage/plugin-catalog-react';\nimport { Container, Header } from '@backstage/ui';\nimport { PolicyReportsTable } from '../PolicyReportsTable';\nimport { SelectEnvironment } from '../SelectEnvironment';\nimport {\n getKinds,\n getNamespaces,\n getResourceName,\n isPolicyReporterAvailable,\n} from '../../utils/annotations';\nimport { MissingEnvironmentsEmptyState } from '../MissingEnvironmentsEmptyState';\nimport { useEntityEnvironment } from '../../hooks/useEntityEnvironment';\nimport { PolicyReportsFiltersProvider } from '../../hooks/usePolicyReportsFilters';\nimport { KYVERNO_RESOURCE_NAME_ANNOTATION } from '@kyverno/backstage-plugin-policy-reporter-common';\nimport { SelectSeverity } from '../SelectSeverity';\nimport { SelectStatus } from '../SelectStatus';\nimport { FilterLayout } from '../FilterLayout';\n\ntype KyvernoPoliciesContentProps = {\n annotationsDocumentationUrl?: string;\n policyDocumentationUrl?: string;\n};\n\nexport const EntityKyvernoPoliciesContent = ({\n annotationsDocumentationUrl,\n policyDocumentationUrl,\n}: KyvernoPoliciesContentProps) => {\n const { entity } = useEntity();\n const annotations = entity.metadata.annotations;\n\n const annotationsState = isPolicyReporterAvailable(entity);\n\n const { environments, environmentsLoading } = useEntityEnvironment(\n entity,\n annotationsState,\n );\n\n // Annotations missing\n if (!annotationsState)\n return (\n <Container>\n <Content>\n <MissingAnnotationEmptyState\n readMoreUrl={annotationsDocumentationUrl}\n annotation={KYVERNO_RESOURCE_NAME_ANNOTATION}\n />\n </Content>\n </Container>\n );\n\n // Fetching environments\n if (environmentsLoading) return <Progress />;\n\n // Environments missing\n if (!environments?.length)\n return (\n <Container>\n <Content>\n <MissingEnvironmentsEmptyState entity={entity} />\n </Content>\n </Container>\n );\n\n return (\n <PolicyReportsFiltersProvider\n defaultFilters={{\n namespaces: getNamespaces(annotations),\n kinds: getKinds(annotations),\n sources: ['kyverno'],\n search: getResourceName(annotations),\n }}\n defaultEnvironment={environments[0].entityRef}\n context=\"namespaced\"\n >\n <Container>\n <Header\n title=\"Kyverno Policy Reports\"\n customActions={<SelectEnvironment environments={environments} />}\n />\n <Content>\n <FilterLayout>\n <FilterLayout.Filters>\n <SelectStatus />\n <SelectSeverity />\n </FilterLayout.Filters>\n <FilterLayout.Content>\n <PolicyReportsTable\n emptyContentText=\"No policies found\"\n policyDocumentationUrl={policyDocumentationUrl}\n />\n </FilterLayout.Content>\n </FilterLayout>\n </Content>\n </Container>\n </PolicyReportsFiltersProvider>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AA2BO,MAAM,+BAA+B,CAAC;AA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A;AAAA,wBAAA,GAAA;AAAA,UAAC,MAAA;AAAA,UAAA;AAAA,YACC,KAAA,EAAM,wBAAA;AAAA,YACN,aAAA,kBAAe,GAAA,CAAC,iBAAA,EAAA,EAAkB,YAAA,EAA4B;AAAA;AAAA,SAChE;AAAA,wBACA,GAAA,CAAC,OAAA,EAAA,EACC,QAAA,kBAAA,IAAA,CAAC,YAAA,EAAA,EACC,QAAA,EAAA;AAAA,0BAAA,IAAA,CAAC,YAAA,CAAa,SAAb,EACC,QAAA,EAAA;AAAA,4BAAA,GAAA,CAAC,YAAA,EAAA,EAAa,CAAA;AAAA,gCACb,cAAA,EAAA,EAAe;AAAA,WAAA,EAClB,CAAA;AAAA,0BACA,GAAA,CAAC,YAAA,CAAa,OAAA,EAAb,EACC,QAAA,kBAAA,GAAA;AAAA,YAAC,kBAAA;AAAA,YAAA;AAAA,cACC,gBAAA,EAAiB,mBAAA;AAAA,cACjB;AAAA;AAAA,WACF,EACF;AAAA,SAAA,EACF,CAAA,EACF;AAAA,OAAA,EACF;AAAA;AAAA,GACF;AAEJ;;;;"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { EmptyState } from '@backstage/core-components';
|
|
3
|
+
import { ButtonLink } from '@backstage/ui';
|
|
4
|
+
|
|
5
|
+
const MissingKubernetesCluster = () => /* @__PURE__ */ jsx(
|
|
6
|
+
EmptyState,
|
|
7
|
+
{
|
|
8
|
+
missing: "content",
|
|
9
|
+
title: "No kubernetes-cluster Resources found",
|
|
10
|
+
description: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
11
|
+
"You need to define a Resource with the kubernetes-cluster type and a",
|
|
12
|
+
/* @__PURE__ */ jsx("code", { children: " kyverno.io/endpoint " }),
|
|
13
|
+
" annotation for this plugin to work."
|
|
14
|
+
] }),
|
|
15
|
+
action: /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
16
|
+
ButtonLink,
|
|
17
|
+
{
|
|
18
|
+
target: "_blank",
|
|
19
|
+
href: "https://github.com/kyverno/backstage-policy-reporter-plugin",
|
|
20
|
+
children: "Read More"
|
|
21
|
+
}
|
|
22
|
+
) })
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
export { MissingKubernetesCluster };
|
|
27
|
+
//# sourceMappingURL=MissingKubernetesCluster.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MissingKubernetesCluster.esm.js","sources":["../../../src/components/MissingKubernetesCluster/MissingKubernetesCluster.tsx"],"sourcesContent":["import { EmptyState } from '@backstage/core-components';\nimport { ButtonLink } from '@backstage/ui';\n\nexport const MissingKubernetesCluster = () => (\n <EmptyState\n missing=\"content\"\n title=\"No kubernetes-cluster Resources found\"\n description={\n <>\n You need to define a Resource with the kubernetes-cluster type and a\n <code> kyverno.io/endpoint </code> annotation for this plugin to work.\n </>\n }\n action={\n <>\n <ButtonLink\n target=\"_blank\"\n href=\"https://github.com/kyverno/backstage-policy-reporter-plugin\"\n >\n Read More\n </ButtonLink>\n </>\n }\n />\n);\n"],"names":[],"mappings":";;;;AAGO,MAAM,2BAA2B,sBACtC,GAAA;AAAA,EAAC,UAAA;AAAA,EAAA;AAAA,IACC,OAAA,EAAQ,SAAA;AAAA,IACR,KAAA,EAAM,uCAAA;AAAA,IACN,6BACE,IAAA,CAAA,QAAA,EAAA,EAAE,QAAA,EAAA;AAAA,MAAA,sEAAA;AAAA,sBAEA,GAAA,CAAC,UAAK,QAAA,EAAA,uBAAA,EAAqB,CAAA;AAAA,MAAO;AAAA,KAAA,EACpC,CAAA;AAAA,IAEF,wBACE,GAAA,CAAA,QAAA,EAAA,EACE,QAAA,kBAAA,GAAA;AAAA,MAAC,UAAA;AAAA,MAAA;AAAA,QACC,MAAA,EAAO,QAAA;AAAA,QACP,IAAA,EAAK,6DAAA;AAAA,QACN,QAAA,EAAA;AAAA;AAAA,KAED,EACF;AAAA;AAEJ;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jsx, jsxs
|
|
2
|
-
import { Progress, Content
|
|
3
|
-
import { Container, Header,
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { Progress, Content } from '@backstage/core-components';
|
|
3
|
+
import { Container, Header, Flex } from '@backstage/ui';
|
|
4
4
|
import { useEnvironments } from '../../hooks/useEnvironments.esm.js';
|
|
5
5
|
import { SelectEnvironment } from '../SelectEnvironment/SelectEnvironment.esm.js';
|
|
6
6
|
import { PolicyReportsTable } from '../PolicyReportsTable/PolicyReportsTable.esm.js';
|
|
@@ -10,10 +10,16 @@ import { SelectNamespace } from '../SelectNamespace/SelectNamespace.esm.js';
|
|
|
10
10
|
import { SearchField } from '../SearchField/SearchField.esm.js';
|
|
11
11
|
import { PolicyReportsFiltersProvider } from '../../hooks/usePolicyReportsFilters.esm.js';
|
|
12
12
|
import { FilterLayout } from '../FilterLayout/FilterLayout.esm.js';
|
|
13
|
+
import { SelectSource } from '../SelectSource/SelectSource.esm.js';
|
|
14
|
+
import { SelectKind } from '../SelectKind/SelectKind.esm.js';
|
|
15
|
+
import { SelectCategory } from '../SelectCategory/SelectCategory.esm.js';
|
|
16
|
+
import { SelectPolicy } from '../SelectPolicy/SelectPolicy.esm.js';
|
|
17
|
+
import { MissingKubernetesCluster } from '../MissingKubernetesCluster/MissingKubernetesCluster.esm.js';
|
|
13
18
|
|
|
14
19
|
const PolicyReportsPage = ({
|
|
15
20
|
title = "Policy Reports",
|
|
16
|
-
policyDocumentationUrl
|
|
21
|
+
policyDocumentationUrl,
|
|
22
|
+
subtitle
|
|
17
23
|
}) => {
|
|
18
24
|
const { environments, environmentsLoading } = useEnvironments();
|
|
19
25
|
const defaultFilter = {
|
|
@@ -23,30 +29,12 @@ const PolicyReportsPage = ({
|
|
|
23
29
|
if (!environments?.length)
|
|
24
30
|
return /* @__PURE__ */ jsxs(Container, { children: [
|
|
25
31
|
/* @__PURE__ */ jsx(Header, { title }),
|
|
26
|
-
/* @__PURE__ */ jsx(Content, { children: /* @__PURE__ */ jsx(
|
|
27
|
-
EmptyState,
|
|
28
|
-
{
|
|
29
|
-
missing: "content",
|
|
30
|
-
title: "No kubernetes-cluster Resources found",
|
|
31
|
-
description: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
32
|
-
"You need to define a Resource with the kubernetes-cluster type and a",
|
|
33
|
-
/* @__PURE__ */ jsx("code", { children: " kyverno.io/endpoint " }),
|
|
34
|
-
" annotation for this plugin to work."
|
|
35
|
-
] }),
|
|
36
|
-
action: /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
37
|
-
ButtonLink,
|
|
38
|
-
{
|
|
39
|
-
target: "_blank",
|
|
40
|
-
href: "https://github.com/kyverno/backstage-policy-reporter-plugin",
|
|
41
|
-
children: "Read More"
|
|
42
|
-
}
|
|
43
|
-
) })
|
|
44
|
-
}
|
|
45
|
-
) })
|
|
32
|
+
/* @__PURE__ */ jsx(Content, { children: /* @__PURE__ */ jsx(MissingKubernetesCluster, {}) })
|
|
46
33
|
] });
|
|
47
34
|
return /* @__PURE__ */ jsx(
|
|
48
35
|
PolicyReportsFiltersProvider,
|
|
49
36
|
{
|
|
37
|
+
context: "namespaced",
|
|
50
38
|
defaultFilters: defaultFilter,
|
|
51
39
|
defaultEnvironment: environments[0].entityRef,
|
|
52
40
|
children: /* @__PURE__ */ jsxs(Container, { children: [
|
|
@@ -54,6 +42,7 @@ const PolicyReportsPage = ({
|
|
|
54
42
|
Header,
|
|
55
43
|
{
|
|
56
44
|
title,
|
|
45
|
+
description: subtitle,
|
|
57
46
|
customActions: /* @__PURE__ */ jsx(SelectEnvironment, { environments })
|
|
58
47
|
}
|
|
59
48
|
),
|
|
@@ -61,7 +50,11 @@ const PolicyReportsPage = ({
|
|
|
61
50
|
/* @__PURE__ */ jsxs(FilterLayout.Filters, { children: [
|
|
62
51
|
/* @__PURE__ */ jsx(SelectStatus, {}),
|
|
63
52
|
/* @__PURE__ */ jsx(SelectSeverity, {}),
|
|
64
|
-
/* @__PURE__ */ jsx(SelectNamespace, {})
|
|
53
|
+
/* @__PURE__ */ jsx(SelectNamespace, {}),
|
|
54
|
+
/* @__PURE__ */ jsx(SelectSource, {}),
|
|
55
|
+
/* @__PURE__ */ jsx(SelectKind, {}),
|
|
56
|
+
/* @__PURE__ */ jsx(SelectCategory, {}),
|
|
57
|
+
/* @__PURE__ */ jsx(SelectPolicy, {})
|
|
65
58
|
] }),
|
|
66
59
|
/* @__PURE__ */ jsx(FilterLayout.Content, { children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: "4", children: [
|
|
67
60
|
/* @__PURE__ */ jsx(SearchField, {}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PolicyReportsPage.esm.js","sources":["../../../src/components/PolicyReportsPage/PolicyReportsPage.tsx"],"sourcesContent":["import { Content,
|
|
1
|
+
{"version":3,"file":"PolicyReportsPage.esm.js","sources":["../../../src/components/PolicyReportsPage/PolicyReportsPage.tsx"],"sourcesContent":["import { Content, Progress } from '@backstage/core-components';\nimport { Container, Flex, Header } from '@backstage/ui';\nimport { useEnvironments } from '../../hooks/useEnvironments';\nimport { SelectEnvironment } from '../SelectEnvironment';\nimport { PolicyReportsTable } from '../PolicyReportsTable';\nimport { SelectStatus } from '../SelectStatus';\nimport { SelectSeverity } from '../SelectSeverity';\nimport { SelectNamespace } from '../SelectNamespace';\nimport { SearchField } from '../SearchField';\nimport { PolicyReportsFiltersProvider } from '../../hooks/usePolicyReportsFilters';\nimport { Filter } from '@kyverno/backstage-plugin-policy-reporter-common';\nimport { FilterLayout } from '../FilterLayout';\nimport { SelectSource } from '../SelectSource';\nimport { SelectKind } from '../SelectKind';\nimport { SelectCategory } from '../SelectCategory';\nimport { SelectPolicy } from '../SelectPolicy';\nimport { MissingKubernetesCluster } from '../MissingKubernetesCluster';\n\nexport interface PolicyReportsPageProps {\n title?: string;\n policyDocumentationUrl?: string;\n subtitle?: string;\n}\n\nexport const PolicyReportsPage = ({\n title = 'Policy Reports',\n policyDocumentationUrl,\n subtitle,\n}: PolicyReportsPageProps) => {\n const { environments, environmentsLoading } = useEnvironments();\n\n const defaultFilter: Filter = {\n status: ['fail'],\n };\n\n // Loading environments\n if (environmentsLoading) return <Progress />;\n\n // Environments missing\n if (!environments?.length)\n return (\n <Container>\n <Header title={title} />\n <Content>\n <MissingKubernetesCluster />\n </Content>\n </Container>\n );\n\n return (\n <PolicyReportsFiltersProvider\n context=\"namespaced\"\n defaultFilters={defaultFilter}\n defaultEnvironment={environments[0].entityRef}\n >\n <Container>\n <Header\n title={title}\n description={subtitle}\n customActions={<SelectEnvironment environments={environments} />}\n />\n <Content>\n <FilterLayout>\n <FilterLayout.Filters>\n <SelectStatus />\n <SelectSeverity />\n <SelectNamespace />\n <SelectSource />\n <SelectKind />\n <SelectCategory />\n <SelectPolicy />\n </FilterLayout.Filters>\n <FilterLayout.Content>\n <Flex direction=\"column\" gap=\"4\">\n <SearchField />\n <PolicyReportsTable\n emptyContentText=\"No policies found\"\n policyDocumentationUrl={policyDocumentationUrl}\n />\n </Flex>\n </FilterLayout.Content>\n </FilterLayout>\n </Content>\n </Container>\n </PolicyReportsFiltersProvider>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAwBO,MAAM,oBAAoB,CAAC;AAAA,EAChC,KAAA,GAAQ,gBAAA;AAAA,EACR,sBAAA;AAAA,EACA;AACF,CAAA,KAA8B;AAC5B,EAAA,MAAM,EAAE,YAAA,EAAc,mBAAA,EAAoB,GAAI,eAAA,EAAgB;AAE9D,EAAA,MAAM,aAAA,GAAwB;AAAA,IAC5B,MAAA,EAAQ,CAAC,MAAM;AAAA,GACjB;AAGA,EAAA,IAAI,mBAAA,EAAqB,uBAAO,GAAA,CAAC,QAAA,EAAA,EAAS,CAAA;AAG1C,EAAA,IAAI,CAAC,YAAA,EAAc,MAAA;AACjB,IA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AA,EAAY,CAAA;AAAA,4BACb,GAAA;AAAA,cAAC,kBAAA;AAAA,cAAA;AAAA,gBACC,gBAAA,EAAiB,mBAAA;AAAA,gBACjB;AAAA;AAAA;AACF,WAAA,EACF,CAAA,EACF;AAAA,SAAA,EACF,CAAA,EACF;AAAA,OAAA,EACF;AAAA;AAAA,GACF;AAEJ;;;;"}
|
|
@@ -5,7 +5,7 @@ import { StatusComponent } from '../StatusComponent/StatusComponent.esm.js';
|
|
|
5
5
|
import { SeverityComponent } from '../SeverityComponent/SeverityComponent.esm.js';
|
|
6
6
|
import { PolicyReportsDrawerComponent } from '../PolicyReportsDrawerComponent/PolicyReportsDrawerComponent.esm.js';
|
|
7
7
|
import { useTable, Table, Text, CellText, Cell, Link } from '@backstage/ui';
|
|
8
|
-
import { useApi } from '@backstage/frontend-plugin-api';
|
|
8
|
+
import { useApi, toastApiRef } from '@backstage/frontend-plugin-api';
|
|
9
9
|
import { policyReporterApiRef } from '../../api/PolicyReporterClient.esm.js';
|
|
10
10
|
import { usePolicyReportsFilters } from '../../hooks/usePolicyReportsFilters.esm.js';
|
|
11
11
|
|
|
@@ -14,8 +14,9 @@ const PolicyReportsTable = ({
|
|
|
14
14
|
policyDocumentationUrl
|
|
15
15
|
}) => {
|
|
16
16
|
const policyReporterApi = useApi(policyReporterApiRef);
|
|
17
|
-
const { filter, environment } = usePolicyReportsFilters();
|
|
17
|
+
const { filter, environment, context } = usePolicyReportsFilters();
|
|
18
18
|
const search = filter.search;
|
|
19
|
+
const toast = useApi(toastApiRef);
|
|
19
20
|
const [drawerContent, setDrawerContent] = useState(
|
|
20
21
|
void 0
|
|
21
22
|
);
|
|
@@ -30,7 +31,7 @@ const PolicyReportsTable = ({
|
|
|
30
31
|
search: searchParam
|
|
31
32
|
}) => {
|
|
32
33
|
const page = Math.floor(offset / pageSize) + 1;
|
|
33
|
-
const
|
|
34
|
+
const request = {
|
|
34
35
|
query: {
|
|
35
36
|
environment: encodeURI(environment),
|
|
36
37
|
page,
|
|
@@ -38,8 +39,17 @@ const PolicyReportsTable = ({
|
|
|
38
39
|
...fetchFilter,
|
|
39
40
|
search: searchParam === "" ? void 0 : searchParam
|
|
40
41
|
}
|
|
41
|
-
}
|
|
42
|
+
};
|
|
43
|
+
const response = context === "cluster" ? await policyReporterApi.getClusterResults(request) : await policyReporterApi.getNamespacedResults(request);
|
|
42
44
|
const result = await response.json();
|
|
45
|
+
if (!response.ok) {
|
|
46
|
+
toast.post({
|
|
47
|
+
title: "Failed to fetch policies",
|
|
48
|
+
description: result.error || response.statusText || `Request failed with status ${response.status}`,
|
|
49
|
+
status: "danger"
|
|
50
|
+
});
|
|
51
|
+
return { data: [], totalCount: 0 };
|
|
52
|
+
}
|
|
43
53
|
return {
|
|
44
54
|
data: result.items,
|
|
45
55
|
totalCount: result.count
|
|
@@ -53,12 +63,14 @@ const PolicyReportsTable = ({
|
|
|
53
63
|
isRowHeader: true,
|
|
54
64
|
cell: (item) => /* @__PURE__ */ jsx(CellText, { title: item.name })
|
|
55
65
|
},
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
66
|
+
...context === "namespaced" ? [
|
|
67
|
+
{
|
|
68
|
+
id: "namespace",
|
|
69
|
+
label: "Namespace",
|
|
70
|
+
isRowHeader: true,
|
|
71
|
+
cell: (item) => /* @__PURE__ */ jsx(CellText, { title: item.namespace })
|
|
72
|
+
}
|
|
73
|
+
] : [],
|
|
62
74
|
{
|
|
63
75
|
id: "kind",
|
|
64
76
|
label: "Kind",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PolicyReportsTable.esm.js","sources":["../../../src/components/PolicyReportsTable/PolicyReportsTable.tsx"],"sourcesContent":["import { useState } from 'react';\nimport {
|
|
1
|
+
{"version":3,"file":"PolicyReportsTable.esm.js","sources":["../../../src/components/PolicyReportsTable/PolicyReportsTable.tsx"],"sourcesContent":["import { useState } from 'react';\nimport {\n GetClusterResults,\n GetNamespacedResults,\n ListResult,\n RequestError,\n} from '@kyverno/backstage-plugin-policy-reporter-common';\nimport { Drawer } from '@material-ui/core';\nimport { StatusComponent } from '../StatusComponent';\nimport { SeverityComponent } from '../SeverityComponent';\nimport { PolicyReportsDrawerComponent } from '../PolicyReportsDrawerComponent';\nimport {\n CellText,\n ColumnConfig,\n Text,\n useTable,\n Table,\n Cell,\n Link,\n} from '@backstage/ui';\nimport { toastApiRef, useApi } from '@backstage/frontend-plugin-api';\nimport { policyReporterApiRef } from '../../api';\nimport { usePolicyReportsFilters } from '../../hooks/usePolicyReportsFilters';\n\ninterface PolicyReportsTableProps {\n emptyContentText: string;\n policyDocumentationUrl?: string;\n}\n\nexport const PolicyReportsTable = ({\n emptyContentText,\n policyDocumentationUrl,\n}: PolicyReportsTableProps) => {\n const policyReporterApi = useApi(policyReporterApiRef);\n const { filter, environment, context } = usePolicyReportsFilters();\n const search = filter.search;\n const toast = useApi(toastApiRef);\n\n const [drawerContent, setDrawerContent] = useState<ListResult | undefined>(\n undefined,\n );\n\n const { tableProps } = useTable({\n filter,\n mode: 'offset',\n search: search,\n getData: async ({\n offset,\n pageSize,\n filter: fetchFilter,\n search: searchParam,\n }) => {\n // useTable provides:\n // - offset: absolute record position (0, 20, 40, 60...)\n // - pageSize: number of records per page (20)\n //\n // Policy Reporter API expects:\n // - page: page number starting from 1 (1, 2, 3, 4...)\n // - offset: number of results per page (this is actually pageSize)\n //\n // Example calculations:\n // useTable offset=0, pageSize=20 → page=1 (first 20 records)\n // useTable offset=20, pageSize=20 → page=2 (records 21-40)\n // useTable offset=40, pageSize=20 → page=3 (records 41-60)\n\n // Convert useTable's absolute offset to 1-indexed page number\n // Math.floor(0/20) + 1 = 1, Math.floor(20/20) + 1 = 2, etc.\n const page = Math.floor(offset / pageSize) + 1;\n\n const request: GetClusterResults | GetNamespacedResults = {\n query: {\n environment: encodeURI(environment),\n page: page,\n offset: pageSize,\n ...fetchFilter,\n search: searchParam === '' ? undefined : searchParam,\n },\n };\n\n const response =\n context === 'cluster'\n ? await policyReporterApi.getClusterResults(request)\n : await policyReporterApi.getNamespacedResults(request);\n\n const result = await response.json();\n\n if (!response.ok) {\n toast.post({\n title: 'Failed to fetch policies',\n description:\n (result as unknown as RequestError).error ||\n response.statusText ||\n `Request failed with status ${response.status}`,\n status: 'danger',\n });\n return { data: [], totalCount: 0 };\n }\n\n return {\n data: result.items,\n totalCount: result.count,\n };\n },\n });\n\n const columns: ColumnConfig<ListResult>[] = [\n {\n id: 'name',\n label: 'Name',\n isRowHeader: true,\n cell: item => <CellText title={item.name} />,\n },\n ...(context === 'namespaced'\n ? ([\n {\n id: 'namespace',\n label: 'Namespace',\n isRowHeader: true,\n cell: item => <CellText title={item.namespace} />,\n },\n ] as ColumnConfig<ListResult>[])\n : []),\n {\n id: 'kind',\n label: 'Kind',\n isRowHeader: true,\n cell: item => <CellText title={item.kind} />,\n },\n {\n id: 'policy',\n label: 'Policy',\n isRowHeader: true,\n cell: item => {\n if (policyDocumentationUrl) {\n return (\n <Cell>\n <Link\n target=\"_blank\"\n href={`${policyDocumentationUrl}#${item.policy}`}\n >\n {item.policy}\n </Link>\n </Cell>\n );\n }\n return <CellText title={item.policy} />;\n },\n },\n {\n id: 'rule',\n label: 'Rule',\n isRowHeader: true,\n cell: item => <CellText title={item.rule} />,\n },\n {\n id: 'status',\n label: 'Status',\n isRowHeader: true,\n cell: item => (\n <Cell>\n <StatusComponent status={item.status} />\n </Cell>\n ),\n },\n {\n id: 'severity',\n label: 'Severity',\n isRowHeader: true,\n cell: item => (\n <Cell>\n <SeverityComponent severity={item.severity} />\n </Cell>\n ),\n },\n ];\n\n return (\n <>\n <Drawer\n anchor=\"right\"\n open={Boolean(drawerContent)}\n onClose={() => setDrawerContent(undefined)}\n >\n <PolicyReportsDrawerComponent content={drawerContent} />\n </Drawer>\n <Table\n rowConfig={{\n onClick: item => setDrawerContent(item),\n }}\n emptyState={\n search ? (\n <Text>No results match \"{search}\"</Text>\n ) : (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