Skip to content

HARVESTER: Fix IP Pool Same Namespace Can Be Added Multiple Times #906

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default {
},

computed: {
...mapGetters(['isRancherInHarvester', 'isStandaloneHarvester']),
...mapGetters(['isRancherInHarvester', 'isStandaloneHarvester', 'allNamespaces']),

isView() {
return this.mode === _VIEW;
Expand All @@ -48,6 +48,28 @@ export default {
showProjectAndCluster() {
return !this.isStandaloneHarvester;
},

uniqNamespaceOptions() {
const selectedNamespaces = this.rows.map(row => row.namespace);

const out = (this.allNamespaces || []).map((namespace) => {
const disabled = (selectedNamespaces.includes(namespace.id) || selectedNamespaces.includes('*')) && selectedNamespaces.length > 1;

return {
label: selectedNamespaces.includes('*') && selectedNamespaces.length > 1 ? `${ namespace.id } (${ this.t('harvester.ipPool.scope.overlap') })` : namespace.id,
value: namespace.id,
disabled,
};
});

const disabled = (selectedNamespaces.includes('*') || selectedNamespaces.find(n => n !== '*' && n)) && selectedNamespaces.length > 1;

return [{
label: (selectedNamespaces.find(n => n !== '*' && n) && selectedNamespaces.length > 1) ? `${ this.t('generic.all') } (${ this.t('harvester.ipPool.scope.overlap') })` : this.t('generic.all'),
value: '*',
disabled,
}, ...out];
},
},

created() {
Expand All @@ -59,7 +81,11 @@ export default {
const defaultRow = { namespace: '*' };

if (!this.showProjectAndCluster) {
this.rows.push(defaultRow);
if (this.rows.length === 0) {
this.rows.push(defaultRow);
} else {
this.rows.push({ namespace: '' });
}
} else {
this.rows.push({
...defaultRow,
Expand Down Expand Up @@ -128,6 +154,7 @@ export default {
:mode="mode"
:rows="rows"
:idx="idx"
:uniqNamespaceOptions="uniqNamespaceOptions"
@input="queueUpdate"
@remove="remove(idx)"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ export default {
type: Number,
required: true,
},

uniqNamespaceOptions: {
type: Array,
required: true,
},
},

data() {
Expand Down Expand Up @@ -199,7 +204,7 @@ export default {
<Select
v-else
v-model="row.namespace"
:options="namespaceOptions"
:options="showProjectAndCluster ? namespaceOptions : uniqNamespaceOptions"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image image

Perhaps filtering duplicate namespaces is also necessary for multiple clusters.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The guest cluster will have more than one under the same namespace, and it doesn't make sense to de-emphasize the namespace.

@input="update"
/>
</div>
Expand Down
1 change: 1 addition & 0 deletions pkg/harvester/l10n/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1181,6 +1181,7 @@ harvester:
scope:
label: Scope
addLabel: Add Scope
overlap: scope overlap
priority:
label: Priority
cidr:
Expand Down