3
0

Fix reading namespaceID of undefined in Namespace Sidebar c-input-select

This commit is contained in:
Jože Fortun
2024-01-03 13:23:02 +01:00
parent 3ed3b1ebb8
commit deea5afcc9

View File

@@ -7,12 +7,12 @@
>
<c-input-select
data-test-id="select-namespace"
:clearable="false"
:value="currentNamespaceID"
:options="filteredNamespaces"
:get-option-label="getOptionLabel"
:value="namespace.namespaceID"
:get-option-label="getNamespaceLabel"
:selectable="option => option.namespaceID !== namespace.namespaceID"
:placeholder="$t('pickNamespace')"
:clearable="false"
:autoscroll="false"
:append-to-body="false"
@input="namespaceSelected"
@@ -192,6 +192,10 @@ export default {
can: 'rbac/can',
}),
currentNamespaceID () {
return this.namespace ? this.namespace.namespaceID : NoID
},
// Loading is true only when a resource is being force loaded (API call)
loading () {
return this.moduleLoading || this.chartLoading || this.pageLoading
@@ -451,10 +455,11 @@ export default {
})
},
getOptionLabel (value) {
getNamespaceLabel (value) {
if (typeof value === 'string') {
return this.filteredNamespaces.find(({ namespaceID }) => namespaceID === value).name
value = this.filteredNamespaces.find(({ namespaceID }) => namespaceID === value) || {}
}
return value.name
},
},