Skip to content

Commit

Permalink
Merge branch 'release/24.01.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
mfraezz committed Jan 5, 2024
2 parents 2dea2ec + 85290b1 commit c1bb889
Show file tree
Hide file tree
Showing 20 changed files with 142 additions and 15 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ 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.01.0] - 2024-01-05
### Added
- Support for Disease and Data Type CollectionProvider metadata
- data-test-* tags for Preprints Selenium tests

## [23.15.0] - 2023-11-10
### Added
- Preprint detail and landing page rewrite
Expand Down
6 changes: 5 additions & 1 deletion app/models/collection-submission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export const choiceFields = tuple(
'volume',
'studyDesign',
'schoolType',
'dataType',
'disease',
);

export enum CollectionSubmissionReviewStates {
Expand Down Expand Up @@ -76,9 +78,11 @@ export default class CollectionSubmissionModel extends OsfModel.extend(Validatio
@attr('string') programArea?: string;
@attr('string') status?: string;
@attr('string') volume?: string;
@attr('string') reviewsState?: CollectionSubmissionReviewStates;
@attr('string') studyDesign?: string; // custom field for Character Lab
@attr('string') schoolType?: string; // custom field for Character Lab
@attr('string') dataType?: string;
@attr('string') disease?: string;
@attr('string') reviewsState?: CollectionSubmissionReviewStates;

@belongsTo('collection') collection!: Collection;
@belongsTo('node') guid!: Node;
Expand Down
6 changes: 5 additions & 1 deletion app/models/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ export type ChoicesFields =
'statusChoices' |
'volumeChoices' |
'studyDesignChoices' |
'schoolTypeChoices';
'schoolTypeChoices' |
'dataTypeChoices' |
'diseaseChoices';

export const choicesFields = choiceFields.map(field => `${field}Choices`) as ChoicesFields[];

Expand All @@ -32,6 +34,8 @@ export default class CollectionModel extends OsfModel {
@attr('array') volumeChoices!: string[];
@attr('array') studyDesignChoices!: string[]; // custom field for Character Lab
@attr('array') schoolTypeChoices!: string[]; // custom field for Character Lab
@attr('array') dataTypeChoices!: string[];
@attr('array') diseaseChoices!: string[];

@belongsTo('collection-provider')
provider!: AsyncBelongsTo<CollectionProviderModel> & CollectionProviderModel;
Expand Down
8 changes: 5 additions & 3 deletions app/preprints/-components/preprint-discipline/template.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<div>
<h4>{{t 'preprints.detail.disciplines'}}</h4>
{{#each this.disciplineReduced as |subject|}}
<span local-class='subject-preview'>{{subject.text}}</span>
{{/each}}
<span data-test-subjects>
{{#each this.disciplineReduced as |subject|}}
<span local-class='subject-preview'>{{subject.text}}</span>
{{/each}}
</span>
</div>
4 changes: 2 additions & 2 deletions app/preprints/-components/preprint-status-banner/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
{{else}}
<div>
<FaIcon @icon='{{this.icon}}' @prefix='far' local-class='status-icon' aria-hidden='true'/>
<strong>{{t this.status }}:</strong>
<span>{{this.bannerContent}}</span>
<strong data-test-status>{{t this.status }}:</strong>
<span data-test-status-explanation>{{this.bannerContent}}</span>
</div>
{{#if (and this.reviewerComment (not this.submission.provider.reviewsCommentsPrivate))}}
<div local-class='reviewer-feedback'>
Expand Down
8 changes: 5 additions & 3 deletions app/preprints/-components/preprint-tag/template.hbs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<div>
<h4>{{t 'preprints.detail.tags'}}</h4>
{{#if @preprint.tags.length}}
{{#each @preprint.tags as |tag|}}
<span local-class='badge'>{{tag}}</span>
{{/each}}
<span data-test-tags>
{{#each @preprint.tags as |tag|}}
<span local-class='badge'>{{tag}}</span>
{{/each}}
</span>
{{else}}
{{t 'preprints.detail.none'}}
{{/if}}
Expand Down
4 changes: 2 additions & 2 deletions app/preprints/-components/preprint-tombstone/template.hbs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<div local-class='withdrawn-container'>
{{#if @preprint.withdrawalJustification}}
<div>
<div data-test-withdrawal-justification>
<h4>{{t 'preprints.detail.reason_for_withdrawal'}}</h4>
<p>
<p data-test-justification>
{{@preprint.withdrawalJustification}}
</p>
</div>
Expand Down
12 changes: 10 additions & 2 deletions app/preprints/detail/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
local-class='preprints-details-page-container {{if this.isMobile 'mobile'}}'
{{with-branding this.model.brand}}
data-analytics-scope='preprints detail page'
data-test-preprint-header
>
<div local-class='header-container'>
<div local-class='preprint-title-container'>
<h1>{{this.model.preprint.title}}</h1>
<h1 data-test-preprint-title>{{this.model.preprint.title}}</h1>
{{#unless this.model.preprint.isWithdrawn}}
<div class='edit-preprint-button'>
{{#if (and this.userIsContrib (not this.isPendingWithdrawal))}}
Expand Down Expand Up @@ -122,7 +123,14 @@
</OsfLink>
</div>
<div>
{{t 'preprints.detail.share.views'}}: {{this.model.preprint.apiMeta.metrics.views}} | {{t 'preprints.detail.share.downloads'}}: {{this.model.preprint.apiMeta.metrics.downloads}}
<span data-test-view-count-label>
{{t 'preprints.detail.share.views'}}:
</span>
<span data-test-view-count> {{this.model.preprint.apiMeta.metrics.views}} </span> |
<span data-test-download-count-label>
{{t 'preprints.detail.share.downloads'}}:
</span>
<span data-test-download-count>{{this.model.preprint.apiMeta.metrics.downloads}}</span>
<EmberTooltip>
{{t 'preprints.detail.share.metrics_disclaimer'}} {{moment-format this.metricsStartDate 'YYYY-MM-DD'}}
</EmberTooltip>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{{#each @context.activeFilter as |item|}}
<DiscoverPage::ActiveFilters::Filter
@item={{item}}
@text={{item}}
@ariaLabel={{t 'collections.discover_page.active_filters.remove_data_type'}}
@removeFilterItem={{action this.removeFilterItem item}}
/>
{{/each}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{{#each @context.activeFilter as |item|}}
<DiscoverPage::ActiveFilters::Filter
@item={{item}}
@text={{item}}
@ariaLabel={{t 'collections.discover_page.active_filters.remove_disease'}}
@removeFilterItem={{action this.removeFilterItem item}}
/>
{{/each}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Collection from 'ember-osf-web/models/collection';
import SearchFacetChecklist from '../checklist/component';

class DataType extends SearchFacetChecklist {
get modelAttribute(): keyof Collection {
return 'dataTypeChoices';
}
get filterProperty() {
return 'dataType';
}
}

export default DataType;
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Collection from 'ember-osf-web/models/collection';
import SearchFacetChecklist from '../checklist/component';

class Disease extends SearchFacetChecklist {
get modelAttribute(): keyof Collection {
return 'diseaseChoices';
}
get filterProperty() {
return 'disease';
}
}

export default Disease;
4 changes: 4 additions & 0 deletions lib/collections/addon/discover/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ export default class Discover extends Controller {
['volume', 'volume'],
['study-design', 'study-design'],
['school-type', 'school-type'],
['data-type', 'data-type'],
['disease', 'disease'],
]
).map(([key, component, options = {}]: [string, string, any]) => ({
key,
Expand Down Expand Up @@ -105,6 +107,8 @@ export default class Discover extends Controller {
volume = '';
studyDesign = '';
schoolType = '';
dataType = '';
disease = '';

// Pass in the list of queryParams for this component
queryParams = [
Expand Down
8 changes: 8 additions & 0 deletions mirage/factories/collection-submission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ export default Factory.extend<MirageCollectionSubmission>({
const schoolType = faker.random.arrayElement(collectionSubmission.collection.schoolTypeChoices);
collectionSubmission.update({ schoolType });
}
if (!collectionSubmission.dataType) {
const dataType = faker.random.arrayElement(collectionSubmission.collection.dataTypeChoices);
collectionSubmission.update({ dataType });
}
if (!collectionSubmission.disease) {
const disease = faker.random.arrayElement(collectionSubmission.collection.diseaseChoices);
collectionSubmission.update({ disease });
}
/**
* Autogenerate the necessary collection submission action business
* logic
Expand Down
2 changes: 2 additions & 0 deletions mirage/factories/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export default Factory.extend<MirageCollection>({
programAreaChoices: [faker.lorem.word(), faker.lorem.word()],
studyDesignChoices: [faker.lorem.word(), faker.lorem.word()],
schoolTypeChoices: [faker.lorem.word(), faker.lorem.word()],
dataTypeChoices: [faker.lorem.word(), faker.lorem.word()],
diseaseChoices: [faker.lorem.word(), faker.lorem.word()],
});

declare module 'ember-cli-mirage/types/registries/model' {
Expand Down
16 changes: 16 additions & 0 deletions mirage/views/collection-search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export function searchCollections(this: HandlerContext, schema: Schema, request:
volume,
schoolType,
studyDesign,
dataType,
disease,
provider,
},
},
Expand Down Expand Up @@ -83,6 +85,20 @@ export function searchCollections(this: HandlerContext, schema: Schema, request:
),
);
}
if (dataType) {
collectionSubmissions = collectionSubmissions.filter(
(item: ModelInstance<CollectionSubmission>) => dataType.any(
(value: string) => item.attrs.dataType === value,
),
);
}
if (disease) {
collectionSubmissions = collectionSubmissions.filter(
(item: ModelInstance<CollectionSubmission>) => disease.any(
(value: string) => item.attrs.disease === value,
),
);
}
if (request.queryParams.sort) {
switch (request.queryParams.sort) {
case 'modified':
Expand Down
6 changes: 6 additions & 0 deletions mirage/views/collection-submission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export function createCollectionSubmission(this: HandlerContext, schema: Schema)
volume,
schoolType,
studyDesign,
dataType,
disease,
} = attrs;
const userId = schema.roots.first().currentUserId;
const currentUser = schema.users.find(userId!);
Expand All @@ -61,6 +63,8 @@ export function createCollectionSubmission(this: HandlerContext, schema: Schema)
volume,
schoolType,
studyDesign,
dataType,
disease,
guid: guidModel,
collection: collectionModel,
creator: currentUser,
Expand All @@ -78,6 +82,8 @@ export function createCollectionSubmission(this: HandlerContext, schema: Schema)
volume,
schoolType,
studyDesign,
dataType,
disease,
});

schema.collectionSubmissionActions.create({
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ember-osf-web",
"version": "23.15.3",
"version": "24.01.0",
"private": true,
"description": "Ember front-end for the Open Science Framework",
"homepage": "https://github.com/CenterForOpenScience/ember-osf-web#readme",
Expand Down
18 changes: 18 additions & 0 deletions tests/engines/collections/acceptance/submit/submit-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,22 @@ module('Collections | Acceptance | submit', hooks => {
throw new Error('could not find study design option');
}

await untrackedClick('[data-test-metadata-field="data_type_label"] .ember-power-select-trigger');
const firstDataTypeOption = document.querySelector('.ember-power-select-option');
if (firstDataTypeOption) {
await untrackedClick(firstDataTypeOption);
} else {
throw new Error('could not find data type option');
}

await untrackedClick('[data-test-metadata-field="disease_label"] .ember-power-select-trigger');
const firstDiseaseOption = document.querySelector('.ember-power-select-option');
if (firstDiseaseOption) {
await untrackedClick(firstDiseaseOption);
} else {
throw new Error('could not find disease option');
}

assert.dom('[data-test-collection-metadata] [data-test-submit-section-continue]')
.isNotDisabled('metadata continue is not disabled');
await untrackedClick('[data-test-collection-metadata] [data-test-submit-section-continue]');
Expand Down Expand Up @@ -233,6 +249,8 @@ module('Collections | Acceptance | submit', hooks => {
programAreaChoices: [],
studyDesignChoices: [],
schoolTypeChoices: [],
dataTypeChoices: [],
diseaseChoices: [],
});
const nodeAlreadyAdded = server.create('node', {
title: 'Node to be added to collection',
Expand Down
6 changes: 6 additions & 0 deletions translations/en-us.yml
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,8 @@ collections:
volume: Volume
study_design: 'Study Design'
school_type: 'School Type'
data_type: 'Data Type'
disease: Disease
collections_submission:
title: Submit
add_header: 'Add to Collection'
Expand Down Expand Up @@ -1043,6 +1045,8 @@ collections:
volume_label: 'Volume:'
study_design_label: 'Study Design:'
school_type_label: 'School Type:'
data_type_label: 'Data Type:'
disease_label: 'Disease:'
collection_search_result:
expand: 'Expand search result'
collapse: 'Collapse search result'
Expand All @@ -1058,6 +1062,8 @@ collections:
remove_school_type: 'Remove school type'
remove_study_design: 'Remove study design'
remove_volume: 'Remove volume'
remove_data_type: 'Remove data type'
remove_disease: 'Remove disease'
asOf: 'as of'
broadenSearch: 'Try broadening your search terms'
date: Date
Expand Down

0 comments on commit c1bb889

Please sign in to comment.