fix: namespace can't be selected the same in IP pool page (#560)

* fix: the namespacess option can't be selected twice in standalone UI

Signed-off-by: Andy Lee <andy.lee@suse.com>

* refactor: disabled slected ns

Signed-off-by: Andy Lee <andy.lee@suse.com>

---------

Signed-off-by: Andy Lee <andy.lee@suse.com>
This commit is contained in:
Andy Lee 2025-10-31 16:52:05 +08:00 committed by GitHub
parent 7e0a9dcd80
commit 756ed383ac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 7 deletions

View File

@ -39,6 +39,10 @@ export default {
return this.mode === _VIEW; return this.mode === _VIEW;
}, },
disableAdd() {
return this.isStandaloneHarvester && this.rows.some((row) => row.namespace === '*');
},
showAdd() { showAdd() {
return !this.isView; return !this.isView;
}, },
@ -141,6 +145,7 @@ export default {
> >
<button <button
type="button" type="button"
:disabled="disableAdd"
class="btn role-tertiary add" class="btn role-tertiary add"
@click="add()" @click="add()"
> >

View File

@ -66,17 +66,26 @@ export default {
}, },
namespaceOptions() { namespaceOptions() {
const out = (this.filteredNamespaces || []).map((namespace) => { const namespaces = this.filteredNamespaces;
return { const selected = this.rows.map((r) => r?.namespace);
label: namespace.metadata.name,
value: namespace.id, if (this.isStandaloneHarvester) {
}; return [
}); { label: this.t('generic.all'), value: '*' },
...namespaces.map((ns) => ({
label: ns.metadata.name,
value: ns.id,
disabled: selected.includes(ns.id) && ns.id !== this.row.namespace
}))
];
}
return [{ return [{
label: this.t('generic.all'), label: this.t('generic.all'),
value: '*', value: '*',
}, ...out]; },
...namespaces.map((ns) => ({ label: ns.metadata.name, value: ns.id }))
];
}, },
guestClusterOptions() { guestClusterOptions() {