Skip to content

Commit

Permalink
Merge branch 'develop' into upstream/addon-services
Browse files Browse the repository at this point in the history
# Conflicts:
#	translations/en-us.yml
  • Loading branch information
brianjgeiger committed Sep 20, 2024
2 parents 0a0320a + 584b785 commit a318f33
Show file tree
Hide file tree
Showing 218 changed files with 9,222 additions and 815 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [24.07.0] - 2024-09-18
### Added
- Preprints Affiliation Project - FE Release
- My Preprints Page: preprint card and paginated public preprint list

## [24.06.0] - 2024-08-21
### Added
- Misc bug and a11y fixes
- Added route for My Preprints page

## [24.05.0] - 2024-07-08
### Added
- Add subjects to project metadata editor
- Preprints to EOW phase 2
### Removed
- Removed LawrXiv logo from OSF Preprints discover page


## [24.04.0] - 2024-04-30
### Added
- Misc bug and a11y fixes
Expand Down Expand Up @@ -1980,6 +1998,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added
- Quick Files

[24.05.2]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/24.05.2
[24.05.1]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/24.05.1
[24.05.0]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/24.05.0
[24.04.0]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/24.04.0
[24.03.0]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/24.03.0
[24.02.0]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/24.02.0
[24.01.0]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/24.01.0
Expand Down
15 changes: 13 additions & 2 deletions app/adapters/contributor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@ export default class ContributorAdapter extends OsfAdapter {
if (requestType === 'findRecord') {
const [objectId, userId] = (id || '').split('-');
const node = this.store.peekRecord('node', objectId);
const preprint = this.store.peekRecord('preprint', objectId);
const draft = this.store.peekRecord('draft-registration', objectId);
let baseUrl;
assert(`"contributorId" must be "objectId-userId": got ${objectId}-${userId}`, Boolean(objectId && userId));
if (node) {
baseUrl = this.buildRelationshipURL((node as any)._internalModel.createSnapshot(), 'contributors');
} else if (preprint) {
baseUrl = this.buildRelationshipURL((preprint as any)._internalModel.createSnapshot(), 'contributors');
} else {
baseUrl = this.buildRelationshipURL((draft as any)._internalModel.createSnapshot(), 'contributors');
}
Expand All @@ -31,13 +34,21 @@ export default class ContributorAdapter extends OsfAdapter {

if (snapshot && requestType === 'createRecord') {
const node = snapshot.belongsTo('node');
const preprint = snapshot.belongsTo('preprint');
const draftRegistration = snapshot.belongsTo('draftRegistration');
const user = snapshot.belongsTo('users');
assert('"node" or "draftRegistration" relationship is needed to create a contributor',
Boolean(node || draftRegistration));
assert('"node" or "draftRegistration" or "preprint" relationship is needed to create a contributor',
Boolean(node || draftRegistration || preprint));
assert('"users" relationship, "email" or "fullName" is needed to create a contributor',
Boolean(user || snapshot.attr('email') || snapshot.attr('fullName')));
let baseUrl;

if (preprint) {
// if preprint relationship is defined
// we post to v2/preprints/<preprint_id>/contributors
baseUrl = this.buildRelationshipURL(preprint, 'contributors');
}

if (node) {
// if node relationship is defined
// we post to v2/nodes/<node_id>/contributors
Expand Down
10 changes: 10 additions & 0 deletions app/adapters/preprint-request.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import ActionAdapter from './action';

export default class PreprintRequestAdapter extends ActionAdapter {
}

declare module 'ember-data/types/registries/adapter' {
export default interface AdapterRegistry {
'preprint-request': PreprintRequestAdapter;
} // eslint-disable-line semi
}
7 changes: 5 additions & 2 deletions app/models/abstract-node.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { hasMany, AsyncHasMany, attr } from '@ember-data/model';

import { PromiseManyArray } from '@ember-data/store/-private';
import BaseFileItem from 'ember-osf-web/models/base-file-item';
import DraftRegistrationModel from 'ember-osf-web/models/draft-registration';
import FileProviderModel from 'ember-osf-web/models/file-provider';

import ReviewActionModel from 'ember-osf-web/models/review-action';
import { Permission } from './osf-model';

export default class AbstractNodeModel extends BaseFileItem {
Expand All @@ -15,6 +15,9 @@ export default class AbstractNodeModel extends BaseFileItem {

@attr('array') currentUserPermissions!: Permission[];

@hasMany('review-action', { inverse: 'target' })
reviewActions!: PromiseManyArray<ReviewActionModel>;

}

declare module 'ember-data/types/registries/model' {
Expand Down
4 changes: 3 additions & 1 deletion app/models/file-provider.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { attr, belongsTo, AsyncBelongsTo, hasMany, AsyncHasMany } from '@ember-data/model';
import PreprintModel from 'ember-osf-web/models/preprint';
import { Link } from 'jsonapi-typescript';

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

@belongsTo('abstract-node', { inverse: 'files', polymorphic: true })
target!: (AsyncBelongsTo<AbstractNodeModel> & AbstractNodeModel) |
(AsyncBelongsTo<DraftNodeModel> & DraftNodeModel);
(AsyncBelongsTo<DraftNodeModel> & DraftNodeModel) |
(AsyncBelongsTo<PreprintModel> & PreprintModel);

// BaseFileItem override
isProvider = true;
Expand Down
4 changes: 4 additions & 0 deletions app/models/license.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ export default class LicenseModel extends OsfModel {
@attr('fixstring') url!: string;
@attr('fixstring') text!: string;
@attr('array') requiredFields!: Array<keyof NodeLicense>;

get hasRequiredFields(): boolean {
return this.requiredFields?.length > 0;
}
}

declare module 'ember-data/types/registries/model' {
Expand Down
2 changes: 2 additions & 0 deletions app/models/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ export default class NodeModel extends AbstractNodeModel.extend(Validations, Col
@attr('boolean') currentUserCanComment!: boolean;
@attr('boolean') wikiEnabled!: boolean;

@hasMany('subject', { inverse: null, async: false }) subjectsAcceptable?: SubjectModel[];

// FE-only property to check enabled addons.
// null until getEnabledAddons has been called
@tracked addonsEnabled?: string[];
Expand Down
31 changes: 22 additions & 9 deletions app/models/osf-model.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Model, { attr } from '@ember-data/model';
import Store from '@ember-data/store';
import EmberArray, { A } from '@ember/array';
import EmberArray, { A, isArray } from '@ember/array';
import { assert } from '@ember/debug';
import { set } from '@ember/object';
import { alias } from '@ember/object/computed';
Expand Down Expand Up @@ -226,6 +226,13 @@ export default class OsfModel extends Model {
return this.modifyM2MRelationship('post', relationshipName, relatedModel);
}

async removeM2MRelationship<T extends OsfModel>(
this: T,
relationshipName: RelationshipsFor<T> & string,
) {
return this.modifyM2MRelationship('patch', relationshipName, []);
}

async deleteM2MRelationship<T extends OsfModel>(
this: T,
relationshipName: RelationshipsFor<T> & string,
Expand Down Expand Up @@ -266,20 +273,26 @@ export default class OsfModel extends Model {

async modifyM2MRelationship<T extends OsfModel>(
this: T,
action: 'post' | 'delete',
action: 'post' | 'delete' | 'patch',
relationshipName: RelationshipsFor<T> & string,
relatedModel: OsfModel,
relatedModel: OsfModel | [],
) {
const apiRelationshipName = underscore(relationshipName);
const url = getSelfHref(this.relationshipLinks[apiRelationshipName]);

const data = JSON.stringify({
data: [{
id: relatedModel.id,
type: relatedModel.apiType,
}],
let data = JSON.stringify({
data: [ ],
});

if (!isArray(relatedModel)) {
data = JSON.stringify({
data: [{
id: relatedModel?.id,
type: relatedModel?.apiType,
}],
});
}

if (!url) {
throw new Error(`Couldn't find self link for ${apiRelationshipName} relationship`);
}
Expand Down Expand Up @@ -353,7 +366,7 @@ export default class OsfModel extends Model {
* });
*
* contributors.sparseModels.forEach(contrib => {
* console.log(contrib.users.fullName);
* console.info(contrib.users.fullName);
* );
* ```
*/
Expand Down
1 change: 1 addition & 0 deletions app/models/preprint-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default class PreprintProviderModel extends ProviderModel {

@attr('fixstring') email_support!: string | null;
@attr('array') subjectsAcceptable!: string[];
@attr('boolean') assertionsEnabled!: boolean;
@attr('array') additionalProviders!: string[];
@attr('string') shareSource!: string;
@attr('string') preprintWord!: PreprintWord;
Expand Down
40 changes: 27 additions & 13 deletions app/models/preprint.ts
Original file line number Diff line number Diff line change
@@ -1,61 +1,75 @@
import { attr, belongsTo, hasMany, AsyncBelongsTo, AsyncHasMany } from '@ember-data/model';
import { computed } from '@ember/object';
import { alias } from '@ember/object/computed';
import AbstractNodeModel from 'ember-osf-web/models/abstract-node';
import CitationModel from 'ember-osf-web/models/citation';
import PreprintRequestModel from 'ember-osf-web/models/preprint-request';
import { ReviewsState } from 'ember-osf-web/models/provider';
import ReviewActionModel from 'ember-osf-web/models/review-action';
import InstitutionModel from 'ember-osf-web/models/institution';

import ContributorModel from './contributor';
import FileModel from './file';
import IdentifierModel from './identifier';
import LicenseModel from './license';
import NodeModel from './node';
import OsfModel, { Permission } from './osf-model';
import { Permission } from './osf-model';
import PreprintProviderModel from './preprint-provider';
import SubjectModel from './subject';

export enum PreprintDataLinksEnum {
AVAILABLE = 'available',
YES = 'yes',
NO = 'no',
NOT_APPLICABLE = 'not_applicable',
}

export enum PreprintPreregLinksEnum {
AVAILABLE = 'available',
YES = 'yes',
NO = 'no',
NOT_APPLICABLE = 'not_applicable',
}

export default class PreprintModel extends OsfModel {
export enum PreprintPreregLinkInfoEnum {
PREREG_EMPTY = '',
PREREG_DESIGNS = 'prereg_designs',
PREREG_ANALYSIS = 'prereg_analysis',
PREREG_BOTH = 'prereg_both',
}

export interface PreprintLicenseRecordModel {
copyright_holders: string[];
year: string;
}

export default class PreprintModel extends AbstractNodeModel {
@attr('fixstring') title!: string;
@attr('date') dateCreated!: Date;
@attr('date') datePublished!: Date;
@attr('date') dateWithdrawn!: Date;
@attr('date') originalPublicationDate!: Date | null;
@attr('fixstring') customPublicationCitation!: string | null;
@attr('date') dateModified!: Date;
@attr('fixstring') doi!: string | null;
@attr('boolean') public!: boolean;
@attr('boolean') isPublished!: boolean;
@attr('boolean') isPreprintOrphan!: boolean;
@attr('object') licenseRecord!: any;
@attr('object') licenseRecord!: PreprintLicenseRecordModel;
@attr('string') reviewsState!: ReviewsState;
@attr('string') description!: string;
@attr('date') dateLastTransitioned!: Date;
@attr('date') preprintDoiCreated!: Date;
@attr('array') currentUserPermissions!: Permission[];
@attr('fixstringarray') tags!: string[];
@attr('fixstring') withdrawalJustification! : string;
@attr('fixstring') withdrawalJustification!: string;
@attr('boolean') hasCoi!: boolean;
@attr('string') hasDataLinks!: PreprintDataLinksEnum;
@attr('string') hasPreregLinks!: PreprintPreregLinksEnum;
@attr('string') conflictOfInterestStatement!: string;
@attr('string') conflictOfInterestStatement!: string | null;
@attr('array') dataLinks!: string[];
@attr('array') preregLinks!: string[];
@attr('string') whyNoData!: string;
@attr('string') whyNoPrereg!: string;
@attr('string') whyNoData!: string | null;
@attr('string') whyNoPrereg!: string | null;
@attr('string') preregLinkInfo!: PreprintPreregLinkInfoEnum;

@belongsTo('node', { inverse: 'preprints' })
node!: AsyncBelongsTo<NodeModel> & NodeModel;
Expand All @@ -69,12 +83,12 @@ export default class PreprintModel extends OsfModel {
@belongsTo('preprint-provider', { inverse: 'preprints' })
provider!: AsyncBelongsTo<PreprintProviderModel> & PreprintProviderModel;

@hasMany('institution')
affiliatedInstitutions!: AsyncHasMany<InstitutionModel>;

@hasMany('review-action')
reviewActions!: AsyncHasMany<ReviewActionModel>;

@hasMany('files', { inverse: 'target'})
files!: AsyncHasMany<FileModel> & FileModel;

@hasMany('contributors', { inverse: 'preprint'})
contributors!: AsyncHasMany<ContributorModel> & ContributorModel;

Expand Down Expand Up @@ -103,7 +117,7 @@ export default class PreprintModel extends OsfModel {
@computed('license', 'licenseRecord')
get licenseText(): string {
const text = this.license.get('text') || '';
const { year = '', copyright_holders = [] } = this.licenseRecord; // eslint-disable-line camelcase
const { year = '', copyright_holders = [] } = this.licenseRecord;

return text
.replace(/({{year}})/g, year)
Expand Down
2 changes: 1 addition & 1 deletion app/models/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface Assets {
wide_white: string;
}

export enum PreprintProviderReviewsWorkFlow{
export enum PreprintProviderReviewsWorkFlow {
PRE_MODERATION = 'pre-moderation',
POST_MODERATION = 'post-moderation'
}
Expand Down
5 changes: 1 addition & 4 deletions app/models/registration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { buildValidations, validator } from 'ember-cp-validations';

import DraftRegistrationModel from 'ember-osf-web/models/draft-registration';
import ResourceModel from 'ember-osf-web/models/resource';
import ReviewActionModel, { ReviewActionTrigger } from 'ember-osf-web/models/review-action';
import { ReviewActionTrigger } from 'ember-osf-web/models/review-action';
import SchemaResponseModel, { RevisionReviewStates } from 'ember-osf-web/models/schema-response';
import { RegistrationResponse } from 'ember-osf-web/packages/registration-schema';

Expand Down Expand Up @@ -150,9 +150,6 @@ export default class RegistrationModel extends NodeModel.extend(Validations) {
@hasMany('institution', { inverse: 'registrations' })
affiliatedInstitutions!: AsyncHasMany<InstitutionModel> | InstitutionModel[];

@hasMany('review-action', { inverse: 'target' })
reviewActions!: AsyncHasMany<ReviewActionModel> | ReviewActionModel[];

@hasMany('schema-response', { inverse: 'registration' })
schemaResponses!: AsyncHasMany<SchemaResponseModel> | SchemaResponseModel[];

Expand Down
2 changes: 1 addition & 1 deletion app/models/review-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default class ReviewActionModel extends Action {
@attr('string') fromState!: RegistrationReviewStates;
@attr('string') toState!: RegistrationReviewStates;

@belongsTo('registration', { inverse: 'reviewActions', polymorphic: true })
@belongsTo('abstract-node', { inverse: 'reviewActions', polymorphic: true })
target!: (AsyncBelongsTo<RegistrationModel> & RegistrationModel
) | (AsyncBelongsTo<PreprintModel> & PreprintModel);

Expand Down
3 changes: 2 additions & 1 deletion app/packages/registration-schema/validations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { RegistrationResponse } from 'ember-osf-web/packages/registration-schema
import { SchemaBlockGroup } from 'ember-osf-web/packages/registration-schema/schema-block-group';
import { validateFileList } from 'ember-osf-web/validators/validate-response-format';
import SchemaResponseModel from 'ember-osf-web/models/schema-response';
import PreprintModel from 'ember-osf-web/models/preprint';

type LicensedContent = DraftRegistration | NodeModel;

Expand Down Expand Up @@ -131,7 +132,7 @@ export function validateNodeLicense() {
}

export function validateSubjects() {
return (_: unknown, __: unknown, ___: unknown, ____: unknown, content: DraftRegistration) => {
return (_: unknown, __: unknown, ___: unknown, ____: unknown, content: DraftRegistration | PreprintModel ) => {
const subjects = content.hasMany('subjects').value();
if (!subjects || subjects.length === 0) {
return {
Expand Down
Loading

0 comments on commit a318f33

Please sign in to comment.