diff --git a/.changelog/22938.txt b/.changelog/22938.txt new file mode 100644 index 000000000000..e2b1f9ca7c6c --- /dev/null +++ b/.changelog/22938.txt @@ -0,0 +1,3 @@ +```release-note:improvement +ui: removes send action instances as part of https://deprecations.emberjs.com/id/ember-component-send-action/ +``` \ No newline at end of file diff --git a/ui/packages/consul-lock-sessions/app/components/consul/lock-session/form/index.hbs b/ui/packages/consul-lock-sessions/app/components/consul/lock-session/form/index.hbs index d84292c72fba..18b4802cd5a8 100644 --- a/ui/packages/consul-lock-sessions/app/components/consul/lock-session/form/index.hbs +++ b/ui/packages/consul-lock-sessions/app/components/consul/lock-session/form/index.hbs @@ -86,7 +86,7 @@ @text='Invalidate Session' @color='critical' data-test-delete - {{on 'click' (fn confirm (fn writer.delete @item))}} + {{on 'click' (fn confirm )}} /> @@ -98,7 +98,7 @@ @text='Confirm Invalidation' @color='critical' data-test-delete - {{on 'click' (fn execute)}} + {{on 'click' (queue execute (fn writer.delete @item))}} /> @text='Invalidate' @color='critical' data-test-delete - {{on 'click' (fn confirm (fn @ondelete item))}} + {{on 'click' confirm}} /> @@ -102,7 +102,7 @@ as |item index|> @text='Confirm Invalidate' @color='critical' data-test-delete - {{on 'click' (fn execute)}} + {{on 'click' (queue execute (fn @ondelete item))}} /> diff --git a/ui/packages/consul-partitions/app/components/consul/partition/form/index.hbs b/ui/packages/consul-partitions/app/components/consul/partition/form/index.hbs index 03119b64106d..3a8c7620d6ab 100644 --- a/ui/packages/consul-partitions/app/components/consul/partition/form/index.hbs +++ b/ui/packages/consul-partitions/app/components/consul/partition/form/index.hbs @@ -118,13 +118,13 @@ as |State Guard ChartAction dispatch state|> @text='Delete' data-test-delete @color='critical' - {{on 'click' (fn confirm (fn writer.delete item))}} + {{on 'click' confirm}} /> diff --git a/ui/packages/consul-ui/app/components/child-selector/index.hbs b/ui/packages/consul-ui/app/components/child-selector/index.hbs index 81c771b90174..0801902b71bb 100644 --- a/ui/packages/consul-ui/app/components/child-selector/index.hbs +++ b/ui/packages/consul-ui/app/components/child-selector/index.hbs @@ -50,7 +50,7 @@ {{/if}} {{#if (gt items.length 0)}} - {{yield}} + {{yield}} {{else}} {{/if}} diff --git a/ui/packages/consul-ui/app/components/confirmation-dialog/index.js b/ui/packages/consul-ui/app/components/confirmation-dialog/index.js index e10782f579d4..bcfdcb25d569 100644 --- a/ui/packages/consul-ui/app/components/confirmation-dialog/index.js +++ b/ui/packages/consul-ui/app/components/confirmation-dialog/index.js @@ -3,30 +3,30 @@ * SPDX-License-Identifier: BUSL-1.1 */ -/*eslint ember/closure-actions: "warn"*/ import Component from '@ember/component'; +import { action } from '@ember/object'; +import { tracked } from '@glimmer/tracking'; import Slotted from 'block-slots'; -import { set } from '@ember/object'; -export default Component.extend(Slotted, { - tagName: '', - message: 'Are you sure?', - confirming: false, - permanent: false, - actions: { - cancel: function () { - set(this, 'confirming', false); - }, - execute: function () { - set(this, 'confirming', false); - this.sendAction(...['actionName', ...this['arguments']]); - }, - confirm: function () { - const [action, ...args] = arguments; - set(this, 'actionName', action); - set(this, 'arguments', args); - set(this, 'confirming', true); - }, - }, -}); +export default class ConfirmationDialogComponent extends Component.extend(Slotted) { + tagName = ''; + message = 'Are you sure?'; + @tracked confirming = false; + permanent = false; + + @action + cancel() { + this.confirming = false; + } + + @action + execute() { + this.confirming = false; + } + + @action + confirm() { + this.confirming = true; + } +} 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 cdc983c37b16..d2b0673369d8 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 @@ -178,14 +178,14 @@ as |item readonly|}} @text='Delete' @color='critical' disabled={{api.disabled}} - {{on 'click' (fn confirm api.delete)}} + {{on 'click' (fn confirm)}} data-test-delete /> diff --git a/ui/packages/consul-ui/app/components/consul/intention/list/table/index.hbs b/ui/packages/consul-ui/app/components/consul/intention/list/table/index.hbs index 78e87a2eedaa..8d55b4446dcb 100644 --- a/ui/packages/consul-ui/app/components/consul/intention/list/table/index.hbs +++ b/ui/packages/consul-ui/app/components/consul/intention/list/table/index.hbs @@ -95,7 +95,7 @@ More - + {{#if (can 'write intention' item=item)}} diff --git a/ui/packages/consul-ui/app/components/consul/kv/form/index.hbs b/ui/packages/consul-ui/app/components/consul/kv/form/index.hbs index 1d6672c1968b..b88243319bbd 100644 --- a/ui/packages/consul-ui/app/components/consul/kv/form/index.hbs +++ b/ui/packages/consul-ui/app/components/consul/kv/form/index.hbs @@ -127,13 +127,13 @@ @color='critical' data-test-delete disabled={{api.disabled}} - {{on 'click' (action confirm api.delete)}} + {{on 'click' (action confirm)}} /> diff --git a/ui/packages/consul-ui/app/components/consul/kv/list/index.hbs b/ui/packages/consul-ui/app/components/consul/kv/list/index.hbs index 26362b9254a3..ab50e4145fed 100644 --- a/ui/packages/consul-ui/app/components/consul/kv/list/index.hbs +++ b/ui/packages/consul-ui/app/components/consul/kv/list/index.hbs @@ -25,7 +25,7 @@ More - + {{#if (can 'write kv' item=item)}} @@ -97,7 +97,7 @@ @text='Yes, Delete' data-test-delete @color='critical' - {{on 'click' execute}} + {{on 'click' (queue execute (fn @onDelete @item))}} /> {{else}} - + {{/if}} diff --git a/ui/packages/consul-ui/app/components/consul/role/form/index.hbs b/ui/packages/consul-ui/app/components/consul/role/form/index.hbs index 0ba9f9ce0534..3ca3a22e7ff3 100644 --- a/ui/packages/consul-ui/app/components/consul/role/form/index.hbs +++ b/ui/packages/consul-ui/app/components/consul/role/form/index.hbs @@ -64,7 +64,7 @@ @@ -95,7 +95,7 @@ @text='Yes, Delete' @color='critical' data-test-delete - {{on 'click' execute}} + {{on 'click' (queue execute (fn @onDelete @item))}} /> {{else}} - + {{/if}} diff --git a/ui/packages/consul-ui/app/components/consul/token/form/index.hbs b/ui/packages/consul-ui/app/components/consul/token/form/index.hbs index 06ef1b4f7082..f816a0862620 100644 --- a/ui/packages/consul-ui/app/components/consul/token/form/index.hbs +++ b/ui/packages/consul-ui/app/components/consul/token/form/index.hbs @@ -6,8 +6,8 @@
{{!-- fieldsets already converted to components --}} {{#if (not (token/is-legacy @item))}} - {{else}} - - + {{/if}} diff --git a/ui/packages/consul-ui/app/components/policy-selector/index.hbs b/ui/packages/consul-ui/app/components/policy-selector/index.hbs index 1b8eeb0fc091..909040fc0de1 100644 --- a/ui/packages/consul-ui/app/components/policy-selector/index.hbs +++ b/ui/packages/consul-ui/app/components/policy-selector/index.hbs @@ -78,7 +78,7 @@ {{option.Name}} - + @@ -202,7 +202,7 @@ @text='Confirm remove' @color='critical' @size='small' - {{action execute}} + {{action (queue execute (action remove item items))}} data-test-delete /> {{/if}} - + {{yield components api}} diff --git a/ui/packages/consul-ui/app/components/popover-menu/index.js b/ui/packages/consul-ui/app/components/popover-menu/index.js index f37321af97c5..181d3e71dc28 100644 --- a/ui/packages/consul-ui/app/components/popover-menu/index.js +++ b/ui/packages/consul-ui/app/components/popover-menu/index.js @@ -45,11 +45,5 @@ export default Component.extend(Slotted, { } this.onchange(e); }, - // Temporary send here so we can send route actions - // easily. It kind of makes sense that you'll want to perform - // route actions from a popup menu for the moment - send: function () { - this.sendAction(...arguments); - }, }, }); diff --git a/ui/packages/consul-ui/app/components/role-selector/index.hbs b/ui/packages/consul-ui/app/components/role-selector/index.hbs index e873cf0fb1e5..07b2c4e08973 100644 --- a/ui/packages/consul-ui/app/components/role-selector/index.hbs +++ b/ui/packages/consul-ui/app/components/role-selector/index.hbs @@ -131,7 +131,7 @@ as |modal|> {{option.Name}} - + More - + {{#if (can "edit role" item=item)}} @@ -166,7 +166,7 @@ as |modal|> {{#if (not disabled)}} - + Remove diff --git a/ui/packages/consul-ui/app/controllers/dc/acls/policies/edit.js b/ui/packages/consul-ui/app/controllers/dc/acls/policies/edit.js index 8aa847e20219..53ddc3e07af1 100644 --- a/ui/packages/consul-ui/app/controllers/dc/acls/policies/edit.js +++ b/ui/packages/consul-ui/app/controllers/dc/acls/policies/edit.js @@ -5,12 +5,14 @@ import { inject as service } from '@ember/service'; import Controller from '@ember/controller'; +import { action } from '@ember/object'; + export default class EditController extends Controller { @service('form') builder; - init() { - super.init(...arguments); + constructor() { + super(...arguments); this.form = this.builder.form('policy'); } @@ -27,4 +29,9 @@ export default class EditController extends Controller { }, model) ); } + + @action + delete(item) { + this.target.send('delete', item); + } } diff --git a/ui/packages/consul-ui/app/controllers/dc/acls/roles/edit.js b/ui/packages/consul-ui/app/controllers/dc/acls/roles/edit.js index 04778c6f34cc..0ffb4c5dde56 100644 --- a/ui/packages/consul-ui/app/controllers/dc/acls/roles/edit.js +++ b/ui/packages/consul-ui/app/controllers/dc/acls/roles/edit.js @@ -5,12 +5,14 @@ import { inject as service } from '@ember/service'; import Controller from '@ember/controller'; +import { action } from '@ember/object'; + export default class EditController extends Controller { @service('form') builder; - init() { - super.init(...arguments); + constructor() { + super(...arguments); this.form = this.builder.form('role'); } @@ -27,4 +29,9 @@ export default class EditController extends Controller { }, model) ); } + + @action + delete(item) { + this.target.send('delete', item); + } } diff --git a/ui/packages/consul-ui/app/controllers/dc/acls/tokens/edit.js b/ui/packages/consul-ui/app/controllers/dc/acls/tokens/edit.js index 81628de627b1..72d0e7bf2e14 100644 --- a/ui/packages/consul-ui/app/controllers/dc/acls/tokens/edit.js +++ b/ui/packages/consul-ui/app/controllers/dc/acls/tokens/edit.js @@ -5,17 +5,22 @@ import Controller from '@ember/controller'; import { inject as service } from '@ember/service'; -export default Controller.extend({ - dom: service('dom'), - builder: service('form'), - isScoped: false, - init: function () { - this._super(...arguments); +import { action } from '@ember/object'; + +export default class EditController extends Controller { + @service('dom') dom; + @service('form') builder; + + isScoped = false; + + constructor() { + super(...arguments); this.form = this.builder.form('token'); - }, - setProperties: function (model) { + } + + setProperties(model) { // essentially this replaces the data with changesets - this._super( + super.setProperties( Object.keys(model).reduce((prev, key, i) => { switch (key) { case 'item': @@ -25,20 +30,30 @@ export default Controller.extend({ return prev; }, model) ); - }, - actions: { - change: function (e, value, item) { - const event = this.dom.normalizeEvent(e, value); - const form = this.form; - try { - form.handleEvent(event); - } catch (err) { - const target = event.target; - switch (target.name) { - default: - throw err; - } + } + + @action + change(e, value, item) { + const event = this.dom.normalizeEvent(e, value); + const form = this.form; + try { + form.handleEvent(event); + } catch (err) { + const target = event.target; + switch (target.name) { + default: + throw err; } - }, - }, -}); + } + } + + @action + use(item) { + this.target.send('use', item); + } + + @action + delete(item) { + this.target.send('delete', item); + } +} diff --git a/ui/packages/consul-ui/app/templates/dc/acls/tokens/edit.hbs b/ui/packages/consul-ui/app/templates/dc/acls/tokens/edit.hbs index 7ebdb4683d2a..91018fe54c5f 100644 --- a/ui/packages/consul-ui/app/templates/dc/acls/tokens/edit.hbs +++ b/ui/packages/consul-ui/app/templates/dc/acls/tokens/edit.hbs @@ -65,7 +65,7 @@ as |dc partition nspace item create|}} @text='Use' @color='secondary' data-test-use - {{ action confirm 'use' item }} + {{ action confirm }} /> @@ -77,7 +77,7 @@ as |dc partition nspace item create|}} @text='Confirm Use' @color='critical' data-test-confirm-use - {{action execute}} + {{action (queue execute (fn this.use item))}} />