Skip to content

Commit 1ff0f79

Browse files
committed
Merge branch 'release/20.1.0'
2 parents 05c9df3 + a8dfdda commit 1ff0f79

File tree

58 files changed

+691
-130
lines changed

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

+691
-130
lines changed

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8
1+
10

CHANGELOG.md

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,67 @@ 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+
## [20.1.0] - 2020-01-21
8+
### Added
9+
- Components
10+
- `registries/schema-block-renderer/read-only/multi-select`
11+
- `registries/registration-form-navigation-dropdown`
12+
- `registries/overview-form-renderer`
13+
14+
### Fixed
15+
- Transforms
16+
- registration-responses
17+
- handle case where registration_responses is null
18+
- Componenets
19+
- `registries/schema-block-renderer/read-only/mapper`
20+
- use `registries/schema-block-renderer/read-only/multi-select`
21+
- `registries/draft-registration-manager`
22+
- use set to set registration responses
23+
- `registries/schema-block-renderer/read-only/response`
24+
- preserve whitespace formatting in read-only response
25+
- `files/menu`
26+
- use responsive-dropdown without trigger div
27+
- prevent outside click from interrupting upload
28+
- `files/upload-zone`
29+
- do not show toast error for ongoing "canceled" uploads
30+
- `registries/schema-block-renderer/label/label-content`
31+
- add links to questions for review page
32+
- Engines
33+
- `registries`
34+
- Components
35+
- `registries-metadata`
36+
- make contributors a link only for users with read access
37+
38+
### Changed
39+
- Models
40+
- `registration`
41+
- apply `registration-responses` transform to `registrationResponses`
42+
- Serializers
43+
- `registration`
44+
- normalize `registration_responses`
45+
- Components
46+
- `registries/review-form-renderer`
47+
- invoke `Registries::RegistrationFormNavigationDropdown`
48+
- `registries/schema-block-renderer/label/label-content`
49+
- only render link to question when `@draftManager` is provided
50+
- `registries/schema-block-renderer/read-only/files`
51+
- only attempt to show validation when `@changeset` is provided
52+
- Routes
53+
- `developer-apps`
54+
- Components
55+
- `client-secret`
56+
- PATCH to API when resetting client secret for developer app
57+
- Engines
58+
- `registries`
59+
- Routes
60+
- `overview/index`
61+
- invoke `Registries::OverviewFormRenderer` instead of `RegistrationFormView`
62+
- Tests
63+
- add percy snapshots for osf-navbar and registries-navbar
64+
- DX
65+
- use Node 10 and pin with Volta
66+
- set EMBER_ENV=test when running tests
67+
768
## [19.11.0] - 2019-12-16
869
### Added
970
- Components
@@ -1491,7 +1552,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
14911552
### Added
14921553
- Quick Files
14931554

1494-
[Unreleased]: https://github.com/CenterForOpenScience/ember-osf-web/compare/19.10.0...develop
1555+
[Unreleased]: https://github.com/CenterForOpenScience/ember-osf-web/compare/20.1.0...develop
1556+
[20.1.0]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/20.1.0
1557+
[19.11.0]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/19.11.0
14951558
[19.10.0]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/19.10.0
14961559
[19.9.0]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/19.9.0
14971560
[19.8.0]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/19.8.0

