Skip to content

Commit

Permalink
Merge branch 'release/0.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
alexschiller committed Mar 5, 2018
2 parents f29be4d + aaadb34 commit ced27f6
Show file tree
Hide file tree
Showing 36 changed files with 1,174 additions and 719 deletions.
23 changes: 23 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org

root = true


[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 4

[*.scss]
indent_size = 2

[*.hbs]
insert_final_newline = false

[*.{diff,md}]
trim_trailing_whitespace = false
3 changes: 3 additions & 0 deletions .watchmanconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"ignore_dirs": ["tmp", "dist"]
}
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [0.4.0] - 2018-03-05
## Added
- Warning modal when navigating away with unsaved changes
- Route specific loading page for the moderation-detail page
- Tests for provider setup controller

## Changed
- Update language
- Add `Submitted by` along with the `accepted by/rejected by` for the accepted/rejected records in the moderation list
- Capitalize first letter (e.g `submitted by` to `Submitted by`)
- Upgraded ember-cli to 2.16.2

## [0.3.1] - 2018-03-01
### Added
- Tests for download URL for branded and un-branded providers
Expand All @@ -26,6 +38,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- moderation-list-row component
- action-feed component
- action-feed-entry component
- preprint-status-banner component
- Unit tests for
- preprint-status-banner component
- preprint-detail controller
- provider setup controller
- provider moderation controller
- Pending count on Reviews Dashboard
- Skeleton screens for providers list

Expand Down
44 changes: 33 additions & 11 deletions app/components/contributor-list/component.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,43 @@
import { filterBy } from '@ember/object/computed';
import { computed } from '@ember/object';
import Component from '@ember/component';
import { loadRelation } from 'ember-osf/utils/load-relationship';
import { inject as service } from '@ember/service';

import { task } from 'ember-concurrency';


