Skip to content

Commit f3e1631

Browse files
authored
[ENG-3423] Version metadata updates (#1361)
* sOnly show approved revisions on overview page * Only show version metadata box when multiple versions have been approved * Update mirage for tests * Hide update button on node-card for non-admin * Remove unneeded computed decorator * Check if latestResponse is not defined. Fix test * Update showMetadata condition for single response registrations * Filter out first time submissions from pending-updates of moderation app * Make how filters are being populated a bit more meaningful * Wording changes
1 parent c4e6a8c commit f3e1631

File tree

10 files changed

+18
-10
lines changed

10 files changed

+18
-10
lines changed

lib/osf-components/addon/components/node-card/component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export default class NodeCard extends Component {
8787
}
8888

8989
get shouldShowUpdateButton() {
90-
if (this.node instanceof RegistrationModel) {
90+
if (this.node instanceof RegistrationModel && this.node.userHasAdminPermission) {
9191
return this.node.revisionState === RevisionReviewStates.Approved &&
9292
(
9393
this.node.reviewsState === RegistrationReviewStates.Accepted ||

lib/osf-components/addon/components/registries/overview-form-renderer/component.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ export default class RegistrationFormViewSchemaBlocks extends Component {
3232
schemaBlockGroups?: SchemaBlockGroup[];
3333
responses?: { [key: string]: string };
3434

35+
get showMetadata() {
36+
return this.registration.latestResponse.content && !this.registration.latestResponse.get('isOriginalResponse');
37+
}
38+
3539
@restartableTask({ on: 'didReceiveAttrs' })
3640
@waitFor
3741
async fetchSchemaBlocks() {

lib/osf-components/addon/components/registries/overview-form-renderer/template.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{{#if this.fetchSchemaBlocks.isRunning}}
22
<LoadingIndicator @dark={{true}}/>
33
{{else}}
4-
{{#if (gt this.registration.schemaResponses.length 1)}}
4+
{{#if this.showMetadata}}
55
<Registries::VersionMetadata @revision={{@revision}} />
66
{{/if}}
77
<Registries::RegistrationFormNavigationDropdown

lib/osf-components/addon/components/registries/registration-list/manager/component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ export default class RegistrationListManager extends Component {
1717
const filter: Record<string, string | undefined> = { reviews_state: this.state, revision_state: undefined };
1818
if (this.state === RegistrationReviewStates.Embargo) {
1919
filter.reviews_state =
20-
[RegistrationReviewStates.Embargo, RegistrationReviewStates.PendingEmbargoTermination].toString();
20+
[RegistrationReviewStates.Embargo, RegistrationReviewStates.PendingEmbargoTermination].join();
2121
}
2222
if (this.state === RevisionReviewStates.RevisionPendingModeration) {
23-
filter.revision_state = [RevisionReviewStates.RevisionPendingModeration].toString();
24-
filter.reviews_state = undefined;
23+
filter.revision_state = [RevisionReviewStates.RevisionPendingModeration].join();
24+
filter.reviews_state = [RegistrationReviewStates.Embargo, RegistrationReviewStates.Accepted].join();
2525
}
2626
const query: Record<string, string | Record<string, string | undefined>> = {
2727
filter,

lib/registries/addon/overview/-components/diff-manager/component.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,17 @@ export default class DiffManager extends Component<Args> {
5353
} else {
5454
this.baseRevision = await registration.originalResponse;
5555
}
56-
const revisions = await registration.queryHasMany('schemaResponses');
5756
if (headRevisionId) {
5857
let headRevision = this.store.peekRecord('schema-response', headRevisionId);
5958
if (!headRevision) {
6059
headRevision = await this.store.findRecord('schema-response', headRevisionId);
6160
}
6261
this.headRevision = headRevision;
6362
} else {
64-
this.headRevision = revisions.firstObject;
63+
this.headRevision = await registration.latestResponse;
64+
if (!this.headRevision) {
65+
this.headRevision = await registration.originalResponse;
66+
}
6567
}
6668
this.getDiff();
6769
}

mirage/factories/registration.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ export default NodeFactory.extend<MirageRegistration & RegistrationTraits>({
153153
revisionResponses: newReg.registrationResponses,
154154
});
155155
newReg.update({ originalResponse: baseResponse });
156+
newReg.update({ latestResponse: baseResponse });
156157
},
157158

158159
dateRegistered() {

mirage/serializers/registration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ export default class RegistrationSerializer extends ApplicationSerializer<Mirage
274274
}
275275
if (model.attrs.latestResponseId !== null) {
276276
const { latestResponseId } = model.attrs;
277-
relationships.originalResponse = {
277+
relationships.latestResponse = {
278278
data: {
279279
id: latestResponseId as string,
280280
type: 'schema-responses',

mirage/views/registration.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ export function createRegistration(this: HandlerContext, schema: Schema) {
9393
registration: newReg, reviewsState: RevisionReviewStates.Unapproved,
9494
});
9595
newReg.update({ originalResponse: baseResponse });
96+
newReg.update({ latestResponse: baseResponse });
9697
return newReg;
9798
}
9899

tests/integration/components/node-card/component-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module('Integration | Component | node-card', hooks => {
2525
tags: ['a', 'b', 'c'],
2626
description: 'Through the night',
2727
revisionState: RevisionReviewStates.Approved,
28-
});
28+
}, 'currentUserAdmin');
2929
server.create('contributor', { node: registration, index: 0, bibliographic: true });
3030
server.create('contributor', { node: registration, index: 1, bibliographic: true });
3131
server.create('contributor', { node: registration, index: 2, bibliographic: true });

translations/en-us.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1608,7 +1608,7 @@ registries:
16081608
modalHeaderNoUpdates: 'Updates not allowed'
16091609
modalBodyFirst: 'Updates to registration responses can be updated by clicking “Next”.<br>Edits to metadata including Description, Category, License, Publication DOI, and Tags are done on the registration by clicking the '
16101610
modalBodySecond: ' icon.'
1611-
modalBodyNoUpdates: 'The {registryName} does not allow updates for this registration template.<br>Contact their registy if you have any questions.'
1611+
modalBodyNoUpdates: '{registryName} does not allow updates.<br>Contact their registry if you have any questions.'
16121612
learnMore: 'Click <a href="https://help.osf.io/hc/en-us/articles/360035806634-Edit-Registration-Metadata" target="_blank">here</a> to learn more.'
16131613
next: Next
16141614
cancel_update: 'Cancel update'

0 commit comments

Comments
 (0)