diff --git a/ui/packages/consul-ui/app/components/consul/intention/form/index.hbs b/ui/packages/consul-ui/app/components/consul/intention/form/index.hbs index e8e4fbd708..bfc0aee5a7 100644 --- a/ui/packages/consul-ui/app/components/consul/intention/form/index.hbs +++ b/ui/packages/consul-ui/app/components/consul/intention/form/index.hbs @@ -1,3 +1,7 @@ +
- {{#let api.data as |item|}} {{#if item.IsEditable}} + +{{#if this.warn}} + {{#let (changeset-get item 'Action') as |newAction|}} + + +

Set intention to {{newAction}}?

+
+ +

+ When you change this Intention to {{newAction}}, you will remove all the L7 policy permissions currently saved to this Intention. Are you sure you want to set it to {{newAction}}? +

+
+ + + + +
+ {{/let}} +{{/if}} + {{#if (and api.isCreate this.isManagedByCRDs)}} {{/if}} -
+ +
diff --git a/ui/packages/consul-ui/app/components/consul/intention/form/index.js b/ui/packages/consul-ui/app/components/consul/intention/form/index.js index c2d8b2d06f..37810c8920 100644 --- a/ui/packages/consul-ui/app/components/consul/intention/form/index.js +++ b/ui/packages/consul-ui/app/components/consul/intention/form/index.js @@ -4,7 +4,6 @@ import { action } from '@ember/object'; import { tracked } from '@glimmer/tracking'; export default class ConsulIntentionForm extends Component { - @tracked services; @tracked SourceName; @tracked DestinationName; @@ -15,6 +14,8 @@ export default class ConsulIntentionForm extends Component { @tracked isManagedByCRDs; + @tracked warn = false; + @service('repository/intention') repo; constructor(owner, args) { @@ -23,7 +24,7 @@ export default class ConsulIntentionForm extends Component { } ondelete() { - if(this.args.ondelete) { + if (this.args.ondelete) { this.args.ondelete(...arguments); } else { this.onsubmit(...arguments); @@ -31,7 +32,7 @@ export default class ConsulIntentionForm extends Component { } oncancel() { - if(this.args.oncancel) { + if (this.args.oncancel) { this.args.oncancel(...arguments); } else { this.onsubmit(...arguments); @@ -39,7 +40,7 @@ export default class ConsulIntentionForm extends Component { } onsubmit() { - if(this.args.onsubmit) { + if (this.args.onsubmit) { this.args.onsubmit(...arguments); } } @@ -48,9 +49,19 @@ export default class ConsulIntentionForm extends Component { updateCRDManagement() { this.isManagedByCRDs = this.repo.isManagedByCRDs(); } - @action - createServices (item, e) { + submit(item, submit, e) { + e.preventDefault(); + // if the action of the intention has changed and its non-empty then warn + // the user + if (typeof item.change.Action !== 'undefined' && typeof item.data.Action === 'undefined') { + this.warn = true; + } else { + submit(); + } + } + @action + createServices(item, e) { // Services in the menus should: // 1. Be unique (they potentially could be duplicated due to services from different namespaces) // 2. Only include services that shold have intentions @@ -59,9 +70,7 @@ export default class ConsulIntentionForm extends Component { let items = e.data .uniqBy('Name') .toArray() - .filter( - item => !['connect-proxy', 'mesh-gateway', 'terminating-gateway'].includes(item.Kind) - ) + .filter(item => !['connect-proxy', 'mesh-gateway', 'terminating-gateway'].includes(item.Kind)) .sort((a, b) => a.Name.localeCompare(b.Name)); items = [{ Name: '*' }].concat(items); let source = items.findBy('Name', item.SourceName); @@ -80,7 +89,7 @@ export default class ConsulIntentionForm extends Component { } @action - createNspaces (item, e) { + createNspaces(item, e) { // Nspaces in the menus should: // 1. Include an 'All Namespaces' option // 2. Include the current SourceNS and DestinationNS incase they don't exist yet diff --git a/ui/packages/consul-ui/app/components/consul/intention/form/index.scss b/ui/packages/consul-ui/app/components/consul/intention/form/index.scss new file mode 100644 index 0000000000..c3413ab3cb --- /dev/null +++ b/ui/packages/consul-ui/app/components/consul/intention/form/index.scss @@ -0,0 +1,11 @@ +.consul-intention-action-warn-modal { + .modal-dialog-window { + max-width: 450px; + } + .modal-dialog-body p { + font-size: $typo-size-600; + } + button.dangerous { + @extend %dangerous-button; + } +} diff --git a/ui/packages/consul-ui/app/components/consul/intention/index.scss b/ui/packages/consul-ui/app/components/consul/intention/index.scss index c7539a74cb..47026b68e8 100644 --- a/ui/packages/consul-ui/app/components/consul/intention/index.scss +++ b/ui/packages/consul-ui/app/components/consul/intention/index.scss @@ -2,6 +2,7 @@ @import './search-bar'; @import './list'; +@import './form'; @import './form/fieldsets'; @import './permission/list'; @import './permission/form'; diff --git a/ui/packages/consul-ui/app/components/modal-dialog/index.hbs b/ui/packages/consul-ui/app/components/modal-dialog/index.hbs index ad8930ff7d..8cb052be49 100644 --- a/ui/packages/consul-ui/app/components/modal-dialog/index.hbs +++ b/ui/packages/consul-ui/app/components/modal-dialog/index.hbs @@ -1,28 +1,44 @@ {{on-window 'resize' (action "resize") }} {{yield}} -
- -
+