Fix reading namespaceID of undefined in Namespace Sidebar c-input-select
This commit is contained in:
@@ -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
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user