Skip to content

Commit

Permalink
Merge branch 'release/0.107.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
brianjgeiger committed Apr 10, 2017
2 parents ee63389 + 0259af4 commit bb26fba
Show file tree
Hide file tree
Showing 58 changed files with 1,638 additions and 1,193 deletions.
5 changes: 4 additions & 1 deletion .ember-cli
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@

Setting `disableAnalytics` to true will prevent any data from being sent.
*/
"disableAnalytics": true
"disableAnalytics": true,
"port": 4200,

"liveReloadPort": 41953 /* Needed for the TouchBar on the new MacBook Pros */
}
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
coverage
dist
docs
tmp
16 changes: 16 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
root: true,
parserOptions: {
ecmaVersion: 6,
sourceType: 'module'
},
extends: 'eslint:recommended',
env: {
browser: true,
es6: true
},
globals: {
MathJax: true
},
rules: {}
};
33 changes: 0 additions & 33 deletions .jshintrc

This file was deleted.

4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ For local development, this is designed to run alongside (and from within) the f
to your `website/settings/local.py` file. Uncomment `'/preprints/': 'http://localhost:4200',` and restart your flask app.
4. Visit your app at http://localhost:5000/preprints/

### Provider Domains
1. Run `sudo ./scripts/add-domains.js`. This will add the domains to your `/etc/hosts`.
2. Visit your app at one of the provider domains with `https://local.<domain>:4200` (e.g. `http://local.socarxiv.org:4200`)

If you encounter problems, make sure that your version of ember-osf is up to date. If login fails, try logging in from
any other OSF page, then returning to the preprints app.

Expand Down
12 changes: 12 additions & 0 deletions app/components/error-page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Ember from 'ember';
import Analytics from '../mixins/analytics';

