Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport/bugfix query params helpers pr #18458 issue #18076 #18546

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions packages/@ember/-internals/glimmer/lib/components/link-to.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1752,9 +1752,14 @@ if (EMBER_GLIMMER_ANGLE_BRACKET_BUILT_INS) {
params && params.length > 0
);

let disabledWhen = get(this, 'disabledWhen');
if (disabledWhen !== undefined) {
this.set('disabled', disabledWhen);
let { _models: models } = this;
if (models.length > 0) {
let lastModel = models[models.length - 1];

if (typeof lastModel === 'object' && lastModel !== null && lastModel.isQueryParams) {
this.query = lastModel.values;
models.pop();
}
}

// Process the positional arguments, in order.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Controller from '@ember/controller';
import { RSVP } from '@ember/-internals/runtime';
import { Route } from '@ember/-internals/routing';
import { DEBUG } from '@glimmer/env';
import {
ApplicationTestCase,
classes as classMatcher,
Expand Down Expand Up @@ -68,22 +67,19 @@ moduleFor(
});
}

async ['@feature(ember-glimmer-angle-bracket-built-ins) `(query-params)` must be used in conjunction with `{{link-to}}'](
assert
) {
async ['@feature(ember-glimmer-angle-bracket-built-ins) `(query-params)` must be used in conjunction with `{{link-to}}']() {
this.addTemplate(
'index',
`{{#let (query-params foo='456' bar='NAW') as |qp|}}{{link-to 'Index' 'index' qp}}{{/let}}`
`{{#let (query-params foo='456' alon='BUKAI') as |qp|}}{{link-to 'Index' 'index' qp}}{{/let}}`
);

// TODO If we visit this page at all in production mode, it'll fail for
// entirely different reasons than what this test is trying to test.
let promise = DEBUG ? this.visit('/') : null;

await assert.rejectsAssertion(
promise,
/The `\(query-params\)` helper can only be used when invoking the `{{link-to}}` component\./
);
return this.visit('/').then(() => {
this.assertComponentElement(this.firstChild, {
tagName: 'a',
attrs: { href: '/?alon=BUKAI&foo=456', class: classMatcher('ember-view') },
content: 'Index',
});
});
}
}
);
Expand Down