Skip to content

Commit 38a84e7

Browse files
committed
Merge branch 'hotfix/24.05.2'
2 parents 53ea45e + 105668c commit 38a84e7

File tree

18 files changed

+219
-81
lines changed

18 files changed

+219
-81
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1988,6 +1988,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
19881988
### Added
19891989
- Quick Files
19901990

1991+
[24.05.2]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/24.05.2
1992+
[24.05.1]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/24.05.1
19911993
[24.05.0]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/24.05.0
19921994
[24.04.0]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/24.04.0
19931995
[24.03.0]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/24.03.0

app/models/provider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export interface Assets {
2121
wide_white: string;
2222
}
2323

24-
export enum PreprintProviderReviewsWorkFlow{
24+
export enum PreprintProviderReviewsWorkFlow {
2525
PRE_MODERATION = 'pre-moderation',
2626
POST_MODERATION = 'post-moderation'
2727
}

app/preprints/-components/submit/author-assertions/link-widget/link/component.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ import { action } from '@ember/object';
33
import { inject as service } from '@ember/service';
44
import Intl from 'ember-intl/services/intl';
55
import { ValidationObject } from 'ember-changeset-validations';
6-
import { validateFormat} from 'ember-changeset-validations/validators';
6+
77
import buildChangeset from 'ember-osf-web/utils/build-changeset';
8+
import { validateUrlWithProtocols } from 'ember-osf-web/validators/url-with-protocol';
89
import { tracked } from '@glimmer/tracking';
910

1011

@@ -31,9 +32,7 @@ export default class Link extends Component<LinkArgs>{
3132
@tracked linkFormChangeset: any = null;
3233

3334
linkFormValidation: ValidationObject<LinkForm> = {
34-
value: validateFormat({
35-
allowBlank: false,
36-
type: 'url',
35+
value: validateUrlWithProtocols({
3736
translationArgs: { description: this.intl.t('validationErrors.description') },
3837
}),
3938
};

app/preprints/-components/submit/file/component.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,22 @@ export default class PreprintFile extends Component<FileArgs>{
4545
if(file) {
4646
this.file = file;
4747
this.isFileAttached = true;
48+
this.isEdit = true;
49+
this.args.manager.validateFile(true);
4850
}
4951
}
5052

53+
public get isSelectProjectButtonDisplayed(): boolean {
54+
return !this.args.manager.isEditFlow;
55+
}
56+
57+
public get isSelectProjectButtonDisabled(): boolean {
58+
return this.isButtonDisabled || this.isEdit;
59+
}
60+
5161
@action
5262
public async validate(file: FileModel): Promise<void> {
63+
this.isEdit = true;
5364
this.file = file;
5465
this.isFileAttached = true;
5566
this.isProjectSelectDisplayed = false;
@@ -77,7 +88,6 @@ export default class PreprintFile extends Component<FileArgs>{
7788

7889
@action
7990
public async addNewfile(): Promise<void> {
80-
this.isEdit = true;
8191
this.file = null;
8292
this.isFileAttached = false;
8393
this.isFileUploadDisplayed = false;
@@ -105,9 +115,13 @@ export default class PreprintFile extends Component<FileArgs>{
105115
this.validate(file);
106116
}
107117

118+
public get getSelectExplanationText(): string {
119+
return this.intl.t('preprints.submit.step-file.project-select-explanation',
120+
{ singularPreprintWord: this.args.manager.provider.documentType.singularCapitalized });
121+
}
122+
108123
public get getUploadText(): string {
109124
return this.intl.t('preprints.submit.step-file.upload-title',
110125
{ singularPreprintWord: this.args.manager.provider.documentType.singularCapitalized });
111-
112126
}
113127
}

app/preprints/-components/submit/file/template.hbs

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@
44
>
55
{{t 'preprints.submit.step-file.title'}}
66
</h3>
7+
{{#if this.isSelectProjectButtonDisplayed}}
8+
<p>
9+
{{t 'preprints.submit.step-file.upload-warning'}}
10+
</p>
11+
{{/if}}
712
{{#if this.loadFiles.isRunning}}
813
<LoadingIndicator data-test-loading-indicator @dark={{true}} />
9-
{{else}}
14+
{{else}}
1015
{{#if this.isFileAttached}}
1116
<div local-class='file-container'>
1217
<div local-class='file'>
@@ -33,16 +38,29 @@
3338
disabled={{this.isButtonDisabled}}
3439
>
3540
{{ t 'preprints.submit.step-file.file-upload-label'}}
41+
<EmberTooltip>
42+
{{t 'preprints.submit.step-file.file-upload-help-text' singularPreprintWord=@manager.provider.documentType.singular}}
43+
</EmberTooltip>
3644
</Button>
37-
<Button
38-
data-test-select-button
39-
data-analytics-name='Select button'
40-
{{on 'click' this.displayFileSelect}}
41-
local-class='btn'
42-
disabled={{this.isButtonDisabled}}
43-
>
44-
{{ t 'preprints.submit.step-file.file-select-label'}}
45-
</Button>
45+
{{#if this.isSelectProjectButtonDisplayed}}
46+
<Button
47+
data-test-select-button
48+
data-analytics-name='Select button'
49+
{{on 'click' this.displayFileSelect}}
50+
local-class='btn'
51+
disabled={{this.isSelectProjectButtonDisabled}}
52+
>
53+
{{ t 'preprints.submit.step-file.file-select-label'}}
54+
<EmberTooltip>
55+
{{t 'preprints.submit.step-file.file-select-help-text' singularPreprintWord=@manager.provider.documentType.singular}}
56+
</EmberTooltip>
57+
{{#if this.isEdit}}
58+
<EmberTooltip>
59+
{{this.getSelectExplanationText}}
60+
</EmberTooltip>
61+
{{/if}}
62+
</Button>
63+
{{/if}}
4664
</div>
4765
{{#if this.isFileUploadDisplayed}}
4866
{{#let (unique-id 'preprint-upload-files-dropzone') as |id|}}

app/preprints/-components/submit/file/upload-file/component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ export default class PreprintUpload extends Component<PreprintUploadArgs> {
8989
@waitFor
9090
async success(_: any, __:any, file: FileModel): Promise<void> {
9191
if (this.args.isEdit) {
92-
await this.primaryFile?.rename(file.name);
92+
if (file.name !== this.primaryFile?.name) {
93+
await this.primaryFile?.rename(file.name);
94+
}
9395
} else {
9496
const primaryFile = await this.rootFolder!.files;
9597
this.args.manager.preprint.set('primaryFile', primaryFile.firstObject);

app/preprints/-components/submit/preprint-state-machine/component.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -229,20 +229,24 @@ export default class PreprintStateMachine extends Component<StateMachineArgs>{
229229
this.args.setPageDirty();
230230
}
231231
this.isNextButtonDisabled = true;
232-
if (this.statusFlowIndex === this.getTypeIndex(PreprintStatusTypeEnum.titleAndAbstract) &&
232+
233+
if (
234+
this.statusFlowIndex === this.getTypeIndex(PreprintStatusTypeEnum.titleAndAbstract) &&
233235
this.titleAndAbstractValidation
234236
) {
235237
await this.saveOnStep();
236238
await this.preprint.files;
237-
this.isNextButtonDisabled = !this.metadataValidation;
239+
this.isNextButtonDisabled = !this.fileValidation;
238240
return;
239-
} else if (this.statusFlowIndex === this.getTypeIndex(PreprintStatusTypeEnum.file) &&
241+
} else if (
242+
this.statusFlowIndex === this.getTypeIndex(PreprintStatusTypeEnum.file) &&
240243
this.fileValidation
241244
) {
242245
await this.saveOnStep();
243-
this.isNextButtonDisabled = !this.authorAssertionValidation;
246+
this.isNextButtonDisabled = !this.metadataValidation;
244247
return;
245-
} else if (this.statusFlowIndex === this.getTypeIndex(PreprintStatusTypeEnum.metadata) &&
248+
} else if (
249+
this.statusFlowIndex === this.getTypeIndex(PreprintStatusTypeEnum.metadata) &&
246250
this.metadataValidation
247251
) {
248252
await this.saveOnStep();
@@ -252,13 +256,15 @@ export default class PreprintStateMachine extends Component<StateMachineArgs>{
252256
this.isNextButtonDisabled = !this.supplementValidation;
253257
}
254258
return;
255-
} else if (this.statusFlowIndex === this.getTypeIndex(PreprintStatusTypeEnum.authorAssertions) &&
259+
} else if (
260+
this.statusFlowIndex === this.getTypeIndex(PreprintStatusTypeEnum.authorAssertions) &&
256261
this.authorAssertionValidation
257262
) {
258263
await this.saveOnStep();
259264
this.isNextButtonDisabled = !this.supplementValidation;
260265
return;
261-
} else if (this.statusFlowIndex === this.getTypeIndex(PreprintStatusTypeEnum.supplements) &&
266+
} else if (
267+
this.statusFlowIndex === this.getTypeIndex(PreprintStatusTypeEnum.supplements) &&
262268
this.supplementValidation
263269
) {
264270
await this.saveOnStep();
@@ -607,10 +613,12 @@ export default class PreprintStateMachine extends Component<StateMachineArgs>{
607613
@task
608614
@waitFor
609615
public async addProjectFile(file: FileModel): Promise<void>{
610-
await file.copy(this.preprint, '/', 'osfstorage');
616+
await file.copy(this.preprint, '/', 'osfstorage', {
617+
conflict: 'replace',
618+
});
611619
const theFiles = await this.preprint.files;
612620
const rootFolder = await theFiles.firstObject!.rootFolder;
613621
const primaryFile = await rootFolder!.files;
614-
this.preprint.set('primaryFile', primaryFile.firstObject);
622+
this.preprint.set('primaryFile', primaryFile.lastObject);
615623
}
616624
}

app/preprints/-components/submit/preprint-state-machine/status-flow/status-flow-display/styles.scss

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
background-color: inherit;
1111
z-index: 1;
1212

13-
&.cursor {
14-
cursor: pointer;
15-
}
1613

1714
&.selected {
1815
width: 193px;
@@ -57,6 +54,11 @@
5754
font-weight: bold;
5855
}
5956

57+
&.cursor {
58+
cursor: pointer;
59+
}
60+
61+
6062
.finished {
6163
color: $brand-success;
6264
}

app/preprints/-components/submit/preprint-state-machine/status-flow/status-flow-display/template.hbs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{{#if this.shouldDisplayStatusType}}
22
<div local-class='status-container
33
{{if this.isSelected 'selected'}}
4-
{{if this.isFinished 'cursor'}}
54
{{if (is-mobile) 'mobile'}}'
65
>
76
<div local-class='graphics-container'>
@@ -20,7 +19,9 @@
2019
/>
2120
{{/if}}
2221
</div>
23-
<div local-class='link-container'>
22+
<div local-class='link-container
23+
{{if this.isFinished 'cursor'}}'
24+
>
2425
{{#if this.isFinished}}
2526
<Button
2627
local-class='btn finished'

app/preprints/-components/submit/review/component.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import { inject as service } from '@ember/service';
88
import { tracked } from '@glimmer/tracking';
99
import moment from 'moment-timezone';
1010
import Intl from 'ember-intl/services/intl';
11+
import { PreprintProviderReviewsWorkFlow } from 'ember-osf-web/models/provider';
12+
import { SafeString } from '@ember/template/-private/handlebars';
1113

1214
/**
1315
* The Review Args
@@ -27,6 +29,8 @@ export default class Review extends Component<ReviewArgs>{
2729
@tracked contributors?: any;
2830
@tracked subjects?: any;
2931
@service intl!: Intl;
32+
@tracked displayProviderAgreement = false;
33+
@tracked providerAgreement: string | SafeString = '';
3034

3135
constructor(owner: unknown, args: ReviewArgs) {
3236
super(owner, args);
@@ -37,7 +41,25 @@ export default class Review extends Component<ReviewArgs>{
3741
@task
3842
@waitFor
3943
private async loadPreprint() {
40-
this.provider = this.preprint.provider.content;
44+
this.provider = await this.preprint.provider.content;
45+
if (
46+
this.provider.reviewsWorkflow === PreprintProviderReviewsWorkFlow.PRE_MODERATION ||
47+
this.provider.reviewsWorkflow === PreprintProviderReviewsWorkFlow.POST_MODERATION
48+
) {
49+
this.displayProviderAgreement = true;
50+
51+
const moderationType = this.provider.reviewsWorkflow ===
52+
PreprintProviderReviewsWorkFlow.PRE_MODERATION ?
53+
PreprintProviderReviewsWorkFlow.PRE_MODERATION :
54+
PreprintProviderReviewsWorkFlow.POST_MODERATION;
55+
this.providerAgreement = this.intl.t('preprints.submit.step-review.agreement-provider',
56+
{
57+
providerName : this.provider.name,
58+
moderationType,
59+
htmlSafe: true,
60+
});
61+
}
62+
4163
this.license = this.preprint.license;
4264
this.subjects = await this.preprint.queryHasMany('subjects');
4365
}

0 commit comments

Comments
 (0)