Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
🏃 improve navigation responsiveness with loading substates (#495)
Browse files Browse the repository at this point in the history
no issue
- add loading substates for all routes that previously blocked transitions until their model had finished loading
  - enables immediate response on navigation click
  - loading templates include the title bar to provide immediate indication of which page is loading
  - loading templates include a new `{{gh-loading-spinner}}` component that will only show the spinner after 200ms to avoid flashing a spinner for users on fast connections
- updated Version Mismatch tests to match new behaviour of intermediate transitions when navigating
  • Loading branch information
kevinansfield authored and acburdine committed Jan 17, 2017
1 parent 85af326 commit 7652969
Show file tree
Hide file tree
Showing 17 changed files with 156 additions and 22 deletions.
20 changes: 20 additions & 0 deletions app/components/gh-loading-spinner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import Component from 'ember-component';
import {task, timeout} from 'ember-concurrency';

export default Component.extend({
tagName: '',

showSpinner: false,
// ms until the loader is displayed,
// prevents unnecessary flash of spinner
slowLoadTimeout: 200,

startSpinnerTimeout: task(function* () {
yield timeout(this.get('slowLoadTimeout'));
this.set('showSpinner', true);
}),

didInsertElement() {
this.get('startSpinnerTimeout').perform();
}
});
4 changes: 3 additions & 1 deletion app/routes/settings/apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export default AuthenticatedRoute.extend(styleBody, CurrentUserSettings, {
},

model() {
return this.store.queryRecord('setting', {type: 'blog,theme,private'});
return this.store.query('setting', {type: 'blog,theme,private'}).then((records) => {
return records.get('firstObject');
});
}
});
20 changes: 6 additions & 14 deletions app/styles/components/loading-indicator.css
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
/* Loading state */
.ember-load-indicator {
.gh-loading-content {
display: flex;
flex-direction: row;
align-items: stretch;
align-items: center;
overflow: hidden;
width: 100%;
position: absolute;
top: 0;
bottom: 0;
padding-bottom: 8vh;
}

.gh-loading-content {
position: relative;
flex-grow: 1;
display: flex;
align-items: center;
position: absolute;
width: 100%;
justify-content: center;
background: #fff;
flex-direction: column;
left: 0;
padding-bottom: 8vh;
}

.gh-loading-content.basic-auth {
Expand Down
5 changes: 5 additions & 0 deletions app/templates/components/gh-loading-spinner.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{{#if showSpinner}}
<div class="gh-loading-content">
<div class="gh-loading-spinner"></div>
</div>
{{/if}}
6 changes: 4 additions & 2 deletions app/templates/components/gh-subscribers-table.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
}}
{{#if isLoading}}
{{#body.loader}}
<span class="gh-subscribers-loading">Loading...</span>
<div class="gh-loading-content" style="margin-top: 2em;">
<div class="gh-loading-spinner"></div>
</div>
{{/body.loader}}
{{else}}
{{#if table.isEmpty}}
Expand All @@ -23,4 +25,4 @@
{{/if}}
{{/if}}
{{/t.body}}
{{/light-table}}
{{/light-table}}
5 changes: 5 additions & 0 deletions app/templates/editor/edit-loading.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div class="gh-view">
<div class="gh-content">
{{gh-loading-spinner}}
</div>
</div>
12 changes: 12 additions & 0 deletions app/templates/posts-loading.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<section class="gh-view">
<header class="view-header">
{{#gh-view-title openMobileMenu="openMobileMenu"}}<span>Content</span>{{/gh-view-title}}
<section class="view-actions">
{{#link-to "editor.new" class="btn btn-green" title="New Post"}}New Post{{/link-to}}
</section>
</header>

<div class="view-container">
{{gh-loading-spinner}}
</div>
</section>
9 changes: 9 additions & 0 deletions app/templates/settings/apps-loading.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<div class="gh-view">
<header class="view-header">
{{#gh-view-title openMobileMenu="openMobileMenu"}}<span style="padding-left:1px">Apps</span>{{/gh-view-title}}
</header>

<div class="view-content">
{{gh-loading-spinner}}
</div>
</div>
12 changes: 12 additions & 0 deletions app/templates/settings/code-injection-loading.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<section class="gh-view">
<header class="view-header">
{{#gh-view-title openMobileMenu="openMobileMenu"}}<span>Code Injection</span>{{/gh-view-title}}
<section class="view-actions">
{{#gh-spin-button class="btn btn-blue" action="save" submitting=submitting}}Save{{/gh-spin-button}}
</section>
</header>

<section class="view-content">
{{gh-loading-spinner}}
</section>
</section>
12 changes: 12 additions & 0 deletions app/templates/settings/general-loading.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<section class="gh-view">
<header class="view-header">
{{#gh-view-title openMobileMenu="openMobileMenu"}}<span>General</span>{{/gh-view-title}}
<section class="view-actions">
{{#gh-spin-button class="btn btn-blue" action="save" submitting=submitting}}Save{{/gh-spin-button}}
</section>
</header>

<section class="view-content">
{{gh-loading-spinner}}
</section>
</section>
9 changes: 9 additions & 0 deletions app/templates/settings/labs-loading.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<section class="gh-view">
<header class="view-header">
{{#gh-view-title openMobileMenu="openMobileMenu"}}<span>Labs</span>{{/gh-view-title}}
</header>

<div class="view-content">
{{gh-loading-spinner}}
</div>
</section>
12 changes: 12 additions & 0 deletions app/templates/settings/navigation-loading.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<section class="gh-view">
<header class="view-header">
{{#gh-view-title openMobileMenu="openMobileMenu"}}<span>Navigation</span>{{/gh-view-title}}
<section class="view-actions">
{{#gh-spin-button class="btn btn-blue" action="save" submitting=submitting}}Save{{/gh-spin-button}}
</section>
</header>

<section class="view-content">
{{gh-loading-spinner}}
</section>
</section>
12 changes: 12 additions & 0 deletions app/templates/settings/tags-loading.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<section class="gh-view">
<header class="view-header">
{{#gh-view-title openMobileMenu="openMobileMenu"}}<span>Tags</span>{{/gh-view-title}}
<section class="view-actions">
{{#link-to "settings.tags.new" class="btn btn-green" title="New Tag"}}New Tag{{/link-to}}
</section>
</header>

<div class="view-content">
{{gh-loading-spinner}}
</div>
</section>
3 changes: 1 addition & 2 deletions app/templates/settings/tags.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
{{#gh-view-title openMobileMenu="openMobileMenu"}}<span>Tags</span>{{/gh-view-title}}
<section class="view-actions">
{{#link-to "settings.tags.new" class="btn btn-green" title="New Tag"}}New Tag{{/link-to}}
{{!-- <button type="button" class="btn btn-green" {{action "newTag"}}>New Tag</button> --}}
</section>
</header>

Expand All @@ -24,4 +23,4 @@
{{outlet}}
</section>
{{/gh-tags-management-container}}
</section>
</section>
15 changes: 15 additions & 0 deletions app/templates/team/index-loading.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<section class="gh-view">
<header class="view-header">
{{#gh-view-title openMobileMenu="openMobileMenu"}}<span>Team</span>{{/gh-view-title}}
{{!-- Do not show Invite user button to authors --}}
{{#unless session.user.isAuthor}}
<section class="view-actions">
<button class="btn btn-green">Invite People</button>
</section>
{{/unless}}
</header>

<div class="view-container">
{{gh-loading-spinner}}
</div>
</section>
16 changes: 16 additions & 0 deletions app/templates/team/user-loading.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<section class="gh-view">
<header class="view-header">
{{#gh-view-title openMobileMenu="openMobileMenu"}}
{{link-to "Team" "team"}}
<i class="icon-arrow-right"></i>
{{/gh-view-title}}

<section class="view-actions">
<div class="btn btn-blue">Save</div>
</section>
</header>

<div class="view-container">
{{gh-loading-spinner}}
</div>
</section>
6 changes: 3 additions & 3 deletions tests/acceptance/version-mismatch-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ describe('Acceptance: Version Mismatch', function() {
click('.gh-nav-settings-tags');

andThen(() => {
// navigation is blocked
expect(currentPath()).to.equal('posts.index');
// navigation is blocked on loading screen
expect(currentPath()).to.equal('settings.tags_loading');

// has the refresh to update alert
expect(find('.gh-alert').length).to.equal(1);
Expand All @@ -80,7 +80,7 @@ describe('Acceptance: Version Mismatch', function() {

andThen(() => {
// navigation is blocked
expect(currentPath()).to.equal('settings.tags.index');
expect(currentPath()).to.equal('settings.general_loading');

// has the refresh to update alert
expect(find('.gh-alert').length).to.equal(1);
Expand Down

0 comments on commit 7652969

Please sign in to comment.