Skip to content

Commit 8216829

Browse files
committed
Merge branch 'release/24.05.0'
2 parents 59c97db + 5f18a04 commit 8216829

File tree

190 files changed

+7203
-751
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

190 files changed

+7203
-751
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ 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+
## [24.05.0] - 2024-07-08
8+
### Added
9+
- Add subjects to project metadata editor
10+
- Preprints to EOW phase 2
11+
### Removed
12+
- Removed LawrXiv logo from OSF Preprints discover page
13+
14+
715
## [24.04.0] - 2024-04-30
816
### Added
917
- Misc bug and a11y fixes
@@ -1980,6 +1988,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
19801988
### Added
19811989
- Quick Files
19821990

1991+
[24.05.0]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/24.05.0
1992+
[24.04.0]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/24.04.0
19831993
[24.03.0]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/24.03.0
19841994
[24.02.0]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/24.02.0
19851995
[24.01.0]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/24.01.0

app/adapters/contributor.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,14 @@ export default class ContributorAdapter extends OsfAdapter {
1818
if (requestType === 'findRecord') {
1919
const [objectId, userId] = (id || '').split('-');
2020
const node = this.store.peekRecord('node', objectId);
21+
const preprint = this.store.peekRecord('preprint', objectId);
2122
const draft = this.store.peekRecord('draft-registration', objectId);
2223
let baseUrl;
2324
assert(`"contributorId" must be "objectId-userId": got ${objectId}-${userId}`, Boolean(objectId && userId));
2425
if (node) {
2526
baseUrl = this.buildRelationshipURL((node as any)._internalModel.createSnapshot(), 'contributors');
27+
} else if (preprint) {
28+
baseUrl = this.buildRelationshipURL((preprint as any)._internalModel.createSnapshot(), 'contributors');
2629
} else {
2730
baseUrl = this.buildRelationshipURL((draft as any)._internalModel.createSnapshot(), 'contributors');
2831
}
@@ -31,13 +34,21 @@ export default class ContributorAdapter extends OsfAdapter {
3134

3235
if (snapshot && requestType === 'createRecord') {
3336
const node = snapshot.belongsTo('node');
37+
const preprint = snapshot.belongsTo('preprint');
3438
const draftRegistration = snapshot.belongsTo('draftRegistration');
3539
const user = snapshot.belongsTo('users');
36-
assert('"node" or "draftRegistration" relationship is needed to create a contributor',
37-
Boolean(node || draftRegistration));
40+
assert('"node" or "draftRegistration" or "preprint" relationship is needed to create a contributor',
41+
Boolean(node || draftRegistration || preprint));
3842
assert('"users" relationship, "email" or "fullName" is needed to create a contributor',
3943
Boolean(user || snapshot.attr('email') || snapshot.attr('fullName')));
4044
let baseUrl;
45+
46+
if (preprint) {
47+
// if preprint relationship is defined
48+
// we post to v2/preprints/<preprint_id>/contributors
49+
baseUrl = this.buildRelationshipURL(preprint, 'contributors');
50+
}
51+
4152
if (node) {
4253
// if node relationship is defined
4354
// we post to v2/nodes/<node_id>/contributors

app/adapters/preprint-request.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import ActionAdapter from './action';
2+
3+
export default class PreprintRequestAdapter extends ActionAdapter {
4+
}
5+
6+
declare module 'ember-data/types/registries/adapter' {
7+
export default interface AdapterRegistry {
8+
'preprint-request': PreprintRequestAdapter;
9+
} // eslint-disable-line semi
10+
}

app/models/file-provider.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { attr, belongsTo, AsyncBelongsTo, hasMany, AsyncHasMany } from '@ember-data/model';
2+
import PreprintModel from 'ember-osf-web/models/preprint';
23
import { Link } from 'jsonapi-typescript';
34

45
import AbstractNodeModel from './abstract-node';
@@ -24,7 +25,8 @@ export default class FileProviderModel extends BaseFileItem {
2425

2526
@belongsTo('abstract-node', { inverse: 'files', polymorphic: true })
2627
target!: (AsyncBelongsTo<AbstractNodeModel> & AbstractNodeModel) |
27-
(AsyncBelongsTo<DraftNodeModel> & DraftNodeModel);
28+
(AsyncBelongsTo<DraftNodeModel> & DraftNodeModel) |
29+
(AsyncBelongsTo<PreprintModel> & PreprintModel);
2830

2931
// BaseFileItem override
3032
isProvider = true;

app/models/license.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ export default class LicenseModel extends OsfModel {
99
@attr('fixstring') url!: string;
1010
@attr('fixstring') text!: string;
1111
@attr('array') requiredFields!: Array<keyof NodeLicense>;
12+
13+
get hasRequiredFields(): boolean {
14+
return this.requiredFields?.length > 0;
15+
}
1216
}
1317

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

app/models/node.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ export default class NodeModel extends AbstractNodeModel.extend(Validations, Col
120120
@attr('boolean') currentUserCanComment!: boolean;
121121
@attr('boolean') wikiEnabled!: boolean;
122122

123+
@hasMany('subject', { inverse: null, async: false }) subjectsAcceptable?: SubjectModel[];
124+
123125
// FE-only property to check enabled addons.
124126
// null until getEnabledAddons has been called
125127
@tracked addonsEnabled?: string[];

app/models/osf-model.ts

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Model, { attr } from '@ember-data/model';
22
import Store from '@ember-data/store';
3-
import EmberArray, { A } from '@ember/array';
3+
import EmberArray, { A, isArray } from '@ember/array';
44
import { assert } from '@ember/debug';
55
import { set } from '@ember/object';
66
import { alias } from '@ember/object/computed';
@@ -226,6 +226,13 @@ export default class OsfModel extends Model {
226226
return this.modifyM2MRelationship('post', relationshipName, relatedModel);
227227
}
228228

229+
async removeM2MRelationship<T extends OsfModel>(
230+
this: T,
231+
relationshipName: RelationshipsFor<T> & string,
232+
) {
233+
return this.modifyM2MRelationship('patch', relationshipName, []);
234+
}
235+
229236
async deleteM2MRelationship<T extends OsfModel>(
230237
this: T,
231238
relationshipName: RelationshipsFor<T> & string,
@@ -266,20 +273,26 @@ export default class OsfModel extends Model {
266273

267274
async modifyM2MRelationship<T extends OsfModel>(
268275
this: T,
269-
action: 'post' | 'delete',
276+
action: 'post' | 'delete' | 'patch',
270277
relationshipName: RelationshipsFor<T> & string,
271-
relatedModel: OsfModel,
278+
relatedModel: OsfModel | [],
272279
) {
273280
const apiRelationshipName = underscore(relationshipName);
274281
const url = getSelfHref(this.relationshipLinks[apiRelationshipName]);
275282

276-
const data = JSON.stringify({
277-
data: [{
278-
id: relatedModel.id,
279-
type: relatedModel.apiType,
280-
}],
283+
let data = JSON.stringify({
284+
data: [ ],
281285
});
282286

287+
if (!isArray(relatedModel)) {
288+
data = JSON.stringify({
289+
data: [{
290+
id: relatedModel?.id,
291+
type: relatedModel?.apiType,
292+
}],
293+
});
294+
}
295+
283296
if (!url) {
284297
throw new Error(`Couldn't find self link for ${apiRelationshipName} relationship`);
285298
}
@@ -353,7 +366,7 @@ export default class OsfModel extends Model {
353366
* });
354367
*
355368
* contributors.sparseModels.forEach(contrib => {
356-
* console.log(contrib.users.fullName);
369+
* console.info(contrib.users.fullName);
357370
* );
358371
* ```
359372
*/

app/models/preprint-provider.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,13 @@ export default class PreprintProviderModel extends ProviderModel {
2020

2121
@attr('fixstring') email_support!: string | null;
2222
@attr('array') subjectsAcceptable!: string[];
23+
@attr('boolean') assertionsEnabled!: boolean;
2324
@attr('array') additionalProviders!: string[];
2425
@attr('string') shareSource!: string;
2526
@attr('string') preprintWord!: PreprintWord;
2627

28+
@attr('boolean', { defaultValue: true }) advertiseOnDiscoverPage!: boolean;
29+
2730
// Reviews settings
2831
@attr('array') permissions!: ReviewPermissions[];
2932
@attr('boolean', { allowNull: true }) reviewsCommentsPrivate!: boolean | null;

app/models/preprint.ts

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { attr, belongsTo, hasMany, AsyncBelongsTo, AsyncHasMany } from '@ember-data/model';
22
import { computed } from '@ember/object';
33
import { alias } from '@ember/object/computed';
4+
import AbstractNodeModel from 'ember-osf-web/models/abstract-node';
45
import CitationModel from 'ember-osf-web/models/citation';
56
import PreprintRequestModel from 'ember-osf-web/models/preprint-request';
67
import { ReviewsState } from 'ember-osf-web/models/provider';
@@ -11,51 +12,63 @@ import FileModel from './file';
1112
import IdentifierModel from './identifier';
1213
import LicenseModel from './license';
1314
import NodeModel from './node';
14-
import OsfModel, { Permission } from './osf-model';
15+
import { Permission } from './osf-model';
1516
import PreprintProviderModel from './preprint-provider';
1617
import SubjectModel from './subject';
1718

1819
export enum PreprintDataLinksEnum {
1920
AVAILABLE = 'available',
20-
YES = 'yes',
2121
NO = 'no',
2222
NOT_APPLICABLE = 'not_applicable',
2323
}
2424

2525
export enum PreprintPreregLinksEnum {
2626
AVAILABLE = 'available',
27-
YES = 'yes',
2827
NO = 'no',
2928
NOT_APPLICABLE = 'not_applicable',
3029
}
3130

32-
export default class PreprintModel extends OsfModel {
31+
export enum PreprintPreregLinkInfoEnum {
32+
PREREG_EMPTY = '',
33+
PREREG_DESIGNS = 'prereg_designs',
34+
PREREG_ANALYSIS = 'prereg_analysis',
35+
PREREG_BOTH = 'prereg_both',
36+
}
37+
38+
export interface PreprintLicenseRecordModel {
39+
copyright_holders: string[];
40+
year: string;
41+
}
42+
43+
export default class PreprintModel extends AbstractNodeModel {
3344
@attr('fixstring') title!: string;
3445
@attr('date') dateCreated!: Date;
3546
@attr('date') datePublished!: Date;
3647
@attr('date') dateWithdrawn!: Date;
3748
@attr('date') originalPublicationDate!: Date | null;
49+
@attr('fixstring') customPublicationCitation!: string | null;
3850
@attr('date') dateModified!: Date;
3951
@attr('fixstring') doi!: string | null;
4052
@attr('boolean') public!: boolean;
4153
@attr('boolean') isPublished!: boolean;
4254
@attr('boolean') isPreprintOrphan!: boolean;
43-
@attr('object') licenseRecord!: any;
55+
@attr('object') licenseRecord!: PreprintLicenseRecordModel;
4456
@attr('string') reviewsState!: ReviewsState;
4557
@attr('string') description!: string;
4658
@attr('date') dateLastTransitioned!: Date;
4759
@attr('date') preprintDoiCreated!: Date;
4860
@attr('array') currentUserPermissions!: Permission[];
4961
@attr('fixstringarray') tags!: string[];
50-
@attr('fixstring') withdrawalJustification! : string;
62+
@attr('fixstring') withdrawalJustification!: string;
5163
@attr('boolean') hasCoi!: boolean;
5264
@attr('string') hasDataLinks!: PreprintDataLinksEnum;
5365
@attr('string') hasPreregLinks!: PreprintPreregLinksEnum;
54-
@attr('string') conflictOfInterestStatement!: string;
66+
@attr('string') conflictOfInterestStatement!: string | null;
5567
@attr('array') dataLinks!: string[];
5668
@attr('array') preregLinks!: string[];
57-
@attr('string') whyNoData!: string;
58-
@attr('string') whyNoPrereg!: string;
69+
@attr('string') whyNoData!: string | null;
70+
@attr('string') whyNoPrereg!: string | null;
71+
@attr('string') preregLinkInfo!: PreprintPreregLinkInfoEnum;
5972

6073
@belongsTo('node', { inverse: 'preprints' })
6174
node!: AsyncBelongsTo<NodeModel> & NodeModel;
@@ -72,9 +85,6 @@ export default class PreprintModel extends OsfModel {
7285
@hasMany('review-action')
7386
reviewActions!: AsyncHasMany<ReviewActionModel>;
7487

75-
@hasMany('files', { inverse: 'target'})
76-
files!: AsyncHasMany<FileModel> & FileModel;
77-
7888
@hasMany('contributors', { inverse: 'preprint'})
7989
contributors!: AsyncHasMany<ContributorModel> & ContributorModel;
8090

@@ -103,7 +113,7 @@ export default class PreprintModel extends OsfModel {
103113
@computed('license', 'licenseRecord')
104114
get licenseText(): string {
105115
const text = this.license.get('text') || '';
106-
const { year = '', copyright_holders = [] } = this.licenseRecord; // eslint-disable-line camelcase
116+
const { year = '', copyright_holders = [] } = this.licenseRecord;
107117

108118
return text
109119
.replace(/({{year}})/g, year)

app/packages/registration-schema/validations.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { RegistrationResponse } from 'ember-osf-web/packages/registration-schema
1111
import { SchemaBlockGroup } from 'ember-osf-web/packages/registration-schema/schema-block-group';
1212
import { validateFileList } from 'ember-osf-web/validators/validate-response-format';
1313
import SchemaResponseModel from 'ember-osf-web/models/schema-response';
14+
import PreprintModel from 'ember-osf-web/models/preprint';
1415

1516
type LicensedContent = DraftRegistration | NodeModel;
1617

@@ -131,7 +132,7 @@ export function validateNodeLicense() {
131132
}
132133

133134
export function validateSubjects() {
134-
return (_: unknown, __: unknown, ___: unknown, ____: unknown, content: DraftRegistration) => {
135+
return (_: unknown, __: unknown, ___: unknown, ____: unknown, content: DraftRegistration | PreprintModel ) => {
135136
const subjects = content.hasMany('subjects').value();
136137
if (!subjects || subjects.length === 0) {
137138
return {

0 commit comments

Comments
 (0)