export default Ember.Component.extend(Analytics, {
theme: Ember.inject.service(),
classNames: ['preprint-error-page'],
label: '',
translationKey: '',
supportEmail: Ember.computed('theme.isProvider', 'theme.provider.emailSupport', function() {
return this.get('theme.isProvider') ? this.get('theme.provider.emailSupport') : 'support@osf.io';
})
});
10 changes: 7 additions & 3 deletions app/components/preprint-form-authors.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import Analytics from '../mixins/analytics';
* @class preprint-form-authors
*/
export default CpPanelBodyComponent.extend(Analytics, {
i18n: Ember.inject.service(),
valid: Ember.computed.alias('newContributorId'),
authorModification: false,
currentPage: 1,
Expand Down Expand Up @@ -94,9 +95,10 @@ export default CpPanelBodyComponent.extend(Analytics, {
this.attrs.addContributor(user.id, 'write', true, this.get('sendEmail'), undefined, undefined, true).then((res) => {
this.toggleAuthorModification();
this.get('contributors').pushObject(res);
this.get('toast').success(this.get('i18n').t('submit.preprint_author_added'));
this.highlightSuccessOrFailure(res.id, this, 'success');
}, () => {
this.get('toast').error('Could not add contributor.');
this.get('toast').error(this.get('i18n').t('submit.error_adding_author'));
this.highlightSuccessOrFailure(user.id, this, 'error');
user.rollbackAttributes();
});
Expand Down Expand Up @@ -142,12 +144,13 @@ export default CpPanelBodyComponent.extend(Analytics, {
this.set('addState', 'searchView');
this.set('fullName', '');
this.set('email', '');
this.get('toast').success(this.get('i18n').t('submit.preprint_unregistered_author_added'));
this.highlightSuccessOrFailure(contributor.id, this, 'success');
}, (error) => {
if (error.errors[0] && error.errors[0].detail && error.errors[0].detail.indexOf('is already a contributor') > -1) {
this.get('toast').error(error.errors[0].detail);
} else {
this.get('toast').error('Could not add unregistered contributor.');
this.get('toast').error(this.get('i18n').t('submit.error_adding_unregistered_author'));
}
this.highlightSuccessOrFailure('add-unregistered-contributor-form', this, 'error');
});
Expand Down Expand Up @@ -178,8 +181,9 @@ export default CpPanelBodyComponent.extend(Analytics, {
this.toggleAuthorModification();
this.removedSelfAsAdmin(contrib, contrib.get('permission'));
this.get('contributors').removeObject(contrib);
this.get('toast').success(this.get('i18n').t('submit.preprint_author_removed'));
}, () => {
this.get('toast').error('Could not remove author');
this.get('toast').error(this.get('i18n').t('submit.error_adding_author'));
this.highlightSuccessOrFailure(contrib.id, this, 'error');
contrib.rollbackAttributes();
});
Expand Down
5 changes: 4 additions & 1 deletion app/components/preprint-navbar-branded.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import Ember from 'ember';
import OSFAgnosticAuthControllerMixin from 'ember-osf/mixins/osf-agnostic-auth-controller';
import Analytics from '../mixins/analytics';
import config from 'ember-get-config';

/**
* @module ember-preprints
* @submodule components
Expand All @@ -22,5 +24,6 @@ export default Ember.Component.extend(OSFAgnosticAuthControllerMixin, Analytics,
session: Ember.inject.service(),
theme: Ember.inject.service(),
tagName: 'nav',
classNames: ['navbar', 'branded-navbar', 'preprint-navbar']
classNames: ['navbar', 'branded-navbar', 'preprint-navbar'],
host: config.OSF.url,
});
39 changes: 33 additions & 6 deletions app/components/supplementary-file-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,32 @@ export default Ember.Component.extend(Analytics, {
this.set('primaryFile', pf);
this.set('selectedFile', this.get('primaryFile'));
this.set('files', [this.get('primaryFile')].concat(this.get('files')));
this.set('indexes', this.get('files').map(each => each.id));
});
}.observes('preprint'),

_chosenFile: Ember.observer('chosenFile', 'indexes', function() {
let fid = this.get('chosenFile');
let index = this.get('indexes').indexOf(fid);
if (fid && index !== -1) {
this.set('selectedFile', this.get('files')[index]);
}
}),
_moveIfNeeded: Ember.observer('selectedFile', function() {
let index = this.get('files').indexOf(this.get('selectedFile'));
if (index < 0) {
return;
}
if (index >= this.get('endIndex') || index < this.get('startIndex')) {
let max = this.get('files').length - 6;
if (index > max) {
this.set('startIndex', max);
this.set('endIndex', this.get('files').length);
} else {
this.set('startIndex', index);
this.set('endIndex', index + 6);
}
}
}),
fileDownloadURL: Ember.computed('selectedFile', function() {
return fileDownloadPath(this.get('selectedFile'), this.get('node'));
}),
Expand Down Expand Up @@ -90,12 +113,17 @@ export default Ember.Component.extend(Analytics, {
action: 'click',
label: 'Preprints - Content - Prev'
});

if (this.get('startIndex') <= 0) return;
let start = this.get('startIndex');
if (start <= 0) return;

this.set('scrollAnim', `to${direction}`);
this.set('endIndex', this.get('endIndex') - 5);
this.set('startIndex', this.get('startIndex') - 5);
if ((start - 5) < 0) {
this.set('startIndex', 0);
this.set('endIndex', 6);
} else {
this.set('startIndex', start - 5);
this.set('endIndex', this.get('endIndex') - 5);
}
},
changeFile(file) {
Ember.get(this, 'metrics')
Expand All @@ -106,7 +134,6 @@ export default Ember.Component.extend(Analytics, {
});

this.set('selectedFile', file);

if (this.attrs.chooseFile) {
this.sendAction('chooseFile', file);
}
Expand Down
10 changes: 7 additions & 3 deletions app/controllers/content.js → app/controllers/content/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import Ember from 'ember';
import loadAll from 'ember-osf/utils/load-relationship';
import config from 'ember-get-config';
import Analytics from '../mixins/analytics';
import Analytics from '../../mixins/analytics';
import permissions from 'ember-osf/const/permissions';
import fileDownloadPath from '../utils/file-download-path';
import fileDownloadPath from '../../utils/file-download-path';

/**
* Takes an object with query parameter name as the key and value, or [value, maxLength] as the values.
Expand Down Expand Up @@ -57,6 +57,9 @@ export default Ember.Controller.extend(Analytics, {
showLicenseText: false,
fileDownloadURL: '',
expandedAbstract: navigator.userAgent.includes('Prerender'),
queryParams: {
chosenFile: 'file'
},
isAdmin: Ember.computed('node', function() {
// True if the current user has admin permissions for the node that contains the preprint
return (this.get('node.currentUserPermissions') || []).includes(permissions.ADMIN);
Expand All @@ -67,7 +70,6 @@ export default Ember.Controller.extend(Analytics, {
text: this.get('node.title'),
via: 'OSFramework'
};

return `https://twitter.com/intent/tweet?${queryStringify(queryParams)}`;
}),
/* TODO: Update this with new Facebook Share Dialog, but an App ID is required
Expand Down Expand Up @@ -105,6 +107,7 @@ export default Ember.Controller.extend(Analytics, {
}),
// The currently selected file (defaults to primary)
activeFile: null,
chosenFile: null,

disciplineReduced: Ember.computed('model.subjects', function() {
// Preprint disciplines are displayed in collapsed form on content page
Expand Down Expand Up @@ -193,6 +196,7 @@ export default Ember.Controller.extend(Analytics, {
},
// Metrics are handled in the component
chooseFile(fileItem) {
this.set('chosenFile', fileItem.get('id'));
this.set('activeFile', fileItem);
},
shareLink(href, category, action, label) {
Expand Down
39 changes: 24 additions & 15 deletions app/controllers/discover.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,23 @@ export default Ember.Controller.extend(Analytics, {
subjectFilter: null,
queryBody: {},
providersPassed: false,

i18n: Ember.inject.service(),

sortByOptions: Ember.computed('i18n.locale', function() {
const i18n = this.get('i18n');
return [i18n.t('discover.relevance'), i18n.t('discover.sort_oldest_newest'), i18n.t('discover.sort_newest_oldest')];
}),

pageNumbers: [],
sortByOptions: ['Relevance', 'Upload date (oldest to newest)', 'Upload date (newest to oldest)'],
sortByOption: '',

treeSubjects: Ember.computed('activeFilters', function() {
return this.get('activeFilters.subjects').slice();
}),
// chosenOption is always the first element in the list
chosenSortByOption: Ember.computed('sortByOptions', function() {
return this.get('sortByOptions')[0];
// chosenSortByOption is going to be the last selected element, or if it's a new page then it's the first in the list
chosenSortByOption: Ember.computed('sortByOption', function() {
return this.get('sortByOption') || this.get('sortByOptions')[0];
}),

showActiveFilters: true, //should always have a provider, don't want to mix osfProviders and non-osf
Expand Down Expand Up @@ -211,7 +219,7 @@ export default Ember.Controller.extend(Analytics, {
result.hyperLinks.push({url: identifier});
} else {
const spl = identifier.split('://');
const [type, uri, ..._] = spl; // jshint ignore:line
const [type, uri] = spl;
result.infoLinks.push({type, uri});
}
});
Expand Down Expand Up @@ -293,12 +301,13 @@ export default Ember.Controller.extend(Analytics, {
});
}

const sortByOption = this.get('chosenSortByOption');
const sort = {};
const i18n = this.get('i18n');
const sortByOption = this.get('sortByOption').toString();

if (sortByOption === 'Upload date (oldest to newest)') {
if (sortByOption === i18n.t('discover.sort_oldest_newest').toString()) {
sort.date_updated = 'asc';
} else if (sortByOption === 'Upload date (newest to oldest)') {
} else if (sortByOption === i18n.t('discover.sort_newest_oldest').toString()) {
sort.date_updated = 'desc';
}

Expand Down Expand Up @@ -330,6 +339,10 @@ export default Ember.Controller.extend(Analytics, {
});
},

_clearQueryString() {
this.set('queryString', '');
},

otherProviders: [],
actions: {
search(val, event) {
Expand Down Expand Up @@ -384,20 +397,16 @@ export default Ember.Controller.extend(Analytics, {
},

sortBySelect(index) {
// Selecting an option just swaps it with whichever option is first
let copy = this.get('sortByOptions').slice(0);
let temp = copy[0];
copy[0] = copy[index];
copy[index] = temp;
this.set('sortByOptions', copy);
// sets the variable for the selected option and reloads the page
this.set('sortByOption', this.get('sortByOptions')[index]);
this.set('page', 1);
this.loadPage();

Ember.get(this, 'metrics')
.trackEvent({
category: 'dropdown',
action: 'select',
label: `Preprints - Discover - Sort by: ${copy[index]}`
label: `Preprints - Discover - Sort by: ${this.get('sortByOptions')[index]}`
});
},

Expand Down
12 changes: 4 additions & 8 deletions app/controllers/submit.js
Original file line number Diff line number Diff line change
Expand Up @@ -932,14 +932,10 @@ export default Ember.Controller.extend(Analytics, BasicsValidations, NodeActions
return model.save()
.then(() => node.save())
.then(() => {
if (this.get('editMode')) {
window.location = window.location.pathname; //TODO Ember way to do this? In edit mode, already in content route.
} else {
this.transitionToRoute(
`${this.get('theme.isProvider') ? 'provider.' : ''}content`,
model
);
}
this.transitionToRoute(
`${this.get('theme.isSubRoute') ? 'provider.' : ''}content`,
model
);
})
.catch(() => {
this.toggleProperty('shareButtonDisabled');
Expand Down
25 changes: 25 additions & 0 deletions app/helpers/route-prefix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import Ember from 'ember';

/**
* @module ember-preprints
* @submodule helpers
*/

/**
* Needed for link-to for branded routing to get the correct route path
*
* @class route-prefix
*/
export default Ember.Helper.extend({
theme: Ember.inject.service(),

onSubRouteChange: Ember.observer('theme.isSubRoute', function() {
this.recompute();
}),

compute(params) {
const route = params.join('');

return this.get('theme.isSubRoute') ? `provider.${route}` : route;
}
});
Loading

0 comments on commit bb26fba

Please sign in to comment.