From 2387db0f059517cffb411bbb15a8be1e04d6d121 Mon Sep 17 00:00:00 2001 From: Vladyslav Palyvoda Date: Tue, 13 Aug 2024 15:03:51 +0300 Subject: [PATCH] fix: Update pipelines filter (#337) --- src/widgets/PipelineRunList/constants.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/widgets/PipelineRunList/constants.ts b/src/widgets/PipelineRunList/constants.ts index 39959a407..567cf573b 100644 --- a/src/widgets/PipelineRunList/constants.ts +++ b/src/widgets/PipelineRunList/constants.ts @@ -17,6 +17,22 @@ export const matchFunctions: MatchFunctions> = { [FILTER_CONTROLS.CODEBASES]: (item: PipelineRunKubeObjectInterface, value: string[]) => { if (!value || value.length === 0) return true; + const pipelineType = item?.metadata.labels?.[PIPELINE_RUN_LABEL_SELECTOR_PIPELINE_TYPE]; + + if (pipelineType === PIPELINE_TYPES.DEPLOY || pipelineType === PIPELINE_TYPES.CLEAN) { + const appPayload = item?.spec?.params?.find( + (param: { name: string; value: string }) => param.name === 'APPLICATIONS_PAYLOAD' + ); + + if (!appPayload) { + return false; + } + + const appPayloadValue = JSON.parse(appPayload.value); + + return Object.keys(appPayloadValue).some((key) => value.includes(key)); + } + const itemCodebase = item?.metadata.labels?.[PIPELINE_RUN_LABEL_SELECTOR_CODEBASE]; return value.includes(itemCodebase);