Skip to content

Commit d602aa4

Browse files
committed
Back merge branch 'hotfix/hide-state-for-anonymous' into develop
2 parents 39ded07 + 4856845 commit d602aa4

File tree

10 files changed

+64
-24
lines changed

10 files changed

+64
-24
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ 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+
## [21.4.1] - 2021-05-26
8+
### Changed
9+
- hide registration state for anonymous VOLs
10+
- `reviewsState` to optional on the `registration` model
11+
712
## [21.4.0] - 2021-04-11
813
### Added
914
- user's `myRegistrations` page
@@ -1723,7 +1728,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
17231728
### Added
17241729
- Quick Files
17251730

1726-
[Unreleased]: https://github.com/CenterForOpenScience/ember-osf-web/compare/21.4.0...develop
1731+
[Unreleased]: https://github.com/CenterForOpenScience/ember-osf-web/compare/21.4.1...develop
1732+
[21.4.1]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/21.4.1
17271733
[21.4.0]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/21.4.0
17281734
[21.3.0]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/21.3.0
17291735
[21.2.0]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/21.2.0

app/models/registration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export default class RegistrationModel extends NodeModel.extend(Validations) {
8181
@attr('fixstring') articleDoi!: string | null;
8282
@attr('object') registeredMeta!: RegistrationMetadata;
8383
@attr('registration-responses') registrationResponses!: RegistrationResponse;
84-
@attr('fixstring') reviewsState!: RegistrationReviewStates;
84+
@attr('fixstring') reviewsState?: RegistrationReviewStates;
8585
@attr('fixstring') iaUrl?: string;
8686
@attr('array') providerSpecificMetadata!: ProviderMetadata[];
8787

lib/registries/addon/components/make-decision-dropdown/component.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,22 +49,30 @@ export default class MakeDecisionDropdown extends Component<Args> {
4949
};
5050

5151
get commentTextArea() {
52-
if ([RegistrationReviewStates.Pending, RegistrationReviewStates.PendingWithdraw]
53-
.includes(this.args.registration.reviewsState)) {
52+
if (this.args.registration.reviewsState) {
53+
if ([RegistrationReviewStates.Pending, RegistrationReviewStates.PendingWithdraw]
54+
.includes(this.args.registration.reviewsState)) {
55+
return {
56+
label: this.intl.t('registries.makeDecisionDropdown.additionalComment'),
57+
placeholder: this.intl.t('registries.makeDecisionDropdown.additionalCommentPlaceholder'),
58+
};
59+
}
60+
5461
return {
55-
label: this.intl.t('registries.makeDecisionDropdown.additionalComment'),
56-
placeholder: this.intl.t('registries.makeDecisionDropdown.additionalCommentPlaceholder'),
62+
label: this.intl.t('registries.makeDecisionDropdown.justificationForWithdrawal'),
63+
placeholder: this.intl.t('registries.makeDecisionDropdown.justificationForWithdrawalPlaceholder'),
5764
};
5865
}
59-
66+
// registration is viewed anonymously and this component should not be visible
6067
return {
61-
label: this.intl.t('registries.makeDecisionDropdown.justificationForWithdrawal'),
62-
placeholder: this.intl.t('registries.makeDecisionDropdown.justificationForWithdrawalPlaceholder'),
68+
label: '',
69+
placeholder: '',
6370
};
6471
}
6572

6673
get hasModeratorActions() {
67-
return ![
74+
return this.args.registration.reviewsState
75+
&& ![
6876
RegistrationReviewStates.Initial,
6977
RegistrationReviewStates.Withdrawn,
7078
RegistrationReviewStates.Rejected,

lib/registries/addon/components/registries-states/component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export default class RegistriesStates extends Component {
4747
'isModeratorMode',
4848
)
4949
get stateText() {
50-
if (!this.registration) {
50+
if (!this.registration || !this.registration.reviewsState) {
5151
return undefined;
5252
}
5353
let stateKey;
@@ -73,6 +73,7 @@ export default class RegistriesStates extends Component {
7373
@computed('registration.{userHasAdminPermission,reviewsState}')
7474
get shouldOpenDropdownOnLoad() {
7575
return this.registration.userHasAdminPermission
76+
&& this.registration.reviewsState
7677
&& ![
7778
RegistrationReviewStates.Embargo,
7879
RegistrationReviewStates.Accepted,
@@ -94,6 +95,7 @@ export default class RegistriesStates extends Component {
9495
!this.registration.isRoot
9596
|| !this.registration.userHasAdminPermission
9697
|| this.isModeratorMode
98+
|| !this.registration.reviewsState
9799
|| !(
98100
[RegistrationReviewStates.Accepted, RegistrationReviewStates.Embargo].includes(
99101
this.registration.reviewsState,

lib/registries/addon/overview/-components/overview-topbar/template.hbs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
<div data-test-topbar-states>
2-
<RegistriesStates
3-
@registration={{@registration}}
4-
@isModeratorMode={{@isModeratorMode}}
5-
/>
6-
</div>
7-
{{#if @isModeratorMode}}
1+
{{#unless @registration.isAnonymous}}
2+
<div data-test-topbar-states>
3+
<RegistriesStates
4+
@registration={{@registration}}
5+
@isModeratorMode={{@isModeratorMode}}
6+
/>
7+
</div>
8+
{{/unless}}
9+
{{#if (and @isModeratorMode (not @registration.isAnonymous))}}
810
<MakeDecisionDropdown @registration={{@registration}} />
911
{{else}}
1012
<div data-test-topbar-share-bookmark-fork

mirage/serializers/application.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ export default class ApplicationSerializer<T extends DS.Model> extends JSONAPISe
5252
serialize(model: ModelInstance<T>, request: Request) {
5353
const json = super.serialize(model, request);
5454
json.data.links = this.buildNormalLinks(model);
55-
json.data.meta = {
55+
json.meta = {
5656
...this.buildApiMeta(model),
57-
...(json.data.meta || {}),
57+
...(json.meta || {}),
5858
};
5959
json.data.relationships = Object
6060
.entries(this.buildRelationships(model))

mirage/serializers/registration.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,4 +241,11 @@ export default class RegistrationSerializer extends ApplicationSerializer<Mirage
241241
}
242242
return relationships;
243243
}
244+
245+
buildApiMeta(model: ModelInstance<MirageRegistration>) {
246+
return {
247+
...super.buildApiMeta(model),
248+
...(model.attrs._anonymized ? { anonymous: true } : {}),
249+
};
250+
}
244251
}

mirage/views/registration.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,13 @@ export function registrationDetail(this: HandlerContext, schema: Schema, request
3232
errors: [{ detail: 'Not found.' }],
3333
});
3434
}
35+
const serializedRegistration = this.serialize(registration);
36+
const { data } = process(schema, request, this, [serializedRegistration.data]);
3537

36-
const { data } = process(schema, request, this, [this.serialize(registration).data]);
37-
38-
return { data: data[0] };
38+
return {
39+
data: data[0],
40+
meta: serializedRegistration.meta,
41+
};
3942
}
4043

4144
export function createNodeFromDraftNode(

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ember-osf-web",
3-
"version": "21.4.0",
3+
"version": "21.4.1",
44
"description": "Ember front-end for the Open Science Framework",
55
"license": "Apache-2.0",
66
"author": "Center for Open Science <support@cos.io>",

tests/engines/registries/acceptance/overview/topbar-test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,18 @@ module('Registries | Acceptance | overview.topbar', hooks => {
9393
assert.dom('[data-test-topbar-states]').doesNotExist();
9494
});
9595

96+
test('registration state is not visible in topbar when viewing registrations anonymously', async assert => {
97+
const anonymousReg = server.create('registration', {
98+
registrationSchema: server.schema.registrationSchemas.find('prereg_challenge'),
99+
}, 'anonymized');
100+
101+
await visit(`/${anonymousReg.id}/`);
102+
await percySnapshot(assert);
103+
104+
assert.dom('[data-test-topbar-share-bookmark-fork]').exists();
105+
assert.dom('[data-test-topbar-states]').doesNotExist();
106+
});
107+
96108
test('bookmarks work', async assert => {
97109
const reg = server.create('registration', {
98110
registrationSchema: server.schema.registrationSchemas.find('prereg_challenge'),

0 commit comments

Comments
 (0)