Skip to content

Commit c962b82

Browse files
committed
Merge branch 'release/19.0.0'
2 parents 4f01be7 + 16088ea commit c962b82

File tree

394 files changed

+7367
-1670
lines changed

Some content is hidden

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

394 files changed

+7367
-1670
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ module.exports = {
7171
files: ['tests/**/*'],
7272
rules: {
7373
'no-await-in-loop': 'off',
74+
'ember/avoid-leaking-state-in-components': 'off',
7475
},
7576
},
7677
],

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*.svg -diff linguist-generated=true
2+
*.png -diff linguist-generated=true
3+
*.jpg -diff linguist-generated=true

.mergify.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# see: https://doc.mergify.io/configuration.html
2+
3+
pull_request_rules:
4+
- name: automatic strict merge on CI success and review
5+
conditions:
6+
- base~=^develop$|^release/ # only for PRs targeting develop or release branches
7+
- status-success=continuous-integration/travis-ci/pr # must pass travis
8+
- "#approved-reviews-by>0" # at least one approval from someone with write permission
9+
- "#changes-requested-reviews-by=0" # no changes requested
10+
- label!=no merge # use this label to prevent automatic merge
11+
- -title~=\b[Ww][Ii][Pp]\b
12+
actions:
13+
merge:
14+
method: merge # merge with a merge commit
15+
strict: smart # make sure PR is up-to-date before merging (but queue updates)

.stylelintrc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ rules:
66
max-nesting-depth: 2
77
order/properties-alphabetical-order: null
88
scss/selector-no-redundant-nesting-selector: null
9+
scss/percent-placeholder-pattern: null
910
selector-class-pattern: null
1011
property-no-unknown:
1112
- true

.travis.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@ cache:
1616
jobs:
1717
include:
1818
- stage: "test"
19+
if: |
20+
branch ~= /^develop$|^master$|^\d+\.\d+\.\d+$|^release\/.+$/ OR \
21+
type = pull_request OR \
22+
env(RESTRICT_PUSH_BUILDS) != true
1923
addons:
2024
chrome: stable
21-
firefox: latest
2225
before_install:
2326
- curl -o- -L https://yarnpkg.com/install.sh | bash
2427
- export PATH=$HOME/.yarn/bin:$PATH
@@ -37,7 +40,7 @@ jobs:
3740
if: |
3841
branch = develop AND \
3942
type != pull_request AND \
40-
fork = false
43+
repo = CenterForOpenScience/ember-osf-web
4144
before_install:
4245
- curl -o- -L https://yarnpkg.com/install.sh | bash
4346
- export PATH=$HOME/.yarn/bin:$PATH