export default Component.extend({
store: service(),

const ContributorListComponent = Component.extend({
tagName: 'ul',
node: null,

bibliographicContributors: filterBy('contributors', 'bibliographic', true),
bibliographicContributors: filterBy('contributorsList', 'bibliographic', true),

didReceiveAttrs() {
this.set('contributorsList', this.get('contributors') || []);
if (!this.get('contributors.length') || this.get('contributors.content.meta.total') > this.get('contributors.length')) {
this.get('fetchData').perform();
}
},

fetchData: task(function* () {
const node = this.get('node.content');
const query = {
'page[size]': 100,
page: 1,
};

contributors: computed('node', function() {
return loadRelation(this.get('node'), 'contributors');
let response = yield this.get('loadContributors').perform(node, query);

while (response.links.next) {
query.page++;
response = yield this.get('loadContributors').perform(node, query);
}
}),
});

ContributorListComponent.reopenClass({
positionalParams: ['node'],
loadContributors: task(function* (node, query) {
const results = yield this.get('store').queryHasMany(node, 'contributors', query);
this.get('contributorsList').pushObjects(results.toArray());
return results;
}),
});

export default ContributorListComponent;
31 changes: 19 additions & 12 deletions app/components/contributor-list/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,26 @@
display: inline;
list-style: none;
padding-left: 0;
color: white;
}

li {
display: inline;
}
li:after {
content: ", "
}
li:last-child:after {
content: "";
}
li {
display: inline;
}

li::after {
content: ', ';
}

li:last-child::after {
content: '';
}

a {
color: $color-text-cyan;
}

a {
color: #6dd1de;
.ember-content-placeholders-text {
&__line {
background: $ember-content-placeholders-primary-color;
}
}
10 changes: 6 additions & 4 deletions app/components/contributor-list/template.hbs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
{{#if contributors.isPending}}
{{loading-indicator}}
{{#if fetchData.isRunning}}
{{#content-placeholders as |placeholder|}}
{{placeholder.text lines=2}}
{{/content-placeholders}}
{{else}}
{{#each bibliographicContributors as |contributor| ~}}
{{#each bibliographicContributors as |contributor|}}
<li>
{{#if contributor.unregisteredContributor}}
{{contributor.unregisteredContributor}}
{{else}}
<a href={{contributor.users.profileURL}}>
{{contributor.users.givenName}} {{contributor.users.familyName}}
{{contributor.users.givenName}} {{contributor.users.familyName~}}
</a>
{{/if}}
</li>
Expand Down
8 changes: 8 additions & 0 deletions app/components/file-renderer-skeleton/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.file-renderer--skeleton {
height: 700px;
width: 99%;
}

.ember-content-placeholders-img {
height: 100%;
}
3 changes: 3 additions & 0 deletions app/components/file-renderer-skeleton/template.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{#content-placeholders as |placeholder|}}
<div class="file-renderer--skeleton">{{placeholder.img}}</div>
{{/content-placeholders}}
50 changes: 31 additions & 19 deletions app/components/moderation-list-row/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import { task } from 'ember-concurrency';

import latestAction from 'reviews/utils/latest-action';

const PENDING = 'pending';
const ACCEPTED = 'accepted';
const REJECTED = 'rejected';

const submittedOnLabel = {
gtDay: 'components.moderationListRow.submission.submittedOn',
ltDay: 'components.moderationListRow.submission.submitted',
};

const ACTION_LABELS = Object.freeze({
[PENDING]: {
gtDay: 'components.moderationListRow.submission.submittedOn',
ltDay: 'components.moderationListRow.submission.submitted',
},
[ACCEPTED]: {
gtDay: 'components.moderationListRow.submission.acceptedOn',
ltDay: 'components.moderationListRow.submission.accepted',
Expand All @@ -39,35 +39,39 @@ export default Component.extend({

noActions: computed.not('submission.reviewActions.length'),

// latest action attempted on the preprint
latestAction: computed('submission.reviewActions.[]', function() {
return latestAction(this.get('submission.reviewActions'));
}),

// first three contributors to the preprint
firstContributors: computed('submission.node.contributors', function() {
return this.get('submission.node.contributors').slice(0, 3);
}),

// count of contributors in-addition to the first three
additionalContributors: computed('submission.node.contributors', function() {
return this.get('submission.node.contributors.content.meta.pagination.total') - 3;
}),

gtDay: computed('submission.dateLastTransitioned', function() {
return moment().diff(this.get('submission.dateLastTransitioned'), 'days') > 1;
}),

relevantDate: computed('submission.dateLastTransitioned', 'gtDay', function() {
return this.get('gtDay') ?
moment(this.get('submission.dateLastTransitioned')).format('MMMM DD, YYYY') :
moment(Math.min(Date.parse(this.get('submission.dateLastTransitioned')), Date.now())).fromNow();
// translations for moderator action label
reviewedOnLabel: computed('submission.{reviewsState,dateLastTransitioned}', 'noActions', 'latestActionCreator', function() {
const i18n = this.get('i18n');
const [acceptedRejectedDate, gtDay] = this.formattedDateLabel(this.get('submission.dateLastTransitioned'));
const dayValue = gtDay ? 'gtDay' : 'ltDay';
const timeWording = this.get('noActions') ? `${dayValue}_automatic` : dayValue;
const status = this.get('submission.reviewsState');
const labels = ACTION_LABELS[status][timeWording];
return i18n.t(labels, { timeDate: acceptedRejectedDate, moderatorName: this.get('latestActionCreator') });
}),

// translations
statusTimeDate: computed('submission.reviewsState', 'gtDay', 'noActions', function() {
// translations for submitted on label
submittedOnLabel: computed('submission.dateCreated', function() {
const i18n = this.get('i18n');
const dayValue = this.get('gtDay') ? 'gtDay' : 'ltDay';
const timeWording = this.get('noActions') ? `${dayValue}_automatic` : dayValue;
const labels = ACTION_LABELS[this.get('submission.reviewsState')][timeWording];
return i18n.t(labels, { timeDate: this.get('relevantDate'), moderatorName: this.get('latestActionCreator') });
const [submitDate, gtDaySubmit] = this.formattedDateLabel(this.get('submission.dateCreated'));
const dayValue = gtDaySubmit ? 'gtDay' : 'ltDay';
const labels = submittedOnLabel[dayValue];
return i18n.t(labels, { timeDate: submitDate });
}),

didReceiveAttrs() {
Expand All @@ -79,6 +83,14 @@ export default Component.extend({
this.get('fetchData').perform();
},

formattedDateLabel(rawDate) {
const gtDayAgo = moment().diff(rawDate, 'days') > 1;
const formattedDate = gtDayAgo ?
moment(rawDate).format('MMMM DD, YYYY') :
moment(Math.min(Date.parse(rawDate), Date.now())).fromNow();
return [formattedDate, gtDayAgo];
},

fetchData: task(function* () {
const node = yield this.get('submission.node');
yield node.get('contributors');
Expand Down
9 changes: 5 additions & 4 deletions app/components/moderation-list-row/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@
<div title={{submission.title}} class="submission-info">
<div class="submission-title">{{submission.title}}</div>
<div class="submission-body">
{{#if (eq submission.reviewsState 'pending')}}
{{statusTimeDate}}
<div>
{{submittedOnLabel}}
{{#each firstContributors as |contributor| ~}}
<li>{{contributor.users.fullName}}</li>
{{/each}}
{{#if (gt additionalContributors 0)}}
+ {{additionalContributors}}
{{/if}}
{{else}}
{{statusTimeDate}}
</div>
{{#if (not-eq submission.reviewsState 'pending')}}
<div>{{reviewedOnLabel}}</div>
{{/if}}
</div>
</div>
Expand Down
10 changes: 4 additions & 6 deletions app/components/preprint-file-browser/style.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
& {
.file-list {
padding: 15px;
display: flex;
justify-content: flex-start;
}
.file-list {
display: flex;
justify-content: flex-start;
padding: 15px;
}
20 changes: 13 additions & 7 deletions app/components/preprint-status-banner/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ export default Component.extend({
// Submission form
initialReviewerComment: '',
reviewerComment: '',
decision: 'accepted',
decision: ACCEPTED,
decisionValueToggled: false,

reviewsWorkflow: alias('submission.provider.reviewsWorkflow'),
reviewsCommentsPrivate: alias('submission.provider.reviewsCommentsPrivate'),
Expand All @@ -121,6 +122,8 @@ export default Component.extend({

commentExceedsLimit: computed.gt('reviewerComment.length', COMMENT_LIMIT),

userActivity: computed.or('commentEdited', 'decisionValueToggled'),

commentLengthErrorMessage: computed('reviewerComment', function () {
const i18n = this.get('i18n');
return i18n.t('components.preprintStatusBanner.decision.commentLengthError', {
Expand Down Expand Up @@ -223,15 +226,12 @@ export default Component.extend({
return this.get('reviewerComment').trim() !== this.get('initialReviewerComment');
}),

decisionChanged: computed('submission.reviewsState', 'decision', function() {
decisionChanged: computed('decision', 'submission.reviewsState', function() {
return this.get('submission.reviewsState') !== this.get('decision');
}),

btnDisabled: computed('decisionChanged', 'commentEdited', 'saving', 'commentExceedsLimit', function() {
if (this.get('saving') || (!this.get('decisionChanged') && !this.get('commentEdited')) || this.get('commentExceedsLimit')) {
return true;
}
return false;
return this.get('saving') || (!this.get('decisionChanged') && !this.get('commentEdited')) || this.get('commentExceedsLimit');
}),

didInsertElement() {
Expand All @@ -256,14 +256,20 @@ export default Component.extend({
cancel() {
this.set('decision', this.get('submission.reviewsState'));
this.set('reviewerComment', this.get('initialReviewerComment'));
this.get('setUserEnteredReview')(false);
},
decisionToggled() {
this.get('setUserEnteredReview')(this.get('decisionChanged'));
},
commentChanged() {
this.get('setUserEnteredReview')(this.get('commentEdited'));
},
},

_handleActions(action) {
if (action) {
if (this.get('submission.reviewsState') !== PENDING) {
const comment = action.get('comment');

this.set('initialReviewerComment', comment);
this.set('reviewerComment', comment);
this.set('decision', this.get('submission.reviewsState'));
Expand Down

0 comments on commit ced27f6

Please sign in to comment.