-
Notifications
You must be signed in to change notification settings - Fork 6
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
feat: add refresh method #84
Merged
Merged
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
7cbf0d3
feat: add refresh method
aklkv 529952a
fix: yarn
aklkv b999167
fix: typo
aklkv 1faf508
fix: add missing component
aklkv e5d38a6
fix: link to post page
aklkv 6e79a6a
feat: add tests for the refresh method
aklkv 7cff3ac
fix: remove single quotes, add newer prettier config
aklkv 9dc5286
fix: remove useless assertions
aklkv 533d280
fix: clean up tests
aklkv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
nodeLinker: node-modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
import type RouterService from '@ember/routing/router-service'; | ||
|
||
export default interface EnginesRouterService extends Omit< | ||
RouterService, | ||
"currentRoute" | "recognize" | "recognizeAndLoad" | ||
> { | ||
export default interface EnginesRouterService | ||
extends Omit< | ||
RouterService, | ||
'currentRoute' | 'recognize' | 'recognizeAndLoad' | ||
> { | ||
isActiveExternal: RouterService['isActive']; | ||
replaceWithExternal: RouterService['replaceWith']; | ||
transitionToExternal: RouterService['transitionTo']; | ||
refreshExternal: RouterService['refresh']; | ||
urlForExternal: RouterService['urlFor']; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import Route from '@ember/routing/route'; | ||
|
||
let count = 0; | ||
|
||
export default class extends Route { | ||
model() { | ||
return { | ||
count: count++, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<h3 class="title">Eager engine</h3> | ||
|
||
<LinkTo @route="index" @current-when="index post" class="current-when-test-link">All Posts</LinkTo> | | ||
<LinkTo @route="post">Post 1</LinkTo> | ||
<LinkTo @route="post" @model={{1}}>Post 1</LinkTo> | ||
|
||
{{outlet}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,30 @@ | ||
<div class="hello-name" ...attributes> | ||
Hello, {{@name}}! | ||
<div class='hello-name' ...attributes> | ||
<span class='greeting'> | ||
Hello, | ||
{{@name}}! | ||
</span> | ||
|
||
<button | ||
class='refresh' | ||
type='button' | ||
{{on 'click' this.refresh}} | ||
> | ||
Refresh | ||
</button> | ||
|
||
<button | ||
class='refresh-route' | ||
type='button' | ||
{{on 'click' this.refreshRoute}} | ||
> | ||
Refresh Route | ||
</button> | ||
|
||
<button | ||
class='refresh-external' | ||
type='button' | ||
{{on 'click' this.refreshExternal}} | ||
> | ||
Refresh External | ||
</button> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { inject as service } from '@ember/service'; | ||
import Route from '@ember/routing/route'; | ||
|
||
let count = 0; | ||
aklkv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
export default class extends Route { | ||
@service exampleService; | ||
|
||
model() { | ||
// cause a service to be instantiated, so that our tests can | ||
// confirm that it gets cleaned up | ||
this.exampleService; | ||
|
||
return { | ||
name: 'Derek Zoolander', | ||
count: count++, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
test-app/lib/ember-chat/addon/components/spanish-greeting.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<span class="greeting">Hola</span> from {{@name}}! | ||
<button class="clicker" type="button" {{on "click" this.click}}>Clicker</button> | ||
<span class="click-count">{{this.clickCount}}</span> |
11 changes: 11 additions & 0 deletions
11
test-app/lib/ember-chat/addon/components/spanish-greeting.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import Component from '@glimmer/component'; | ||
import { tracked } from '@glimmer/tracking'; | ||
import { action } from '@ember/object'; | ||
|
||
export default class extends Component { | ||
@tracked clickCount = 0; | ||
|
||
@action click() { | ||
this.clickCount++; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
test-app/tests/acceptance/routeable-engine-demo-refresh-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { module, test } from 'qunit'; | ||
aklkv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import { setupApplicationTest } from 'ember-qunit'; | ||
import { visit, find, click } from '@ember/test-helpers'; | ||
|
||
module('Acceptance | routeless engine demo', function (hooks) { | ||
setupApplicationTest(hooks); | ||
|
||
module('Engine Router Service Refresh Method', function () { | ||
test('refresh without params triggers refresh with current route', async function (assert) { | ||
await visit('/routable-engine-demo/ember-blog/new'); | ||
|
||
let counter = await find('.route-refresh-counter').textContent; | ||
assert.dom('.route-refresh-counter').hasText(counter); | ||
aklkv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
await click('.refresh'); | ||
|
||
counter = parseInt(counter, 10); | ||
counter = ++counter; | ||
counter = counter.toString(); | ||
assert.dom('.route-refresh-counter').hasText(counter); | ||
}); | ||
|
||
test('refresh with params triggers refresh on provided route', async function (assert) { | ||
await visit('/routable-engine-demo/ember-blog/new'); | ||
|
||
let counter = await find('.route-refresh-counter').textContent; | ||
assert.dom('.route-refresh-counter').hasText(counter); | ||
await click('.refresh-route'); | ||
|
||
counter = parseInt(counter, 10); | ||
counter = ++counter; | ||
counter = counter.toString(); | ||
assert.dom('.route-refresh-counter').hasText(counter); | ||
}); | ||
|
||
test('refresh external route', async function (assert) { | ||
await visit('/routable-engine-demo/ember-blog/new'); | ||
|
||
let counter = await find('.route-refresh-counter').textContent; | ||
assert.dom('.global-refresh-counter').hasText(counter); | ||
await click('.refresh-external'); | ||
|
||
counter = parseInt(counter, 10); | ||
counter = ++counter; | ||
counter = counter.toString(); | ||
assert.dom('.global-refresh-counter').hasText(counter); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this approach might be able to solve #74 as well @SergeAstapov if you want I can add it as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aklkv sure, feel free to open separate PR, to keep each PR focused on one thing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @SergeAstapov here, let's open another PR for this purpose