Skip to content

Commit

Permalink
Merge pull request #1291 from kubeshop/devcatalin/fix/helm-charts
Browse files Browse the repository at this point in the history
fix Helm chart folder recognition
  • Loading branch information
devcatalin authored Feb 3, 2022
2 parents d9cd2f1 + a3205be commit eea8986
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 15 deletions.
30 changes: 18 additions & 12 deletions src/components/molecules/SectionRenderer/SectionRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,18 +221,24 @@ function SectionRenderer(props: SectionRendererProps) {
<S.ItemsLength selected={false}>{group.visibleItemIds.length}</S.ItemsLength>
</S.Name>
</S.SectionContainer>
{group.visibleItemIds.map(itemId => (
<ItemRenderer
key={itemId}
itemId={itemId}
blueprint={itemBlueprint}
level={level + 2}
isLastItem={isLastVisibleItemIdInGroup(group.id, itemId)}
isSectionCheckable={Boolean(sectionInstance.checkable)}
sectionContainerElementId={sectionBlueprint.containerElementId}
options={itemRendererOptions}
/>
))}
{group.visibleItemIds.length ? (
group.visibleItemIds.map(itemId => (
<ItemRenderer
key={itemId}
itemId={itemId}
blueprint={itemBlueprint}
level={level + 2}
isLastItem={isLastVisibleItemIdInGroup(group.id, itemId)}
isSectionCheckable={Boolean(sectionInstance.checkable)}
sectionContainerElementId={sectionBlueprint.containerElementId}
options={itemRendererOptions}
/>
))
) : (
<S.EmptyGroupText>
{sectionBlueprint.customization?.emptyGroupText || 'No items in this group.'}
</S.EmptyGroupText>
)}
</React.Fragment>
);
})}
Expand Down
5 changes: 5 additions & 0 deletions src/components/molecules/SectionRenderer/styled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ export const Name = styled.span<NameProps>`
}}
`;

export const EmptyGroupText = styled.span`
margin-left: 26px;
font-size: 12px;
`;

export const Collapsible = styled.span`
margin-left: auto;
margin-right: 15px;
Expand Down
1 change: 1 addition & 0 deletions src/models/navigator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export interface SectionCustomization {
nameContext?: {
component: SectionCustomComponent;
};
emptyGroupText?: string;
disableHoverStyle?: boolean;
beforeInitializationText?: string;
isCheckVisibleOnHover?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const HelmChartSectionBlueprint: SectionBlueprint<HelmValuesFile, HelmChartScope
},
customization: {
emptyDisplay: {component: HelmChartSectionEmptyDisplay},
emptyGroupText: 'No values files found for this Chart.',
beforeInitializationText: 'Get started by browsing a folder in the File Explorer.',
},
itemBlueprint: {
Expand Down
15 changes: 13 additions & 2 deletions src/navsections/sectionBlueprintMiddleware.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {shallowEqual} from 'react-redux';

import asyncLib from 'async';
import _ from 'lodash';
import log from 'loglevel';
import {Middleware} from 'redux';

Expand Down Expand Up @@ -273,8 +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 visibleGroupIds = sectionInstanceGroups.filter(g => g.visibleItemIds.length > 0).map(g => g.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)
.value();
const sectionInstance: SectionInstance = {
id: sectionBlueprint.id,
rootSectionId: sectionBlueprint.rootSectionId,
Expand Down
2 changes: 1 addition & 1 deletion src/redux/services/helm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit eea8986

Please sign in to comment.