chore: 🤖 add refreshRouteOnChange option to resource filters (#1289)
This commit is contained in:
1 parent
2614b311a1
commit
3ff89279e6
14 files changed
+92
-54
No files matched your search
@@ -1,8 +1,9 @@
|
||||
<a
|
||||
class="doc-link"
|
||||
class='doc-link'
|
||||
href={{(doc-url @doc)}}
|
||||
target="_blank"
|
||||
rel="noreferrer noopener"
|
||||
title={{t "actions.get-topic-help"}}>
|
||||
<Rose::Icon @name="flight-icons/svg/help-24" @size={{@iconSize}} />
|
||||
</a>
|
||||
target='_blank'
|
||||
rel='noreferrer noopener'
|
||||
title={{t 'actions.get-topic-help'}}
|
||||
>
|
||||
<Rose::Icon @name='flight-icons/svg/help-24' @size={{@iconSize}} />
|
||||
</a>
|
||||
@@ -1,10 +1,13 @@
|
||||
<Rose::Message
|
||||
@title={{t (concat "errors." this.messageCode ".title")}}
|
||||
@subtitle={{concat (t "errors.generic.title") " " @status}}
|
||||
@title={{t (concat 'errors.' this.messageCode '.title')}}
|
||||
@subtitle={{concat (t 'errors.generic.title') ' ' @status}}
|
||||
@icon={{this.icon}}
|
||||
as |message|>
|
||||
<message.description>{{t (concat "errors." this.messageCode ".description")}}</message.description>
|
||||
as |message|
|
||||
>
|
||||
<message.description>{{t
|
||||
(concat 'errors.' this.messageCode '.description')
|
||||
}}</message.description>
|
||||
{{#if this.helpRoute}}
|
||||
<message.link @route={{this.helpRoute}}>{{t "actions.help"}}</message.link>
|
||||
<message.link @route={{this.helpRoute}}>{{t 'actions.help'}}</message.link>
|
||||
{{/if}}
|
||||
</Rose::Message>
|
||||
</Rose::Message>
|
||||
@@ -1,9 +1,10 @@
|
||||
{{!-- //TODO fix the issue and delete disabling the rule --}}
|
||||
{{!-- template-lint-disable no-passed-in-event-handlers --}}
|
||||
{{! //TODO fix the issue and delete disabling the rule }}
|
||||
{{! template-lint-disable no-passed-in-event-handlers }}
|
||||
{{#if @model.type}}
|
||||
{{component (concat "form/authenticate/" @model.type)
|
||||
{{component
|
||||
(concat 'form/authenticate/' @model.type)
|
||||
submit=@submit
|
||||
cancel=false
|
||||
disabled=@disabled
|
||||
}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
@@ -1,5 +1,5 @@
|
||||
<Rose::Form
|
||||
class="full-width"
|
||||
class='full-width'
|
||||
@onSubmit={{@submit}}
|
||||
@cancel={{false}}
|
||||
@disabled={{@disabled}}
|
||||
@@ -7,7 +7,8 @@
|
||||
>
|
||||
|
||||
<form.actions
|
||||
@submitText={{t "actions.authenticate"}}
|
||||
@showCancel={{false}} />
|
||||
@submitText={{t 'actions.authenticate'}}
|
||||
@showCancel={{false}}
|
||||
/>
|
||||
|
||||
</Rose::Form>
|
||||
</Rose::Form>
|
||||
@@ -1,28 +1,32 @@
|
||||
<Rose::Form
|
||||
class="full-width"
|
||||
@onSubmit={{fn this.submit @submit (hash
|
||||
identification=this.identification
|
||||
password=this.password
|
||||
)}}
|
||||
class='full-width'
|
||||
@onSubmit={{fn
|
||||
this.submit
|
||||
@submit
|
||||
(hash identification=this.identification password=this.password)
|
||||
}}
|
||||
@cancel={{false}}
|
||||
@disabled={{@disabled}}
|
||||
as |form|
|
||||
>
|
||||
|
||||
<form.input
|
||||
@name="identification"
|
||||
@type="text"
|
||||
@name='identification'
|
||||
@type='text'
|
||||
@value={{this.identification}}
|
||||
@label={{t "form.login_name.label"}} />
|
||||
@label={{t 'form.login_name.label'}}
|
||||
/>
|
||||
|
||||
<form.input
|
||||
@name="password"
|
||||
@type="password"
|
||||
@name='password'
|
||||
@type='password'
|
||||
@value={{this.password}}
|
||||
@label={{t "form.password.label"}} />
|
||||
@label={{t 'form.password.label'}}
|
||||
/>
|
||||
|
||||
<form.actions
|
||||
@submitText={{t "actions.authenticate"}}
|
||||
@showCancel={{false}} />
|
||||
@submitText={{t 'actions.authenticate'}}
|
||||
@showCancel={{false}}
|
||||
/>
|
||||
|
||||
</Rose::Form>
|
||||
</Rose::Form>
|
||||
@@ -6,13 +6,9 @@
|
||||
'flight-icons/svg/loading-16'
|
||||
'flight-icons/svg/reload-16'
|
||||
}}
|
||||
class={{if
|
||||
this.isLoading
|
||||
'loading-button is-loading'
|
||||
'loading-button'
|
||||
}}
|
||||
class={{if this.isLoading 'loading-button is-loading' 'loading-button'}}
|
||||
@disabled={{this.isLoading}}
|
||||
{{on 'click' this.toggleRefresh}}
|
||||
>
|
||||
{{yield}}
|
||||
</Rose::Button>
|
||||
</Rose::Button>
|
||||
@@ -2,5 +2,6 @@
|
||||
{{yield
|
||||
confirmation
|
||||
(fn this.accept confirmation)
|
||||
(fn this.deny confirmation)}}
|
||||
{{/each}}
|
||||
(fn this.deny confirmation)
|
||||
}}
|
||||
{{/each}}
|
||||
@@ -6,4 +6,4 @@
|
||||
|
||||
<LoadingButton @onClick={{this.onClick}}>
|
||||
{{t 'actions.refresh'}}
|
||||
</LoadingButton>
|
||||
</LoadingButton>
|
||||
@@ -112,8 +112,12 @@ class RouteResourceFilter extends EmberObject {
|
||||
* @static
|
||||
* @param {Route} routeClass
|
||||
* @param {string} name
|
||||
* @param {boolean} refreshRouteOnChange - set to false if you plan to
|
||||
* transition from a sibling to this route, which is currently
|
||||
* buggy in Ember. When set to false, you must manually refresh
|
||||
* the route as necessary.
|
||||
*/
|
||||
static setupRouteQueryParams(routeClass, name) {
|
||||
static setupRouteQueryParams(routeClass, name, refreshRouteOnChange = true) {
|
||||
const filterKey = `filter-${name}`;
|
||||
|
||||
// If the route has no query params specified yet, declare them.
|
||||
@@ -127,7 +131,7 @@ class RouteResourceFilter extends EmberObject {
|
||||
// param changes refresh the model but do not contribute to browser history.
|
||||
// See https://guides.emberjs.com/release/routing/query-params/
|
||||
routeClass.queryParams[filterKey] = {
|
||||
refreshModel: true,
|
||||
refreshModel: refreshRouteOnChange,
|
||||
replace: true,
|
||||
};
|
||||
}
|
||||
@@ -213,6 +217,7 @@ export function resourceFilter({
|
||||
defaultValue,
|
||||
serialize,
|
||||
findBySerialized,
|
||||
refreshRouteOnChange,
|
||||
}) {
|
||||
/**
|
||||
* @param {object} target
|
||||
@@ -221,7 +226,11 @@ export function resourceFilter({
|
||||
* @return {object{get, set}}
|
||||
*/
|
||||
return function (target, name /*, descriptor*/) {
|
||||
RouteResourceFilter.setupRouteQueryParams(target, name);
|
||||
RouteResourceFilter.setupRouteQueryParams(
|
||||
target,
|
||||
name,
|
||||
refreshRouteOnChange
|
||||
);
|
||||
|
||||
let instance;
|
||||
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
<h2 id="title">Welcome to Ember</h2>
|
||||
<p>{{relative-datetime-live this.now}}</p>
|
||||
<h2 id='title'>Welcome to Ember</h2>
|
||||
<p>{{relative-datetime-live this.now}}</p>
|
||||
@@ -15,14 +15,22 @@ module('Integration | Component | pending-confirmations', function (hooks) {
|
||||
<div class="pending">Pending</div>
|
||||
</PendingConfirmations>
|
||||
`);
|
||||
assert.strictEqual(findAll('.pending').length, 0, 'No pending confirmations');
|
||||
assert.strictEqual(
|
||||
findAll('.pending').length,
|
||||
0,
|
||||
'No pending confirmations'
|
||||
);
|
||||
service.confirm();
|
||||
await render(hbs`
|
||||
<PendingConfirmations as |confirmations|>
|
||||
<div class="pending">Pending</div>
|
||||
</PendingConfirmations>
|
||||
`);
|
||||
assert.strictEqual(findAll('.pending').length, 1, 'One pending confirmations');
|
||||
assert.strictEqual(
|
||||
findAll('.pending').length,
|
||||
1,
|
||||
'One pending confirmations'
|
||||
);
|
||||
});
|
||||
|
||||
test('it exposes a confirm action that confirms the confirmation', async function (assert) {
|
||||
|
||||
@@ -11,6 +11,9 @@ module('Integration | Helper | format-date-iso', function (hooks) {
|
||||
|
||||
await render(hbs`{{format-date-iso inputValue}}`);
|
||||
|
||||
assert.strictEqual(this.element.textContent.trim(), '2020-01-01T00:00:00.999Z');
|
||||
assert.strictEqual(
|
||||
this.element.textContent.trim(),
|
||||
'2020-01-01T00:00:00.999Z'
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -32,7 +32,10 @@ module('Unit | Authenticator | password', function (hooks) {
|
||||
return new Response(200);
|
||||
});
|
||||
authenticator.restore(mockData);
|
||||
assert.strictEqual(applicationAdapter.headers.Authorization, 'Bearer token1234');
|
||||
assert.strictEqual(
|
||||
applicationAdapter.headers.Authorization,
|
||||
'Bearer token1234'
|
||||
);
|
||||
});
|
||||
|
||||
test('it adds an authorization header to application adapter on authenticate', async function (assert) {
|
||||
|
||||
@@ -18,9 +18,17 @@ module('Unit | Service | confirm', function (hooks) {
|
||||
assert.expect(3);
|
||||
const service = this.owner.lookup('service:confirm');
|
||||
service.enabled = true;
|
||||
assert.strictEqual(service.pending.length, 0, 'No pending confirmations yet');
|
||||
assert.strictEqual(
|
||||
service.pending.length,
|
||||
0,
|
||||
'No pending confirmations yet'
|
||||
);
|
||||
const confirmation = service.confirm();
|
||||
assert.strictEqual(service.pending.length, 1, 'One pending confirmation created');
|
||||
assert.strictEqual(
|
||||
service.pending.length,
|
||||
1,
|
||||
'One pending confirmation created'
|
||||
);
|
||||
confirmation.confirm();
|
||||
assert.strictEqual(service.pending.length, 0, 'Confirmation was confirmed');
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user