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

[MOD-136][Improvement] Loading for the dashboard #73

Merged

Conversation

laurenbarker
Copy link
Contributor

@laurenbarker laurenbarker commented Oct 23, 2017

TODO

  • Use the cos-fork of ember-content-placeholders

Changes

  • Install ember-concurrency
  • Move loading data out of routes
  • Add skeleton screens for dashboard

dashboard-skeleton

@laurenbarker laurenbarker force-pushed the improvement/MOD-136 branch 2 times, most recently from c0a75ed to fce23bc Compare November 6, 2017 19:05
@laurenbarker laurenbarker changed the title [WIP][MOD-136][Improvement] Add loading pages [WIP][MOD-136][Improvement] Loading for the dashboard Nov 6, 2017
@laurenbarker laurenbarker changed the title [WIP][MOD-136][Improvement] Loading for the dashboard [MOD-136][Improvement] Loading for the dashboard Nov 6, 2017
Copy link
Contributor

@aaxelb aaxelb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, looks awesome, just a smattering of small things.

Tiny bug: I think something happened moving data out of the route -- when I refresh the settings page, the count on the moderation tab is initially correct, then changes to 0 after a second.

...and there were some tests merged earlier today that this breaks, sorry about that.

@@ -1,14 +1,18 @@
{{#if listLoading}}
{{loading-indicator classes='ball-dark text-center loading'}}
{{#if (and loadActions.isRunning (not loadingMore))}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could get rid of loadingMore and DRY this up a little...

{{#each actionsList ...}}
  entry
{{else if (not loadActions.isRunning)}}
  No actions
{{/if}}
{{#if loadActions.isRunning}}
  dummy list
{{else if moreActions}}
  see more
{{/if}}

},

fetchData: task(function* () {
yield timeout(1000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this left over from debugging?

@@ -1,26 +1,4 @@
import { inject as service } from '@ember/service';
import Route from '@ember/routing/route';

export default Route.extend({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we delete this file?

const page = this.get('page');
try {
const results = yield this.get('currentUser.user')
.then(user => this.get('store').queryHasMany(user, 'actions', { page }));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't directly related to your changes, but would it load faster if we added embed: 'target' here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Embedding isn't faster but it prevents the piecemeal loading.

loadActions: task(function* () {
const page = this.get('page');
try {
const results = yield this.get('currentUser.user')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thoughts on the ember-concurrency idiom instead of chaining promises?

const user = yield this.get('currentUser.user');
const actions = yield this.get('store').queryHasMany(user, ...);
this.get('actionsList').pushObjects(actions.toArray());
...

nextPage() {
this.incrementProperty('page');
this.set('loadingMore', true);
this.loadPage();
this.get('loadActions').perform();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you add .drop() to loadActions, seems like we could safely increment page inside it and get rid of nextPage

@@ -1,10 +1,6 @@
& {
clear: both;

.entry-body {
padding: 20px 15px;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why no padding?
screen shot 2017-11-06 at 4 46 51 pm

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aw...I forgot about the hover box. The top of the list looks out of line with the provider box with top padding.

Remove extra file

Chaining promises --> ember-concurrency

Embed target

DRY up code
@coveralls
Copy link

Coverage Status

Coverage increased (+0.5%) to 14.6% when pulling 93e5de0 on laurenbarker:improvement/MOD-136 into d28e6cd on CenterForOpenScience:develop.

Copy link
Contributor

@aaxelb aaxelb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found a little bug and had a few suggestions.

<div class="icon--skeleton">{{placeholder.icon}}</div>
{{/content-placeholders}}
<div class="action-body--skeleton">
{{#content-placeholders as |placeholder|}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could these two {{#content-placeholders as |placeholder|}} blocks be combined in one?

this.transitionToRoute('preprints.provider.preprint-detail', provider.get('id'), reviewable.get('id'));
},
setupProvider(provider) {
this.transitionToRoute('preprints.provider.setup', provider.id);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uncaught TypeError: this.transitionToRoute is not a function

The router service would help.

{{loading-indicator-page}}
{{else}}
{{#if showDashboard}}
<div class='reviews-dashboard content'>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're doing all components, I think it'd be nice to make the landing page and dashboard separate components. Maybe the logic to switch between them would make sense on the controller? Not super important, but now seems like a convenient time to clean this up, if you don't mind...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The request for providers is what messes up the other pages. So I can move some stuff around but I don't think the logic to switch between them can go in the controller since it's called when the app refreshes no matter what page the user is on (that was the bug on the settings page).

this.setProperties({
totalPages: Math.ceil(response.get('links.meta.total') / response.get('links.meta.per_page')),
listLoading: false,
actionsList: [],
loadingMore: false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loadingMore is gone

Condense placeholders
@coveralls
Copy link

Coverage Status

Coverage increased (+0.5%) to 14.6% when pulling 4f66212 on laurenbarker:improvement/MOD-136 into d28e6cd on CenterForOpenScience:develop.

Copy link
Contributor

@aaxelb aaxelb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one last thing, if it makes sense to you.

</div>
<div class='col-md-8 col-md-pull-4'>
{{action-feed
toDetail=(action transitionToDetail)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since transitionToDetail is already a closure action, I think you could just do toDetail=transitionToDetail. But more than that, it feels wrong to pass this action so far down (controller => reviews-dashboard => action-feed => action-feed-entry) when action-feed-entry could just use the router service and trigger a transition all by itself.

Copy link
Contributor Author

@laurenbarker laurenbarker Nov 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to avoid that since it seems very anti-Ember but we are ignoring pretty much everything they recommend so I guess it doesn't really matter. I do hate passing things down 10 levels.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it'd make more sense if these components were meant to be reusable outside this app, or the action varied depending on other state, or it did anything other than a simple transition.

They added router, though, so I figure we may as well use it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aaxelb, bad news. We can't use the router service yet because their is a bug that breaks when all query params aren't present. So when we try and use this.get('router').transitionTo(...) we always get an error about the ticket query parameter on the application route.

"Assertion Failed: You passed the `false` query parameter during a transition into application, please update to ticket"

Fix release:

Apologies for not getting this in for 2.16, I'll get the changes into the next 2.17 beta release and once some folks can confirm all is working well for us I'll pull down into 2.16 for the LTS.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That fix is in 2.16.1... we should upgrade. In another ticket.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh nice, I missed that. I'll add a ticket 👍

<div class="text-center m-t-lg col-xs-12">
<div class="m-b-lg reviews-brand"></div>
{{#if showSetup}}
{{start-moderating action=(action setupProvider) providers=providersToSetup}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here: It seems cleaner for start-moderating to use the router service and trigger the transition itself, rather than passing setupProvider all the way down from the controller.

@aaxelb aaxelb merged commit 1d150ff into CenterForOpenScience:develop Nov 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants