Skip to content

Commit 29e0a8b

Browse files
Replace deprecated template-action (#988)
1 parent 19b8845 commit 29e0a8b

File tree

5 files changed

+30
-35
lines changed

5 files changed

+30
-35
lines changed

addon/templates/components/attach-popover.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
...attributes
1717
>
1818
<div class={{this._class}} style={{this._style}}>
19-
{{yield (hash hide=(action 'hide'))}}
19+
{{yield (hash hide=this.hide)}}
2020
{{#if this.arrow}}
2121
<div x-arrow {{did-insert this.didInsertArrow}}></div>
2222
{{/if}}

tests/dummy/app/templates/components/attachment-example.hbs

+12-12
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
@hideOn={{this.tooltipData.hideOn}}
1919
@interactive={{this.tooltipData.interactive}}
2020
@isShown={{this.tooltipData.isShown}}
21-
@onChange={{action (mut this.tooltipData.isShown)}}
21+
@onChange={{fn (mut this.tooltipData.isShown)}}
2222
@placement={{this.tooltipData.placement}}
2323
@renderInPlace={{this.tooltipData.renderInPlace}}
2424
@showDelay={{this.tooltipData.showDelay}}
@@ -44,7 +44,7 @@
4444
@interactive={{this.popoverData.interactive}}
4545
@isShown={{this.popoverData.isShown}}
4646
@lazyRender={{this.popoverData.lazyRender}}
47-
@onChange={{action (mut this.popoverData.isShown)}}
47+
@onChange={{fn (mut this.popoverData.isShown)}}
4848
@placement={{this.popoverData.placement}}
4949
@renderInPlace={{this.popoverData.renderInPlace}}
5050
@showDelay={{this.popoverData.showDelay}}
@@ -54,7 +54,7 @@
5454
>
5555
<p>Popovers and tooltips, oh my!</p>
5656

57-
<button {{action emberAttacher.hide}}>Close</button>
57+
<button {{on 'click' emberAttacher.hide}}>Close</button>
5858
</AttachPopover>
5959
</button>
6060
</div>
@@ -74,10 +74,10 @@
7474
<div data-element-centered class="edit-section">
7575
<div data-element-vbox class="fit-lm">
7676
<div data-element-hbox class="nav-bar">
77-
<div data-element-centered class="col-xs-12 nav{{if this.isConfiguringTooltip ' active'}}" {{action 'setIsConfiguringTooltip' true}}>
77+
<div data-element-centered class="col-xs-12 nav{{if this.isConfiguringTooltip ' active'}}" {{on 'click' (fn this.setIsConfiguringTooltip true)}}>
7878
<code>&lt;AttachTooltip&gt;</code>
7979
</div>
80-
<div data-element-centered class="col-xs-12 nav{{unless this.isConfiguringTooltip ' active'}}" {{action 'setIsConfiguringTooltip' false}}>
80+
<div data-element-centered class="col-xs-12 nav{{unless this.isConfiguringTooltip ' active'}}" {{on 'click' (fn this.setIsConfiguringTooltip false)}}>
8181
<code>&lt;AttachPopover&gt;</code>
8282
</div>
8383
</div>
@@ -131,7 +131,7 @@
131131
<div data-element-hbox>
132132
&nbsp;&nbsp;&nbsp;&nbsp;<div data-element-box class="flexi-fit horizontal-lm">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>
133133
<div data-element-centered class="flexi-fit">
134-
@arrow=<button class="button medium" {{action "toggleArrow"}}>{{this.service.arrow}}</button>
134+
@arrow=<button class="button medium" {{on 'click' this.toggleArrow}}>{{this.service.arrow}}</button>
135135
</div>
136136
</div>
137137
<div data-element-hbox>
@@ -198,7 +198,7 @@
198198
{{/attach-tooltip}}
199199
</span>
200200
=
201-
<button class="button medium" {{action "toggleInteractive"}}>
201+
<button class="button medium" {{on 'click' this.toggleInteractive}}>
202202
{{this.service.interactive}}
203203
</button>
204204
</div>
@@ -214,7 +214,7 @@
214214
{{/attach-tooltip}}
215215
</span>
216216
=
217-
<button class="button medium" {{action "toggleIsShown"}}>{{this.service.isShown}}</button>
217+
<button class="button medium" {{on 'click' this.toggleIsShown}}>{{this.service.isShown}}</button>
218218
</div>
219219
</div>
220220
<div data-element-hbox>
@@ -229,7 +229,7 @@
229229
{{/attach-tooltip}}
230230
</span>
231231
=
232-
<button class="button medium" {{action "toggleLazyRender"}}>{{this.service.lazyRender}}</button>
232+
<button class="button medium" {{on 'click' this.toggleLazyRender}}>{{this.service.lazyRender}}</button>
233233
</div>
234234
</div>
235235
<div data-element-hbox>
@@ -270,7 +270,7 @@
270270
{{/attach-tooltip}}
271271
</span>
272272
=
273-
<button class="button medium" {{action "toggleAutoUpdate"}}>
273+
<button class="button medium" {{on 'click' this.toggleAutoUpdate}}>
274274
{{this.service.autoUpdate}}
275275
</button>
276276
</div>
@@ -292,7 +292,7 @@
292292
{{/attach-tooltip}}
293293
</span>
294294
=
295-
<button class="button medium" {{action "toggleRenderInPlace"}}>
295+
<button class="button medium" {{on 'click' this.toggleRenderInPlace}}>
296296
{{this.service.renderInPlace}}
297297
</button>
298298
</div>
@@ -386,7 +386,7 @@
386386
<div data-element-hbox>
387387
&nbsp;&nbsp;&nbsp;&nbsp;
388388
<div data-element-centered class="flexi-fit">
389-
&lt;button \{{action attacher.hide}}>
389+
&lt;button \{{on 'click' attacher.hide}}>
390390
</div>
391391
</div>
392392
<div data-element-hbox>

tests/integration/components/ember-attacher/hide-on-mouseleave-test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ module('Integration | Component | hideOn "mouseleave"', function(hooks) {
8787
hideOn='mouseleave'
8888
interactive=true
8989
isShown=this.isShown
90-
onChange=(action (mut this.isShown)) as |attacher|}}
90+
onChange=(fn (mut this.isShown)) as |attacher|}}
9191
hideOn mouseleave
9292
93-
<button id="manual-hide" {{action attacher.hide}}>hide</button>
93+
<button id="manual-hide" {{on 'click' attacher.hide}}>hide</button>
9494
{{/attach-popover}}
9595
</div>
9696

tests/integration/components/ember-attacher/is-shown-test.js

+14-19
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@ import { render, click, find, settled, waitFor } from '@ember/test-helpers';
77
module('Integration | Component | isShown', function(hooks) {
88
setupRenderingTest(hooks);
99

10-
hooks.beforeEach(function() {
11-
this.actions = {};
12-
this.send = (actionName, ...args) => this.actions[actionName].apply(this, args);
13-
});
14-
1510
test('isShown works with showOn/hideOn set to "click"', async function(assert) {
1611
assert.expect(3);
1712

@@ -44,11 +39,11 @@ module('Integration | Component | isShown', function(hooks) {
4439
test('isShown works with showOn/hideOn set to `null`', async function(assert) {
4540
assert.expect(3);
4641

47-
this.actions.closePopover = () => {
42+
this.closePopover = () => {
4843
this.set('isShown', false);
4944
};
5045

51-
this.actions.openPopover = () => {
46+
this.openPopover = () => {
5247
this.set('isShown', true);
5348
};
5449

@@ -58,7 +53,7 @@ module('Integration | Component | isShown', function(hooks) {
5853
this.set('showOn', null);
5954

6055
await render(hbs`
61-
<button id="open" {{action 'openPopover'}}>
56+
<button id="open" {{on 'click' this.openPopover}}>
6257
Click me, captain!
6358
6459
{{#attach-popover id='attachment'
@@ -67,7 +62,7 @@ module('Integration | Component | isShown', function(hooks) {
6762
showOn=this.showOn}}
6863
isShown w/ hideOn/ShowOn of 'none'
6964
70-
<button id="close" {{action 'closePopover'}}>
65+
<button id="close" {{on 'click' this.closePopover}}>
7166
Close
7267
</button>
7368
@@ -91,11 +86,11 @@ module('Integration | Component | isShown', function(hooks) {
9186
test('isShown works with showOn/hideOn set to `null` with lazyRender', async function(assert) {
9287
assert.expect(3);
9388

94-
this.actions.closePopover = () => {
89+
this.closePopover = () => {
9590
this.set('isShown', false);
9691
};
9792

98-
this.actions.openPopover = () => {
93+
this.openPopover = () => {
9994
this.set('isShown', true);
10095
};
10196

@@ -105,7 +100,7 @@ module('Integration | Component | isShown', function(hooks) {
105100
this.set('showOn', null);
106101

107102
await render(hbs`
108-
<button id="open" {{action 'openPopover'}}>
103+
<button id="open" {{on 'click' this.openPopover}}>
109104
Click me, captain!
110105
111106
{{#attach-popover id='attachment'
@@ -115,7 +110,7 @@ module('Integration | Component | isShown', function(hooks) {
115110
showOn=this.showOn}}
116111
isShown w/ hideOn/ShowOn of 'none'
117112
118-
<button id="close" {{action 'closePopover'}}>
113+
<button id="close" {{on 'click' this.closePopover}}>
119114
Close
120115
</button>
121116
@@ -141,15 +136,15 @@ module('Integration | Component | isShown', function(hooks) {
141136
test('nested attachers open and close as expected', async function(assert) {
142137
assert.expect(7);
143138

144-
this.actions.openParentPopover = () => {
139+
this.openParentPopover = () => {
145140
this.set('parentIsShown', true);
146141
};
147142

148-
this.actions.closeChildPopover = () => {
143+
this.closeChildPopover = () => {
149144
this.set('childIsShown', false);
150145
};
151146

152-
this.actions.openChildPopover = () => {
147+
this.openChildPopover = () => {
153148
this.set('childIsShown', true);
154149
};
155150

@@ -162,23 +157,23 @@ module('Integration | Component | isShown', function(hooks) {
162157
});
163158

164159
await render(hbs`
165-
<button id="openParent" {{action 'openParentPopover'}}>
160+
<button id="openParent" {{on 'click' this.openParentPopover}}>
166161
Open parent
167162
168163
{{#attach-popover hideOn=this.hideOn
169164
id='parent'
170165
isShown=this.parentIsShown
171166
showOn=this.showOn
172167
interactive=true}}
173-
<button id="openChild" {{action 'openChildPopover'}}>
168+
<button id="openChild" {{on 'click' this.openChildPopover}}>
174169
Open child
175170
176171
{{#attach-popover hideDuration=0
177172
hideOn='none'
178173
id='child'
179174
isShown=this.childIsShown
180175
showOn='none'}}
181-
<button id="closeChild" {{action 'closeChildPopover'}}>
176+
<button id="closeChild" {{on 'click' this.closeChildPopover}}>
182177
Close child
183178
</button>
184179
{{/attach-popover}}

tests/integration/components/ember-attacher/use-capture-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module('Integration | Component | useCapture "true"', function(hooks) {
1111
assert.expect(2);
1212

1313
await render(hbs`
14-
<div id="click-out-target" {{action (mut this.unusedVar) bubbles=false}}>
14+
<div id="click-out-target" {{on 'click' (fn (mut this.unusedVar) bubbles=false)}}>
1515
</div>
1616
1717
<button>

0 commit comments

Comments
 (0)