Browse Source

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

pull/11822/head
John Cowen 3 years ago committed by GitHub
parent
commit
2ba0e86d6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      .changelog/11804.txt
  2. 12
      ui/packages/consul-ui/app/components/consul/intention/form/fieldsets/index.hbs
  3. 3
      ui/packages/consul-ui/app/components/consul/intention/form/index.js
  4. 2
      ui/packages/consul-ui/app/services/repository/intention.js

4
.changelog/11804.txt

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

12
ui/packages/consul-ui/app/components/consul/intention/form/fieldsets/index.hbs

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

3
ui/packages/consul-ui/app/components/consul/intention/form/index.js

@ -122,10 +122,9 @@ export default class ConsulIntentionForm extends Component {
@action
createPartitions(item, e) {
// 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
let items = e.data.toArray().sort((a, b) => a.Name.localeCompare(b.Name));
items = [{ Name: '*' }].concat(items);
let source = items.findBy('Name', item.SourcePartition);
if (!source) {
source = { Name: item.SourcePartition };

2
ui/packages/consul-ui/app/services/repository/intention.js

@ -69,7 +69,7 @@ export default class IntentionRepository extends RepositoryService {
let item;
if (params.id === '') {
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({
SourceNS: params.nspace || defaultNspace,
DestinationNS: params.nspace || defaultNspace,

Loading…
Cancel
Save