Skip to content

Commit bb26fba

Browse files
committed
Merge branch 'release/0.107.0'
2 parents ee63389 + 0259af4 commit bb26fba

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1638
-1193
lines changed

.ember-cli

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@
55

66
Setting `disableAnalytics` to true will prevent any data from being sent.
77
*/
8-
"disableAnalytics": true
8+
"disableAnalytics": true,
9+
"port": 4200,
10+
11+
"liveReloadPort": 41953 /* Needed for the TouchBar on the new MacBook Pros */
912
}

.eslintignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
coverage
2+
dist
3+
docs
4+
tmp

.eslintrc.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module.exports = {
2+
root: true,
3+
parserOptions: {
4+
ecmaVersion: 6,
5+
sourceType: 'module'
6+
},
7+
extends: 'eslint:recommended',
8+
env: {
9+
browser: true,
10+
es6: true
11+
},
12+
globals: {
13+
MathJax: true
14+
},
15+
rules: {}
16+
};

.jshintrc

Lines changed: 0 additions & 33 deletions
This file was deleted.

README.md

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

38+
### Provider Domains
39+
1. Run `sudo ./scripts/add-domains.js`. This will add the domains to your `/etc/hosts`.
40+
2. Visit your app at one of the provider domains with `https://local.<domain>:4200` (e.g. `http://local.socarxiv.org:4200`)
41+
3842
If you encounter problems, make sure that your version of ember-osf is up to date. If login fails, try logging in from
3943
any other OSF page, then returning to the preprints app.
4044

app/components/error-page.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import Ember from 'ember';
2+
import Analytics from '../mixins/analytics';
3+
4+
export default Ember.Component.extend(Analytics, {
5+
theme: Ember.inject.service(),
6+
classNames: ['preprint-error-page'],
7+
label: '',
8+
translationKey: '',
9+
supportEmail: Ember.computed('theme.isProvider', 'theme.provider.emailSupport', function() {
10+
return this.get('theme.isProvider') ? this.get('theme.provider.emailSupport') : 'support@osf.io';
11+
})
12+
});

