Skip to content

Commit bf5874c

Browse files
committed
Merge branch 'develop' into feature/mirage-user-registrations
2 parents a57c94a + 2138c52 commit bf5874c

File tree

8 files changed

+98
-4
lines changed

8 files changed

+98
-4
lines changed

app/models/draft-registration.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export default class DraftRegistrationModel extends OsfModel {
3737
@attr('fixstringarray') tags!: string[];
3838
@attr('node-license') nodeLicense!: NodeLicense | null;
3939
@attr('node-category') category!: NodeCategory;
40+
@attr('boolean') hasProject!: boolean;
4041

4142
@belongsTo('node', { inverse: 'draftRegistrations' })
4243
branchedFrom!: DS.PromiseObject<NodeModel> & NodeModel;

lib/osf-components/addon/components/registries/finalize-registration-modal/component.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import { tagName } from '@ember-decorators/component';
22
import Component from '@ember/component';
33
import { assert } from '@ember/debug';
44
import { action, computed } from '@ember/object';
5+
import { inject as service } from '@ember/service';
56
import config from 'ember-get-config';
7+
import Intl from 'ember-intl/services/intl';
68
import moment from 'moment';
79

810
import { layout } from 'ember-osf-web/decorators/component';
@@ -16,6 +18,7 @@ import template from './template';
1618
@layout(template, styles)
1719
@tagName('')
1820
export default class FinalizeRegisrationModalComponent extends Component {
21+
@service intl!: Intl;
1922
// Required parameter
2023
manager!: FinalizeRegistrationModalManager;
2124

@@ -38,6 +41,18 @@ export default class FinalizeRegisrationModalComponent extends Component {
3841
}
3942
}
4043

44+
@computed('manager.draftManager.reviewsWorkflow')
45+
get noticeText() {
46+
const translationOptions = { learnMoreLink: this.learnMoreLink, htmlSafe: true };
47+
if (this.manager.draftManager.reviewsWorkflow) {
48+
return this.intl.t(
49+
'registries.finalizeRegistrationModal.notice.withModerationFromProject',
50+
translationOptions,
51+
);
52+
}
53+
return this.intl.t('registries.finalizeRegistrationModal.notice.noModerationFromProject', translationOptions);
54+
}
55+
4156
@computed('manager.{hasEmbargoEndDate,submittingRegistration}', 'makePublicOption')
4257
get shouldDisableSubmitButton() {
4358
return this.makePublicOption === ''

lib/osf-components/addon/components/registries/finalize-registration-modal/manager/template.hbs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
registration=this.registration
66
hasEmbargoEndDate=this.hasEmbargoEndDate
77
submittingRegistration=this.submittingRegistration
8+
draftManager=this.draftManager
89
)}}

lib/osf-components/addon/components/registries/finalize-registration-modal/template.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</dialog.heading>
1010
<dialog.main data-test-finalize-main>
1111
<div local-class='notice'>
12-
{{t 'registries.finalizeRegistrationModal.notice' learnMoreLink=this.learnMoreLink htmlSafe=true}}
12+
{{this.noticeText}}
1313
</div>
1414
<div>
1515
<RadioButton

