Skip to content

Commit baf2414

Browse files
authored
Merge pull request #127 from headlamp-k8s/fixes-for-app-catalog
Fixes for app catalog
2 parents 006252c + 484dc96 commit baf2414

File tree

5 files changed

+142
-161
lines changed

5 files changed

+142
-161
lines changed

app-catalog/package-lock.json

Lines changed: 8 additions & 50 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app-catalog/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"js-yaml": "^4.1.0",
3939
"react-markdown": "^8.0.7",
4040
"react-syntax-highlighter": "^15.5.0",
41-
"remark-gfm": "^3.0.1"
41+
"remark-gfm": "^3.0.1",
42+
"semver": "^7.6.3"
4243
}
4344
}

app-catalog/src/components/charts/EditorDialog.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,9 @@ export function EditorDialog(props: {
7676
setChartInstallDescription(`${chart.name} deployment`);
7777
fetchChartDetailFromArtifact(chart.name, chart.repository.name).then(response => {
7878
if (response.available_versions) {
79-
setVersions(
80-
response.available_versions.map(({ version }) => ({ title: version, value: version }))
81-
);
82-
setSelectedVersion(response.available_versions[0].version);
79+
const availableVersions = response.available_versions.map(({ version }) => ({ title: version, value: version }));
80+
setVersions(availableVersions);
81+
setSelectedVersion(availableVersions[0]);
8382
}
8483
});
8584
handleChartValueFetch(chart);
@@ -259,7 +258,7 @@ export function EditorDialog(props: {
259258
}}
260259
options={versions}
261260
getOptionLabel={(option: any) => option.title ?? option}
262-
value={selectedVersion}
261+
value={selectedVersion ?? versions[0]}
263262
// @ts-ignore
264263
onChange={(event, newValue: FieldType) => {
265264
setSelectedVersion(newValue);
@@ -306,7 +305,6 @@ export function EditorDialog(props: {
306305
onMount={editor => {
307306
setInstallLoading(false);
308307
editor.focus();
309-
setReleaseName('');
310308
}}
311309
language="yaml"
312310
height="500px"

app-catalog/src/components/charts/List.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,17 @@ export function ChartsList({ fetchCharts = fetchChartsFromArtifact }) {
118118
width: '20vw',
119119
}}
120120
options={helmChartCategoryList}
121-
getOptionLabel={option => option.title}
121+
getOptionLabel={option => option?.title ?? helmChartCategoryList[0].title}
122122
defaultValue={helmChartCategoryList[0]}
123123
value={chartCategory}
124124
onChange={(event, newValue) => {
125125
// @ts-ignore
126-
setChartCategory(newValue);
126+
setChartCategory((oldValue) => {
127+
if ((newValue?.value ?? helmChartCategoryList[0].value) === oldValue.value) {
128+
return oldValue;
129+
}
130+
return newValue ?? helmChartCategoryList[0];
131+
});
127132
}}
128133
renderInput={params => {
129134
if (process.env.NODE_ENV === 'test') {

0 commit comments

Comments
 (0)