ui: Disable setting wildcard partitions for intentions (#11804)

This commit is contained in:
John Cowen 2021-12-13 15:42:10 +00:00 committed by GitHub
parent ca04a62702
commit b8888fc0f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 13 deletions

4
.changelog/11804.txt Normal file
View File

@ -0,0 +1,4 @@
```release-note:bugfix
ui: Don't offer to save an intention with a source/destinatiojn wildcard
partition
```

View File

@ -63,11 +63,7 @@
@showCreateWhen={{action "isUnique" partitions}} @showCreateWhen={{action "isUnique" partitions}}
@onCreate={{action onchange "SourcePartition"}} @onCreate={{action onchange "SourcePartition"}}
@onChange={{action onchange "SourcePartition"}} as |partition|> @onChange={{action onchange "SourcePartition"}} as |partition|>
{{#if (eq partition.Name '*') }} {{partition.Name}}
* (All Partitions)
{{else}}
{{partition.Name}}
{{/if}}
</PowerSelectWithCreate> </PowerSelectWithCreate>
{{#if create}} {{#if create}}
<em>Search for an existing partition, or enter any Partition name.</em> <em>Search for an existing partition, or enter any Partition name.</em>
@ -136,11 +132,7 @@
@showCreateWhen={{action "isUnique" partitions}} @showCreateWhen={{action "isUnique" partitions}}
@onCreate={{action onchange "DestinationPartition"}} @onCreate={{action onchange "DestinationPartition"}}
@onChange={{action onchange "DestinationPartition"}} as |partition|> @onChange={{action onchange "DestinationPartition"}} as |partition|>
{{#if (eq partition.Name '*') }} {{partition.Name}}
* (All Partitions)
{{else}}
{{partition.Name}}
{{/if}}
</PowerSelectWithCreate> </PowerSelectWithCreate>
{{#if create}} {{#if create}}
<em>For the destination, you may choose any partition for which you have access.</em> <em>For the destination, you may choose any partition for which you have access.</em>

View File

@ -122,10 +122,9 @@ export default class ConsulIntentionForm extends Component {
@action @action
createPartitions(item, e) { createPartitions(item, e) {
// Partitions in the menus should: // Partitions in the menus should:
// 1. Include an 'All Partitions' option // 1. NOT include an 'All Partitions' option
// 2. Include the current SourcePartition and DestinationPartition incase they don't exist yet // 2. Include the current SourcePartition and DestinationPartition incase they don't exist yet
let items = e.data.toArray().sort((a, b) => a.Name.localeCompare(b.Name)); let items = e.data.toArray().sort((a, b) => a.Name.localeCompare(b.Name));
items = [{ Name: '*' }].concat(items);
let source = items.findBy('Name', item.SourcePartition); let source = items.findBy('Name', item.SourcePartition);
if (!source) { if (!source) {
source = { Name: item.SourcePartition }; source = { Name: item.SourcePartition };

View File

@ -69,7 +69,7 @@ export default class IntentionRepository extends RepositoryService {
let item; let item;
if (params.id === '') { if (params.id === '') {
const defaultNspace = this.env.var('CONSUL_NSPACES_ENABLED') ? '*' : 'default'; const defaultNspace = this.env.var('CONSUL_NSPACES_ENABLED') ? '*' : 'default';
const defaultPartition = this.env.var('CONSUL_PARTITIONS_ENABLED') ? '*' : 'default'; const defaultPartition = 'default';
item = await this.create({ item = await this.create({
SourceNS: params.nspace || defaultNspace, SourceNS: params.nspace || defaultNspace,
DestinationNS: params.nspace || defaultNspace, DestinationNS: params.nspace || defaultNspace,