From edc21efe30e5ee66d4fa7adb8090be7a0abb13f7 Mon Sep 17 00:00:00 2001 From: Catalin <20538711+devcatalin@users.noreply.github.com> Date: Thu, 3 Feb 2022 14:05:59 +0200 Subject: [PATCH 1/3] fix: isHelmChartFolder --- src/redux/services/helm.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/redux/services/helm.ts b/src/redux/services/helm.ts index 75847d8db9..2e4145b5ec 100644 --- a/src/redux/services/helm.ts +++ b/src/redux/services/helm.ts @@ -26,7 +26,7 @@ export function getHelmValuesFile(fileEntry: FileEntry, helmValuesMap: HelmValue */ export function isHelmChartFolder(files: string[]) { - return files.indexOf('Chart.yaml') !== -1 && files.indexOf('values.yaml') !== -1; + return files.indexOf('Chart.yaml') !== -1; } /** From 29903c01440f53e3f76f2bbdc7d09c5624567e6c Mon Sep 17 00:00:00 2001 From: Catalin <20538711+devcatalin@users.noreply.github.com> Date: Thu, 3 Feb 2022 14:28:49 +0200 Subject: [PATCH 2/3] feat: custom text for empty groups --- .../SectionRenderer/SectionRenderer.tsx | 30 +++++++++++-------- .../molecules/SectionRenderer/styled.tsx | 5 ++++ src/models/navigator.ts | 1 + .../HelmChartSectionBlueprint.ts | 1 + src/navsections/sectionBlueprintMiddleware.ts | 4 ++- 5 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/components/molecules/SectionRenderer/SectionRenderer.tsx b/src/components/molecules/SectionRenderer/SectionRenderer.tsx index 1e010db78b..53259b6658 100644 --- a/src/components/molecules/SectionRenderer/SectionRenderer.tsx +++ b/src/components/molecules/SectionRenderer/SectionRenderer.tsx @@ -221,18 +221,24 @@ function SectionRenderer(props: SectionRendererProps) { {group.visibleItemIds.length} - {group.visibleItemIds.map(itemId => ( - - ))} + {group.visibleItemIds.length ? ( + group.visibleItemIds.map(itemId => ( + + )) + ) : ( + + {sectionBlueprint.customization?.emptyGroupText || 'No items in this group.'} + + )} ); })} diff --git a/src/components/molecules/SectionRenderer/styled.tsx b/src/components/molecules/SectionRenderer/styled.tsx index 5cf2d731a5..c8c3324da5 100644 --- a/src/components/molecules/SectionRenderer/styled.tsx +++ b/src/components/molecules/SectionRenderer/styled.tsx @@ -108,6 +108,11 @@ export const Name = styled.span` }} `; +export const EmptyGroupText = styled.span` + margin-left: 26px; + font-size: 12px; +`; + export const Collapsible = styled.span` margin-left: auto; margin-right: 15px; diff --git a/src/models/navigator.ts b/src/models/navigator.ts index 36ee553ca5..5ab2c20ef9 100644 --- a/src/models/navigator.ts +++ b/src/models/navigator.ts @@ -63,6 +63,7 @@ export interface SectionCustomization { nameContext?: { component: SectionCustomComponent; }; + emptyGroupText?: string; disableHoverStyle?: boolean; beforeInitializationText?: string; isCheckVisibleOnHover?: boolean; diff --git a/src/navsections/HelmChartSectionBlueprint/HelmChartSectionBlueprint.ts b/src/navsections/HelmChartSectionBlueprint/HelmChartSectionBlueprint.ts index dc3d3d637b..8428c93c95 100644 --- a/src/navsections/HelmChartSectionBlueprint/HelmChartSectionBlueprint.ts +++ b/src/navsections/HelmChartSectionBlueprint/HelmChartSectionBlueprint.ts @@ -73,6 +73,7 @@ const HelmChartSectionBlueprint: SectionBlueprint itemInstanceMap[itemId].isVisible === true), })); const visibleItemIds = itemInstances?.filter(i => i.isVisible === true).map(i => i.id) || []; - const visibleGroupIds = sectionInstanceGroups.filter(g => g.visibleItemIds.length > 0).map(g => g.id); + const visibleGroupIds = sectionBlueprint.customization?.emptyGroupText + ? sectionInstanceGroups.map(g => g.id) + : sectionInstanceGroups.filter(g => g.visibleItemIds.length > 0).map(g => g.id); const sectionInstance: SectionInstance = { id: sectionBlueprint.id, rootSectionId: sectionBlueprint.rootSectionId, From a3205beab22fa5c52e023d381a88bc893be48f86 Mon Sep 17 00:00:00 2001 From: Catalin <20538711+devcatalin@users.noreply.github.com> Date: Thu, 3 Feb 2022 15:05:58 +0200 Subject: [PATCH 3/3] refactor: use lodash sequence --- src/navsections/sectionBlueprintMiddleware.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/navsections/sectionBlueprintMiddleware.ts b/src/navsections/sectionBlueprintMiddleware.ts index da22e63c7c..4f2ba48d8c 100644 --- a/src/navsections/sectionBlueprintMiddleware.ts +++ b/src/navsections/sectionBlueprintMiddleware.ts @@ -1,6 +1,7 @@ import {shallowEqual} from 'react-redux'; import asyncLib from 'async'; +import _ from 'lodash'; import log from 'loglevel'; import {Middleware} from 'redux'; @@ -273,10 +274,18 @@ const processSectionBlueprints = async (state: RootState, dispatch: AppDispatch) ...g, visibleItemIds: g.itemIds.filter(itemId => itemInstanceMap[itemId].isVisible === true), })); - const visibleItemIds = itemInstances?.filter(i => i.isVisible === true).map(i => i.id) || []; + const visibleItemIds = itemInstances + ? _(itemInstances) + .filter(i => i.isVisible === true) + .map(i => i.id) + .value() + : []; const visibleGroupIds = sectionBlueprint.customization?.emptyGroupText ? sectionInstanceGroups.map(g => g.id) - : sectionInstanceGroups.filter(g => g.visibleItemIds.length > 0).map(g => g.id); + : _(sectionInstanceGroups) + .filter(g => g.visibleItemIds.length > 0) + .map(g => g.id) + .value(); const sectionInstance: SectionInstance = { id: sectionBlueprint.id, rootSectionId: sectionBlueprint.rootSectionId,