Skip to content

Commit 5e88af3

Browse files
authored
Fix LinkTo usage and explicitly provide @route and @models arguments (#1021)
* Fix LinkTo usage and explicitly provide `@route` and `@models` arguments * Set emberKeyboard.disableInputsInitializer to make CI pass
1 parent f44e3b5 commit 5e88af3

File tree

7 files changed

+34
-40
lines changed

7 files changed

+34
-40
lines changed

Diff for: addon/components/docs-header/search-result/index.hbs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
{{! template-lint-disable no-unknown-arguments-for-builtin-components }}
21
<div {{on 'click' this.onClick}} {{on 'mouseenter' this.onMouseEnter}} data-test-search-result>
32
<LinkTo
43
class={{
54
concat
65
'docs-block docs-py-2 docs-px-3 docs-text-black docs-no-underline hover:docs-bg-grey-lighter '
76
(if @selected 'docs-bg-grey-lighter')
87
}}
9-
@params={{this.linkArgs}}
8+
@route={{this.linkArgs.route}}
9+
@models={{this.linkArgs.models}}
1010
>
1111
<div class='docs-flex docs-items-center'>
1212
{{svg-jar

Diff for: addon/components/docs-header/search-result/index.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,18 @@ export default Component.extend({
1111
'result.document.{route,type}',
1212
'result.model.routingId',
1313
function () {
14-
let args = [];
1514
let type = this.get('result.document.type');
1615
if (type === 'template') {
17-
args = [this.get('result.document.route')];
16+
return {
17+
route: this.get('result.document.route'),
18+
models: [],
19+
};
1820
} else {
19-
args = ['docs.api.item', this.get('result.model.routingId')];
21+
return {
22+
route: 'docs.api.item',
23+
models: [this.get('result.model.routingId')],
24+
};
2025
}
21-
22-
return args;
2326
}
2427
),
2528

Diff for: addon/components/docs-viewer/index.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ export default class DocsViewerComponent extends Component {
4848
nextPage() {
4949
if (!formElementHasFocus()) {
5050
if (this.get('docsRoutes.next')) {
51-
this.router.transitionTo(...this.get('docsRoutes.next.route'));
51+
const { route, model } = this.get('docsRoutes.next');
52+
this.router.transitionTo(route, model);
5253
}
5354
}
5455
}
@@ -58,7 +59,8 @@ export default class DocsViewerComponent extends Component {
5859
previousPage() {
5960
if (!formElementHasFocus()) {
6061
if (this.get('docsRoutes.previous')) {
61-
this.router.transitionTo(...this.get('docsRoutes.previous.route'));
62+
const { route, model } = this.get('docsRoutes.previous');
63+
this.router.transitionTo(route, model);
6264
}
6365
}
6466
}

Diff for: addon/components/docs-viewer/x-main/index.hbs

+4-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
<LinkTo
2727
class='docs-text-grey-darkest docs-text-large-4 docs-font-light docs-no-underline
2828
docs-border-b docs-border-grey hover:docs-border-grey-darkest docs-transition'
29-
@params={{this.docsRoutes.previous.route}}
29+
@route={{this.docsRoutes.previous.route}}
30+
@models={{this.docsRoutes.previous.models}}
3031
>
3132
{{this.docsRoutes.previous.label}}
3233
</LinkTo>
@@ -41,7 +42,8 @@
4142
<LinkTo
4243
class='docs-text-grey-darkest docs-text-large-4 docs-font-light docs-no-underline
4344
docs-border-b docs-border-grey hover:docs-border-grey-darkest docs-transition'
44-
@params={{this.docsRoutes.next.route}}
45+
@route={{this.docsRoutes.next.route}}
46+
@models={{this.docsRoutes.next.models}}
4547
>
4648
{{this.docsRoutes.next.label}}
4749
</LinkTo>

Diff for: addon/services/docs-routes.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,12 @@ export default Service.extend({
6161

6262
if (currentIndex < this.get('routes.length') - 1) {
6363
let nextRouteIndex = currentIndex + 1;
64-
let route = this.routes[nextRouteIndex];
64+
let route = this.items.objectAt(nextRouteIndex);
6565

6666
return {
67-
route,
68-
label: this.items.objectAt(nextRouteIndex).get('label'),
67+
route: route.get('route'),
68+
models: route.get('model') ? [route.get('model')] : [],
69+
label: route.get('label'),
6970
};
7071
}
7172
}),
@@ -75,11 +76,12 @@ export default Service.extend({
7576

7677
if (currentIndex > 0) {
7778
let previousRouteIndex = currentIndex - 1;
78-
let route = this.routes[previousRouteIndex];
79+
let route = this.items.objectAt(previousRouteIndex);
7980

8081
return {
81-
route,
82-
label: this.items.objectAt(previousRouteIndex).get('label'),
82+
route: route.get('route'),
83+
models: route.get('model') ? [route.get('model')] : [],
84+
label: route.get('label'),
8385
};
8486
}
8587
}),

Diff for: tests/acceptance/search-test.js

+5-23
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
11
import { module, test } from 'qunit';
22
import { setupApplicationTest } from 'ember-qunit';
33
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
4-
import {
5-
click,
6-
currentURL,
7-
fillIn,
8-
find,
9-
findAll,
10-
visit,
11-
waitUntil,
12-
} from '@ember/test-helpers';
4+
import { click, currentURL, fillIn, visit, waitFor } from '@ember/test-helpers';
135

146
module('Acceptance | Search', function (hooks) {
157
setupApplicationTest(hooks);
@@ -19,29 +11,19 @@ module('Acceptance | Search', function (hooks) {
1911
await visit('/');
2012
await fillIn('[data-test-search-box-input]', 'quickstart');
2113

22-
await waitUntil(
23-
function () {
24-
return findAll('[data-test-search-result]').length > 0;
25-
},
26-
{ timeout: 2000 }
27-
);
14+
await waitFor('[data-test-search-result]', { timeout: 2000 });
2815

29-
await click(find('[data-test-search-result] a'));
16+
await click('[data-test-search-result] a');
3017
assert.equal(currentURL(), '/docs/quickstart');
3118
});
3219

3320
test('search works for API pages', async function (assert) {
3421
await visit('/');
3522
await fillIn('[data-test-search-box-input]', 'hero');
3623

37-
await waitUntil(
38-
function () {
39-
return findAll('[data-test-search-result]').length > 0;
40-
},
41-
{ timeout: 2000 }
42-
);
24+
await waitFor('[data-test-search-result]', { timeout: 2000 });
4325

44-
await click(find('[data-test-search-result] a'));
26+
await click('[data-test-search-result] a');
4527
assert.equal(currentURL(), '/docs/api/components/docs-hero');
4628
});
4729
});

Diff for: tests/dummy/config/environment.js

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ module.exports = function (environment) {
2323
// Here you can pass flags/options to your application instance
2424
// when it is created
2525
},
26+
emberKeyboard: {
27+
disableInputsInitializer: true,
28+
},
2629
};
2730

2831
if (environment === 'development') {

0 commit comments

Comments
 (0)