CHANGELOG.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,72 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## [19.0.0] - 2019-01-03
8+
### Added
9+
- Addons:
10+
- `ember-onbeforeunload` - Handle warnings if we have unsaved changes on a page
11+
- Components:
12+
- `new-project-navigation-modal` - For navigating away to nodes. Or not.
13+
- Handbook:
14+
- `new-project-modal` component
15+
- `new-project-navigation-modal` component
16+
- Models:
17+
- `user-email`
18+
- Routes:
19+
- `settings.profile` - redirects to `settings.profile.name`
20+
- `settings.profile.education`
21+
- `settings.profile.employment`
22+
- `settings.profile.name` - Adds ability to change your name and name parts (with citation preview)
23+
- `settings.profile.social`
24+
- Tests:
25+
- Integration:
26+
- `settings.profile.name.-components.citation-preview`
27+
- `new-project-navigation-modal` - component integration test
28+
- Acceptance:
29+
- `settings.profile.name`
30+
- `guid-user/quickfiles` - acceptance tests around landing on the page and mostly move to project
31+
- Add percy everywhere in the main app
32+
- Helpers:
33+
- `require-auth` - Mocks currentUser service to verify that routes that require auth redirect if unauthenticated
34+
- Types:
35+
- `ember-power-select/test-support` - types for useful functions
36+
- Travis
37+
- Remove Firefox Testing
38+
39+
### Changed
40+
- Addons:
41+
42+
- Components:
43+
- `node-navbar` - Choose links to display with the same logic as legacy
44+
- `validated-model-form` - Add an optional hook for onWillDestroy
45+
- `sign-up-form` - accept `campaign` as an optional argument and set on user-registration model
46+
- Handbook:
47+
- `validated-model-form` - Show how onWillDestroy works and use ember-onbeforeunload
48+
- Models:
49+
- `node`
50+
- added `wikiEnabled` boolean attribute
51+
- added `userHasReadPermission` computed property
52+
- renamed `currentUserCanEdit` computed property to `userHasWritePermission`
53+
- renamed `currentUserIsAdmin` computed property to `userHasAdminPermission`
54+
- `user`
55+
- added validations for name fields
56+
- `provider` - made partial assets acceptable
57+
- `preprint-provider` - added `documentType` computed property for preprint word lookup
58+
- `user-registration` - added `campaign` property
59+
- Routes:
60+
- `settings` - redirects to `settings.profile.name`
61+
- `register` - add branding for registries and preprint providers
62+
- Tests:
63+
- improved integration tests for `node-navbar` component
64+
- Acceptance:
65+
- `register` - acceptance tests for the sign up page
66+
- Adapters:
67+
- Added `parentRelationship` property to `osf-adapter`. Allows creating records at nested endpoints.
68+
- Routes:
69+
- Add email verification modal to application template
70+
- Misc:
71+
- Upgraded to `osf-style` 1.8.0
72+
773
## [18.2.2] - 2018-12-18
874
### Added:
975
- Flags:
@@ -44,6 +110,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
44110
- Engines:
45111
- `registries` - page resetting and scrolling fixes
46112

113+
### Changed
114+
- Components:
115+
- `file-browser` - replaced project navigation modal with `new-project-navigation-modal` component
116+
- `new-project-modal` - Made it smarter and more reusable
117+
- `project-selector` - replaced project creation modal with `new-project-modal` component
118+
- Pages:
119+
- `dashboard` - replaced project creation modal with `new-project-modal` component
120+
- Tests:
121+
- `dashboard` - acceptance tests related to project creation workflow
122+
47123
## [18.1.0] - 2018-10-30
48124
### Added
49125
- Components:
@@ -61,6 +137,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
61137
- `settings.applications` - list of developer apps
62138
- `settings.applications.edit`
63139
- `settings.applications.create`
140+
- Decorators:
141+
- `@layout(template, styles)` in `ember-osf-web/decorators/component`
64142

65143
### Changed
66144
- Components:
@@ -75,6 +153,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
75153
- `root` factory now adds all feature flags, not just route flags
76154
- `user` factory has 'withFiles' trait so non-current users can have files easily
77155
- `user` serializer has default_region relationship (hardcoded to us)
156+
- Decorators:
157+
- `@requiredAction` moved to `ember-osf-web/decorators/component`
158+
- Blueprints:
159+
- `component` - use `@layout`, don't add `styles.scss` or `@localClassNames`
78160

79161
### Removed
80162
- Flags:

app/adapters/osf-adapter.ts

