From 7a6210788f167c3d9be560d85c9f0d7e894355f9 Mon Sep 17 00:00:00 2001 From: Mateusz Wisniewski Date: Tue, 17 Oct 2023 15:56:57 +0200 Subject: [PATCH] add functionality for filtering general (#2609) * add functionality for filtering general * rename, bump, docs * fix --- docs/extensibility/resources.md | 2 +- resources/web/deployment.yaml | 2 +- src/components/Extensibility/ExtensibilityList.js | 15 ++++++++++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/docs/extensibility/resources.md b/docs/extensibility/resources.md index fe4994f32b..87472aca4a 100644 --- a/docs/extensibility/resources.md +++ b/docs/extensibility/resources.md @@ -58,7 +58,7 @@ category: My Category scope: namespace defaultPlaceholder: '- not set -' description: See the {{[docs](https://github.com/kyma-project/busola)}} for more information. -filter: "$filter($item, function($data) {$data.type = 'Opaque'})" +filter: "$filter(data, function($data) {$data.type = 'Opaque'})" features: actions: disableCreate: true diff --git a/resources/web/deployment.yaml b/resources/web/deployment.yaml index 403ddb45e9..632d00c212 100644 --- a/resources/web/deployment.yaml +++ b/resources/web/deployment.yaml @@ -16,7 +16,7 @@ spec: spec: containers: - name: busola - image: europe-docker.pkg.dev/kyma-project/dev/busola-web:PR-2596 + image: europe-docker.pkg.dev/kyma-project/dev/busola-web:PR-2609 imagePullPolicy: Always resources: requests: diff --git a/src/components/Extensibility/ExtensibilityList.js b/src/components/Extensibility/ExtensibilityList.js index 56cb066575..e5640afe72 100644 --- a/src/components/Extensibility/ExtensibilityList.js +++ b/src/components/Extensibility/ExtensibilityList.js @@ -32,7 +32,8 @@ export const ExtensibilityListCore = ({ const { t: tBusola } = useTranslation(); const jsonata = useJsonata({}); - const { resource, description, features } = resMetaData?.general ?? {}; + const { resource, description, features, filter: generalFilter } = + resMetaData?.general ?? {}; const { disableCreate, disableEdit, disableDelete } = features?.actions ?? { disableCreate: props.disableCreate, @@ -85,9 +86,17 @@ export const ExtensibilityListCore = ({ })) : []; - const isFilterAString = typeof resMetaData?.resource?.filter === 'string'; + const isFilterAString = + typeof resMetaData?.resource?.filter === 'string' || + typeof generalFilter === 'string'; + const filterFn = value => - applyFormula(value, resMetaData.resource.filter, tBusola); + applyFormula( + value, + resMetaData?.resource?.filter || generalFilter, + tBusola, + ); + listProps.filter = isFilterAString ? filterFn : filterFunction; const sortOptions = (resMetaData?.list || []).filter(element => element.sort);