Skip to content

Commit

Permalink
add functionality for filtering general (#2609)
Browse files Browse the repository at this point in the history
* add functionality for filtering general

* rename, bump, docs

* fix
  • Loading branch information
mrCherry97 authored Oct 17, 2023
1 parent 2af0d7e commit 7a62107
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/extensibility/resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion resources/web/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
15 changes: 12 additions & 3 deletions src/components/Extensibility/ExtensibilityList.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 7a62107

Please sign in to comment.