Skip to content

Commit a23fc71

Browse files
committed
Merge branch 'release/0.7.0'
2 parents 4986efc + ee546b4 commit a23fc71

File tree

277 files changed

+3110
-1654
lines changed

Some content is hidden

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

277 files changed

+3110
-1654
lines changed

CHANGELOG.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,45 @@ 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+
## [0.7.0] - 2018-08-07
8+
### Added
9+
- Models:
10+
- `region` - for storage i18n
11+
- Components:
12+
- `cookie-banner` - notify logged-out users the site uses cookies
13+
- Feature Flags:
14+
- `storage_i18n` - enable region selector on project creation
15+
- Assets:
16+
- images for home page
17+
- images for dashboard
18+
- Third-party Packages:
19+
- `qunit-dom` - Better test assetions (especially for hidden things)
20+
- `ember-test-selectors` - Find things in your dom without messing everything up
21+
- Tests:
22+
- `dashboard` - more application tests
23+
- Misc:
24+
- `keen` metrics adapter configured for anonymized IP addresses
25+
- CSRF support on all ajax requests
26+
- DX:
27+
- `ember-cli-mirage` factories for users, nodes, contributors, and institutions
28+
- resources to the handbook
29+
30+
### Changed
31+
- Models:
32+
- `node` - add `region` relationship
33+
- `user` - add `defaultRegion` relationship
34+
- Components:
35+
- `maintenance-banner` - set cookie on dismiss and check cookie before showing
36+
- `osf-footer` - remove Google Plus logo/link
37+
- Services:
38+
- `analytics` - support multiple metrics adapters
39+
- Routes:
40+
- `guid-node` - add `join-osf-banner`
41+
- `home` - replace testimonial and use local assets
42+
- `dashboard` - use local assets
43+
- DX:
44+
- enable sourcemap generation by default
45+
746
## [0.6.1] - 2018-07-31
847
### Changed
948
- local storage key used for `ember-simple-auth`
@@ -35,6 +74,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
3574
- Dashboard filtering
3675
- User quick files page (more event tracking)
3776
- Quick files detail page (event tracking)
77+
- Mirage/Tests:
78+
- Factories (and supporting code) for Mirage and the Dashboard
79+
- Dashboard application test
3880

3981
### Changed
4082
- Components:

app/adapters/osf-adapter.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ import config from 'ember-get-config';
55
import { pluralize } from 'ember-inflector';
66
import Session from 'ember-simple-auth/services/session';
77