lib/registries/addon/drafts/draft/draft-registration-manager.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export default class DraftRegistrationManager {
4444
schemaBlocks!: SchemaBlock[];
4545

4646
@alias('draftRegistration.id') draftId!: string;
47+
@alias('provider.reviewsWorkflow') reviewsWorkflow?: string;
4748
@or('onPageInput.isRunning', 'onMetadataInput.isRunning') autoSaving!: boolean;
4849
@or('initializePageManagers.isRunning', 'initializeMetadataChangeset.isRunning') initializing!: boolean;
4950
@not('registrationResponsesIsValid') hasInvalidResponses!: boolean;

mirage/factories/draft-registration.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ export default Factory.extend<DraftRegistration & DraftRegistrationTraits>({
6565

6666
category: NodeCategory.Uncategorized,
6767

68+
hasProject: true,
69+
6870
withRegistrationMetadata: trait<DraftRegistration>({
6971
afterCreate(draftRegistration) {
7072
draftRegistration.update({

tests/integration/components/registries/finalize-registration-modal/component-test.ts

Lines changed: 74 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
11
import { click, fillIn, render, settled } from '@ember/test-helpers';
22
import { hbs } from 'ember-cli-htmlbars';
33
import { setupMirage } from 'ember-cli-mirage/test-support';
4+
import { t } from 'ember-intl/test-support';
45
import { setupRenderingTest } from 'ember-qunit';
56
import moment from 'moment';
67
import { module, test } from 'qunit';
78

9+
import stripHtmlTags from 'ember-osf-web/utils/strip-html-tags';
10+
811
module('Integration | Component | finalize-registration-modal', hooks => {
912
setupRenderingTest(hooks);
1013
setupMirage(hooks);
1114

1215
test('make registration public immediately', async function(assert) {
1316
this.store = this.owner.lookup('service:store');
14-
const registration = server.create('registration');
17+
const provider = server.create('registration-provider');
18+
const registration = server.create('registration', { provider });
1519

1620
const registrationModel = await this.store.findRecord('registration', registration.id);
21+
this.set('draftManager', { provider });
1722
this.set('model', registrationModel);
1823
this.set('isOpen', false);
1924
await render(hbs`
2025
<Registries::FinalizeRegistrationModal::Manager
2126
@registration={{this.model}}
27+
@draftManager={{this.draftManager}}
2228
as |manager|
2329
>
2430
<Registries::FinalizeRegistrationModal @isOpen={{this.isOpen}} @manager={{manager}} />
@@ -55,14 +61,17 @@ module('Integration | Component | finalize-registration-modal', hooks => {
5561

5662
test('embargo registration', async function(assert) {
5763
this.store = this.owner.lookup('service:store');
58-
const registration = server.create('registration');
64+
const provider = server.create('registration-provider');
65+
const registration = server.create('registration', { provider });
5966

6067
const registrationModel = await this.store.findRecord('registration', registration.id);
68+
this.set('draftManager', { provider });
6169
this.set('model', registrationModel);
6270
this.set('isOpen', false);
6371
await render(hbs`
6472
<Registries::FinalizeRegistrationModal::Manager
6573
@registration={{this.model}}
74+
@draftManager={{this.draftManager}}
6675
as |manager|
6776
>
6877
<Registries::FinalizeRegistrationModal @isOpen={{this.isOpen}} @manager={{manager}} />
@@ -102,4 +111,67 @@ module('Integration | Component | finalize-registration-modal', hooks => {
102111
// // Close the dialog
103112
this.set('isOpen', false);
104113
});
114+
115+
test('almost done modal content: no moderation', async function(assert) {
116+
this.store = this.owner.lookup('service:store');
117+
const noModerationProvider = server.create('registration-provider', { reviewsWorkflow: null });
118+
const noModRegistration = server.create('registration', { provider: noModerationProvider });
119+
120+
const registrationModel = await this.store.findRecord('registration', noModRegistration.id);
121+
this.set('draftManager', { provider: noModerationProvider });
122+
this.set('model', registrationModel);
123+
this.set('isOpen', true);
124+
await render(hbs`
125+
<Registries::FinalizeRegistrationModal::Manager
126+
@registration={{this.model}}
127+
@draftManager={{this.draftManager}}
128+
as |manager|
129+
>
130+
<Registries::FinalizeRegistrationModal @isOpen={{this.isOpen}} @manager={{manager}} />
131+
</Registries::FinalizeRegistrationModal::Manager>
132+
`);
133+
// Click immediate radio button
134+
await click('[data-test-immediate-button]');
135+
// Click submit button
136+
await click('[data-test-submit-registration-button]');
137+
138+
const opts = { learnMoreLink: 'aaa.aa', htmlSafe: true };
139+
assert.dom('[data-test-finalize-main]').hasTextContaining(
140+
stripHtmlTags(t('registries.finalizeRegistrationModal.notice.noModerationFromProject', opts).toString()),
141+
'modal shows warning',
142+
);
143+
assert.dom('[data-test-finalize-main]').doesNotHaveTextContaining(
144+
'A moderator must review and approve', 'modal does not mention moderation for unmoderated providers',
145+
);
146+
});
147+
148+
test('almost done modal content: with moderation', async function(assert) {
149+
this.store = this.owner.lookup('service:store');
150+
const withModerationProvider = server.create('registration-provider');
151+
const withModRegistration = server.create('registration', { provider: withModerationProvider });
152+
153+
const registrationModel = await this.store.findRecord('registration', withModRegistration.id);
154+
this.set('draftManager', { provider: withModerationProvider, reviewsWorkflow: 'pre-moderation' });
155+
this.set('model', registrationModel);
156+
this.set('isOpen', true);
157+
await render(hbs`
158+
<Registries::FinalizeRegistrationModal::Manager
159+
@registration={{this.model}}
160+
@draftManager={{this.draftManager}}
161+
as |manager|
162+
>
163+
<Registries::FinalizeRegistrationModal @isOpen={{this.isOpen}} @manager={{manager}} />
164+
</Registries::FinalizeRegistrationModal::Manager>
165+
`);
166+
// Click immediate radio button
167+
await click('[data-test-immediate-button]');
168+
// Click submit button
169+
await click('[data-test-submit-registration-button]');
170+
171+
const opts = { learnMoreLink: 'aaa.aa', htmlSafe: true };
172+
assert.dom('[data-test-finalize-main]').hasTextContaining(
173+
stripHtmlTags(t('registries.finalizeRegistrationModal.notice.withModerationFromProject', opts).toString()),
174+
'modal shows warning with moderation for moderated providers',
175+
);
176+
});
105177
});

translations/en-us.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1354,7 +1354,9 @@ registries:
13541354
request_embargo_termination: 'embargo termination requested'
13551355
finalizeRegistrationModal:
13561356
title: 'Almost done...'
1357-
notice: "Please keep in mind that:\n <ul>\n <li>\n Registrations cannot be modified or deleted once completed.\n </li>\n <li>\n The content and version history of Wiki and OSF Storage will be copied to the registration.\n </li>\n <li>\n This project contains links to other projects. These links will be copied into your registration, but the\n projects that they link to will not be registered. If you wish to register the linked projects, they must be\n registered separately. <a href='{learnMoreLink}' target='_blank' rel='noopener noreferrer'>Learn more about links</a>.\n </li>\n </ul>"
1357+
notice:
1358+
noModerationFromProject: 'Remember:<ul><li>Registrations cannot be modified or deleted once submitted.</li><li>Changes to any files (1) in the projects or components being registered, (2) uploaded or selected as prompt responses, including those connected through add-ons during archiving will result in archiving failure and loss of your registration timestamp. Please do not modify your files until after you have received email confirmation of archiving completion. If this registration has been archiving for more than 72 hours, please email <a href="mailto:support@osf.io">support@osf.io</a> for assistance.</li><li>The content and version history of Wiki and OSF Storage will be copied to the registration.</li><li>This project may contain links to other projects. These links will be copied into your registration, but the projects that they link to will not be registered. If you wish to register the linked projects, they must be registered separately. <a href="{learnMoreLink}" target="_blank" rel="noopener noreferrer">Learn more about links</a>.</li></ul>'
1359+
withModerationFromProject: 'Remember:<ul><li>Registrations cannot be modified or deleted once submitted.</li><li>Changes to any files (1) in the projects or components being registered, (2) uploaded or selected as prompt responses, including those connected through add-ons during archiving will result in archiving failure and loss of your registration timestamp. Please do not modify your files until after you have received email confirmation of archiving completion. If this registration has been archiving for more than 72 hours, please email <a href="mailto:support@osf.io">support@osf.io</a> for assistance.</li><li>The content and version history of Wiki and OSF Storage will be copied to the registration.</li><li>This project may contain links to other projects. These links will be copied into your registration, but the projects that they link to will not be registered. If you wish to register the linked projects, they must be registered separately. <a href="{learnMoreLink}" target="_blank" rel="noopener noreferrer">Learn more about links</a>.</li><li>A moderator must review and approve your registration before it will be made public or embargoed.</li></ul>'
13581360
immediateOption: 'Make registration public immediately'
13591361
embargoOption: 'Enter registration into embargo'
13601362
createDoi: 'Create DOI'

0 commit comments

Comments
 (0)