Lines changed: 78 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { service } from '@ember-decorators/service';
2+
import { assert } from '@ember/debug';
23
import { underscore } from '@ember/string';
34
import DS from 'ember-data';
45
import config from 'ember-get-config';
@@ -39,9 +40,29 @@ enum RequestType {
3940
* @extends DS.JSONAPIAdapter
4041
* @uses GenericDataAdapterMixin
4142
*/
42-
export default class OsfAdapter extends JSONAPIAdapter.extend({
43-
host,
44-
namespace,
43+
export default class OsfAdapter extends JSONAPIAdapter {
44+
@service session!: Session;
45+
@service currentUser!: CurrentUser;
46+
47+
host = host;
48+
namespace = namespace;
49+
50+
/**
51+
* When an object lives "under" another in the API, set `parentRelationship` to the name of
52+
* the belongsTo that points to the parent object. Requests for creating new children will
53+
* go to the nested route for that relationship.
54+
*
55+
* e.g. If the contributor adapter has `parentRelationship = 'node'`, creating a new contributor
56+
* for node xyz will POST to /v2/nodes/xyz/contributors/
57+
*
58+
* TODO: `OsfAdapter<M extends OsfModel>`, `parentRelationship: RelationshipsFor<M> | null`
59+
*/
60+
parentRelationship: string | null = null;
61+
62+
get headers() {
63+
// Not a computed; evaluate every time in case something changes
64+
return this.currentUser.ajaxHeaders();
65+
}
4566

4667
/**
4768
* Overrides buildQuery method - Allows users to embed resources with findRecord
@@ -51,11 +72,11 @@ export default class OsfAdapter extends JSONAPIAdapter.extend({
5172
*
5273
* @method buildQuery
5374
*/
54-
buildQuery(this: OsfAdapter, snapshot: DS.Snapshot): object {
75+
buildQuery(snapshot: DS.Snapshot): object {
5576
const { query: adapterOptionsQuery = {} } = (snapshot.adapterOptions || {}) as AdapterOptions;
5677

5778
const query: { include?: any, embed?: any } = {
58-
...this._super(snapshot),
79+
...super.buildQuery(snapshot),
5980
...adapterOptionsQuery,
6081
};
6182

@@ -64,32 +85,21 @@ export default class OsfAdapter extends JSONAPIAdapter.extend({
6485
embed: query.include,
6586
include: undefined,
6687
};
67-
},
88+
}
6889

6990
buildURL(
70-
this: OsfAdapter,
71-
modelName: string,
91+
modelName: string | undefined,
7292
id: string | null,
7393
snapshot: DS.Snapshot | null,
7494
requestType: string,
95+
query?: {},
7596
): string {
76-
let url: string = this._super(modelName, id, snapshot, requestType);
97+
let url: string = super.buildURL(modelName, id, snapshot, requestType, query);
7798

7899
if (snapshot) {
79-
const { record, adapterOptions } = snapshot;
80-
const opts: AdapterOptions = adapterOptions || {};
81-
if (requestType === 'deleteRecord') {
82-
if (record && record.get('links.delete')) {
83-
url = record.get('links.delete');
84-
} else if (record && record.get('links.self')) {
85-
url = record.get('links.self');
86-
}
87-
} else if (requestType === 'updateRecord' || requestType === 'findRecord') {
88-
if (record && record.get('links.self')) {
89-
url = record.get('links.self');
90-
}
91-
} else if (opts.url) {
92-
url = opts.url; // eslint-disable-line prefer-destructuring
100+
const { adapterOptions }: { adapterOptions?: { url?: string } } = snapshot;
101+
if (adapterOptions && adapterOptions.url) {
102+
url = adapterOptions.url; // eslint-disable-line prefer-destructuring
93103
}
94104
}
95105

@@ -98,11 +108,51 @@ export default class OsfAdapter extends JSONAPIAdapter.extend({
98108
if (url.lastIndexOf('/') !== url.length - 1) {
99109
url += '/';
100110
}
111+
101112
return url;
102-
},
113+
}
114+
115+
urlForFindRecord(id: string, modelName: string, snapshot: DS.Snapshot): string {
116+
if (snapshot && snapshot.record && snapshot.record.links && snapshot.record.links.self) {
117+
return snapshot.record.links.self;
118+
}
119+
return super.urlForFindRecord(id, modelName, snapshot);
120+
}
121+
122+
urlForCreateRecord(modelName: string, snapshot: DS.Snapshot): string {
123+
const { parentRelationship } = this;
124+
if (!parentRelationship) {
125+
return super.urlForCreateRecord(modelName, snapshot);
126+
}
103127

104-
ajaxOptions(this: OsfAdapter, url: string, type: RequestType, options?: { isBulk?: boolean }): object {
105-
const hash = this._super(url, type, options);
128+
const parentObj = snapshot.record.belongsTo(parentRelationship).value();
129+
const inverseRelation: string = snapshot.record.inverseFor(parentRelationship).name;
130+
131+
assert('To create a nested object, the parent must already be loaded.', parentObj);
132+
133+
const url = parentObj.get(`links.relationships.${inverseRelation}.links.related.href`);
134+
135+
assert(`Couldn't find create link for nested ${modelName}`, url);
136+
137+
return url;
138+
}
139+
140+
urlForUpdateRecord(id: string, modelName: string, snapshot: DS.Snapshot): string {
141+
const { links } = snapshot.record;
142+
if (links && links.self) {
143+
return links.self;
144+
}
145+
return super.urlForUpdateRecord(id, modelName, snapshot);
146+
}
147+
148+
urlForDeleteRecord(id: string, modelName: string, snapshot: DS.Snapshot): string {
149+
const { links } = snapshot.record;
150+
const url = links.delete || links.self;
151+
return url || super.urlForDeleteRecord(id, modelName, snapshot);
152+
}
153+
154+
ajaxOptions(url: string, type: RequestType, options?: { isBulk?: boolean }): object {
155+
const hash: any = super.ajaxOptions(url, type, options);
106156

107157
hash.xhrFields = {
108158
withCredentials: true,
@@ -113,7 +163,7 @@ export default class OsfAdapter extends JSONAPIAdapter.extend({
113163
}
114164

115165
return hash;
116-
},
166+
}
117167

118168
buildRelationshipURL(snapshot: DS.Snapshot, relationship: string): string {
119169
const links = !!relationship && snapshot.record.get(`relationshipLinks.${underscore(relationship)}.links`);
@@ -123,19 +173,11 @@ export default class OsfAdapter extends JSONAPIAdapter.extend({
123173
}
124174

125175
return '';
126-
},
176+
}
127177

128178
pathForType(modelName: string): string {
129179
const underscored: string = underscore(modelName);
130180
return pluralize(underscored);
131-
},
132-
}) {
133-
@service session!: Session;
134-
@service currentUser!: CurrentUser;
135-
136-
get headers() {
137-
// Not a computed; evaluate every time in case something changes
138-
return this.currentUser.ajaxHeaders();
139181
}
140182

141183
handleResponse(

app/adapters/user-email.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import OsfAdapter from './osf-adapter';
2+
3+
export default class UserEmailAdapter extends OsfAdapter {
4+
parentRelationship = 'user';
5+
}
6+
7+
declare module 'ember-data' {
8+
interface AdapterRegistry {
9+
'user-email': UserEmailAdapter;
10+
}
11+
}

app/app.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ const App = Application.extend({
3333
dependencies: {
3434
services: [
3535
'analytics',
36+
'current-user',
37+
'features',
3638
'i18n',
3739
'router',
3840
'store',
@@ -49,22 +51,25 @@ const App = Application.extend({
4951
'features',
5052
'head-data',
5153
'i18n',
54+
'media',
5255
'page-title-list',
56+
'ready',
5357
'router',
5458
'session',
5559
'status-messages',
5660
'store',
5761
],
5862
externalRoutes: {
59-
registration: 'guid-registration',
63+
'guid-registration': 'guid-registration',
64+
'guid-registration.analytics': 'guid-registration.analytics',
65+
'guid-registration.forks': 'guid-registration.forks',
6066
},
6167
},
6268
},
6369
analyticsPage: {
6470
dependencies: {
6571
services: [
6672
'i18n',
67-
'route-context',
6873
'cookies',
6974
'store',
7075
'analytics',

0 commit comments

Comments
 (0)