8+
import CurrentUser from 'ember-osf-web/services/current-user';
9+
810
const { JSONAPIAdapter } = DS;
911
const {
1012
OSF: {
11-
apiHeaders,
1213
apiUrl: host,
1314
apiNamespace: namespace,
1415
},
@@ -41,7 +42,6 @@ enum RequestType {
4142
export default class OsfAdapter extends JSONAPIAdapter.extend({
4243
host,
4344
namespace,
44-
headers: apiHeaders,
4545

4646
/**
4747
* Overrides buildQuery method - Allows users to embed resources with findRecord
@@ -129,6 +129,12 @@ export default class OsfAdapter extends JSONAPIAdapter.extend({
129129
},
130130
}) {
131131
@service session!: Session;
132+
@service currentUser!: CurrentUser;
133+
134+
get headers() {
135+
// Not a computed; evaluate every time in case something changes
136+
return this.currentUser.ajaxHeaders();
137+
}
132138

133139
handleResponse(
134140
status: number,

app/adapters/region.ts

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

app/application/template.hbs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212
{{outlet}}
1313
</div>
1414
{{osf-footer}}
15+
{{cookie-banner}}
1516
{{osf-mode-footer}}
1617
</div>

app/authenticators/osf-cookie.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import Base from 'ember-simple-auth/authenticators/base';
77
import Session from 'ember-simple-auth/services/session';
88

99
import { NotLoggedIn } from 'ember-osf-web/errors';
10-
import authenticatedAJAX from 'ember-osf-web/utils/ajax-helpers';
10+
import CurrentUser from 'ember-osf-web/services/current-user';
1111

1212
const {
1313
OSF: {
@@ -30,13 +30,14 @@ export default class OsfCookie extends Base {
3030
@service features!: Features;
3131
@service session!: Session;
3232
@service store!: DS.Store;
33+
@service currentUser!: CurrentUser;
3334

3435
/**
3536
* @method authenticate
3637
* @return {Promise}
3738
*/
3839
async authenticate(): Promise<object> {
39-
const res: ApiRootResponse = await authenticatedAJAX({
40+
const res: ApiRootResponse = await this.currentUser.authenticatedAJAX({
4041
url: `${apiUrl}/${apiNamespace}/`,
4142
});
4243

@@ -69,7 +70,7 @@ export default class OsfCookie extends Base {
6970
}
7071

7172
async _checkApiVersion() {
72-
const res: ApiRootResponse = await authenticatedAJAX(
73+
const res: ApiRootResponse = await this.currentUser.authenticatedAJAX(
7374
{
7475
url: `${apiUrl}/${apiNamespace}/`,
7576
data: {

app/dashboard/controller.ts

Lines changed: 44 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,27 @@
11
import { action, computed } from '@ember-decorators/object';
2-
import { alias, oneWay, or } from '@ember-decorators/object/computed';
2+
import { alias, or } from '@ember-decorators/object/computed';
33
import { service } from '@ember-decorators/service';
44
import { A } from '@ember/array';
55
import Controller from '@ember/controller';
6-
import { task, timeout } from 'ember-concurrency';
6+
import { all, task, timeout } from 'ember-concurrency';
77
import DS from 'ember-data';
8+
import config from 'ember-get-config';
9+
810
import Institution from 'ember-osf-web/models/institution';
911
import Node from 'ember-osf-web/models/node';
12+
import Region from 'ember-osf-web/models/region';
1013
import User from 'ember-osf-web/models/user';
1114
import Analytics from 'ember-osf-web/services/analytics';
1215
import CurrentUser from 'ember-osf-web/services/current-user';
1316

17+
// TODO pull these from the database
18+
const {
19+
dashboard: {
20+
noteworthyNode,
21+
popularNode,
22+
},
23+
} = config;
24+
1425
interface QueryHasManyResponse<T> extends Array<T> {
1526
meta?: {
1627
total?: number;
@@ -36,13 +47,24 @@ export default class Dashboard extends Controller {
3647
'failedLoading-noteworthy': boolean = false;
3748
'failedLoading-popular': boolean = false;
3849

39-
institutions = A([]);
50+
institutions: Institution[] = A([]);
4051
nodes: QueryHasManyResponse<Node> = A([]);
4152
noteworthy = A([]);
4253
popular = A([]);
4354

44-
getInstitutions = task(function *(this: Dashboard) {
45-
this.set('institutions', yield this.get('store').findAll('institution'));
55+
setupTask = task(function *(this: Dashboard) {
56+
this.set('filter', null);
57+
58+
const institutions = this.store.findAll('institution');
59+
60+
yield all([
61+
institutions,
62+
this.get('findNodes').perform(),
63+
this.get('getPopularAndNoteworthy').perform(popularNode, 'popular'),
64+
this.get('getPopularAndNoteworthy').perform(noteworthyNode, 'noteworthy'),
65+
]);
66+
67+
this.set('institutions', institutions.toArray());
4668
}).restartable();
4769

4870
filterNodes = task(function *(this: Dashboard, filter: string) {
@@ -96,30 +118,39 @@ export default class Dashboard extends Controller {
96118
return yield user.queryHasMany('nodes', { filter: { title } });
97119
}).restartable();
98120

99-
createNode = task(function *(this: Dashboard, title: string, description: string, templateFrom: Node) {
121+
createNode = task(function *(
122+
this: Dashboard,
123+
title: string,
124+
description: string,
125+
institutions: Institution[],
126+
templateFrom?: Node,
127+
storageRegion?: Region,
128+
) {
100129
if (!title) {
101130
return;
102131
}
103-
const store = this.get('store');
104-
const data = {
132+
const node = this.store.createRecord('node', {
105133
category: 'project',
106134
description,
107135
public: false,
108-
templateFrom,
109136
title,
110-
};
111-
const node = store.createRecord('node', data);
112-
const institutions = this.get('institutionsSelected');
137+
});
138+
139+
if (templateFrom) {
140+
node.set('templateFrom', templateFrom.id);
141+
}
113142
if (institutions.length) {
114143
node.set('affiliatedInstitutions', institutions.slice());
115144
}
145+
if (storageRegion) {
146+
node.set('region', storageRegion);
147+
}
116148
yield node.save();
117149

118150
this.set('newNode', node);
119151
}).drop();
120152

121153
@alias('currentUser.user') user!: User;
122-
@oneWay('user.institutions') institutionsSelected!: DS.PromiseManyArray<Institution> | Institution[];
123154

124155
@or('nodes.length', 'filter', 'findNodes.isRunning') hasNodes!: boolean;
125156

@@ -139,27 +170,6 @@ export default class Dashboard extends Controller {
139170
this.get('findNodes').perform();
140171
}
141172

142-
@action
143-
selectInstitution(this: Dashboard, institution: Institution) {
144-
const selected = this.set('institutionsSelected', this.get('institutionsSelected').slice());
145-
146-
if (selected.includes(institution)) {
147-
selected.removeObject(institution);
148-
} else {
149-
selected.pushObject(institution);
150-
}
151-
}
152-
153-
@action
154-
selectAllInstitutions(this: Dashboard) {
155-
this.set('institutionsSelected', this.get('user').get('institutions').slice());
156-
}
157-
158-
@action
159-
removeAllInstitutions(this: Dashboard) {
160-
this.set('institutionsSelected', A([]));
161-
}
162-
163173
@action
164174
toggleModal(this: Dashboard) {
165175
if (this.get('modalOpen')) {

app/dashboard/route.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { action } from '@ember-decorators/object';
22
import { service } from '@ember-decorators/service';
33
import Route from '@ember/routing/route';
4-
import config from 'ember-get-config';
54
import Session from 'ember-simple-auth/services/session';
65

76
import DashboardController from 'ember-osf-web/dashboard/controller';
@@ -10,14 +9,6 @@ import Analytics from 'ember-osf-web/services/analytics';
109
import CurrentUser from 'ember-osf-web/services/current-user';
1110
import Ready from 'ember-osf-web/services/ready';
1211

13-
// TODO pull these from the database
14-
const {
15-
dashboard: {
16-
noteworthyNode,
17-
popularNode,
18-
},
19-
} = config;
20-
2112
@requireAuth('home')
2213
export default class Dashboard extends Route {
2314
@service analytics!: Analytics;
@@ -27,16 +18,9 @@ export default class Dashboard extends Route {
2718

2819
async setupController(this: Dashboard, controller: DashboardController): Promise<void> {
2920
const blocker = this.get('ready').getBlocker();
30-
controller.set('filter', null);
3121

3222
try {
33-
await Promise.all([
34-
controller.get('findNodes').perform(),
35-
controller.get('getInstitutions').perform(),
36-
controller.get('getPopularAndNoteworthy').perform(popularNode, 'popular'),
37-
controller.get('getPopularAndNoteworthy').perform(noteworthyNode, 'noteworthy'),
38-
]);
39-
23+
await controller.get('setupTask').perform();
4024
blocker.done();
4125
} catch (e) {
4226
blocker.errored(e);

app/dashboard/styles.scss

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* stylelint-disable */
22
.quickSearch {
33
min-height: 700px;
4-
background: #C5D6E6 url('/static/img/bg6.jpg') top center repeat-y;
4+
background: #C5D6E6 url('/assets/images/dashboard/bg6.jpg') top center repeat-y;
55
background-size: cover;
66
}
77

@@ -24,7 +24,7 @@
2424
}
2525

2626
.bg-web {
27-
background: #166595 url("/static/img/front-page/bg-web.png") no-repeat center top;
27+
background: #166595 url("/assets/images/home/bg-web.png") no-repeat center top;
2828
background-size: cover;
2929
}
3030

@@ -37,17 +37,6 @@
3737
color: $color-text-white;
3838
}
3939

40-
// .prereg {
41-
// background: #C5D6E6 url("/static/img/bg6.jpg") no-repeat center top;
42-
// background-size: cover;
43-
44-
// }
45-
46-
// .prereg-banner {
47-
// background: $color-bg-blue-dark;
48-
// color: $color-text-white;
49-
// }
50-
5140
.preprints {
5241
background: $color-bg-gray-blue-dark;
5342
color: $color-text-white;
@@ -185,26 +174,3 @@
185174
color: $color-text-placeholder-grey-dark;
186175
opacity: 1;
187176
}
188-
189-
// ::-webkit-input-placeholder {
190-
// /* Webkit, Blink, Edge */
191-
// color: $color-text-placeholder-grey-dark;
192-
// }
193-
// :-moz-placeholder {
194-
// /* Mozilla Firefox 4 to 18 */
195-
// color: $color-text-placeholder-grey-dark;
196-
// opacity: 1;
197-
// }
198-
// ::-moz-placeholder {
199-
// /* Mozilla Firefox 19+ */
200-
// color: $color-text-placeholder-grey-dark;
201-
// opacity: 1;
202-
// }
203-
// :-ms-input-placeholder {
204-
// /* Internet Explorer 10-11 */
205-
// color: $color-text-placeholder-grey-dark;
206-
// }
207-
// ::-ms-input-placeholder {
208-
// /* Microsoft Edge */
209-
// color: $color-text-placeholder-grey-dark;
210-
// }

0 commit comments

Comments
 (0)