app/locales/en/translations.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,6 +1678,7 @@ export default {
16781678
'schema-block-renderer/label': {
16791679
showExample: 'Show example',
16801680
hideExample: 'Hide example',
1681+
editButtonAriaLabel: 'Edit {{questionLabel}}',
16811682
},
16821683
'schema-block-renderer/editable/files': {
16831684
instructions: 'You may attach up to 5 file(s) to this question. You may attach files that you already have in OSF Storage in this <a href={{nodeUrl}}>{{projectOrComponent}}</a> or upload (drag and drop) a new file from your computer. Uploaded files will automatically be added to this <a href={{nodeUrl}}>{{projectOrComponent}}</a> so that they can be registered. To attach files from other components or an add-on, first add them to this <a href={{nodeUrl}}>{{projectOrComponent}}</a>.',

app/models/developer-app.ts

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ import { attr } from '@ember-decorators/data';
22
import { buildValidations, validator } from 'ember-cp-validations';
33
import { Link } from 'jsonapi-typescript';
44

5-
import { Document as ApiResponseDocument } from 'osf-api';
6-
7-
import getHref from 'ember-osf-web/utils/get-href';
8-
95
import OsfModel, { OsfLinks } from './osf-model';
106

117
const Validations = buildValidations({
@@ -42,34 +38,6 @@ export default class DeveloperAppModel extends OsfModel.extend(Validations) {
4238
@attr() homeUrl!: string;
4339
@attr() name!: string;
4440
@attr() owner!: string;
45-
46-
// TODO (EMB-407) When the API is updated, remove this method and reset the secret
47-
// by PATCHing `clientSecret` to `null`
48-
async resetSecret(): Promise<void> {
49-
const resetUrl = getHref(this.links.reset);
50-
const adapter = this.store.adapterFor('developer-app');
51-
const serializer = this.store.serializerFor('developer-app');
52-
53-
// @ts-ignore -- Private API
54-
const snapshot = this._createSnapshot();
55-
56-
const response: ApiResponseDocument = await adapter.ajax(resetUrl, 'POST', {
57-
data: serializer.serialize(snapshot, {
58-
includeId: true,
59-
osf: {
60-
includeCleanData: true,
61-
},
62-
}),
63-
});
64-
65-
if ('data' in response && 'id' in response.data) {
66-
this.store.pushPayload('developer-app', response);
67-
} else if ('errors' in response) {
68-
throw new Error(response.errors.map(error => error.detail).join('\n'));
69-
} else {
70-
throw new Error('Unexpected response while resetting client secret for developer app');
71-
}
72-
}
7341
}
7442

7543
declare module 'ember-data/types/registries/model' {

app/models/registration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export default class RegistrationModel extends NodeModel.extend(Validations) {
5555
@attr('fixstring') registrationSupplement?: string;
5656
@attr('fixstring') articleDoi!: string | null;
5757
@attr('object') registeredMeta!: RegistrationMetadata;
58-
@attr('object') registrationResponses!: RegistrationResponse;
58+
@attr('registration-responses') registrationResponses!: RegistrationResponse;
5959

6060
// Write-only attributes
6161
@attr('array') includedNodeIds?: string[];

app/serializers/developer-app.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ export default class DeveloperAppSerializer extends OsfSerializer {
44
attrs: any = {
55
// eslint-disable-next-line ember/no-attrs-in-components
66
...this.attrs, // from OsfSerializer
7-
8-
clientSecret: {
9-
serialize: false,
10-
},
117
clientId: {
128
serialize: false,
139
},

app/serializers/draft-registration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function isObject(value: unknown) {
2020
return typeof value === 'object' && !isEmpty(value);
2121
}
2222

23-
function normalizeRegistrationResponses(value: ResponseValue, store: DS.Store) {
23+
export function normalizeRegistrationResponses(value: ResponseValue, store: DS.Store) {
2424
if (Array.isArray(value) && !isEmpty(value) && isObject(value.firstObject) &&
2525
('file_id' in value.firstObject)) {
2626
return (value as FileReference[]).map((fileRef: FileReference) => {

app/serializers/registration.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,34 @@
1+
import DS from 'ember-data';
2+
3+
import {
4+
NormalizedRegistrationResponse,
5+
RegistrationResponse,
6+
} from 'ember-osf-web/packages/registration-schema';
7+
import { normalizeRegistrationResponses } from 'ember-osf-web/serializers/draft-registration';
8+
import { mapKeysAndValues } from 'ember-osf-web/utils/map-keys';
9+
import { SingleResourceDocument } from 'osf-api';
110
import OsfSerializer from './osf-serializer';
211

312
export default class RegistrationSerializer extends OsfSerializer {
13+
normalizeResponse(
14+
store: DS.Store,
15+
primaryModelClass: any,
16+
payload: SingleResourceDocument,
17+
id: string,
18+
requestType: string,
19+
) {
20+
if (payload.data.attributes) {
21+
const registrationResponses = payload.data.attributes.registration_responses as RegistrationResponse;
22+
// @ts-ignore
23+
// eslint-disable-next-line no-param-reassign
24+
payload.data.attributes.registration_responses = mapKeysAndValues(
25+
registrationResponses || {},
26+
key => key,
27+
value => normalizeRegistrationResponses(value, store),
28+
) as NormalizedRegistrationResponse;
29+
}
30+
return super.normalizeResponse(store, primaryModelClass, payload, id, requestType);
31+
}
432
}
533

634
declare module 'ember-data/types/registries/serializer' {

app/settings/developer-apps/-components/client-secret/component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ export default class DeveloperAppClientSecret extends Component {
3131
async resetSecret() {
3232
if (this.developerApp) {
3333
this.set('shouldShowSecret', false);
34-
// TODO (EMB-407) When the API is updated, PATCH `clientSecret` to `null`
35-
await this.developerApp.resetSecret();
34+
this.developerApp.set('clientSecret', null);
35+
await this.developerApp.save();
3636
this.toast.success(this.i18n.t('settings.developer-apps.resetSecret.success'));
3737
}
3838
}

app/transforms/registration-responses.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,15 @@ import { deserializeResponseKey, serializeResponseKey } from './registration-res
55

66
const { Transform } = DS;
77

8+
function isResponse(obj: unknown): obj is Record<string, unknown> {
9+
return typeof obj === 'object' && obj !== null && Object.keys(obj).every(key => typeof key === 'string');
10+
}
11+
812
export default class RegistrationResponsesTransform extends Transform {
9-
deserialize(obj: any) {
13+
deserialize(obj: unknown) {
14+
if (!isResponse(obj)) {
15+
return {};
16+
}
1017
return mapKeysAndValues(
1118
obj,
1219
key => deserializeResponseKey(key),

0 commit comments

Comments
 (0)