app/components/preprint-form-authors.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import Analytics from '../mixins/analytics';
3636
* @class preprint-form-authors
3737
*/
3838
export default CpPanelBodyComponent.extend(Analytics, {
39+
i18n: Ember.inject.service(),
3940
valid: Ember.computed.alias('newContributorId'),
4041
authorModification: false,
4142
currentPage: 1,
@@ -94,9 +95,10 @@ export default CpPanelBodyComponent.extend(Analytics, {
9495
this.attrs.addContributor(user.id, 'write', true, this.get('sendEmail'), undefined, undefined, true).then((res) => {
9596
this.toggleAuthorModification();
9697
this.get('contributors').pushObject(res);
98+
this.get('toast').success(this.get('i18n').t('submit.preprint_author_added'));
9799
this.highlightSuccessOrFailure(res.id, this, 'success');
98100
}, () => {
99-
this.get('toast').error('Could not add contributor.');
101+
this.get('toast').error(this.get('i18n').t('submit.error_adding_author'));
100102
this.highlightSuccessOrFailure(user.id, this, 'error');
101103
user.rollbackAttributes();
102104
});
@@ -142,12 +144,13 @@ export default CpPanelBodyComponent.extend(Analytics, {
142144
this.set('addState', 'searchView');
143145
this.set('fullName', '');
144146
this.set('email', '');
147+
this.get('toast').success(this.get('i18n').t('submit.preprint_unregistered_author_added'));
145148
this.highlightSuccessOrFailure(contributor.id, this, 'success');
146149
}, (error) => {
147150
if (error.errors[0] && error.errors[0].detail && error.errors[0].detail.indexOf('is already a contributor') > -1) {
148151
this.get('toast').error(error.errors[0].detail);
149152
} else {
150-
this.get('toast').error('Could not add unregistered contributor.');
153+
this.get('toast').error(this.get('i18n').t('submit.error_adding_unregistered_author'));
151154
}
152155
this.highlightSuccessOrFailure('add-unregistered-contributor-form', this, 'error');
153156
});
@@ -178,8 +181,9 @@ export default CpPanelBodyComponent.extend(Analytics, {
178181
this.toggleAuthorModification();
179182
this.removedSelfAsAdmin(contrib, contrib.get('permission'));
180183
this.get('contributors').removeObject(contrib);
184+
this.get('toast').success(this.get('i18n').t('submit.preprint_author_removed'));
181185
}, () => {
182-
this.get('toast').error('Could not remove author');
186+
this.get('toast').error(this.get('i18n').t('submit.error_adding_author'));
183187
this.highlightSuccessOrFailure(contrib.id, this, 'error');
184188
contrib.rollbackAttributes();
185189
});

app/components/preprint-navbar-branded.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import Ember from 'ember';
22
import OSFAgnosticAuthControllerMixin from 'ember-osf/mixins/osf-agnostic-auth-controller';
33
import Analytics from '../mixins/analytics';
4+
import config from 'ember-get-config';
5+
46
/**
57
* @module ember-preprints
68
* @submodule components
@@ -22,5 +24,6 @@ export default Ember.Component.extend(OSFAgnosticAuthControllerMixin, Analytics,
2224
session: Ember.inject.service(),
2325
theme: Ember.inject.service(),
2426
tagName: 'nav',
25-
classNames: ['navbar', 'branded-navbar', 'preprint-navbar']
27+
classNames: ['navbar', 'branded-navbar', 'preprint-navbar'],
28+
host: config.OSF.url,
2629
});

app/components/supplementary-file-browser.js

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,32 @@ export default Ember.Component.extend(Analytics, {
5656
this.set('primaryFile', pf);
5757
this.set('selectedFile', this.get('primaryFile'));
5858
this.set('files', [this.get('primaryFile')].concat(this.get('files')));
59+
this.set('indexes', this.get('files').map(each => each.id));
5960
});
6061
}.observes('preprint'),
61-
62+
_chosenFile: Ember.observer('chosenFile', 'indexes', function() {
63+
let fid = this.get('chosenFile');
64+
let index = this.get('indexes').indexOf(fid);
65+
if (fid && index !== -1) {
66+
this.set('selectedFile', this.get('files')[index]);
67+
}
68+
}),
69+
_moveIfNeeded: Ember.observer('selectedFile', function() {
70+
let index = this.get('files').indexOf(this.get('selectedFile'));
71+
if (index < 0) {
72+
return;
73+
}
74+
if (index >= this.get('endIndex') || index < this.get('startIndex')) {
75+
let max = this.get('files').length - 6;
76+
if (index > max) {
77+
this.set('startIndex', max);
78+
this.set('endIndex', this.get('files').length);
79+
} else {
80+
this.set('startIndex', index);
81+
this.set('endIndex', index + 6);
82+
}
83+
}
84+
}),
6285
fileDownloadURL: Ember.computed('selectedFile', function() {
6386
return fileDownloadPath(this.get('selectedFile'), this.get('node'));
6487
}),
@@ -90,12 +113,17 @@ export default Ember.Component.extend(Analytics, {
90113
action: 'click',
91114
label: 'Preprints - Content - Prev'
92115
});
93-
94-
if (this.get('startIndex') <= 0) return;
116+
let start = this.get('startIndex');
117+
if (start <= 0) return;
95118

96119
this.set('scrollAnim', `to${direction}`);
97-
this.set('endIndex', this.get('endIndex') - 5);
98-
this.set('startIndex', this.get('startIndex') - 5);
120+
if ((start - 5) < 0) {
121+
this.set('startIndex', 0);
122+
this.set('endIndex', 6);
123+
} else {
124+
this.set('startIndex', start - 5);
125+
this.set('endIndex', this.get('endIndex') - 5);
126+
}
99127
},
100128
changeFile(file) {
101129
Ember.get(this, 'metrics')
@@ -106,7 +134,6 @@ export default Ember.Component.extend(Analytics, {
106134
});
107135

108136
this.set('selectedFile', file);
109-
110137
if (this.attrs.chooseFile) {
111138
this.sendAction('chooseFile', file);
112139
}

app/controllers/content.js renamed to app/controllers/content/index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import Ember from 'ember';
22
import loadAll from 'ember-osf/utils/load-relationship';
33
import config from 'ember-get-config';
4-
import Analytics from '../mixins/analytics';
4+
import Analytics from '../../mixins/analytics';
55
import permissions from 'ember-osf/const/permissions';
6-
import fileDownloadPath from '../utils/file-download-path';
6+
import fileDownloadPath from '../../utils/file-download-path';
77

88
/**
99
* Takes an object with query parameter name as the key and value, or [value, maxLength] as the values.
@@ -57,6 +57,9 @@ export default Ember.Controller.extend(Analytics, {
5757
showLicenseText: false,
5858
fileDownloadURL: '',
5959
expandedAbstract: navigator.userAgent.includes('Prerender'),
60+
queryParams: {
61+
chosenFile: 'file'
62+
},
6063
isAdmin: Ember.computed('node', function() {
6164
// True if the current user has admin permissions for the node that contains the preprint
6265
return (this.get('node.currentUserPermissions') || []).includes(permissions.ADMIN);
@@ -67,7 +70,6 @@ export default Ember.Controller.extend(Analytics, {
6770
text: this.get('node.title'),
6871
via: 'OSFramework'
6972
};
70-
7173
return `https://twitter.com/intent/tweet?${queryStringify(queryParams)}`;
7274
}),
7375
/* TODO: Update this with new Facebook Share Dialog, but an App ID is required
@@ -105,6 +107,7 @@ export default Ember.Controller.extend(Analytics, {
105107
}),
106108
// The currently selected file (defaults to primary)
107109
activeFile: null,
110+
chosenFile: null,
108111

109112
disciplineReduced: Ember.computed('model.subjects', function() {
110113
// Preprint disciplines are displayed in collapsed form on content page
@@ -193,6 +196,7 @@ export default Ember.Controller.extend(Analytics, {
193196
},
194197
// Metrics are handled in the component
195198
chooseFile(fileItem) {
199+
this.set('chosenFile', fileItem.get('id'));
196200
this.set('activeFile', fileItem);
197201
},
198202
shareLink(href, category, action, label) {

app/controllers/discover.js

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,23 @@ export default Ember.Controller.extend(Analytics, {
5050
subjectFilter: null,
5151
queryBody: {},
5252
providersPassed: false,
53+
54+
i18n: Ember.inject.service(),
55+
56+
sortByOptions: Ember.computed('i18n.locale', function() {
57+
const i18n = this.get('i18n');
58+
return [i18n.t('discover.relevance'), i18n.t('discover.sort_oldest_newest'), i18n.t('discover.sort_newest_oldest')];
59+
}),
60+
5361
pageNumbers: [],
54-
sortByOptions: ['Relevance', 'Upload date (oldest to newest)', 'Upload date (newest to oldest)'],
62+
sortByOption: '',
5563

5664
treeSubjects: Ember.computed('activeFilters', function() {
5765
return this.get('activeFilters.subjects').slice();
5866
}),
59-
// chosenOption is always the first element in the list
60-
chosenSortByOption: Ember.computed('sortByOptions', function() {
61-
return this.get('sortByOptions')[0];
67+
// chosenSortByOption is going to be the last selected element, or if it's a new page then it's the first in the list
68+
chosenSortByOption: Ember.computed('sortByOption', function() {
69+
return this.get('sortByOption') || this.get('sortByOptions')[0];
6270
}),
6371

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

296-
const sortByOption = this.get('chosenSortByOption');
297304
const sort = {};
305+
const i18n = this.get('i18n');
306+
const sortByOption = this.get('sortByOption').toString();
298307

299-
if (sortByOption === 'Upload date (oldest to newest)') {
308+
if (sortByOption === i18n.t('discover.sort_oldest_newest').toString()) {
300309
sort.date_updated = 'asc';
301-
} else if (sortByOption === 'Upload date (newest to oldest)') {
310+
} else if (sortByOption === i18n.t('discover.sort_newest_oldest').toString()) {
302311
sort.date_updated = 'desc';
303312
}
304313

@@ -330,6 +339,10 @@ export default Ember.Controller.extend(Analytics, {
330339
});
331340
},
332341

342+
_clearQueryString() {
343+
this.set('queryString', '');
344+
},
345+
333346
otherProviders: [],
334347
actions: {
335348
search(val, event) {
@@ -384,20 +397,16 @@ export default Ember.Controller.extend(Analytics, {
384397
},
385398

386399
sortBySelect(index) {
387-
// Selecting an option just swaps it with whichever option is first
388-
let copy = this.get('sortByOptions').slice(0);
389-
let temp = copy[0];
390-
copy[0] = copy[index];
391-
copy[index] = temp;
392-
this.set('sortByOptions', copy);
400+
// sets the variable for the selected option and reloads the page
401+
this.set('sortByOption', this.get('sortByOptions')[index]);
393402
this.set('page', 1);
394403
this.loadPage();
395404

396405
Ember.get(this, 'metrics')
397406
.trackEvent({
398407
category: 'dropdown',
399408
action: 'select',
400-
label: `Preprints - Discover - Sort by: ${copy[index]}`
409+
label: `Preprints - Discover - Sort by: ${this.get('sortByOptions')[index]}`
401410
});
402411
},
403412

app/controllers/submit.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -932,14 +932,10 @@ export default Ember.Controller.extend(Analytics, BasicsValidations, NodeActions
932932
return model.save()
933933
.then(() => node.save())
934934
.then(() => {
935-
if (this.get('editMode')) {
936-
window.location = window.location.pathname; //TODO Ember way to do this? In edit mode, already in content route.
937-
} else {
938-
this.transitionToRoute(
939-
`${this.get('theme.isProvider') ? 'provider.' : ''}content`,
940-
model
941-
);
942-
}
935+
this.transitionToRoute(
936+
`${this.get('theme.isSubRoute') ? 'provider.' : ''}content`,
937+
model
938+
);
943939
})
944940
.catch(() => {
945941
this.toggleProperty('shareButtonDisabled');

app/helpers/route-prefix.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import Ember from 'ember';
2+
3+
/**
4+
* @module ember-preprints
5+
* @submodule helpers
6+
*/
7+
8+
/**
9+
* Needed for link-to for branded routing to get the correct route path
10+
*
11+
* @class route-prefix
12+
*/
13+
export default Ember.Helper.extend({
14+
theme: Ember.inject.service(),
15+
16+
onSubRouteChange: Ember.observer('theme.isSubRoute', function() {
17+
this.recompute();
18+
}),
19+
20+
compute(params) {
21+
const route = params.join('');
22+
23+
return this.get('theme.isSubRoute') ? `provider.${route}` : route;
24+
}
25+
});

0 commit comments

Comments
 (0)