From a8b8f89dadfcc92ff40e5379fa996cf87684dc69 Mon Sep 17 00:00:00 2001 From: futa-ikeda <51409893+futa-ikeda@users.noreply.github.com> Date: Wed, 19 Apr 2023 11:05:22 -0400 Subject: [PATCH 001/170] [ENG-4450] Add new share-search models (#1835) - Ticket: [ENG-4450] - Feature flag: n/a - Add new models needed for SHARE-powered search page - Add new models - `metadata-record-search` - `metadata-property-search` - `metadata-value-search` - `metadata-record` - `search-match` - New `ShareAdapter` and `ShareSerializer` to be used by these new models - New mirage endpoint for metadata-record-search (other endpoints coming later) --- app/adapters/metadata-property-search.ts | 10 ++++++++ app/adapters/metadata-record-search.ts | 9 +++++++ app/adapters/metadata-record.ts | 10 ++++++++ app/adapters/metadata-value-search.ts | 10 ++++++++ app/models/metadata-property-search.ts | 21 ++++++++++++++++ app/models/metadata-record-search.ts | 28 +++++++++++++++++++++ app/models/metadata-record.ts | 21 ++++++++++++++++ app/models/metadata-value-search.ts | 25 ++++++++++++++++++ app/serializers/metadata-property-search.ts | 10 ++++++++ app/serializers/metadata-record-search.ts | 10 ++++++++ app/serializers/metadata-record.ts | 10 ++++++++ app/serializers/metadata-value-search.ts | 10 ++++++++ 12 files changed, 174 insertions(+) create mode 100644 app/adapters/metadata-property-search.ts create mode 100644 app/adapters/metadata-record-search.ts create mode 100644 app/adapters/metadata-record.ts create mode 100644 app/adapters/metadata-value-search.ts create mode 100644 app/models/metadata-property-search.ts create mode 100644 app/models/metadata-record-search.ts create mode 100644 app/models/metadata-record.ts create mode 100644 app/models/metadata-value-search.ts create mode 100644 app/serializers/metadata-property-search.ts create mode 100644 app/serializers/metadata-record-search.ts create mode 100644 app/serializers/metadata-record.ts create mode 100644 app/serializers/metadata-value-search.ts diff --git a/app/adapters/metadata-property-search.ts b/app/adapters/metadata-property-search.ts new file mode 100644 index 00000000000..a1b399e109d --- /dev/null +++ b/app/adapters/metadata-property-search.ts @@ -0,0 +1,10 @@ +import ShareAdapter from './share-adapter'; + +export default class MetadataPropertySearchAdapter extends ShareAdapter { +} + +declare module 'ember-data/types/registries/adapter' { + export default interface AdapterRegistry { + 'metadata-property-search': MetadataPropertySearchAdapter; + } // eslint-disable-line semi +} diff --git a/app/adapters/metadata-record-search.ts b/app/adapters/metadata-record-search.ts new file mode 100644 index 00000000000..6049cfaaf99 --- /dev/null +++ b/app/adapters/metadata-record-search.ts @@ -0,0 +1,9 @@ +import ShareAdapter from './share-adapter'; +export default class MetadataRecordSearchAdapter extends ShareAdapter { +} + +declare module 'ember-data/types/registries/adapter' { + export default interface AdapterRegistry { + 'metadata-record-search': MetadataRecordSearchAdapter; + } // eslint-disable-line semi +} diff --git a/app/adapters/metadata-record.ts b/app/adapters/metadata-record.ts new file mode 100644 index 00000000000..dfbf851870e --- /dev/null +++ b/app/adapters/metadata-record.ts @@ -0,0 +1,10 @@ +import ShareAdapter from './share-adapter'; + +export default class MetadataRecordAdapter extends ShareAdapter { +} + +declare module 'ember-data/types/registries/adapter' { + export default interface AdapterRegistry { + 'metadata-record': MetadataRecordAdapter; + } // eslint-disable-line semi +} diff --git a/app/adapters/metadata-value-search.ts b/app/adapters/metadata-value-search.ts new file mode 100644 index 00000000000..e1e021292df --- /dev/null +++ b/app/adapters/metadata-value-search.ts @@ -0,0 +1,10 @@ +import ShareAdapter from './share-adapter'; + +export default class MetadataValueSearchAdapter extends ShareAdapter { +} + +declare module 'ember-data/types/registries/adapter' { + export default interface AdapterRegistry { + 'metadata-value-search': MetadataValueSearchAdapter; + } // eslint-disable-line semi +} diff --git a/app/models/metadata-property-search.ts b/app/models/metadata-property-search.ts new file mode 100644 index 00000000000..744ced694ba --- /dev/null +++ b/app/models/metadata-property-search.ts @@ -0,0 +1,21 @@ +import Model, { AsyncHasMany, attr, hasMany } from '@ember-data/model'; + +import { SearchFilter } from './metadata-record-search'; +import SearchResultModel from './search-result'; + +export default class MetadataPropertySearchModel extends Model { + @attr('string') propertySearchText!: string; + @attr('array') propertySearchFilter!: SearchFilter[]; + @attr('string') recordSearchText!: string; + @attr('array') recordSearchFilter!: SearchFilter[]; + @attr('number') totalResultCount!: number; + + @hasMany('search-result', { inverse: null }) + searchResultPage!: AsyncHasMany & SearchResultModel[]; +} + +declare module 'ember-data/types/registries/model' { + export default interface ModelRegistry { + 'metadata-property-search': MetadataPropertySearchModel; + } // eslint-disable-line semi +} diff --git a/app/models/metadata-record-search.ts b/app/models/metadata-record-search.ts new file mode 100644 index 00000000000..199301e0461 --- /dev/null +++ b/app/models/metadata-record-search.ts @@ -0,0 +1,28 @@ +import Model, { AsyncBelongsTo, AsyncHasMany, attr, belongsTo, hasMany } from '@ember-data/model'; + +import MetadataPropertySearchModel from './metadata-property-search'; +import SearchResultModel from './search-result'; + +export interface SearchFilter { + propertyPath: string; + filterValue: string[]; + filterType?: string; +} + +export default class MetadataRecordSearchModel extends Model { + @attr('string') recordSearchText!: string; + @attr('array') recordSearchFilters!: SearchFilter[]; + @attr('number') totalResultCount!: number; + + @hasMany('search-result', { inverse: null }) + searchResultPage!: AsyncHasMany & SearchResultModel[]; + + @belongsTo('metadata-property-search', { inverse: null }) + relatedPropertySearch!: AsyncBelongsTo & MetadataPropertySearchModel; +} + +declare module 'ember-data/types/registries/model' { + export default interface ModelRegistry { + 'metadata-record-search': MetadataRecordSearchModel; + } // eslint-disable-line semi +} diff --git a/app/models/metadata-record.ts b/app/models/metadata-record.ts new file mode 100644 index 00000000000..e6480363a39 --- /dev/null +++ b/app/models/metadata-record.ts @@ -0,0 +1,21 @@ +import Model, { AsyncHasMany, attr, hasMany } from '@ember-data/model'; + +export interface LanguageText { + '@language': string; + '@value': string; +} + +export default class MetadataRecordModel extends Model { + @attr('array') resourceType!: string[]; + @attr('array') resourceIdentifier!: string[]; + @attr('object') resourceMetadata!: any; + + @hasMany('metadata-record', { inverse: null }) + relatedRecordSet!: AsyncHasMany & MetadataRecordModel[]; +} + +declare module 'ember-data/types/registries/model' { + export default interface ModelRegistry { + 'metadata-record': MetadataRecordModel; + } // eslint-disable-line semi +} diff --git a/app/models/metadata-value-search.ts b/app/models/metadata-value-search.ts new file mode 100644 index 00000000000..cc97695694a --- /dev/null +++ b/app/models/metadata-value-search.ts @@ -0,0 +1,25 @@ +import Model, { AsyncHasMany, AsyncBelongsTo, attr, belongsTo, hasMany } from '@ember-data/model'; + +import MetadataPropertySearchModel from './metadata-property-search'; +import { SearchFilter } from './metadata-record-search'; +import SearchResultModel from './search-result'; + +export default class MetadataValueSearchModel extends Model { + @attr('string') valueSearchText!: string; + @attr('array') valueSearchFilter!: SearchFilter[]; + @attr('string') recordSearchText!: string; + @attr('array') recordSearchFilter!: SearchFilter[]; + @attr('number') totalResultCount!: number; + + @hasMany('search-result', { inverse: null }) + searchResultPage!: AsyncHasMany & SearchResultModel[]; + + @belongsTo('metadata-property-search', { inverse: null }) + relatedPropertySearch!: AsyncBelongsTo & MetadataPropertySearchModel; +} + +declare module 'ember-data/types/registries/model' { + export default interface ModelRegistry { + 'metadata-value-search': MetadataValueSearchModel; + } // eslint-disable-line semi +} diff --git a/app/serializers/metadata-property-search.ts b/app/serializers/metadata-property-search.ts new file mode 100644 index 00000000000..6751421b625 --- /dev/null +++ b/app/serializers/metadata-property-search.ts @@ -0,0 +1,10 @@ +import ShareSerializer from './share-serializer'; + +export default class MetadataPropertySearchSerializer extends ShareSerializer { +} + +declare module 'ember-data/types/registries/serializer' { + export default interface SerializerRegistry { + 'metadata-property-search': MetadataPropertySearchSerializer; + } // eslint-disable-line semi +} diff --git a/app/serializers/metadata-record-search.ts b/app/serializers/metadata-record-search.ts new file mode 100644 index 00000000000..c868b4c2edc --- /dev/null +++ b/app/serializers/metadata-record-search.ts @@ -0,0 +1,10 @@ +import ShareSerializer from './share-serializer'; + +export default class MetadataRecordSearchSerializer extends ShareSerializer { +} + +declare module 'ember-data/types/registries/serializer' { + export default interface SerializerRegistry { + 'metadata-record-search': MetadataRecordSearchSerializer; + } // eslint-disable-line semi +} diff --git a/app/serializers/metadata-record.ts b/app/serializers/metadata-record.ts new file mode 100644 index 00000000000..a91a8e27bdc --- /dev/null +++ b/app/serializers/metadata-record.ts @@ -0,0 +1,10 @@ +import ShareSerializer from './share-serializer'; + +export default class MetadataRecordSerializer extends ShareSerializer { +} + +declare module 'ember-data/types/registries/serializer' { + export default interface SerializerRegistry { + 'metadata-record': MetadataRecordSerializer; + } // eslint-disable-line semi +} diff --git a/app/serializers/metadata-value-search.ts b/app/serializers/metadata-value-search.ts new file mode 100644 index 00000000000..655a3f882cb --- /dev/null +++ b/app/serializers/metadata-value-search.ts @@ -0,0 +1,10 @@ +import ShareSerializer from './share-serializer'; + +export default class MetadataValueSearchSerializer extends ShareSerializer { +} + +declare module 'ember-data/types/registries/serializer' { + export default interface SerializerRegistry { + 'metadata-value-search': MetadataValueSearchSerializer; + } // eslint-disable-line semi +} From 9426827f700e35e2e9e14a03670ad398160d1a5a Mon Sep 17 00:00:00 2001 From: futa-ikeda <51409893+futa-ikeda@users.noreply.github.com> Date: Mon, 24 Apr 2023 10:23:48 -0400 Subject: [PATCH 002/170] Add basic search page layout (#1850) --- app/search/styles.scss | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 app/search/styles.scss diff --git a/app/search/styles.scss b/app/search/styles.scss new file mode 100644 index 00000000000..d08096b4ca6 --- /dev/null +++ b/app/search/styles.scss @@ -0,0 +1,34 @@ +.search-page { + background-color: $color-bg-gray; +} + +.heading-wrapper { + text-align: center; + color: $color-text-white; + background-color: $osf-dark-blue-navbar; +} + +.heading-label { + font-size: 1.5em; + font-weight: 400; + padding: 40px; +} + +.search-input { + color: $color-text-black; + padding: 9px 5px; + font-size: 1.5em; + max-width: 700px; + min-width: 250px; + width: 50vw; +} + +.search-button { + position: relative; + right: 3px; + bottom: 4px; +} + +.sidenav-toggle { + float: left; +} From b6cb9c4d9cb17f8c934edaa52d4ab59bd72bf6d7 Mon Sep 17 00:00:00 2001 From: futa-ikeda <51409893+futa-ikeda@users.noreply.github.com> Date: Mon, 15 May 2023 11:03:09 -0400 Subject: [PATCH 003/170] [ENG-4465] Left panel facets manager (#1858) - Ticket: [ENG-4465] [ENG-4466] - Feature flag: n/a - Add logic to search page controller to handle active filters and list of filterable properties - Add a component to handle fetching values in a filterable properties in the search page - Add a `filter-facet` component - takes care of fetching filterable property values - `See more` modal --- app/models/metadata-record.ts | 36 ++++++ .../-components/filter-facet/component.ts | 83 ++++++++++++++ .../-components/filter-facet/styles.scss | 40 +++++++ .../-components/filter-facet/template.hbs | 105 ++++++++++++++++++ app/search/route.ts | 2 + app/search/styles.scss | 22 +++- translations/en-us.yml | 1 + 7 files changed, 287 insertions(+), 2 deletions(-) create mode 100644 app/search/-components/filter-facet/component.ts create mode 100644 app/search/-components/filter-facet/styles.scss create mode 100644 app/search/-components/filter-facet/template.hbs diff --git a/app/models/metadata-record.ts b/app/models/metadata-record.ts index e6480363a39..0094bd8ea7d 100644 --- a/app/models/metadata-record.ts +++ b/app/models/metadata-record.ts @@ -1,4 +1,6 @@ +import { inject as service } from '@ember/service'; import Model, { AsyncHasMany, attr, hasMany } from '@ember-data/model'; +import IntlService from 'ember-intl/services/intl'; export interface LanguageText { '@language': string; @@ -6,12 +8,46 @@ export interface LanguageText { } export default class MetadataRecordModel extends Model { + @service intl!: IntlService; + @attr('array') resourceType!: string[]; @attr('array') resourceIdentifier!: string[]; @attr('object') resourceMetadata!: any; @hasMany('metadata-record', { inverse: null }) relatedRecordSet!: AsyncHasMany & MetadataRecordModel[]; + + get label(): string { + const { resourceMetadata } = this; + const preferredLanguage = this.intl.locale; + const labels = resourceMetadata?.label; + if (labels) { + const languageAppropriateLabel = labels.filter((label: any) => label['@language'] === preferredLanguage); + // give the locale appropriate label if it exists, otherwise give the first label + if (languageAppropriateLabel.length > 0) { + return labels.filter((label: any) => label['@language'] === preferredLanguage)[0]['@value']; + } else if (labels.length > 0) { + return labels[0]['@value']; + } + } + return this.intl.t('search.metadata-record.no-label'); + } + + get title(): string { + const { resourceMetadata } = this; + const preferredLanguage = this.intl.locale; + const titles = resourceMetadata?.title; + if (titles) { + const languageAppropriateTitle = titles.filter((title: any) => title['@language'] === preferredLanguage); + // give the locale appropriate title if it exists, otherwise give the first title + if (languageAppropriateTitle.length > 0) { + return titles.filter((title: any) => title['@language'] === preferredLanguage)[0]['@value']; + } else if (titles.length > 0) { + return titles[0]['@value']; + } + } + return this.intl.t('search.metadata-record.no-title'); + } } declare module 'ember-data/types/registries/model' { diff --git a/app/search/-components/filter-facet/component.ts b/app/search/-components/filter-facet/component.ts new file mode 100644 index 00000000000..008553507b8 --- /dev/null +++ b/app/search/-components/filter-facet/component.ts @@ -0,0 +1,83 @@ +import Store from '@ember-data/store'; +import { action } from '@ember/object'; +import { inject as service } from '@ember/service'; +import { waitFor } from '@ember/test-waiters'; +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { task } from 'ember-concurrency'; +import { taskFor } from 'ember-concurrency-ts'; +import IntlService from 'ember-intl/services/intl'; + +import MetadataRecordModel from 'ember-osf-web/models/metadata-record'; +import SearchResultModel from 'ember-osf-web/models/search-result'; + +import { Filter } from '../../controller'; + +interface FilterFacetArgs { + recordSearchText: string; + recordSearchFilters: Filter[]; + propertyRecord: MetadataRecordModel; + propertySearch: SearchResultModel; + toggleFilter: (filter: Filter) => void; +} + +export default class FilterFacet extends Component { + @service store!: Store; + @service intl!: IntlService; + @service toast!: Toastr; + + @tracked page = 1; + @tracked sort = '-relevance'; + @tracked collapsed = true; + @tracked filterableValues: SearchResultModel[] = []; + @tracked seeMoreModalShown = false; + @tracked selectedProperty: SearchResultModel | null = null; + + get showSeeMoreButton() { + // TODO: make this actually check if there are more + return true; + } + + @action + toggleFacet() { + if (this.filterableValues.length === 0 && !taskFor(this.fetchFacetValues).lastComplete) { + taskFor(this.fetchFacetValues).perform(); + } + this.collapsed = !this.collapsed; + } + + @action + updateSelectedProperty(property: SearchResultModel) { + this.selectedProperty = property; + } + + @task + @waitFor + async applySelectedProperty() { + if (this.selectedProperty) { + const { toggleFilter, propertyRecord } = this.args; + const record = await this.selectedProperty.metadataRecord; + const filter = { + property: propertyRecord.get('label'), + value: record.title, + }; + toggleFilter(filter); + this.selectedProperty = null; + } + } + + @task + @waitFor + async fetchFacetValues() { + const { recordSearchText, recordSearchFilters } = this.args; + const { page, sort } = this; + const valueSearch = await this.store.queryRecord('metadata-value-search', { + recordSearchText, + recordSearchFilters, + page, + sort, + }); + const results = valueSearch.get('searchResultPage').toArray(); + this.filterableValues = results; + } +} diff --git a/app/search/-components/filter-facet/styles.scss b/app/search/-components/filter-facet/styles.scss new file mode 100644 index 00000000000..dcc89e22e45 --- /dev/null +++ b/app/search/-components/filter-facet/styles.scss @@ -0,0 +1,40 @@ +.facet-wrapper { + border-top: 1px solid $color-border-gray; + padding: 0.5rem 0; +} + +.facet-expand-button { + display: flex; + justify-content: space-between; + align-items: center; + width: 100%; + + &:active { + box-shadow: none; + } +} + +.facet-list { + padding: 0; + margin: 0; + list-style: none; + + &.collapsed { + display: none; + } +} + +.facet-value { + margin: 10px 0; + display: flex; + justify-content: space-between; + + .facet-link, + .facet-count { + margin: 0 5px; + } +} + +.see-more-dialog { + min-width: 50vw; +} diff --git a/app/search/-components/filter-facet/template.hbs b/app/search/-components/filter-facet/template.hbs new file mode 100644 index 00000000000..260f5ec9e6b --- /dev/null +++ b/app/search/-components/filter-facet/template.hbs @@ -0,0 +1,105 @@ +
+ {{#let (unique-id @propertyRecord.label) as |facetElementId|}} + + {{#if this.fetchFacetValues.isRunning}} + + {{else if this.fetchFacetValues.isError}} + {{t 'search.filter-facet.facet-load-failed'}} + {{else}} +
    + {{#each this.filterableValues as |value|}} +
  • + + + {{value.recordResultCount}} + +
  • + {{/each}} + + {{#if this.showSeeMoreButton}} +
  • + +
  • + {{/if}} +
+ {{/if}} + + + {{@propertyRecord.label}} + + + {{t 'search.filter-facet.see-more-modal-text'}} + + {{property.metadataRecord.title}} + + + + + + + + {{/let}} +
diff --git a/app/search/route.ts b/app/search/route.ts index 0a451bd304d..fbb0689f98d 100644 --- a/app/search/route.ts +++ b/app/search/route.ts @@ -1,5 +1,7 @@ import Route from '@ember/routing/route'; +import SearchController from './controller'; + export default class Search extends Route { buildRouteInfoMetadata() { return { diff --git a/app/search/styles.scss b/app/search/styles.scss index d08096b4ca6..b0b1b98f406 100644 --- a/app/search/styles.scss +++ b/app/search/styles.scss @@ -9,11 +9,13 @@ } .heading-label { - font-size: 1.5em; - font-weight: 400; padding: 40px; } +.search-input-wrapper { + white-space: nowrap; +} + .search-input { color: $color-text-black; padding: 9px 5px; @@ -32,3 +34,19 @@ .sidenav-toggle { float: left; } + +.left-panel { + padding-left: 12px; + width: 300px; +} + +.active-filter-list { + padding-left: 0; + list-style: none; +} + +.active-filter-item { + display: flex; + justify-content: space-between; +} + diff --git a/translations/en-us.yml b/translations/en-us.yml index 99c02c3ec78..73fe9bd67a9 100644 --- a/translations/en-us.yml +++ b/translations/en-us.yml @@ -38,6 +38,7 @@ general: add: Add ok: OK apply: Apply + apply: Apply revisions: Revisions md5: MD5 date: Date From 7f120958a411f6ccab70ee3ec3f9563a3026af36 Mon Sep 17 00:00:00 2001 From: futa-ikeda <51409893+futa-ikeda@users.noreply.github.com> Date: Tue, 23 May 2023 14:17:53 -0400 Subject: [PATCH 004/170] [ENG-4469] Add object filter and sort dropdown to search (#1864) - Ticket: [ENG-4469] - Feature flag: n/a - Add object type filter and sort dropdown to search page - Add tabs to filter by object type (All, Projects, Registrations, Preprints, Files, Users) - Add dropdown to sort results by Relevance, Date modified/created ascending and descending - Change model names to reflect more library-analogy based names - Change how metadata properties are fetched from SHARE models --- ...lue-search.ts => index-property-search.ts} | 4 +- app/adapters/metadata-property-search.ts | 10 - app/adapters/metadata-record-search.ts | 9 - app/adapters/metadata-record.ts | 10 - ...rty-search.ts => index-property-search.ts} | 10 +- app/models/metadata-record-search.ts | 28 --- app/models/metadata-record.ts | 57 ----- app/models/metadata-value-search.ts | 25 --- .../-components/filter-facet/component.ts | 28 +-- .../-components/filter-facet/template.hbs | 198 +++++++++--------- app/search/styles.scss | 38 +++- ...lue-search.ts => index-property-search.ts} | 4 +- app/serializers/metadata-property-search.ts | 10 - app/serializers/metadata-record-search.ts | 10 - app/serializers/metadata-record.ts | 10 - mirage/config.ts | 4 + 16 files changed, 167 insertions(+), 288 deletions(-) rename app/adapters/{metadata-value-search.ts => index-property-search.ts} (60%) delete mode 100644 app/adapters/metadata-property-search.ts delete mode 100644 app/adapters/metadata-record-search.ts delete mode 100644 app/adapters/metadata-record.ts rename app/models/{metadata-property-search.ts => index-property-search.ts} (65%) delete mode 100644 app/models/metadata-record-search.ts delete mode 100644 app/models/metadata-record.ts delete mode 100644 app/models/metadata-value-search.ts rename app/serializers/{metadata-value-search.ts => index-property-search.ts} (62%) delete mode 100644 app/serializers/metadata-property-search.ts delete mode 100644 app/serializers/metadata-record-search.ts delete mode 100644 app/serializers/metadata-record.ts diff --git a/app/adapters/metadata-value-search.ts b/app/adapters/index-property-search.ts similarity index 60% rename from app/adapters/metadata-value-search.ts rename to app/adapters/index-property-search.ts index e1e021292df..3bec7157b32 100644 --- a/app/adapters/metadata-value-search.ts +++ b/app/adapters/index-property-search.ts @@ -1,10 +1,10 @@ import ShareAdapter from './share-adapter'; -export default class MetadataValueSearchAdapter extends ShareAdapter { +export default class IndexPropertySearchAdapter extends ShareAdapter { } declare module 'ember-data/types/registries/adapter' { export default interface AdapterRegistry { - 'metadata-value-search': MetadataValueSearchAdapter; + 'index-property-search': IndexPropertySearchAdapter; } // eslint-disable-line semi } diff --git a/app/adapters/metadata-property-search.ts b/app/adapters/metadata-property-search.ts deleted file mode 100644 index a1b399e109d..00000000000 --- a/app/adapters/metadata-property-search.ts +++ /dev/null @@ -1,10 +0,0 @@ -import ShareAdapter from './share-adapter'; - -export default class MetadataPropertySearchAdapter extends ShareAdapter { -} - -declare module 'ember-data/types/registries/adapter' { - export default interface AdapterRegistry { - 'metadata-property-search': MetadataPropertySearchAdapter; - } // eslint-disable-line semi -} diff --git a/app/adapters/metadata-record-search.ts b/app/adapters/metadata-record-search.ts deleted file mode 100644 index 6049cfaaf99..00000000000 --- a/app/adapters/metadata-record-search.ts +++ /dev/null @@ -1,9 +0,0 @@ -import ShareAdapter from './share-adapter'; -export default class MetadataRecordSearchAdapter extends ShareAdapter { -} - -declare module 'ember-data/types/registries/adapter' { - export default interface AdapterRegistry { - 'metadata-record-search': MetadataRecordSearchAdapter; - } // eslint-disable-line semi -} diff --git a/app/adapters/metadata-record.ts b/app/adapters/metadata-record.ts deleted file mode 100644 index dfbf851870e..00000000000 --- a/app/adapters/metadata-record.ts +++ /dev/null @@ -1,10 +0,0 @@ -import ShareAdapter from './share-adapter'; - -export default class MetadataRecordAdapter extends ShareAdapter { -} - -declare module 'ember-data/types/registries/adapter' { - export default interface AdapterRegistry { - 'metadata-record': MetadataRecordAdapter; - } // eslint-disable-line semi -} diff --git a/app/models/metadata-property-search.ts b/app/models/index-property-search.ts similarity index 65% rename from app/models/metadata-property-search.ts rename to app/models/index-property-search.ts index 744ced694ba..c87fe60feb6 100644 --- a/app/models/metadata-property-search.ts +++ b/app/models/index-property-search.ts @@ -1,13 +1,13 @@ import Model, { AsyncHasMany, attr, hasMany } from '@ember-data/model'; -import { SearchFilter } from './metadata-record-search'; +import { SearchFilter } from './index-card-search'; import SearchResultModel from './search-result'; -export default class MetadataPropertySearchModel extends Model { +export default class IndexPropertySearchModel extends Model { @attr('string') propertySearchText!: string; @attr('array') propertySearchFilter!: SearchFilter[]; - @attr('string') recordSearchText!: string; - @attr('array') recordSearchFilter!: SearchFilter[]; + @attr('string') cardSearchText!: string; + @attr('array') cardSearchFilter!: SearchFilter[]; @attr('number') totalResultCount!: number; @hasMany('search-result', { inverse: null }) @@ -16,6 +16,6 @@ export default class MetadataPropertySearchModel extends Model { declare module 'ember-data/types/registries/model' { export default interface ModelRegistry { - 'metadata-property-search': MetadataPropertySearchModel; + 'index-property-search': IndexPropertySearchModel; } // eslint-disable-line semi } diff --git a/app/models/metadata-record-search.ts b/app/models/metadata-record-search.ts deleted file mode 100644 index 199301e0461..00000000000 --- a/app/models/metadata-record-search.ts +++ /dev/null @@ -1,28 +0,0 @@ -import Model, { AsyncBelongsTo, AsyncHasMany, attr, belongsTo, hasMany } from '@ember-data/model'; - -import MetadataPropertySearchModel from './metadata-property-search'; -import SearchResultModel from './search-result'; - -export interface SearchFilter { - propertyPath: string; - filterValue: string[]; - filterType?: string; -} - -export default class MetadataRecordSearchModel extends Model { - @attr('string') recordSearchText!: string; - @attr('array') recordSearchFilters!: SearchFilter[]; - @attr('number') totalResultCount!: number; - - @hasMany('search-result', { inverse: null }) - searchResultPage!: AsyncHasMany & SearchResultModel[]; - - @belongsTo('metadata-property-search', { inverse: null }) - relatedPropertySearch!: AsyncBelongsTo & MetadataPropertySearchModel; -} - -declare module 'ember-data/types/registries/model' { - export default interface ModelRegistry { - 'metadata-record-search': MetadataRecordSearchModel; - } // eslint-disable-line semi -} diff --git a/app/models/metadata-record.ts b/app/models/metadata-record.ts deleted file mode 100644 index 0094bd8ea7d..00000000000 --- a/app/models/metadata-record.ts +++ /dev/null @@ -1,57 +0,0 @@ -import { inject as service } from '@ember/service'; -import Model, { AsyncHasMany, attr, hasMany } from '@ember-data/model'; -import IntlService from 'ember-intl/services/intl'; - -export interface LanguageText { - '@language': string; - '@value': string; -} - -export default class MetadataRecordModel extends Model { - @service intl!: IntlService; - - @attr('array') resourceType!: string[]; - @attr('array') resourceIdentifier!: string[]; - @attr('object') resourceMetadata!: any; - - @hasMany('metadata-record', { inverse: null }) - relatedRecordSet!: AsyncHasMany & MetadataRecordModel[]; - - get label(): string { - const { resourceMetadata } = this; - const preferredLanguage = this.intl.locale; - const labels = resourceMetadata?.label; - if (labels) { - const languageAppropriateLabel = labels.filter((label: any) => label['@language'] === preferredLanguage); - // give the locale appropriate label if it exists, otherwise give the first label - if (languageAppropriateLabel.length > 0) { - return labels.filter((label: any) => label['@language'] === preferredLanguage)[0]['@value']; - } else if (labels.length > 0) { - return labels[0]['@value']; - } - } - return this.intl.t('search.metadata-record.no-label'); - } - - get title(): string { - const { resourceMetadata } = this; - const preferredLanguage = this.intl.locale; - const titles = resourceMetadata?.title; - if (titles) { - const languageAppropriateTitle = titles.filter((title: any) => title['@language'] === preferredLanguage); - // give the locale appropriate title if it exists, otherwise give the first title - if (languageAppropriateTitle.length > 0) { - return titles.filter((title: any) => title['@language'] === preferredLanguage)[0]['@value']; - } else if (titles.length > 0) { - return titles[0]['@value']; - } - } - return this.intl.t('search.metadata-record.no-title'); - } -} - -declare module 'ember-data/types/registries/model' { - export default interface ModelRegistry { - 'metadata-record': MetadataRecordModel; - } // eslint-disable-line semi -} diff --git a/app/models/metadata-value-search.ts b/app/models/metadata-value-search.ts deleted file mode 100644 index cc97695694a..00000000000 --- a/app/models/metadata-value-search.ts +++ /dev/null @@ -1,25 +0,0 @@ -import Model, { AsyncHasMany, AsyncBelongsTo, attr, belongsTo, hasMany } from '@ember-data/model'; - -import MetadataPropertySearchModel from './metadata-property-search'; -import { SearchFilter } from './metadata-record-search'; -import SearchResultModel from './search-result'; - -export default class MetadataValueSearchModel extends Model { - @attr('string') valueSearchText!: string; - @attr('array') valueSearchFilter!: SearchFilter[]; - @attr('string') recordSearchText!: string; - @attr('array') recordSearchFilter!: SearchFilter[]; - @attr('number') totalResultCount!: number; - - @hasMany('search-result', { inverse: null }) - searchResultPage!: AsyncHasMany & SearchResultModel[]; - - @belongsTo('metadata-property-search', { inverse: null }) - relatedPropertySearch!: AsyncBelongsTo & MetadataPropertySearchModel; -} - -declare module 'ember-data/types/registries/model' { - export default interface ModelRegistry { - 'metadata-value-search': MetadataValueSearchModel; - } // eslint-disable-line semi -} diff --git a/app/search/-components/filter-facet/component.ts b/app/search/-components/filter-facet/component.ts index 008553507b8..ce903a676df 100644 --- a/app/search/-components/filter-facet/component.ts +++ b/app/search/-components/filter-facet/component.ts @@ -1,4 +1,5 @@ import Store from '@ember-data/store'; +import { getOwner } from '@ember/application'; import { action } from '@ember/object'; import { inject as service } from '@ember/service'; import { waitFor } from '@ember/test-waiters'; @@ -7,16 +8,17 @@ import { tracked } from '@glimmer/tracking'; import { task } from 'ember-concurrency'; import { taskFor } from 'ember-concurrency-ts'; import IntlService from 'ember-intl/services/intl'; +import GetLocalizedPropertyHelper from 'ember-osf-web/helpers/get-localized-property'; -import MetadataRecordModel from 'ember-osf-web/models/metadata-record'; +import IndexCardModel from 'ember-osf-web/models/index-card'; import SearchResultModel from 'ember-osf-web/models/search-result'; import { Filter } from '../../controller'; interface FilterFacetArgs { - recordSearchText: string; - recordSearchFilters: Filter[]; - propertyRecord: MetadataRecordModel; + cardSearchText: string; + cardSearchFilters: Filter[]; + propertyCard: IndexCardModel; propertySearch: SearchResultModel; toggleFilter: (filter: Filter) => void; } @@ -33,6 +35,8 @@ export default class FilterFacet extends Component { @tracked seeMoreModalShown = false; @tracked selectedProperty: SearchResultModel | null = null; + getLocalizedString = new GetLocalizedPropertyHelper(getOwner(this)); + get showSeeMoreButton() { // TODO: make this actually check if there are more return true; @@ -55,11 +59,11 @@ export default class FilterFacet extends Component { @waitFor async applySelectedProperty() { if (this.selectedProperty) { - const { toggleFilter, propertyRecord } = this.args; - const record = await this.selectedProperty.metadataRecord; + const { toggleFilter, propertyCard } = this.args; + const card = await this.selectedProperty.indexCard; const filter = { - property: propertyRecord.get('label'), - value: record.title, + property: this.getLocalizedString.compute([propertyCard.get('resourceMetadata'), 'label']), + value: this.getLocalizedString.compute([card.resourceMetadata, 'title']), }; toggleFilter(filter); this.selectedProperty = null; @@ -69,11 +73,11 @@ export default class FilterFacet extends Component { @task @waitFor async fetchFacetValues() { - const { recordSearchText, recordSearchFilters } = this.args; + const { cardSearchText, cardSearchFilters } = this.args; const { page, sort } = this; - const valueSearch = await this.store.queryRecord('metadata-value-search', { - recordSearchText, - recordSearchFilters, + const valueSearch = await this.store.queryRecord('index-value-search', { + cardSearchText, + cardSearchFilters, page, sort, }); diff --git a/app/search/-components/filter-facet/template.hbs b/app/search/-components/filter-facet/template.hbs index 260f5ec9e6b..1c1862232c1 100644 --- a/app/search/-components/filter-facet/template.hbs +++ b/app/search/-components/filter-facet/template.hbs @@ -2,104 +2,108 @@ data-test-filter-facet local-class='facet-wrapper' > - {{#let (unique-id @propertyRecord.label) as |facetElementId|}} - - {{#if this.fetchFacetValues.isRunning}} - - {{else if this.fetchFacetValues.isError}} - {{t 'search.filter-facet.facet-load-failed'}} - {{else}} -
    - {{#each this.filterableValues as |value|}} -
  • - - - {{value.recordResultCount}} - -
  • - {{/each}} - - {{#if this.showSeeMoreButton}} -
  • - -
  • - {{/if}} -
- {{/if}} - - - {{@propertyRecord.label}} - - - {{t 'search.filter-facet.see-more-modal-text'}} - - {{property.metadataRecord.title}} - - - - + {{#if this.fetchFacetValues.isRunning}} + + {{else if this.fetchFacetValues.isError}} + {{t 'search.filter-facet.facet-load-failed'}} + {{else}} +
    - {{t 'general.cancel'}} - - - - + {{#each this.filterableValues as |value|}} + {{#let (get-localized-property value.indexCard.resourceMetadata 'title') as |valueTitle|}} +
  • + + + {{value.recordResultCount}} + +
  • + {{/let}} + {{/each}} + + {{#if this.showSeeMoreButton}} +
  • + +
  • + {{/if}} +
+ {{/if}} + + + {{propertyLabel}} + + + {{t 'search.filter-facet.see-more-modal-text'}} + + {{get-localized-property property.indexCard.resourceMetadata 'title'}} + + + + + + + + {{/let}} {{/let}} diff --git a/app/search/styles.scss b/app/search/styles.scss index b0b1b98f406..07b6ae675ce 100644 --- a/app/search/styles.scss +++ b/app/search/styles.scss @@ -31,6 +31,43 @@ bottom: 4px; } +.topbar { + margin-left: 20px; + display: flex; + border-bottom: 1px solid $color-text-black; +} + +.object-type-nav { + ul { + padding-left: 0; + margin-bottom: 0; + list-style: none; + } + + li { + display: inline-flex; + margin-right: 10px; + } +} + +.object-type-filter-link { + padding: 10px 15px; + font-size: 1.3em; + + &:global(.active), + &:hover { + text-decoration: none; + background-color: $color-bg-gray; + color: $color-text-black; + border-bottom: 2px solid $color-text-black; + } +} + +.sort-dropdown { + width: 170px; + margin-top: 10px; +} + .sidenav-toggle { float: left; } @@ -49,4 +86,3 @@ display: flex; justify-content: space-between; } - diff --git a/app/serializers/metadata-value-search.ts b/app/serializers/index-property-search.ts similarity index 62% rename from app/serializers/metadata-value-search.ts rename to app/serializers/index-property-search.ts index 655a3f882cb..22707f3206d 100644 --- a/app/serializers/metadata-value-search.ts +++ b/app/serializers/index-property-search.ts @@ -1,10 +1,10 @@ import ShareSerializer from './share-serializer'; -export default class MetadataValueSearchSerializer extends ShareSerializer { +export default class IndexPropertySearchSerializer extends ShareSerializer { } declare module 'ember-data/types/registries/serializer' { export default interface SerializerRegistry { - 'metadata-value-search': MetadataValueSearchSerializer; + 'index-property-search': IndexPropertySearchSerializer; } // eslint-disable-line semi } diff --git a/app/serializers/metadata-property-search.ts b/app/serializers/metadata-property-search.ts deleted file mode 100644 index 6751421b625..00000000000 --- a/app/serializers/metadata-property-search.ts +++ /dev/null @@ -1,10 +0,0 @@ -import ShareSerializer from './share-serializer'; - -export default class MetadataPropertySearchSerializer extends ShareSerializer { -} - -declare module 'ember-data/types/registries/serializer' { - export default interface SerializerRegistry { - 'metadata-property-search': MetadataPropertySearchSerializer; - } // eslint-disable-line semi -} diff --git a/app/serializers/metadata-record-search.ts b/app/serializers/metadata-record-search.ts deleted file mode 100644 index c868b4c2edc..00000000000 --- a/app/serializers/metadata-record-search.ts +++ /dev/null @@ -1,10 +0,0 @@ -import ShareSerializer from './share-serializer'; - -export default class MetadataRecordSearchSerializer extends ShareSerializer { -} - -declare module 'ember-data/types/registries/serializer' { - export default interface SerializerRegistry { - 'metadata-record-search': MetadataRecordSearchSerializer; - } // eslint-disable-line semi -} diff --git a/app/serializers/metadata-record.ts b/app/serializers/metadata-record.ts deleted file mode 100644 index a91a8e27bdc..00000000000 --- a/app/serializers/metadata-record.ts +++ /dev/null @@ -1,10 +0,0 @@ -import ShareSerializer from './share-serializer'; - -export default class MetadataRecordSerializer extends ShareSerializer { -} - -declare module 'ember-data/types/registries/serializer' { - export default interface SerializerRegistry { - 'metadata-record': MetadataRecordSerializer; - } // eslint-disable-line semi -} diff --git a/mirage/config.ts b/mirage/config.ts index 8f1437b91d2..75ecd2b7fd4 100644 --- a/mirage/config.ts +++ b/mirage/config.ts @@ -38,6 +38,7 @@ import { createSchemaResponseAction } from './views/schema-response-action'; import { rootDetail } from './views/root'; import { shareSearch } from './views/share-search'; import { cardSearch, valueSearch } from './views/search'; +import { cardSearch, valueSearch } from './views/search'; import { createToken } from './views/token'; import { createEmails, updateEmails } from './views/update-email'; import { @@ -66,6 +67,9 @@ export default function(this: Server) { this.get('/index-card-search', cardSearch); this.get('/index-value-search', valueSearch); // this.get('/index-card/:id', Detail); + this.get('/index-card-searches', cardSearch); + this.get('/index-value-searches', valueSearch); + // this.get('/index-cards/:id', Detail); this.urlPrefix = apiUrl; this.namespace = '/v2'; From 0bd1fcad337819e409a628c4e317428f2c5f2e90 Mon Sep 17 00:00:00 2001 From: futa-ikeda <51409893+futa-ikeda@users.noreply.github.com> Date: Wed, 21 Jun 2023 17:05:12 -0400 Subject: [PATCH 005/170] [No ticket] Update SHARE endpoints (#1879) - Ticket: [No ticket] - Feature flag: n/a - Update SHAREAdapter to point to correct locations - Update SHAREAdapter parent class to point use config variable for share-url - Update SHAREAdapter parent class to point use api/v3 endpoints - Update search-related adapters to point to singularized endpoint names (e.g. api/v3/index-card-search**es** -> api/v3/index-card-search - Update mirage endpoints to reflect these changes --- app/adapters/index-property-search.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/adapters/index-property-search.ts b/app/adapters/index-property-search.ts index 3bec7157b32..9a69df75bfc 100644 --- a/app/adapters/index-property-search.ts +++ b/app/adapters/index-property-search.ts @@ -1,6 +1,9 @@ import ShareAdapter from './share-adapter'; export default class IndexPropertySearchAdapter extends ShareAdapter { + pathForType() { + return 'index-property-search'; + } } declare module 'ember-data/types/registries/adapter' { From 0de159bdb0c4ac18c155154c2bef40680e5bdd59 Mon Sep 17 00:00:00 2001 From: futa-ikeda <51409893+futa-ikeda@users.noreply.github.com> Date: Tue, 27 Jun 2023 11:19:34 -0400 Subject: [PATCH 006/170] [ENG-4568] Componentize search page (#1886) - Ticket: [ENG-4568] - Feature flag: n/a - Componentize search page for reuse in branded pages - Move logic and templating from search page route to `search-page` component - No logic for branding and default query-params yet in this PR --- .../-components/filter-facet/component.ts | 87 -------------- .../-components/filter-facet/styles.scss | 40 ------- .../-components/filter-facet/template.hbs | 109 ------------------ app/search/route.ts | 2 - app/search/styles.scss | 88 -------------- 5 files changed, 326 deletions(-) delete mode 100644 app/search/-components/filter-facet/component.ts delete mode 100644 app/search/-components/filter-facet/styles.scss delete mode 100644 app/search/-components/filter-facet/template.hbs delete mode 100644 app/search/styles.scss diff --git a/app/search/-components/filter-facet/component.ts b/app/search/-components/filter-facet/component.ts deleted file mode 100644 index ce903a676df..00000000000 --- a/app/search/-components/filter-facet/component.ts +++ /dev/null @@ -1,87 +0,0 @@ -import Store from '@ember-data/store'; -import { getOwner } from '@ember/application'; -import { action } from '@ember/object'; -import { inject as service } from '@ember/service'; -import { waitFor } from '@ember/test-waiters'; -import Component from '@glimmer/component'; -import { tracked } from '@glimmer/tracking'; -import { task } from 'ember-concurrency'; -import { taskFor } from 'ember-concurrency-ts'; -import IntlService from 'ember-intl/services/intl'; -import GetLocalizedPropertyHelper from 'ember-osf-web/helpers/get-localized-property'; - -import IndexCardModel from 'ember-osf-web/models/index-card'; -import SearchResultModel from 'ember-osf-web/models/search-result'; - -import { Filter } from '../../controller'; - -interface FilterFacetArgs { - cardSearchText: string; - cardSearchFilters: Filter[]; - propertyCard: IndexCardModel; - propertySearch: SearchResultModel; - toggleFilter: (filter: Filter) => void; -} - -export default class FilterFacet extends Component { - @service store!: Store; - @service intl!: IntlService; - @service toast!: Toastr; - - @tracked page = 1; - @tracked sort = '-relevance'; - @tracked collapsed = true; - @tracked filterableValues: SearchResultModel[] = []; - @tracked seeMoreModalShown = false; - @tracked selectedProperty: SearchResultModel | null = null; - - getLocalizedString = new GetLocalizedPropertyHelper(getOwner(this)); - - get showSeeMoreButton() { - // TODO: make this actually check if there are more - return true; - } - - @action - toggleFacet() { - if (this.filterableValues.length === 0 && !taskFor(this.fetchFacetValues).lastComplete) { - taskFor(this.fetchFacetValues).perform(); - } - this.collapsed = !this.collapsed; - } - - @action - updateSelectedProperty(property: SearchResultModel) { - this.selectedProperty = property; - } - - @task - @waitFor - async applySelectedProperty() { - if (this.selectedProperty) { - const { toggleFilter, propertyCard } = this.args; - const card = await this.selectedProperty.indexCard; - const filter = { - property: this.getLocalizedString.compute([propertyCard.get('resourceMetadata'), 'label']), - value: this.getLocalizedString.compute([card.resourceMetadata, 'title']), - }; - toggleFilter(filter); - this.selectedProperty = null; - } - } - - @task - @waitFor - async fetchFacetValues() { - const { cardSearchText, cardSearchFilters } = this.args; - const { page, sort } = this; - const valueSearch = await this.store.queryRecord('index-value-search', { - cardSearchText, - cardSearchFilters, - page, - sort, - }); - const results = valueSearch.get('searchResultPage').toArray(); - this.filterableValues = results; - } -} diff --git a/app/search/-components/filter-facet/styles.scss b/app/search/-components/filter-facet/styles.scss deleted file mode 100644 index dcc89e22e45..00000000000 --- a/app/search/-components/filter-facet/styles.scss +++ /dev/null @@ -1,40 +0,0 @@ -.facet-wrapper { - border-top: 1px solid $color-border-gray; - padding: 0.5rem 0; -} - -.facet-expand-button { - display: flex; - justify-content: space-between; - align-items: center; - width: 100%; - - &:active { - box-shadow: none; - } -} - -.facet-list { - padding: 0; - margin: 0; - list-style: none; - - &.collapsed { - display: none; - } -} - -.facet-value { - margin: 10px 0; - display: flex; - justify-content: space-between; - - .facet-link, - .facet-count { - margin: 0 5px; - } -} - -.see-more-dialog { - min-width: 50vw; -} diff --git a/app/search/-components/filter-facet/template.hbs b/app/search/-components/filter-facet/template.hbs deleted file mode 100644 index 1c1862232c1..00000000000 --- a/app/search/-components/filter-facet/template.hbs +++ /dev/null @@ -1,109 +0,0 @@ -
- {{#let (get-localized-property @propertyCard.resourceMetadata 'label') as |propertyLabel|}} - {{#let (unique-id propertyLabel) as |facetElementId|}} - - {{#if this.fetchFacetValues.isRunning}} - - {{else if this.fetchFacetValues.isError}} - {{t 'search.filter-facet.facet-load-failed'}} - {{else}} -
    - {{#each this.filterableValues as |value|}} - {{#let (get-localized-property value.indexCard.resourceMetadata 'title') as |valueTitle|}} -
  • - - - {{value.recordResultCount}} - -
  • - {{/let}} - {{/each}} - - {{#if this.showSeeMoreButton}} -
  • - -
  • - {{/if}} -
- {{/if}} - - - {{propertyLabel}} - - - {{t 'search.filter-facet.see-more-modal-text'}} - - {{get-localized-property property.indexCard.resourceMetadata 'title'}} - - - - - - - - {{/let}} - {{/let}} -
diff --git a/app/search/route.ts b/app/search/route.ts index fbb0689f98d..0a451bd304d 100644 --- a/app/search/route.ts +++ b/app/search/route.ts @@ -1,7 +1,5 @@ import Route from '@ember/routing/route'; -import SearchController from './controller'; - export default class Search extends Route { buildRouteInfoMetadata() { return { diff --git a/app/search/styles.scss b/app/search/styles.scss deleted file mode 100644 index 07b6ae675ce..00000000000 --- a/app/search/styles.scss +++ /dev/null @@ -1,88 +0,0 @@ -.search-page { - background-color: $color-bg-gray; -} - -.heading-wrapper { - text-align: center; - color: $color-text-white; - background-color: $osf-dark-blue-navbar; -} - -.heading-label { - padding: 40px; -} - -.search-input-wrapper { - white-space: nowrap; -} - -.search-input { - color: $color-text-black; - padding: 9px 5px; - font-size: 1.5em; - max-width: 700px; - min-width: 250px; - width: 50vw; -} - -.search-button { - position: relative; - right: 3px; - bottom: 4px; -} - -.topbar { - margin-left: 20px; - display: flex; - border-bottom: 1px solid $color-text-black; -} - -.object-type-nav { - ul { - padding-left: 0; - margin-bottom: 0; - list-style: none; - } - - li { - display: inline-flex; - margin-right: 10px; - } -} - -.object-type-filter-link { - padding: 10px 15px; - font-size: 1.3em; - - &:global(.active), - &:hover { - text-decoration: none; - background-color: $color-bg-gray; - color: $color-text-black; - border-bottom: 2px solid $color-text-black; - } -} - -.sort-dropdown { - width: 170px; - margin-top: 10px; -} - -.sidenav-toggle { - float: left; -} - -.left-panel { - padding-left: 12px; - width: 300px; -} - -.active-filter-list { - padding-left: 0; - list-style: none; -} - -.active-filter-item { - display: flex; - justify-content: space-between; -} From cb960b292f15937e7659ff9ee4636d1356e78384 Mon Sep 17 00:00:00 2001 From: futa-ikeda <51409893+futa-ikeda@users.noreply.github.com> Date: Mon, 10 Jul 2023 23:07:34 -0400 Subject: [PATCH 007/170] [ENG-4574] Preprint discover rewrite (#1896) * add brand relationship to preprint provider model (#1887) * Remove unused services from search controller * Use search-page component on preprint discover page * Modifiy branded-navbar for preprints * Error handling and theme resetting * Branded preprint discover part 1 * Branded preprint discover part 2 * Test prerpint discover page * Group CR feedback re: search-page component arguments * Fix test --------- Co-authored-by: Yuhuai Liu --- app/preprints/template.hbs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/app/preprints/template.hbs b/app/preprints/template.hbs index 21847e39d8d..3eecfc9f29d 100644 --- a/app/preprints/template.hbs +++ b/app/preprints/template.hbs @@ -1,9 +1,7 @@ -{{page-title this.theme.provider.providerTitle replace=true}} -
- - {{outlet}} -
+ + +{{outlet}} From d35126c69196489922ee91801e2132dfb4438ac3 Mon Sep 17 00:00:00 2001 From: Yuhuai Liu Date: Thu, 13 Jul 2023 13:10:31 -0400 Subject: [PATCH 008/170] [ENG-4573] Registry discover (#1900) * preliminary * moar * some more * delete unused components * remove top-level aggregate registries discover route * remove top-level registries discover route cont. * remove unused action and variable on registries application route * remove aggregate registries discover page tests * fix tests * remove discover-test.ts * CR followup --- lib/registries/addon/branded/discover/route.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/registries/addon/branded/discover/route.ts b/lib/registries/addon/branded/discover/route.ts index c9f253ba6ba..b502a2f2c28 100644 --- a/lib/registries/addon/branded/discover/route.ts +++ b/lib/registries/addon/branded/discover/route.ts @@ -2,7 +2,6 @@ import Route from '@ember/routing/route'; import RouterService from '@ember/routing/router-service'; import { inject as service } from '@ember/service'; -import RegistrationProviderModel from 'ember-osf-web/models/registration-provider'; import { notFoundURL } from 'ember-osf-web/utils/clean-url'; export default class BrandedRegistriesDiscoverRoute extends Route { From 6b6666d3983284c99498eb5241f503c86b4cd83d Mon Sep 17 00:00:00 2001 From: futa-ikeda <51409893+futa-ikeda@users.noreply.github.com> Date: Thu, 13 Jul 2023 15:06:15 -0400 Subject: [PATCH 009/170] [ENG-4574] Preprint discover fixes (#1905) - Ticket: [ENG-4574] - Feature flag: n/a - Add appropriate page title to discover page - Add appropriate analytics scope to discover page - Make provider description now show html entities - Use `{{html-safe}}` when showing provider description - Add `providerTitle` in preprint-provider model - Most branded providers should show their name with their preprint word (e.g. AfricaRxiv Preprints, MarXiv Papers), except Thesis Commons - If it's OSF, we just show "OSF Preprints" - Add page-title and analytics scope using the new `providerTitle` --- app/preprints/template.hbs | 1 + 1 file changed, 1 insertion(+) diff --git a/app/preprints/template.hbs b/app/preprints/template.hbs index 3eecfc9f29d..2c3dfa699a7 100644 --- a/app/preprints/template.hbs +++ b/app/preprints/template.hbs @@ -1,3 +1,4 @@ +{{page-title this.theme.provider.providerTitle replace=true}} Date: Tue, 1 Aug 2023 13:43:53 -0400 Subject: [PATCH 010/170] [ENG-4535] Search help feature (#1907) - Ticket: [ENG-4535] - Feature flag: n/a - Add search help feature - Basically a re-implementation of https://github.com/CenterForOpenScience/ember-osf-web/pull/1891 and https://github.com/CenterForOpenScience/ember-osf-web/pull/1877 - Notable difference is moving the Popovers to the end of the file to avoid merge conflicts - Added EmberPopovers to the search-page component - Added getters to search-page component to fetch EmberPopover targets dynamically - Translations - Tests --- .../addon/components/search-page/styles.scss | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lib/osf-components/addon/components/search-page/styles.scss b/lib/osf-components/addon/components/search-page/styles.scss index a243d42c7ec..71e99fcfd0c 100644 --- a/lib/osf-components/addon/components/search-page/styles.scss +++ b/lib/osf-components/addon/components/search-page/styles.scss @@ -327,6 +327,31 @@ } } +.search-help-tutorial { + background-color: $osf-dark-blue-navbar; + color: $color-text-white; + width: 400px; + max-width: 100%; + z-index: 100; + + // prevent target element styles from dictating popover text-styles + white-space: wrap; + text-align: initial; + + .enumeration { + float: left; + } + + .help-button-wrappers { + float: right; + } + + .skip-button { + color: $color-text-white; + } +} + + .object-type-filter-link { font-size: 1.3em; padding: 18px 15px; From af7d42e2fb5450c25cc56358d68dfc075c14d64a Mon Sep 17 00:00:00 2001 From: Yuhuai Liu Date: Mon, 7 Aug 2023 20:07:19 -0400 Subject: [PATCH 011/170] [No Ticket] Change queryparam passed to SHARE when filtering by resourceType (#1915) * change queryparam passed to SHARE when filtering by resourceType * add types * add some more types * update tests --- app/institutions/discover/controller.ts | 2 +- app/search/controller.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/institutions/discover/controller.ts b/app/institutions/discover/controller.ts index ffb5706ddb4..48a4a3cd0d6 100644 --- a/app/institutions/discover/controller.ts +++ b/app/institutions/discover/controller.ts @@ -8,7 +8,7 @@ import { Filter, OnSearchParams, ResourceTypeFilterValue } from 'osf-components/ export default class InstitutionDiscoverController extends Controller { @service currentUser!: CurrentUser; - @tracked q?: string = ''; + @tracked cardSearchText?: string = ''; @tracked sort?: string = '-relevance'; @tracked resourceType: ResourceTypeFilterValue = ResourceTypeFilterValue.Projects; @tracked activeFilters?: Filter[] = []; diff --git a/app/search/controller.ts b/app/search/controller.ts index e8ed982aa50..5aca419d97b 100644 --- a/app/search/controller.ts +++ b/app/search/controller.ts @@ -4,7 +4,7 @@ import { tracked } from '@glimmer/tracking'; import { Filter, OnSearchParams, ResourceTypeFilterValue } from 'osf-components/components/search-page/component'; export default class SearchController extends Controller { - @tracked q?: string = ''; + @tracked cardSearchText?: string = ''; @tracked sort?: string = '-relevance'; @tracked resourceType?: ResourceTypeFilterValue | null = null; @tracked activeFilters?: Filter[] = []; From 55be328a7a51e2e163417f25f57a2ae187e281e3 Mon Sep 17 00:00:00 2001 From: futa-ikeda <51409893+futa-ikeda@users.noreply.github.com> Date: Tue, 8 Aug 2023 10:33:12 -0400 Subject: [PATCH 012/170] [No ticket] Preprint branding rework (#1913) - Ticket: [] - Feature flag: n/a - Only rely on `brand` relationship for setting preprint colors - Use `brand.primaryColor` for branded navbar background color - Add styling if the brand's primaryColor does not provide sufficient contrast with white text - Add special-case for BioHackrXiv to change navbar color to white (their primary color would be white, but that creates problems for ` - + {{#if this.showHelp}} @@ -58,6 +58,6 @@ {{yield (hash row=(element ''))}} - {{search-help-modal isOpen=(mut this.showingHelp)}} + diff --git a/lib/osf-components/package.json b/lib/osf-components/package.json index dbedc84df3f..7d3d6601b48 100644 --- a/lib/osf-components/package.json +++ b/lib/osf-components/package.json @@ -25,5 +25,10 @@ "ember-radio-button": "*", "ember-responsive": "*", "ember-in-viewport": "*" + }, + "ember-addon": { + "paths": [ + "lib/app-components" + ] } } diff --git a/lib/registries/addon/index/template.hbs b/lib/registries/addon/index/template.hbs index cf094760a5e..e571e88bf31 100644 --- a/lib/registries/addon/index/template.hbs +++ b/lib/registries/addon/index/template.hbs @@ -4,6 +4,7 @@ {{#branded-header.lead}} diff --git a/package.json b/package.json index e914391b777..efca26632c3 100644 --- a/package.json +++ b/package.json @@ -260,6 +260,7 @@ "ember-addon": { "paths": [ "lib/analytics-page", + "lib/app-components", "lib/assets-prefix-middleware", "lib/collections", "lib/app-components", From 9e5f8abccdc1fac4dec2a9b43cb9cc45eb1d27ed Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Fri, 7 Jul 2023 14:54:54 -0600 Subject: [PATCH 020/170] Removed the add-ons and moved search-help-modal to osf-components --- app/preprints/index/template.hbs | 30 +++++++++++-------- .../components/search-help-modal/component.js | 1 - .../components/search-help-modal/template.js | 1 - lib/app-components/package.json | 5 ---- .../components/search-help-modal/component.ts | 0 .../components/search-help-modal/styles.scss | 0 .../components/search-help-modal/template.hbs | 0 .../components/search-help-modal/component.js | 1 + .../components/search-help-modal/template.js | 1 + lib/osf-components/package.json | 5 ---- package.json | 1 - 11 files changed, 19 insertions(+), 26 deletions(-) delete mode 100644 lib/app-components/app/components/search-help-modal/component.js delete mode 100644 lib/app-components/app/components/search-help-modal/template.js rename lib/{app-components => osf-components}/addon/components/search-help-modal/component.ts (100%) rename lib/{app-components => osf-components}/addon/components/search-help-modal/styles.scss (100%) rename lib/{app-components => osf-components}/addon/components/search-help-modal/template.hbs (100%) create mode 100644 lib/osf-components/app/components/search-help-modal/component.js create mode 100644 lib/osf-components/app/components/search-help-modal/template.js diff --git a/app/preprints/index/template.hbs b/app/preprints/index/template.hbs index 51d7725abdf..5ceee0aa96d 100644 --- a/app/preprints/index/template.hbs +++ b/app/preprints/index/template.hbs @@ -12,19 +12,23 @@ @showHelp=true as |branded-header| > - {{#branded-header.lead}} - {{t 'registries.index.lead' htmlSafe=true}} - {{/branded-header.lead}} - {{#branded-header.row}} - - {{/branded-header.row}} + {{#if this.theme.isProvider}} +
+ {{else}} +
+ {{/if}} + {{#if this.theme.isProvider}} + {{#branded-header.lead}} + {{html-safe this.theme.provider.description}} + {{/branded-header.lead}} + {{#branded-header.row}} + + {{/branded-header.row}} + {{/if}}
{{!END ROW}} {{#if this.theme.provider.allowSubmissions}} diff --git a/lib/app-components/app/components/search-help-modal/component.js b/lib/app-components/app/components/search-help-modal/component.js deleted file mode 100644 index 6056b8489d7..00000000000 --- a/lib/app-components/app/components/search-help-modal/component.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from 'app-components/components/search-help-modal/component'; diff --git a/lib/app-components/app/components/search-help-modal/template.js b/lib/app-components/app/components/search-help-modal/template.js deleted file mode 100644 index 793e0538fe6..00000000000 --- a/lib/app-components/app/components/search-help-modal/template.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from 'app-components/components/search-help-modal/template'; diff --git a/lib/app-components/package.json b/lib/app-components/package.json index ada12a99293..a3e11011992 100644 --- a/lib/app-components/package.json +++ b/lib/app-components/package.json @@ -29,10 +29,5 @@ "ember-wormhole": "*", "katex": "*", "liquid-fire": "*" - }, - "ember-addon": { - "paths": [ - "lib/osf-components" - ] } } diff --git a/lib/app-components/addon/components/search-help-modal/component.ts b/lib/osf-components/addon/components/search-help-modal/component.ts similarity index 100% rename from lib/app-components/addon/components/search-help-modal/component.ts rename to lib/osf-components/addon/components/search-help-modal/component.ts diff --git a/lib/app-components/addon/components/search-help-modal/styles.scss b/lib/osf-components/addon/components/search-help-modal/styles.scss similarity index 100% rename from lib/app-components/addon/components/search-help-modal/styles.scss rename to lib/osf-components/addon/components/search-help-modal/styles.scss diff --git a/lib/app-components/addon/components/search-help-modal/template.hbs b/lib/osf-components/addon/components/search-help-modal/template.hbs similarity index 100% rename from lib/app-components/addon/components/search-help-modal/template.hbs rename to lib/osf-components/addon/components/search-help-modal/template.hbs diff --git a/lib/osf-components/app/components/search-help-modal/component.js b/lib/osf-components/app/components/search-help-modal/component.js new file mode 100644 index 00000000000..7f96f5c5fde --- /dev/null +++ b/lib/osf-components/app/components/search-help-modal/component.js @@ -0,0 +1 @@ +export { default } from 'osf-components/components/search-help-modal/component'; diff --git a/lib/osf-components/app/components/search-help-modal/template.js b/lib/osf-components/app/components/search-help-modal/template.js new file mode 100644 index 00000000000..8faada3c8d7 --- /dev/null +++ b/lib/osf-components/app/components/search-help-modal/template.js @@ -0,0 +1 @@ +export { default } from 'osf-components/components/search-help-modal/template'; diff --git a/lib/osf-components/package.json b/lib/osf-components/package.json index 7d3d6601b48..dbedc84df3f 100644 --- a/lib/osf-components/package.json +++ b/lib/osf-components/package.json @@ -25,10 +25,5 @@ "ember-radio-button": "*", "ember-responsive": "*", "ember-in-viewport": "*" - }, - "ember-addon": { - "paths": [ - "lib/app-components" - ] } } diff --git a/package.json b/package.json index efca26632c3..e914391b777 100644 --- a/package.json +++ b/package.json @@ -260,7 +260,6 @@ "ember-addon": { "paths": [ "lib/analytics-page", - "lib/app-components", "lib/assets-prefix-middleware", "lib/collections", "lib/app-components", From 676611b0f108de9d5da25ac0dad383eee504b6dc Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Tue, 8 Aug 2023 11:49:05 -0600 Subject: [PATCH 021/170] Fixed a merge conflict --- app/preprints/branded/controller.ts | 27 +++++++++++ app/preprints/branded/route.ts | 60 +++++++++++++++++++++++ app/preprints/branded/styles.scss | 63 +++++++++++++++++++++++++ app/preprints/index/route.ts | 1 + app/preprints/template.hbs | 19 ++++---- app/router.ts | 6 ++- mirage/config.ts | 7 +++ mirage/scenarios/preprints.ts | 4 ++ mirage/serializers/preprint-provider.ts | 8 +++- types/osf-api.d.ts | 1 + 10 files changed, 185 insertions(+), 11 deletions(-) create mode 100644 app/preprints/branded/controller.ts create mode 100644 app/preprints/branded/route.ts create mode 100644 app/preprints/branded/styles.scss diff --git a/app/preprints/branded/controller.ts b/app/preprints/branded/controller.ts new file mode 100644 index 00000000000..17069b0fdb6 --- /dev/null +++ b/app/preprints/branded/controller.ts @@ -0,0 +1,27 @@ +import Store from '@ember-data/store'; +import Controller from '@ember/controller'; +import { action } from '@ember/object'; +import RouterService from '@ember/routing/router-service'; +import { inject as service } from '@ember/service'; +import Analytics from 'ember-osf-web/services/analytics'; +import Theme from 'ember-osf-web/services/theme'; + +export default class Preprints extends Controller { + @service store!: Store; + @service theme!: Theme; + @service router!: RouterService; + @service analytics!: Analytics; + + livedata = 'livedata'; + + @action + onSearch(query: string) { + let route = 'search'; + + if (this.theme.isSubRoute) { + route = 'provider.discover'; + } + + this.router.transitionTo(route, { queryParams: { q: query } }); + } +} diff --git a/app/preprints/branded/route.ts b/app/preprints/branded/route.ts new file mode 100644 index 00000000000..b110d6cb8a0 --- /dev/null +++ b/app/preprints/branded/route.ts @@ -0,0 +1,60 @@ +import Store from '@ember-data/store'; +import Route from '@ember/routing/route'; +import { inject as service } from '@ember/service'; + +import Theme from 'ember-osf-web/services/theme'; +/** + * @module ember-preprints + * @submodule routes + */ + +/** + * Loads all disciplines and preprint providers to the index page + * @class Index Route Handler + */ +export default class Preprints extends Route { + @service store!: Store; + @service theme!: Theme; + livedata = 'livedata'; + templateName = 'index'; + + async model(args: any) { + try { + const provider = await this.store.findRecord('preprint-provider', args.provider_id); + this.theme.set('providerType', 'preprint'); + this.theme.set('id', args.provider_id); + + const taxonomies = await this.theme.provider?.queryHasMany('highlightedSubjects', { + page: { + size: 20, + }, + }); + + return { + provider, + taxonomies, + }; + } catch (e) { + return null; + } + + /* + return { + taxonomies: await this.theme.provider?.queryHasMany('highlightedSubjects', { + page: { + size: 20, + }, + }), + brandedProviders: this.theme.isProvider + ? [] + : await this.store + .findAll('preprint-provider', { + reload: true, + }).filter((item: any) => { + console.log('item', item); + return item.id !== 'osf'; + }), + }; + */ + } +} diff --git a/app/preprints/branded/styles.scss b/app/preprints/branded/styles.scss new file mode 100644 index 00000000000..fecc9489c25 --- /dev/null +++ b/app/preprints/branded/styles.scss @@ -0,0 +1,63 @@ +/* Main header with search bar */ +.preprint-header { + background: #214661 url('img/preprints-bg.jpg') top center; + background-position-y: -50px; + padding-top: 100px; + padding-bottom: 30px; + border-bottom: 1px solid #ddd; + color: $color-text-white; + + h1 { + font-size: 41px; + font-weight: 300; + } + + a:not(.btn) { + color: #80c2f7; + text-decoration: underline; + } + + .btn-info { + color: $color-text-white; + } + +} + +.preprint-lead, +.preprint-tool h2 { + text-transform: capitalize; +} + +/* Recent uploads list panel */ +.preprint-list { + background: #fbfbfb; + border-bottom: 1px solid #eee; +} + +/* Subject Panel */ +.preprint-subjects { + background-color: #f1f3f2; + border-bottom: 1px solid #6d8a98; + + .subject-item a { + width: 100%; + font-size: 17px; + overflow: hidden; + text-overflow: ellipsis; + } +} + +/* Preprint providers and become provider */ +.preprint-tool { + background: #cbd9d5 url('img/index-tool-bg.jpg') top center; + color: $color-text-white; + text-shadow: 0 0 5px #506069; + background-size: cover; + + .provider-logo { + height: 120px; + background-size: contain; + background-repeat: no-repeat; + background-position: center; + } +} diff --git a/app/preprints/index/route.ts b/app/preprints/index/route.ts index dfcc5b72ac5..3ca3a65cebb 100644 --- a/app/preprints/index/route.ts +++ b/app/preprints/index/route.ts @@ -17,6 +17,7 @@ export default class Preprints extends Route { @service theme!: Theme; livedata = 'livedata'; + async model() { return { taxonomies: await this.theme.provider?.queryHasMany('highlightedSubjects', { diff --git a/app/preprints/template.hbs b/app/preprints/template.hbs index 21847e39d8d..5c74b906e29 100644 --- a/app/preprints/template.hbs +++ b/app/preprints/template.hbs @@ -1,9 +1,12 @@ {{page-title this.theme.provider.providerTitle replace=true}} -
- - {{outlet}} -
+{{#if this.theme.isProvider}} +
+ + +
+{{/if}} +{{outlet}} diff --git a/app/router.ts b/app/router.ts index e69ef624be8..38c2513e5cb 100644 --- a/app/router.ts +++ b/app/router.ts @@ -25,10 +25,13 @@ Router.map(function() { this.route('discover', { path: '/:institution_id' }); this.route('dashboard', { path: '/:institution_id/dashboard' }); }); + this.route('preprints', function() { - this.route('discover'); + this.route('index', { path: '/' }); + this.route('branded', { path: '/:provider_id' }); this.route('discover', { path: '/:provider_id/discover' }); }); + this.route('register'); this.route('settings', function() { this.route('profile', function() { @@ -67,6 +70,7 @@ Router.map(function() { this.route('files', function() { this.route('provider', { path: '/:providerId' }); }); + this.route('preprints'); this.route('metadata'); this.route('registrations'); this.route('drafts', { path: '/drafts/:draftId' }, function() { diff --git a/mirage/config.ts b/mirage/config.ts index 75ecd2b7fd4..c1a9b95f294 100644 --- a/mirage/config.ts +++ b/mirage/config.ts @@ -298,6 +298,13 @@ export default function(this: Server) { }); osfResource(this, 'preprint-provider', { path: '/providers/preprints' }); + osfNestedResource(this, 'preprint-provider', 'highlightedSubjects', { + only: ['index'], + path: '/providers/preprints/:parentID/subjects/highlighted/', + relatedModelName: 'subject', + }); + + osfResource(this, 'registration-provider', { path: '/providers/registrations' }); osfNestedResource(this, 'registration-provider', 'moderators', { only: ['index', 'show', 'update', 'delete'], diff --git a/mirage/scenarios/preprints.ts b/mirage/scenarios/preprints.ts index 12bbf7f0d14..522f834b37c 100644 --- a/mirage/scenarios/preprints.ts +++ b/mirage/scenarios/preprints.ts @@ -19,7 +19,11 @@ export function preprintsScenario( const preprints = server.createList('preprint', 3, { provider: thesisCommons, }); + + const subjects = server.createList('subject', 2); + thesisCommons.update({ + highlightedSubjects: subjects, brand, moderators: [currentUserModerator], preprints, diff --git a/mirage/serializers/preprint-provider.ts b/mirage/serializers/preprint-provider.ts index d504ed68abb..753e75f5375 100644 --- a/mirage/serializers/preprint-provider.ts +++ b/mirage/serializers/preprint-provider.ts @@ -13,6 +13,8 @@ export default class PreprintProviderSerializer extends ApplicationSerializer) { + const has_highlighted_subjects = model.highlightedSubjects.length > 0; + const relationships: SerializedRelationships = { subjects: { links: { @@ -25,8 +27,10 @@ export default class PreprintProviderSerializer extends ApplicationSerializer Date: Wed, 12 Jul 2023 12:27:22 -0600 Subject: [PATCH 022/170] Fixed a few git merge conflicts --- app/router.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/app/router.ts b/app/router.ts index 38c2513e5cb..8eddbedff2c 100644 --- a/app/router.ts +++ b/app/router.ts @@ -70,7 +70,6 @@ Router.map(function() { this.route('files', function() { this.route('provider', { path: '/:providerId' }); }); - this.route('preprints'); this.route('metadata'); this.route('registrations'); this.route('drafts', { path: '/drafts/:draftId' }, function() { From 5cdb00fba3aada7efbd8b69c9647e5d019b15a9b Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Thu, 13 Jul 2023 11:25:08 -0600 Subject: [PATCH 023/170] Added more logic to get the page to render --- app/preprints/branded/route.ts | 28 +--- app/preprints/branded/template.hbs | 141 ++++++++++++++++++ app/preprints/index/controller.ts | 2 + app/preprints/index/route.ts | 35 +++-- app/preprints/index/styles.scss | 11 +- app/preprints/index/template.hbs | 80 +++++----- app/styles/_branding.scss | 3 +- .../components/branded-header/component.ts | 4 + .../components/branded-header/styles.scss | 14 +- .../components/branded-header/template.hbs | 2 +- .../addon/components/search-page/styles.scss | 2 +- .../addon/modifiers/with-branding.ts | 4 +- .../{component.ts => component.js} | 0 mirage/scenarios/preprints.ts | 33 ++++ .../default-brand/osf-preprints-white.png | Bin 0 -> 8256 bytes translations/en-us.yml | 14 ++ 16 files changed, 287 insertions(+), 86 deletions(-) create mode 100644 app/preprints/branded/template.hbs rename lib/osf-components/app/components/branded-header/{component.ts => component.js} (100%) create mode 100644 public/assets/images/default-brand/osf-preprints-white.png diff --git a/app/preprints/branded/route.ts b/app/preprints/branded/route.ts index b110d6cb8a0..6257a34ce86 100644 --- a/app/preprints/branded/route.ts +++ b/app/preprints/branded/route.ts @@ -1,12 +1,8 @@ import Store from '@ember-data/store'; import Route from '@ember/routing/route'; import { inject as service } from '@ember/service'; - +import RouterService from '@ember/routing/router-service'; import Theme from 'ember-osf-web/services/theme'; -/** - * @module ember-preprints - * @submodule routes - */ /** * Loads all disciplines and preprint providers to the index page @@ -15,8 +11,8 @@ import Theme from 'ember-osf-web/services/theme'; export default class Preprints extends Route { @service store!: Store; @service theme!: Theme; + @service router!: RouterService; livedata = 'livedata'; - templateName = 'index'; async model(args: any) { try { @@ -35,26 +31,8 @@ export default class Preprints extends Route { taxonomies, }; } catch (e) { + this.router.transitionTo('not-found', 'preprints'); return null; } - - /* - return { - taxonomies: await this.theme.provider?.queryHasMany('highlightedSubjects', { - page: { - size: 20, - }, - }), - brandedProviders: this.theme.isProvider - ? [] - : await this.store - .findAll('preprint-provider', { - reload: true, - }).filter((item: any) => { - console.log('item', item); - return item.id !== 'osf'; - }), - }; - */ } } diff --git a/app/preprints/branded/template.hbs b/app/preprints/branded/template.hbs new file mode 100644 index 00000000000..2f838d590a3 --- /dev/null +++ b/app/preprints/branded/template.hbs @@ -0,0 +1,141 @@ +{{page-title (t 'preprints.title')}} + +
+ + {{!HEADER}} +
+ {{!CONTAINER}} +
+ + {{#if this.theme.isProvider}} +
+ {{else}} +
+ {{/if}} + {{#if this.theme.isProvider}} + {{#branded-header.lead}} + {{html-safe this.theme.provider.description}} + {{/branded-header.lead}} + {{#branded-header.row}} + + {{/branded-header.row}} + {{/if}} +
+ {{!END ROW}} + {{#if this.theme.provider.allowSubmissions}} +
+
+

{{t 'preprints.header.or'}}

+ + {{t this.submitLabel documentType=this.theme.provider.content.documentType}} + +
+ {{#link-to (route-prefix 'content') (if this.theme.provider.example this.theme.provider.example 'khbvy') invokeAction=(action 'click' 'link' 'Index - See example')}} + {{t 'preprints.header.example'}} + {{/link-to}} +
+
+
+ {{/if}} +
+ {{!END CONTAINER}} +
+ {{!END HEADER}} + + {{!SUBJECTS}} +
+
+
+
+

{{#if this.theme.provider.additionalProviders}} + {{t 'preprints.subjects.heading.provider'}} + {{else}} + {{if this.theme.provider.hasHighlightedSubjects (t 'preprints.subjects.heading.hasHighlightedSubjects') (t 'preprints.subjects.heading.noHighlightedSubjects')}} + {{/if}} +

+ {{#if this.theme.provider.hasHighlightedSubjects}} + {{#link-to (route-prefix 'discover') class='seeAllSubjects'}} + {{t 'preprints.subjects.links.seeAllSubjects'}} + {{/link-to}} + {{/if}} +
+ {{#if this.theme.provider.additionalProviders}} + {{additional-provider-list additionalProviders=this.theme.provider.additionalProviders}} + {{else}} + {{/if}} +
+
+
+
+
+ + {{#unless this.theme.isProvider}} + {{!SERVICES}} +
+
+
+
+

{{t 'preprints.services.top.heading' documentType=this.theme.provider.content.documentType}}

+

+ {{t 'preprints.services.top.paragraph' documentType=this.theme.provider.content.documentType}} +

+
+
+
+
+ {{#each this.model.brandedProviders as |provider| }} + {{#if (not-eq provider.id this.livedata) }} + + {{/if}} + {{/each}} +
+
+
+
+

+ {{t 'preprints.services.bottom.p1' documentType=this.theme.provider.content.documentType}} +

+ {{t 'preprints.services.bottom.div.line1'}} + + {{t 'preprints.services.bottom.div.linkText1'}} + + {{t 'preprints.services.bottom.div.line2'}} + + {{t 'preprints.services.bottom.div.linkText2'}} + + {{t 'preprints.services.bottom.div.line3'}} +
+

+ + {{t 'prints.services.bottom.contact'}} + +
+
+
+
+ {{/unless}} + + + {{!ADVISORY GROUP}} + {{#if this.theme.provider.advisoryBoard.length}} +
+
+
+ {{html-safe this.theme.provider.advisoryBoard 'advisory-board'}} +
+
+
+ {{/if}} +
+{{!END INDEX}} diff --git a/app/preprints/index/controller.ts b/app/preprints/index/controller.ts index 17069b0fdb6..657db70f6cc 100644 --- a/app/preprints/index/controller.ts +++ b/app/preprints/index/controller.ts @@ -13,6 +13,8 @@ export default class Preprints extends Controller { @service analytics!: Analytics; livedata = 'livedata'; + providerAsset = 'https://localhost:4200'; + routePrefix = 'https://localhost:4200'; @action onSearch(query: string) { diff --git a/app/preprints/index/route.ts b/app/preprints/index/route.ts index 3ca3a65cebb..e339e489c93 100644 --- a/app/preprints/index/route.ts +++ b/app/preprints/index/route.ts @@ -1,12 +1,8 @@ import Store from '@ember-data/store'; import Route from '@ember/routing/route'; +import RouterService from '@ember/routing/router-service'; import { inject as service } from '@ember/service'; - import Theme from 'ember-osf-web/services/theme'; -/** - * @module ember-preprints - * @submodule routes - */ /** * Loads all disciplines and preprint providers to the index page @@ -15,22 +11,29 @@ import Theme from 'ember-osf-web/services/theme'; export default class Preprints extends Route { @service store!: Store; @service theme!: Theme; + @service router!: RouterService; livedata = 'livedata'; - async model() { - return { - taxonomies: await this.theme.provider?.queryHasMany('highlightedSubjects', { + try { + const provider = await this.store.findRecord('preprint-provider', 'osf'); + this.theme.set('providerType', 'preprint'); + this.theme.set('id', 'osf'); + + const taxonomies = await this.theme.provider?.queryHasMany('highlightedSubjects', { page: { size: 20, }, - }), - brandedProviders: this.theme.isProvider - ? [] - : await this.store - .findAll('preprint-provider', { - reload: true, - }).filter(item => item.id !== 'osf'), - }; + }); + + return { + provider, + taxonomies, + }; + + } catch (e) { + this.router.transitionTo('not-found', 'preprints'); + return null; + } } } diff --git a/app/preprints/index/styles.scss b/app/preprints/index/styles.scss index fecc9489c25..d858166a2cf 100644 --- a/app/preprints/index/styles.scss +++ b/app/preprints/index/styles.scss @@ -12,7 +12,7 @@ font-weight: 300; } - a:not(.btn) { + a:not(:global(.btn)) { color: #80c2f7; text-decoration: underline; } @@ -23,6 +23,15 @@ } +.example-container { + display: flex; + flex-direction: row; + justify-content: center; + align-items: center; + width: 100%; + margin-top: 25px; +} + .preprint-lead, .preprint-tool h2 { text-transform: capitalize; diff --git a/app/preprints/index/template.hbs b/app/preprints/index/template.hbs index 5ceee0aa96d..bb8214d50e0 100644 --- a/app/preprints/index/template.hbs +++ b/app/preprints/index/template.hbs @@ -3,49 +3,55 @@
{{!HEADER}} -
+
{{!CONTAINER}}
- {{#if this.theme.isProvider}} -
- {{else}} -
- {{/if}} - {{#if this.theme.isProvider}} - {{#branded-header.lead}} +
+ {{#branded-header.lead}} +
{{html-safe this.theme.provider.description}} - {{/branded-header.lead}} - {{#branded-header.row}} - + + {{/branded-header.lead}} + {{#branded-header.row}} + {{#if this.theme.provider.allowSubmissions}} +
+
+

{{t 'preprints.header.or'}}

+ + {{t 'preprints.header.submit_label' documentType=this.theme.provider.content.documentType}} + +
+ + {{t 'preprints.header.example'}} + +
+
- {{/branded-header.row}} - {{/if}} + {{/if}} + {{/branded-header.row}} {{!END ROW}} - {{#if this.theme.provider.allowSubmissions}} -
-
-

{{t 'index.header.or'}}

- - {{t this.submitLabel documentType=this.theme.provider.content.documentType}} - -
- {{#link-to (route-prefix 'content') (if this.theme.provider.example this.theme.provider.example 'khbvy') invokeAction=(action 'click' 'link' 'Index - See example')}} - {{t 'index.header.example'}} - {{/link-to}} -
-
-
- {{/if}}
{{!END CONTAINER}}
@@ -57,14 +63,14 @@

{{#if this.theme.provider.additionalProviders}} - {{t 'index.subjects.heading.provider'}} + {{t 'preprints.subjects.heading.provider'}} {{else}} - {{if this.theme.provider.hasHighlightedSubjects (t 'index.subjects.heading.hasHighlightedSubjects') (t 'preprints.subjects.heading.noHighlightedSubjects')}} + {{if this.theme.provider.hasHighlightedSubjects (t 'preprints.subjects.heading.hasHighlightedSubjects') (t 'preprints.subjects.heading.noHighlightedSubjects')}} {{/if}}

{{#if this.theme.provider.hasHighlightedSubjects}} - {{#link-to (route-prefix 'discover') class='seeAllSubjects'}} - {{t 'index.subjects.links.seeAllSubjects'}} + {{#link-to (this.route-prefix 'discover') class='seeAllSubjects'}} + {{t 'preprints.subjects.links.seeAllSubjects'}} {{/link-to}} {{/if}}
@@ -94,7 +100,7 @@
{{#each this.model.brandedProviders as |provider| }} {{#if (not-eq provider.id this.livedata) }} - + {{/if}} {{/each}}
diff --git a/app/styles/_branding.scss b/app/styles/_branding.scss index 48d67e835f1..1143a5cb24a 100644 --- a/app/styles/_branding.scss +++ b/app/styles/_branding.scss @@ -2,7 +2,8 @@ --primary-color: #{$color-osf-primary}; --secondary-color: #{$color-osf-secondary}; --navbar-logo-img-url: url('images/default-brand/cos-logo-white.svg'); - --hero-logo-img-url: url('images/default-brand/osf-registries-white.png'); + --hero-logo-registries-img-url: url('images/default-brand/osf-registries-white.png'); + --hero-logo-preprints-img-url: url('images/default-brand/osf-preprints-white.png'); --hero-background-img-url: url('images/default-brand/bg-dark.jpg'); } diff --git a/lib/osf-components/addon/components/branded-header/component.ts b/lib/osf-components/addon/components/branded-header/component.ts index 9003e40b5c1..c80f3376207 100644 --- a/lib/osf-components/addon/components/branded-header/component.ts +++ b/lib/osf-components/addon/components/branded-header/component.ts @@ -32,6 +32,10 @@ export default class BrandedHeader extends Component { return this.args.showHelp; } + get brandLogo(): string { + return this.args.translationParent === 'preprints' ? 'preprints-brand-logo' : 'registries-brand-logo'; + } + @computed('providerModel.name', 'args.translationParent') get headerAriaLabel() { return this.providerModel ? diff --git a/lib/osf-components/addon/components/branded-header/styles.scss b/lib/osf-components/addon/components/branded-header/styles.scss index 86017179f8b..35e8f04b5ea 100644 --- a/lib/osf-components/addon/components/branded-header/styles.scss +++ b/lib/osf-components/addon/components/branded-header/styles.scss @@ -28,12 +28,22 @@ width: 100%; margin-top: 25px; + .brand { - background: var(--hero-logo-img-url) top center no-repeat; - background-size: contain; height: 70px; width: 100%; + + &.registries-brand-logo { + background: var(--hero-logo-registries-img-url) top center no-repeat; + background-size: contain; + } + + &.preprints-brand-logo { + background: var(--hero-logo-preprints-img-url) top center no-repeat; + background-size: contain; + } } + } .search-container { diff --git a/lib/osf-components/addon/components/branded-header/template.hbs b/lib/osf-components/addon/components/branded-header/template.hbs index f756c112d2d..ef65a2f66a1 100644 --- a/lib/osf-components/addon/components/branded-header/template.hbs +++ b/lib/osf-components/addon/components/branded-header/template.hbs @@ -1,7 +1,7 @@
, +) { + buildOSF(server, currentUser); + buildThesisCommons(server, currentUser); +} + +function buildOSF( + server: Server, + currentUser: ModelInstance, +) { + const osf = server.schema.preprintProviders.find('osf') as ModelInstance; + const brand = server.create('brand'); + const currentUserModerator = server.create('moderator', + { id: currentUser.id, user: currentUser, provider: osf }, 'asAdmin'); + + const preprints = server.createList('preprint', 4, { + provider: osf, + }); + + const subjects = server.createList('subject', 7); + + osf.update({ + allowSubmissions: true, + highlightedSubjects: subjects, + brand, + moderators: [currentUserModerator], + preprints, + description: 'This is the description for osf', + }); +} + +function buildThesisCommons( + server: Server, + currentUser: ModelInstance, ) { const thesisCommons = server.schema.preprintProviders.find('thesiscommons') as ModelInstance; const brand = server.create('brand', { diff --git a/public/assets/images/default-brand/osf-preprints-white.png b/public/assets/images/default-brand/osf-preprints-white.png new file mode 100644 index 0000000000000000000000000000000000000000..ff363f18a63b532f5489522cde45bc43e6101d70 GIT binary patch literal 8256 zcmZvBcQ~6-8+WYQRBbV24+6nTif z6QlO{;_dgo*Z0SlE7zTK&U2mT{{8NC?sFwXOXC?e1seqj1fo_^eyRfkks$HoHZmf- zv@BzW<9}SV)btdeIjCJ;Udq&M;N`>mEBSBy|H}U@{u|&Q{rlpl|6769Z~mM9Tlps~ zer>0W?)&xZR04+`OUM5f(bzMEA>{)+fLqQw8oD6db>E%qzRiywH4lo-ac77PW^kL$ znSF6^_)=P`rM0@cvVRU~ymJf!aT%yQeXNHt-9!)BPjfT)Vgkq%Maf_VNmd@FQ|q^| zm!FMu1w)JlT;>r^rY_M=r<6Q%U2NAjA};9GB~^AnpfX9B8*Bo6M4+c7T&zOvgrHiD z+@4MoM!&T9|S5K zFi&M50)27*rV&a2`stE$>jxo75?F$v2tY*xZ?dn0d@j{O-3 zK!a2m5+BpzTYWN5_Yzpnzv>mo_T~fVKarVft0I;$_Bfj z?h!lh-d04u*|1^-aie8;Ae8fV&(4F8{z`)%z7;Hftvri$J;L6 zo^@Te!(N1Qg68~9hec6#IvaddF?=9jSIvT@4?%~&r~9{Swt5R1S31I2+{i(iLNy+R z(tCHuHeBJAZhtoNJZ<38v}?L=iVlrvkytxjX(MB{4_g78ELc1Gr6$na+DdCpXNf?a z=h+VKJWP1>wIkt;zir+P;OU1OA>J4Afd=C%K?57obub|#)kXI8U0${sKd52n3wQ?AsXG;+{q9(>&K(#pxj^-e^mk|x z#Eoz5By5SaaKUcuRmp?k&YFl5lRTe=rO~6`o@jc-Db%Og^vLhUvZSr6N73peaX__4 zGRKOM!DJKs<0N<6k~Xt;n%3@JoCHf1iUd`C+ib5(5AMFfsvPhaGJWV~QK^_QIkU*@ zYl0m$Q(vyloB5@wujhSkKkzcCQ}<*YLCF$t*&v$}{uUAn!X7Dxhe4dXb~vqb#u)ZW zm&&Yvut4a}?UMkHGHUZaznFcAWFyzQljpBYD`TQ>wfokrJ`Ze;iWXgG;%#?CHz$^ZgI0&cgU@77&t_N*LW7N7Lsa zoHdaKk~GY~=o+u3T-Cx^+9}+~2Se)VevH&$1?0; zv3vf3%5lW$Z07OacC)jJT5RrNH7IH8Uqbg+ML(F35EbG43(kP4)%b9B7 z%DQWSbs*eDzzj|eNz&F|Mdv!Czx%V>o9nxh=eT=Pvbbo{o2}WE-=~BS7#R9cG{a7; zE2-EHR;9C?qlSi(!PaNkWyf>|h_NOOx5D&E9Y=Jd?~?Mh{uOUhu}yr)p}tbYuH=M5 z=QF*O)(FT>vcyE>f4+wcBB2E;iB?vB!jR9lq8-fDj_$_W+RHmO0IKn{f5PEHtKQx{ zTK?3qRhusoUbm2rjQ6eq4o`h+N}-ri;}x%#^Pp)@n|xc{ha(+=0kiwLy; zHzG;o_pHam`;IszgEkg~LKrcO=DISrP5DKB*x~jL14R^Ey>N}ma~ccrjt=)(ts%}U z!%%ZjN9RQOL#l6fG^c1YAP(mQnYc!fik{8^iR4)$d-i{1B>>WS%;!Fdvatr9@%Kt4 zR&m$qfzm*gk~jeYIY)k9uf9uBk>SgI&RhHL3m{M@q9D@{ViTavMvosh(pI? zsopvx6qxw?83qFQJ4#A3%%B8&I%x|KOAf2DS#k2_yR=`=T$-UT(a~ zYz2pk*-qgQyuud5NX$VG;uJ^R%x^7^@MY+^!XRmWI^QJnl@9zNGTm4*? zOAZN_P)?4#)(N)6gX<4s?mS(sqkC9fYGpBMcg=P%7z^Wn?|bH5aO=nH+Pwa|N|gP= z$+E+vU`U_&uvN=WhhZBTLg8=F2_$U#023mjDv$^(x%TMxGVL<_t9B$qsf_ANd-`==(_ zJ<2CzQFE>lX0_Pa^Ob(<-9HDt3nd;I+A#sc_HdL+R>MF}wMJs^-5Xrkc@-<897uSL z;SaidYkcb>-tnq)S17(`neOC#(rDgWrATAptdl87%dzik+(6s>en2-7Gy9I``FpWh ztFtJSI9i86InyDUpYS&HX0iSlb>k)Pz*>^HozWfU&nCVDr_=nmHc!ZIT7G}RRFUG1 zpj$ER?YAH8A(tbNhbzWUauio6ypNHe*5wufi?`jb_D-_%JeknC0 z>-*#6tA3p=ITDf~8mIyDq*()P(omz)>Y7hQFT;U*OU;#CUs+G=j0D*H;KsihfWNDj zljp0VZWC)sI~PL0W0>~2+5@lde#AmIH?-Ma=ZW<+M!ES2V}vzx#aRnew~T^S#QyS{ z1$i2ehgi>{bM^w^QjMT;9b<>x<2%u>o6v3AvcfT)AFIPNSxiE6^qbmLKtG|LbwiG> zxQ;Z6JYn&Nq}E+EZ_;e80d(nnNa%eoEswY=poy!ouYv6GXi2H4eNPNOXMHTPmn*vk zyiz7v5dh)DY4rx!(wH9S{oA?a7KzhPNqdGBe?zCnLWFK>ApN*==&6`m0AZAQ;^Op% z+m4=pKv>#73Pz_|pYo>#93T)&HX^<{#tX!|Wbz-t#46=)@EnL^hu4;_T0lTRf<@NmgY} zYDfNFD}`DZo((nD=2^i*PHa|X{4}(_NV3NK_``8``|Kuc=Juwl!~&6c+jO~x1PQDq zfe7n=@S5+}*HgMweHxLr@F~)eL%Us#?$1+x*&&N>Gg^?0SOHECjQ4h1YqKp|Yfz;S$5vbPc z8qS*0Wr>SdDZ=9cu3BT128Q{bsQ8BHuT?SHuOo_@ z3u}b1Bxa4c4h8ood14Wztp2haPc3owC8~b#_8|FuMN>yfclsPSP^I_pkGPKV&M-Fgf4AS-aP^GPF#~3_V0nztg}Sv_J!$?E=QQ zP`6=Sf}0(dq+E<97oK4X*GD?YJJh1h%)9~-uV>i`*m6e7|StNYj+ zFp+l6chja(>ed!4ZC{J!^iF2mUA@1YCPL2)a8j|)rK#17Zb1-f-Iu% zZ*7qMO$NA4|Im7g;}GZm*XP0e-?)HG86>5#W1osy&vJ1 zT(KMBSJ3-S3NXs}#06jjMv(D)lWc~Y6-{(|-r2VD%s%4se~IeRH6q6v&A#Ch9ko)5 zdy_ftTGV)^#n%D6A28^g3O@+!>&NtgjBK}(m{TV!GnDCscMI8_i%o+f&jC&bc*K1Z zYOX`LS&xgq`GtWswn>DsZTHQUk*Sd4eoA`%B!DpN`~68NmE_BM$0Q~@4pv=@sCVzw z9sJLSkH0qD_%%_kE)zKZS(y&cbm^Dzs4pDzVQ#C&EB19!9uyFoHy7Q}-mY*M7i?SXjG7 zam>;DNjfT2hhKdncw>RYmgX8juqm%KX~o*ADf`apa{>YEUFQ>#A+^Vo*$T0jno`=7 zNTZ<0<7GnZlggs|-VOLNJox>NlLkohRd4s)*CkABC~lI8{jWD8|X;(Oo2 z-L#)1K%$$+0*?Rp+w46Ll1b`SkvMcBAeDUZ2vhZ;T{esrt-HrPc-bU{$bHhgJ;O%) zJ|Bbf6j=9zSerheM^t!04UJw=O}8BhKW4E}&Nn>g4g|nB?KQ$Be)ub(Y2ia;iv=cv zIXZZ^PmkL`mm0eS)n-OIPC?Vikw!q|U>%!Q?pfhovDd!Y+m+)bJKt;S=?eFA+w&Jx z)>3J9K4SXCwT}2Y)kr4u*@0eorYK?|oo`{}6XXJ2+SbVOiXTDL#G~&rad>UXU)R3| z!aWLqakvU5o(uD@x$Dp%j;6v=ITDY6uJm#trJsAOi2FenR$NnmQCNMLT_f6;(jGe= zL6#i4y8jM9iHXS280#7VTnXGnjVy@0ZOEK*bkcKQdeOf)(?GJb z54gTQsH;l5!;oe$KM2iW@EKIR3;V;bF_JeTT7%5GW%sP8G;YM5( zs78rQ*nXOZ>u6GITOowSTQBUqqE&bE@lDs(9w%N=*KqQMq|IuSr->seXPb)m3fn3C zSXFlaHhW++Mk!&b2Xeo!0pTUnL!rg37ju5o#94VZ4S)SYN$w$Q)WT@8ocdeJpqE>5 zBf*eYjZES^BShFwP;GI%k33{q5tcs!XBSPVjsswREb13F2&fmPKQ_$%o~Y(4f}>)S zhe!okYfp8YX*GRSD>xVBg~sKqvQ=5~+4>~cMWsX!rrNHJsTnjarc^Xvm$>U{ezV}_S~M{3MS=B=mnIBQ$V$_YwX{TY%& z;Ol_w3MxqmSyml9LC%nCatHZd#QH!Dj7->kDvq;up>!Ujg4H89BC=|JH+Hic-$}fe zIc4wV_b$fm7g$IR8Qw$>Cqo9@`$+AuQrO;?v=(sapJqb=NNv5c!JErg^k-QOX@?F< zzt~2YkyG6z)zHIpxJmZgpkJM%zyzn}iw>8>?pjgA-6{N86fpwKfRJnT-#UlDC67)c zO!YrcMQxP|=gK99iq?42G^K6L&xuf&DG9l*?&7I9;W})wGh|47D^1#DuDkZeDk0KL zkC9gwP*-CqQU9_`Fwaao=y8E#5){i~hB_asx@M{%7AoOy$N*lc*(FihDTfxIbj>tERIs0z+v7UUI#x!ye-0WuC>h)n#mVgt zSZwwcKh7#}egt?7;39Q6tPf(RU()K8nFu5YL4KP_KITGF?-}Db8y0+odJqc(FLvZ` zt}}vnx%tVlsD~n?0PBRAk}@kJzH8$Igg^1-FJFT_jACXEL-ga?y1%JtOIlD)IX-H& z%&5~5vzEa8*bDyA>`~I%m(<%5>5}P&Sn!*yvPF!z^iP}KaSsIgnYrb)9};a|^Miy2 z(y9e$yi2M>Kb-MKk|CbSiSdq+aX_z5nttxdVSMWb$8v+X2v7tKYx^CWoNbn0-h2^x zwnLD2`Uq=9jx%-oYn>U|-TF^YC0vRWVR?-4Ev%WYqCZRkz32Emb=U)^onN>n(cd-3 zWaVr%0{te7+#^gLQs4;Z*k~hfxe9i5oMaSs9qc3Hd`fuve$iWd=Z^%pt-tfA%nMvb zW!B#DT5=yd;P$;$?KbOwz~MtcTap&9%Lr>k@@C}6bnekcnpaD<5DGhRdNk(Ty+*PS zHlAGruUWnmzU>#6)C|q9<42B_msws}QECfy9kIa2Ks9t)JX|udF}0%hmBI&Q`oeqI z%+<0k<9jf-ZifN)hCC(W*{R;^4|i%mY#ItA2Sa)Nx>(jIbGHILE$qBLs=d%C ztbokrabA{#&(^A-XY5L(vI3WcwR*MtH@XO@5aOA6<3Sy}_(jaS>nYdqn5FI^DmG>? zX*9VI@4|X)Ca^#x9Lmm~N+p}c5XGlicF4ae7yg_MoA|Q5IW~0g^u8?O6nkr;kNbww z@D{!Y42DeqW&sqvm{>RNin??0cdG0O!%iKl1SXa|aU6l@s^AtOPl26UX&?0rk>5_E z`lIE^oXGwp!R8dcp>HnpqjUY`Zog7qxJe+q7G0Y4CXPCp+R-~-lWc>O7R>bLKPepX zHu?zjPIAl)WveDWucPTo{zi%Q6=N@J;f6f!V zz!z*+a?|bJXF$J+0NS#?c%CqAs?$L{EGSnl{FkwM)AVII&YBKUmHnqeBb5#L$Hf$< zv9WhVsW%tj#me$^xJfPN1E8Fl{Im9ECn~l_>8By$)a>BDm=7xa;Mz-chy()WFD|OA zD0T^w+}v`8RdQ4>Cn~+=9q*gR6__i+PQ-$xLOZt%Zv!)+*bu#Y2 zL}zDh`|#1$=E6enUSxr4A@?nfN-Ja(zU5D6zoRaK#IkwvHzmM+U-htci8RPEsPcEX zQp1nkMNe3q54l77;O_C?4cDd%(K_XlFkpSvBfNo&r>qcKj`L>vshczPA7V-JM2M0f zec^P0#vfnMBU?x6B z?^RORFEYV%P!9OZWB0(h?VFH&x!bVf4;ES^-j%lWpR9Fo@F$gT)1;&k6%HrT*uu{7 z)u9p=e}Zq!4cH;eXvX5PvfIEG2Cq&v^HE*x7#zc)1 zcrYUyTE&&(PM*4qk{hflg*GN1PJLJ-5qL*0U`(2j+;-!==?zNkp*4b-pKAnv{m`HR z`qCdF-A+wetK{W6LxL|Thl3`_Gl$UkE7*jpHtcAm&R!3}I$aGT-_6wa{L@tUO$@oS zzmqybBm2H>n`htqNOZ!5CG#BCgi+ zKY`Xipc@RIa=pEfO?ia4&y{ny*B)x(c{((4_SbFcZNOsf4WZ-IqWVC1#g^_(o#-(2 zO|yJQ`n%&4SGT2LNL1gi6hwaVk3cX(#wD@p!`4%`?TnwVQAC~+hG3=9<<_jHajg~}UyMg&vTuhF%5rUT5Y5nVgXLS5FzS3B)gtS8K{GOzv42Hbkvoon! zhIB@N^H!7XT0QvHZ$T0qsOW^3&#G&-FZ#=|p~{>hiR3uCq&!?qD6uVG;JQyWgjW_* z#pey68Y{agAW|&tdFuza$!2aayBb-w;MS=%a>*sGQ={|F8^UK;X{v1MMbU94WP~9i zp!;tT3{%v6r95A-8SEopC`PsC#A1z-o6dbw53kGceOo|cS%~OC@JfH&8;Q`ppFE>0 zE*4MQ+!@>`-^K)3uE&ZX^`-E6XC!BbsBjW`EhojXkvBU_xItxQdvSrRxu$IGq>ihk zOwZV&DFq`tQoE8)1C0<-ZXu?|hyn-v*|_&%3b&jYSHwPNZ3sMdNc67vA%3gAcu)@+|xr$V-QtxALmF#B5k34#t834o}!XJh)$3^H-uj(fMnGS;UoD@^_#ioaI( zaZ{5)rHpmWK_`(Gka0g(o8-CRq)(7yIkNvEeSk+=A6Fp6LUCVsEloW3f!opG+mY8a zF&V>OOSfB43eLBKGy}V4W&MJ;qU8PYq zgbJnxlijpVSZW5tT=opGB5iNVJ&s`}9bNnO$YOy`K1a4bdrH{Jm3`{3?DNJN6A@Qn z0U2;xc-ctE%1H|2*W6x1%d*oxK5HdS7_*%~#yWA!LUA#c#y~gqM}8(?U$LGEaK;BP zoQIzVX3#5D5I7a-57|IRHSsp5E z33#50ucRO3T@d0LNlrJ56`12JU!62EWoOYmjZ!P05A?Nvs~CQk=IH8YL!u? zbUy9a-hOdvP=ig4TI=6&wu=GCSNnOa?=v1sY~7l>5J8f=^e_Po0va~};ZXwojUnzY zb^Rd;I3N8vMgog9O?&Gl7cDiU``*7n0K$?XKv?&fo`xGjc7Wem5hsky(@4FAtQ#bP z)rZP#Jl>8KBLv&7TpS5-ZK-;lC%$ESPk}6(=^gU$@yJzZjukX?sNbU01Aa+4FVhcppRKtYOSEAWd1;G{bfqWB6ay*b=sxHEDE=X{IK@uY z^YYn@d#e()?X&kJdtP^&(dHkm2adzi%kmX|=6kc~k4a|BFhM4^pS;j-{aKQKy@OU> za&Bp251TcLiDI8$k-z&Qr}(X@K#-&2W?pVhnMB&#e9d0kGy<~(Ba=>xCV6SkrtM(u zo@41)JA!6-4XRg4dt>%>`h`3e&@_2ey+nOLPWa^`O$XY+>hj>Q_0(I6uE`Xo>qr37 zQBtVyOJB3?1@EhYY);L4_)Qt4nvy>Ar%W{@)A~x?>jEa)%TCJkQe2Yg;GpIQ(9{#X z)R(WN?z1Ym1uS`i3dj3bbf+=%W~qtQE8US3L}pc#)9Ypx#U(Q!xqG((eNwb04Kv~O zk2Ti;E|6f&ikA;)w5|nuNcyM`xWrE+T5SkUpM$zWeh6C=`$|GJk1jwq@e>aSxJ7W^ zxk3HAGytfQ_NWWo{MnN$><>YPvFSH4P??cwE7-TzE5ixm`?%M-qYCU>pZ;0sn>c9L z=y=t)yDPz1i4*^-x7o<7x2|Gynes Dr$L|A literal 0 HcmV?d00001 diff --git a/translations/en-us.yml b/translations/en-us.yml index fbf1906eb99..b5f3e8cd2c8 100644 --- a/translations/en-us.yml +++ b/translations/en-us.yml @@ -737,10 +737,24 @@ social: google_group: 'Google Group' github: GitHub preprints: + title: 'Preprints' + header: + osf_registrations: 'OSF Preprints' + registrations: 'Preprints' + search_placeholder: 'Search preprints ...' + search_button: 'Perform search' + search_label: 'Search' + search_help: 'Search help' + powered_by: 'Powered by OSF Preprints' + or: 'or' + submit_label: 'Submit a preprint' + example: 'See an example' subjects: heading: hasHighlightedSubjects: 'Highlighted Subjects' noHighlightedSubjects: 'No Highlighted Subjects' + links: + seeAllSubjects: 'See all subjects' services: top: heading: 'Heading' From 48423c487d394168c2e1578b0a97bd157bc9a753 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Fri, 14 Jul 2023 10:30:20 -0600 Subject: [PATCH 024/170] Added the taxonomy top list component and integrated it into the index page --- app/preprints/index/template.hbs | 1 + .../preprints/taxonomy-top-list/component.ts | 46 +++++++++++++++++++ .../preprints/taxonomy-top-list/template.hbs | 16 +++++++ .../preprints/taxonomy-top-list/component.js | 1 + .../preprints/taxonomy-top-list/template.js | 1 + translations/en-us.yml | 7 +-- 6 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 lib/osf-components/addon/components/preprints/taxonomy-top-list/component.ts create mode 100644 lib/osf-components/addon/components/preprints/taxonomy-top-list/template.hbs create mode 100644 lib/osf-components/app/components/preprints/taxonomy-top-list/component.js create mode 100644 lib/osf-components/app/components/preprints/taxonomy-top-list/template.js diff --git a/app/preprints/index/template.hbs b/app/preprints/index/template.hbs index bb8214d50e0..d6a1c2f4955 100644 --- a/app/preprints/index/template.hbs +++ b/app/preprints/index/template.hbs @@ -77,6 +77,7 @@ {{#if this.theme.provider.additionalProviders}} {{additional-provider-list additionalProviders=this.theme.provider.additionalProviders}} {{else}} + {{/if}}
diff --git a/lib/osf-components/addon/components/preprints/taxonomy-top-list/component.ts b/lib/osf-components/addon/components/preprints/taxonomy-top-list/component.ts new file mode 100644 index 00000000000..7addf545d5d --- /dev/null +++ b/lib/osf-components/addon/components/preprints/taxonomy-top-list/component.ts @@ -0,0 +1,46 @@ +import Component from '@glimmer/component'; +import { computed } from '@ember/object'; +import SubjectModel from 'ember-osf-web/models/subject'; + +interface InputArgs { + list: SubjectModel[]; +} + +interface PairModel { + path: string[]; + text: string; +} + +export default class TaxonomyTopList extends Component { + routerPrefix = 'http://localhost:4200'; + + + @computed('args.list') + get sortedList() { + if (!this.args.list) { + return; + } + const sortedList = this.args.list.sortBy('text'); + const pairedList = [] as PairModel[][]; + for (let i = 0; i < sortedList.get('length'); i += 2) { + const pair: PairModel[] = []; + // path in pair needs to be a list because that's what the + // subject param in the discover controller is expecting + const subjectOdd = sortedList.objectAt(i) as SubjectModel; + pair.pushObject({ + path: [subjectOdd?.taxonomyName], + text: subjectOdd?.text, + } as PairModel); + + if (sortedList.objectAt(i + 1)) { + const subjectEven = sortedList.objectAt(i + 1) as SubjectModel; + pair.pushObject({ + path: [subjectEven?.taxonomyName], + text: subjectEven?.text, + }); + } + pairedList.pushObject(pair); + } + return pairedList; + } +} diff --git a/lib/osf-components/addon/components/preprints/taxonomy-top-list/template.hbs b/lib/osf-components/addon/components/preprints/taxonomy-top-list/template.hbs new file mode 100644 index 00000000000..dadac8b9f52 --- /dev/null +++ b/lib/osf-components/addon/components/preprints/taxonomy-top-list/template.hbs @@ -0,0 +1,16 @@ +{{#each this.sortedList as |pair|}} +
+ {{#each pair as |subject|}} +
+ + {{subject.text}} + +
+ {{/each}} +
+{{/each}} diff --git a/lib/osf-components/app/components/preprints/taxonomy-top-list/component.js b/lib/osf-components/app/components/preprints/taxonomy-top-list/component.js new file mode 100644 index 00000000000..90bed31d38d --- /dev/null +++ b/lib/osf-components/app/components/preprints/taxonomy-top-list/component.js @@ -0,0 +1 @@ +export { default } from 'osf-components/components/preprints/taxonomy-top-list/component'; diff --git a/lib/osf-components/app/components/preprints/taxonomy-top-list/template.js b/lib/osf-components/app/components/preprints/taxonomy-top-list/template.js new file mode 100644 index 00000000000..40849b6fc92 --- /dev/null +++ b/lib/osf-components/app/components/preprints/taxonomy-top-list/template.js @@ -0,0 +1 @@ +export { default } from 'osf-components/components/preprints/taxonomy-top-list/template'; diff --git a/translations/en-us.yml b/translations/en-us.yml index b5f3e8cd2c8..8ba5580491e 100644 --- a/translations/en-us.yml +++ b/translations/en-us.yml @@ -751,10 +751,11 @@ preprints: example: 'See an example' subjects: heading: - hasHighlightedSubjects: 'Highlighted Subjects' - noHighlightedSubjects: 'No Highlighted Subjects' + provider: 'Browse by provider' + hasHighlightedSubjects: 'Browse by featured subjects' + noHighlightedSubjects: 'Browse by subjects' links: - seeAllSubjects: 'See all subjects' + seeAllSubjects: 'See all subjects available' services: top: heading: 'Heading' From 170fa0427fc9b49e7a2436921d127f6310698c0a Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Mon, 17 Jul 2023 11:39:49 -0600 Subject: [PATCH 025/170] Updates to the preprints template file to remove bootstrap --- app/preprints/index/styles.scss | 43 ++++----- app/preprints/index/template.hbs | 95 +++++++++---------- .../components/branded-header/styles.scss | 6 ++ .../addon/branded/discover/route.ts | 1 + translations/en-us.yml | 65 +++++++------ 5 files changed, 104 insertions(+), 106 deletions(-) diff --git a/app/preprints/index/styles.scss b/app/preprints/index/styles.scss index d858166a2cf..223b0019359 100644 --- a/app/preprints/index/styles.scss +++ b/app/preprints/index/styles.scss @@ -2,15 +2,9 @@ .preprint-header { background: #214661 url('img/preprints-bg.jpg') top center; background-position-y: -50px; - padding-top: 100px; - padding-bottom: 30px; border-bottom: 1px solid #ddd; color: $color-text-white; - - h1 { - font-size: 41px; - font-weight: 300; - } + width: 100%; a:not(:global(.btn)) { color: #80c2f7; @@ -21,27 +15,24 @@ color: $color-text-white; } -} -.example-container { - display: flex; - flex-direction: row; - justify-content: center; - align-items: center; - width: 100%; - margin-top: 25px; -} + .submit-container { + width: 100%; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; -.preprint-lead, -.preprint-tool h2 { - text-transform: capitalize; + .example-container { + display: flex; + justify-content: center; + align-items: center; + width: 100%; + margin-top: 25px; + } + } } -/* Recent uploads list panel */ -.preprint-list { - background: #fbfbfb; - border-bottom: 1px solid #eee; -} /* Subject Panel */ .preprint-subjects { @@ -63,6 +54,10 @@ text-shadow: 0 0 5px #506069; background-size: cover; + h2 { + text-transform: capitalize; + } + .provider-logo { height: 120px; background-size: contain; diff --git a/app/preprints/index/template.hbs b/app/preprints/index/template.hbs index d6a1c2f4955..f5cdb36e19e 100644 --- a/app/preprints/index/template.hbs +++ b/app/preprints/index/template.hbs @@ -4,56 +4,53 @@ {{!HEADER}}
- {{!CONTAINER}} -
- -
- {{#branded-header.lead}} -
- {{html-safe this.theme.provider.description}} -
- - {{/branded-header.lead}} - {{#branded-header.row}} - {{#if this.theme.provider.allowSubmissions}} -
-
-

{{t 'preprints.header.or'}}

- - {{t 'preprints.header.submit_label' documentType=this.theme.provider.content.documentType}} - -
- - {{t 'preprints.header.example'}} - -
-
+ +
+ {{#branded-header.lead}} +
+ {{html-safe this.theme.provider.description}} +
+
+ + {{t 'preprints.header.powered_by'}} + +
+ {{/branded-header.lead}} + {{#branded-header.row}} + {{#if this.theme.provider.allowSubmissions}} +
+

{{t 'preprints.header.or'}}

+ + {{t 'preprints.header.submit_label' documentType=this.theme.provider.content.documentType}} + +
+ + {{t 'preprints.header.example'}} +
- {{/if}} - {{/branded-header.row}} - - {{!END ROW}} -
- {{!END CONTAINER}} +
+ {{/if}} + {{/branded-header.row}} +
{{!END HEADER}} diff --git a/lib/osf-components/addon/components/branded-header/styles.scss b/lib/osf-components/addon/components/branded-header/styles.scss index 35e8f04b5ea..195ddee63c4 100644 --- a/lib/osf-components/addon/components/branded-header/styles.scss +++ b/lib/osf-components/addon/components/branded-header/styles.scss @@ -14,6 +14,12 @@ margin-bottom: 20px; font-weight: 300; line-height: 1.4; + + width: 100%; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; } p { diff --git a/lib/registries/addon/branded/discover/route.ts b/lib/registries/addon/branded/discover/route.ts index b502a2f2c28..fdd17e9da42 100644 --- a/lib/registries/addon/branded/discover/route.ts +++ b/lib/registries/addon/branded/discover/route.ts @@ -1,6 +1,7 @@ import Route from '@ember/routing/route'; import RouterService from '@ember/routing/router-service'; import { inject as service } from '@ember/service'; +import RegistrationProviderModel from 'ember-osf-web/models/registration-provider'; import { notFoundURL } from 'ember-osf-web/utils/clean-url'; diff --git a/translations/en-us.yml b/translations/en-us.yml index 8ba5580491e..8079dd3f5cb 100644 --- a/translations/en-us.yml +++ b/translations/en-us.yml @@ -736,39 +736,6 @@ social: facebook: Facebook google_group: 'Google Group' github: GitHub -preprints: - title: 'Preprints' - header: - osf_registrations: 'OSF Preprints' - registrations: 'Preprints' - search_placeholder: 'Search preprints ...' - search_button: 'Perform search' - search_label: 'Search' - search_help: 'Search help' - powered_by: 'Powered by OSF Preprints' - or: 'or' - submit_label: 'Submit a preprint' - example: 'See an example' - subjects: - heading: - provider: 'Browse by provider' - hasHighlightedSubjects: 'Browse by featured subjects' - noHighlightedSubjects: 'Browse by subjects' - links: - seeAllSubjects: 'See all subjects available' - services: - top: - heading: 'Heading' - paragraph: 'Paragraph' - bottom: - contact: 'contact' - p1: 'Bottom P1' - div: - line1: 'Line 1' - line2: 'Line 2' - line3: 'Line 3' - linkText1: 'Link Text 1' - linkText2: 'Link Text 2' institutions: description: 'OSF Institutions enhances transparency and increases the visibility of research outputs, accelerating discovery and reuse. Institutional members focus on generating and sharing research, and let OSF Institutions handle the infrastructure.' read_more: 'Read more' @@ -1152,6 +1119,38 @@ preprints: provider-title: '{name} {pluralizedPreprintWord}' discover: title: 'Search' + title: 'Preprints' + header: + osf_registrations: 'OSF Preprints' + registrations: 'Preprints' + search_placeholder: 'Search preprints ...' + search_button: 'Perform search' + search_label: 'Search' + search_help: 'Search help' + powered_by: 'Powered by OSF Preprints' + or: 'or' + submit_label: 'Submit a preprint' + example: 'See an example' + subjects: + heading: + provider: 'Browse by provider' + hasHighlightedSubjects: 'Browse by featured subjects' + noHighlightedSubjects: 'Browse by subjects' + links: + seeAllSubjects: 'See all subjects available' + services: + top: + heading: 'Heading' + paragraph: 'Paragraph' + bottom: + contact: 'contact' + p1: 'Bottom P1' + div: + line1: 'Line 1' + line2: 'Line 2' + line3: 'Line 3' + linkText1: 'Link Text 1' + linkText2: 'Link Text 2' registries: header: osf_registrations: 'OSF Registrations' From b83711f5d5ba9a80653fc532ce0301734e8a408a Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Mon, 17 Jul 2023 12:24:13 -0600 Subject: [PATCH 026/170] Fixed the css for the taxonomy-top-list --- app/preprints/index/styles.scss | 122 +++++++++++------- app/preprints/index/template.hbs | 48 +++---- .../preprints/taxonomy-top-list/styles.scss | 21 +++ .../preprints/taxonomy-top-list/template.hbs | 5 +- 4 files changed, 123 insertions(+), 73 deletions(-) create mode 100644 lib/osf-components/addon/components/preprints/taxonomy-top-list/styles.scss diff --git a/app/preprints/index/styles.scss b/app/preprints/index/styles.scss index 223b0019359..3bc90404872 100644 --- a/app/preprints/index/styles.scss +++ b/app/preprints/index/styles.scss @@ -1,67 +1,95 @@ -/* Main header with search bar */ -.preprint-header { - background: #214661 url('img/preprints-bg.jpg') top center; - background-position-y: -50px; - border-bottom: 1px solid #ddd; - color: $color-text-white; - width: 100%; +// stylelint-disable max-nesting-depth, selector-max-compound-selectors - a:not(:global(.btn)) { - color: #80c2f7; - text-decoration: underline; - } +.preprints-page-container { + width: 100%; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; - .btn-info { + .preprint-header { + background: #214661 url('img/preprints-bg.jpg') top center; + background-position-y: -50px; + border-bottom: 1px solid #ddd; color: $color-text-white; - } + width: 100%; + a:not(:global(.btn)) { + color: $color-link-blue; + text-decoration: underline; + } - .submit-container { - width: 100%; - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; + .btn-info { + color: $color-text-white; + } - .example-container { + + .submit-container { + width: 100%; display: flex; + flex-direction: column; justify-content: center; align-items: center; - width: 100%; - margin-top: 25px; + + .example-container { + display: flex; + justify-content: center; + align-items: center; + width: 100%; + margin-top: 25px; + } } } -} + /* Subject Panel */ + .preprint-subjects-container { + background-color: $color-bg-gray-lighter; + border-bottom: 1px solid #6d8a98; + padding-top: 15px; + padding-bottom: 15px; + width: 100%; + flex-direction: column; + display: flex; + justify-content: center; + align-items: center; -/* Subject Panel */ -.preprint-subjects { - background-color: #f1f3f2; - border-bottom: 1px solid #6d8a98; + .preprint-subjects-inner-container { + background-color: $color-bg-gray-lighter; + padding-right: 30px; + padding-left: 30px; + width: calc(100% - 60px); + flex-direction: column; + display: flex; + justify-content: flex-start; + align-items: flex-start; - .subject-item a { - width: 100%; - font-size: 17px; - overflow: hidden; - text-overflow: ellipsis; + .subject-list-container { + padding: 25px; + width: 100%; + flex-direction: column; + display: flex; + justify-content: flex-start; + align-items: flex-start; + } + } } -} -/* Preprint providers and become provider */ -.preprint-tool { - background: #cbd9d5 url('img/index-tool-bg.jpg') top center; - color: $color-text-white; - text-shadow: 0 0 5px #506069; - background-size: cover; + /* Preprint providers and become provider */ + .preprint-tool { + background: #cbd9d5 url('img/index-tool-bg.jpg') top center; + color: $color-text-white; + text-shadow: 0 0 5px #506069; + background-size: cover; - h2 { - text-transform: capitalize; - } + h2 { + text-transform: capitalize; + } - .provider-logo { - height: 120px; - background-size: contain; - background-repeat: no-repeat; - background-position: center; + .provider-logo { + height: 120px; + background-size: contain; + background-repeat: no-repeat; + background-position: center; + } } } diff --git a/app/preprints/index/template.hbs b/app/preprints/index/template.hbs index f5cdb36e19e..9de409fee22 100644 --- a/app/preprints/index/template.hbs +++ b/app/preprints/index/template.hbs @@ -1,6 +1,6 @@ {{page-title (t 'preprints.title')}} -
+
{{!HEADER}}
@@ -55,29 +55,29 @@ {{!END HEADER}} {{!SUBJECTS}} -
-
-
-
-

{{#if this.theme.provider.additionalProviders}} - {{t 'preprints.subjects.heading.provider'}} - {{else}} - {{if this.theme.provider.hasHighlightedSubjects (t 'preprints.subjects.heading.hasHighlightedSubjects') (t 'preprints.subjects.heading.noHighlightedSubjects')}} - {{/if}} -

- {{#if this.theme.provider.hasHighlightedSubjects}} - {{#link-to (this.route-prefix 'discover') class='seeAllSubjects'}} - {{t 'preprints.subjects.links.seeAllSubjects'}} - {{/link-to}} - {{/if}} -
- {{#if this.theme.provider.additionalProviders}} - {{additional-provider-list additionalProviders=this.theme.provider.additionalProviders}} - {{else}} - - {{/if}} -
-
+
+
+

{{#if this.theme.provider.additionalProviders}} + {{t 'preprints.subjects.heading.provider'}} + {{else}} + {{if this.theme.provider.hasHighlightedSubjects (t 'preprints.subjects.heading.hasHighlightedSubjects') (t 'preprints.subjects.heading.noHighlightedSubjects')}} + {{/if}} +

+ {{#if this.theme.provider.hasHighlightedSubjects}} + + {{t 'preprints.subjects.links.seeAllSubjects'}} + + {{/if}} +
+ {{#if this.theme.provider.additionalProviders}} + {{additional-provider-list additionalProviders=this.theme.provider.additionalProviders}} + {{else}} + + {{/if}}
diff --git a/lib/osf-components/addon/components/preprints/taxonomy-top-list/styles.scss b/lib/osf-components/addon/components/preprints/taxonomy-top-list/styles.scss new file mode 100644 index 00000000000..dc9c822e816 --- /dev/null +++ b/lib/osf-components/addon/components/preprints/taxonomy-top-list/styles.scss @@ -0,0 +1,21 @@ +// stylelint-disable max-nesting-depth, selector-max-compound-selectors + +.subject-container { + width: 100%; + display: flex; + flex-direction: row; + justify-content: space-between; + align-items: flex-start; + margin-bottom: 10px; + + .subject-item { + width: calc(50% - 20px); + + .subject-button { + width: 100%; + font-size: 17px; + overflow: hidden; + text-overflow: ellipsis; + } + } +} diff --git a/lib/osf-components/addon/components/preprints/taxonomy-top-list/template.hbs b/lib/osf-components/addon/components/preprints/taxonomy-top-list/template.hbs index dadac8b9f52..28ee59d77ef 100644 --- a/lib/osf-components/addon/components/preprints/taxonomy-top-list/template.hbs +++ b/lib/osf-components/addon/components/preprints/taxonomy-top-list/template.hbs @@ -1,11 +1,12 @@ {{#each this.sortedList as |pair|}} -
+
{{#each pair as |subject|}} -
+
{{subject.text}} From 9cf21b33d3552f152ea0651e36aea4ea9a2101bb Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Mon, 17 Jul 2023 12:30:33 -0600 Subject: [PATCH 027/170] Removed an unnecessary import for analytics --- app/preprints/index/controller.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/preprints/index/controller.ts b/app/preprints/index/controller.ts index 657db70f6cc..f8936e7d661 100644 --- a/app/preprints/index/controller.ts +++ b/app/preprints/index/controller.ts @@ -3,14 +3,12 @@ import Controller from '@ember/controller'; import { action } from '@ember/object'; import RouterService from '@ember/routing/router-service'; import { inject as service } from '@ember/service'; -import Analytics from 'ember-osf-web/services/analytics'; import Theme from 'ember-osf-web/services/theme'; export default class Preprints extends Controller { @service store!: Store; @service theme!: Theme; @service router!: RouterService; - @service analytics!: Analytics; livedata = 'livedata'; providerAsset = 'https://localhost:4200'; From 27d895f2f7107ef27ee69f331d5b5f9837432b72 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Tue, 18 Jul 2023 14:26:05 -0600 Subject: [PATCH 028/170] Added more information for the providers --- app/preprints/index/controller.ts | 1 + app/preprints/index/route.ts | 7 ++++- app/preprints/index/styles.scss | 52 ++++++++++++++++++++++++++----- app/preprints/index/template.hbs | 41 +++++++++++++----------- translations/en-us.yml | 24 ++++++++------ 5 files changed, 88 insertions(+), 37 deletions(-) diff --git a/app/preprints/index/controller.ts b/app/preprints/index/controller.ts index f8936e7d661..07a7c86bcf5 100644 --- a/app/preprints/index/controller.ts +++ b/app/preprints/index/controller.ts @@ -13,6 +13,7 @@ export default class Preprints extends Controller { livedata = 'livedata'; providerAsset = 'https://localhost:4200'; routePrefix = 'https://localhost:4200'; + brandedPreprintUrl = 'http://localhost:4200'; @action onSearch(query: string) { diff --git a/app/preprints/index/route.ts b/app/preprints/index/route.ts index e339e489c93..bbcdb118e7a 100644 --- a/app/preprints/index/route.ts +++ b/app/preprints/index/route.ts @@ -12,7 +12,6 @@ export default class Preprints extends Route { @service store!: Store; @service theme!: Theme; @service router!: RouterService; - livedata = 'livedata'; async model() { try { @@ -26,9 +25,15 @@ export default class Preprints extends Route { }, }); + const brandedProviders = this.theme.id === 'osf' ? await this.store + .findAll('preprint-provider', { reload: true }) + .then(result => result + .filter(item => item.id !== 'osf')) : []; + return { provider, taxonomies, + brandedProviders, }; } catch (e) { diff --git a/app/preprints/index/styles.scss b/app/preprints/index/styles.scss index 3bc90404872..ca0667d4466 100644 --- a/app/preprints/index/styles.scss +++ b/app/preprints/index/styles.scss @@ -75,21 +75,57 @@ } /* Preprint providers and become provider */ - .preprint-tool { - background: #cbd9d5 url('img/index-tool-bg.jpg') top center; + .preprint-tool-container { + background: url('images/default-brand/bg-dark.jpg'); color: $color-text-white; text-shadow: 0 0 5px #506069; background-size: cover; + padding-top: 15px; + padding-bottom: 15px; + min-width: 100%; + min-height: 100%; + width: 100%; + flex-direction: column; + display: flex; + justify-content: center; + align-items: center; + + .preprint-tool-inner-container { + padding-right: 30px; + padding-left: 30px; + width: calc(100% - 60px); + flex-direction: column; + display: flex; + justify-content: flex-start; + align-items: flex-start; + + .subtitle { + margin-bottom: 25px; + } + + .preprint-logos-container { + padding: 25px; + width: 100%; + flex-direction: row; + flex-wrap: wrap; + display: flex; + justify-content: center; + align-items: flex-start; + + .provider-logo { + width: 150px; + height: 75px; + background-size: contain; + background-repeat: no-repeat; + background-position: center; + margin: 15px; + } + } + } h2 { text-transform: capitalize; } - .provider-logo { - height: 120px; - background-size: contain; - background-repeat: no-repeat; - background-position: center; - } } } diff --git a/app/preprints/index/template.hbs b/app/preprints/index/template.hbs index 9de409fee22..5bc6cc8dd99 100644 --- a/app/preprints/index/template.hbs +++ b/app/preprints/index/template.hbs @@ -72,7 +72,7 @@ {{t 'preprints.subjects.links.seeAllSubjects'}} {{/if}} -
+
{{#if this.theme.provider.additionalProviders}} {{additional-provider-list additionalProviders=this.theme.provider.additionalProviders}} {{else}} @@ -84,24 +84,27 @@ {{#unless this.theme.isProvider}} {{!SERVICES}} -
-
-
-
-

{{t 'preprints.services.top.heading' documentType=this.theme.provider.content.documentType}}

-

- {{t 'preprints.services.top.paragraph' documentType=this.theme.provider.content.documentType}} -

-
-
-
-
- {{#each this.model.brandedProviders as |provider| }} - {{#if (not-eq provider.id this.livedata) }} - - {{/if}} - {{/each}} -
+
+
+

{{t 'preprints.services.top.heading' documentType=this.theme.provider.documentType.singularCapitalized}}

+

+ {{t 'preprints.services.top.paragraph' documentType=this.theme.provider.documentType.singular}} +

+
+ {{#each this.model.brandedProviders as |provider| }} + {{#if (not-eq provider.id this.livedata) }} + + {{ provider.name }} + + {{/if}} + {{/each}}
diff --git a/translations/en-us.yml b/translations/en-us.yml index 8079dd3f5cb..6c494b8e55f 100644 --- a/translations/en-us.yml +++ b/translations/en-us.yml @@ -1140,17 +1140,23 @@ preprints: seeAllSubjects: 'See all subjects available' services: top: - heading: 'Heading' - paragraph: 'Paragraph' + # heading: '{documentType.singularCapitalized} Services' + heading: '{documentType} Services' + # paragraph: 'Leading {documentType.singular} service providers use this open source infrastructure to support their communities.' + paragraph: 'Leading {documentType} service providers use this open source infrastructure to support their communities.' bottom: - contact: 'contact' - p1: 'Bottom P1' + contact: 'Contact us' + # p1: 'Create your own branded {documentType.singular} servers backed by the OSF.' + p1: 'Create your own branded {documentType} servers backed by the OSF.' div: - line1: 'Line 1' - line2: 'Line 2' - line3: 'Line 3' - linkText1: 'Link Text 1' - linkText2: 'Link Text 2' + line1: 'Check out the' + linkText1: 'open source code' + line2: 'and our' + linkText2: 'public roadmap' + line3: '. Input welcome!' + advisory: + heading: 'Advisory Group' + paragraph: 'Our advisory group includes leaders in preprints and scholarly communication' registries: header: osf_registrations: 'OSF Registrations' From 916d58ce76f4d945a22488546dcfb038871b50a4 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Tue, 18 Jul 2023 14:44:49 -0600 Subject: [PATCH 029/170] Added the advisory board attribute --- mirage/scenarios/preprints.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mirage/scenarios/preprints.ts b/mirage/scenarios/preprints.ts index e50aa80df4f..3abe4f19076 100644 --- a/mirage/scenarios/preprints.ts +++ b/mirage/scenarios/preprints.ts @@ -29,6 +29,8 @@ function buildOSF( osf.update({ allowSubmissions: true, highlightedSubjects: subjects, + // eslint-disable-next-line max-len + advisory_board: '
\n

Advisory Group

\n

Our advisory group includes leaders in preprints and scholarly communication

\n
\n
\n
    \n
  • Devin Berg : engrXiv, University of Wisconsin-Stout
  • \n
  • Pete Binfield : PeerJ PrePrints
  • \n
  • Benjamin Brown : PsyArXiv, Georgia Gwinnett College
  • \n
  • Philip Cohen : SocArXiv, University of Maryland
  • \n
  • Kathleen Fitzpatrick : Modern Language Association
  • \n
\n
\n
\n
    \n
  • John Inglis : bioRxiv, Cold Spring Harbor Laboratory Press
  • \n
  • Rebecca Kennison : K | N Consultants
  • \n
  • Kristen Ratan : CoKo Foundation
  • \n
  • Oya Rieger : Ithaka S+R
  • \n
  • Judy Ruttenberg : SHARE, Association of Research Libraries
  • \n
\n
', brand, moderators: [currentUserModerator], preprints, @@ -61,6 +63,8 @@ function buildThesisCommons( moderators: [currentUserModerator], preprints, description: '

This is the description for Thesis Commons and it has an inline-style!

', + // eslint-disable-next-line max-len + advisory_board: '

Steering Committee

\n
\n
    \n
  • Obasegun Ayodele, Vilsquare.org, Nigeria
  • \n
  • Fayza Mahmoud, Alexandria University, Egypt
  • \n
  • Johanssen Obanda, Jabulani Youths for Transformation (JAY4T), Kenya
  • \n
  • Umar Ahmad, University Putra Malaysia (UPM) and the Malaysia Genome Institute (MGI)
  • \n
  • Michael Cary, West Virginia University, USA
  • \n
  • Nada Fath, Mohamed V University & Hassan II Institute of Agronomy and Veterinary Medicine, Rabat, Morocco
  • \n
  • Greg Simpson, Cranfield University, England & South Africa
  • \n
\n
\n
    \n
  • Hisham Arafat, EMEA Applications Consulting, Egypt
  • \n
  • Justin Sègbédji Ahinon, AfricArXiv co-founder, IGDORE, Bénin
  • \n
  • Mahmoud M Ibrahim, Uniklinik RWTH Aachen, Germany & Egypt
  • \n
  • Luke Okelo, Technical University of Kenya
  • \n
  • Ryszard Auksztulewicz, MPI of Empirical Aesthetics, Germany & City University of Hong Kong
  • \n
  • Osman Aldirdiri, University of Khartoum, Sudan
  • \n
  • Jo Havemann, AfricArXiv co-founder, Access 2 Perspectives‘, IGDORE, Germany & Kenya
  • \n
', }); const agrixiv = server.schema.preprintProviders.find('agrixiv') as ModelInstance; From 2f7ba52a2f8441c1d9e5e8338ae0f503357ed1f0 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Tue, 25 Jul 2023 10:40:26 -0600 Subject: [PATCH 030/170] Finished the html transformation for preprints --- app/preprints/index/styles.scss | 23 +++++++++++++ app/preprints/index/template.hbs | 59 ++++++++++++++++++++------------ 2 files changed, 61 insertions(+), 21 deletions(-) diff --git a/app/preprints/index/styles.scss b/app/preprints/index/styles.scss index ca0667d4466..ccd3fedb26c 100644 --- a/app/preprints/index/styles.scss +++ b/app/preprints/index/styles.scss @@ -103,6 +103,7 @@ margin-bottom: 25px; } + .preprint-contact-container, .preprint-logos-container { padding: 25px; width: 100%; @@ -121,6 +122,28 @@ margin: 15px; } } + + .preprint-contact-container { + flex-direction: column; + align-items: center; + + .lead { + font-size: 21px; + line-height: 1.4; + font-weight: 300; + + .links { + color: $color-text-white; + text-decoration: underline; + + } + + } + + .contact { + margin-top: 20px; + } + } } h2 { diff --git a/app/preprints/index/template.hbs b/app/preprints/index/template.hbs index 5bc6cc8dd99..579e26122c4 100644 --- a/app/preprints/index/template.hbs +++ b/app/preprints/index/template.hbs @@ -106,27 +106,44 @@ {{/if}} {{/each}}
-
-
-

- {{t 'preprints.services.bottom.p1' documentType=this.theme.provider.content.documentType}} -

- {{t 'preprints.services.bottom.div.line1'}} - - {{t 'preprints.services.bottom.div.linkText1'}} - - {{t 'preprints.services.bottom.div.line2'}} - - {{t 'preprints.services.bottom.div.linkText2'}} - - {{t 'preprints.services.bottom.div.line3'}} -
-

- - {{t 'prints.services.bottom.contact'}} - +
+
+ {{t 'preprints.services.bottom.p1' documentType=this.theme.provider.documentType.singular}} +
+
+ {{t 'preprints.services.bottom.div.line1'}} + + + {{t 'preprints.services.bottom.div.linkText1'}} + + + {{t 'preprints.services.bottom.div.line2'}} + + + {{t 'preprints.services.bottom.div.linkText2'}} + + + {{t 'preprints.services.bottom.div.line3'}} +
+
+ + {{t 'preprints.services.bottom.contact'}} +
From e578f1dd7e8b9a2e0ac29ddf02b51f1fc86bc8af Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Tue, 25 Jul 2023 10:53:44 -0600 Subject: [PATCH 031/170] Fixed the routing to use a single template --- app/preprints/branded/controller.ts | 27 ------ app/preprints/branded/route.ts | 38 -------- app/preprints/branded/styles.scss | 63 ------------- app/preprints/branded/template.hbs | 141 ---------------------------- app/preprints/index/route.ts | 8 +- app/router.ts | 2 +- 6 files changed, 6 insertions(+), 273 deletions(-) delete mode 100644 app/preprints/branded/controller.ts delete mode 100644 app/preprints/branded/route.ts delete mode 100644 app/preprints/branded/styles.scss delete mode 100644 app/preprints/branded/template.hbs diff --git a/app/preprints/branded/controller.ts b/app/preprints/branded/controller.ts deleted file mode 100644 index 17069b0fdb6..00000000000 --- a/app/preprints/branded/controller.ts +++ /dev/null @@ -1,27 +0,0 @@ -import Store from '@ember-data/store'; -import Controller from '@ember/controller'; -import { action } from '@ember/object'; -import RouterService from '@ember/routing/router-service'; -import { inject as service } from '@ember/service'; -import Analytics from 'ember-osf-web/services/analytics'; -import Theme from 'ember-osf-web/services/theme'; - -export default class Preprints extends Controller { - @service store!: Store; - @service theme!: Theme; - @service router!: RouterService; - @service analytics!: Analytics; - - livedata = 'livedata'; - - @action - onSearch(query: string) { - let route = 'search'; - - if (this.theme.isSubRoute) { - route = 'provider.discover'; - } - - this.router.transitionTo(route, { queryParams: { q: query } }); - } -} diff --git a/app/preprints/branded/route.ts b/app/preprints/branded/route.ts deleted file mode 100644 index 6257a34ce86..00000000000 --- a/app/preprints/branded/route.ts +++ /dev/null @@ -1,38 +0,0 @@ -import Store from '@ember-data/store'; -import Route from '@ember/routing/route'; -import { inject as service } from '@ember/service'; -import RouterService from '@ember/routing/router-service'; -import Theme from 'ember-osf-web/services/theme'; - -/** - * Loads all disciplines and preprint providers to the index page - * @class Index Route Handler - */ -export default class Preprints extends Route { - @service store!: Store; - @service theme!: Theme; - @service router!: RouterService; - livedata = 'livedata'; - - async model(args: any) { - try { - const provider = await this.store.findRecord('preprint-provider', args.provider_id); - this.theme.set('providerType', 'preprint'); - this.theme.set('id', args.provider_id); - - const taxonomies = await this.theme.provider?.queryHasMany('highlightedSubjects', { - page: { - size: 20, - }, - }); - - return { - provider, - taxonomies, - }; - } catch (e) { - this.router.transitionTo('not-found', 'preprints'); - return null; - } - } -} diff --git a/app/preprints/branded/styles.scss b/app/preprints/branded/styles.scss deleted file mode 100644 index fecc9489c25..00000000000 --- a/app/preprints/branded/styles.scss +++ /dev/null @@ -1,63 +0,0 @@ -/* Main header with search bar */ -.preprint-header { - background: #214661 url('img/preprints-bg.jpg') top center; - background-position-y: -50px; - padding-top: 100px; - padding-bottom: 30px; - border-bottom: 1px solid #ddd; - color: $color-text-white; - - h1 { - font-size: 41px; - font-weight: 300; - } - - a:not(.btn) { - color: #80c2f7; - text-decoration: underline; - } - - .btn-info { - color: $color-text-white; - } - -} - -.preprint-lead, -.preprint-tool h2 { - text-transform: capitalize; -} - -/* Recent uploads list panel */ -.preprint-list { - background: #fbfbfb; - border-bottom: 1px solid #eee; -} - -/* Subject Panel */ -.preprint-subjects { - background-color: #f1f3f2; - border-bottom: 1px solid #6d8a98; - - .subject-item a { - width: 100%; - font-size: 17px; - overflow: hidden; - text-overflow: ellipsis; - } -} - -/* Preprint providers and become provider */ -.preprint-tool { - background: #cbd9d5 url('img/index-tool-bg.jpg') top center; - color: $color-text-white; - text-shadow: 0 0 5px #506069; - background-size: cover; - - .provider-logo { - height: 120px; - background-size: contain; - background-repeat: no-repeat; - background-position: center; - } -} diff --git a/app/preprints/branded/template.hbs b/app/preprints/branded/template.hbs deleted file mode 100644 index 2f838d590a3..00000000000 --- a/app/preprints/branded/template.hbs +++ /dev/null @@ -1,141 +0,0 @@ -{{page-title (t 'preprints.title')}} - -
- - {{!HEADER}} -
- {{!CONTAINER}} -
- - {{#if this.theme.isProvider}} -
- {{else}} -
- {{/if}} - {{#if this.theme.isProvider}} - {{#branded-header.lead}} - {{html-safe this.theme.provider.description}} - {{/branded-header.lead}} - {{#branded-header.row}} - - {{/branded-header.row}} - {{/if}} -
- {{!END ROW}} - {{#if this.theme.provider.allowSubmissions}} -
-
-

{{t 'preprints.header.or'}}

- - {{t this.submitLabel documentType=this.theme.provider.content.documentType}} - -
- {{#link-to (route-prefix 'content') (if this.theme.provider.example this.theme.provider.example 'khbvy') invokeAction=(action 'click' 'link' 'Index - See example')}} - {{t 'preprints.header.example'}} - {{/link-to}} -
-
-
- {{/if}} -
- {{!END CONTAINER}} -
- {{!END HEADER}} - - {{!SUBJECTS}} -
-
-
-
-

{{#if this.theme.provider.additionalProviders}} - {{t 'preprints.subjects.heading.provider'}} - {{else}} - {{if this.theme.provider.hasHighlightedSubjects (t 'preprints.subjects.heading.hasHighlightedSubjects') (t 'preprints.subjects.heading.noHighlightedSubjects')}} - {{/if}} -

- {{#if this.theme.provider.hasHighlightedSubjects}} - {{#link-to (route-prefix 'discover') class='seeAllSubjects'}} - {{t 'preprints.subjects.links.seeAllSubjects'}} - {{/link-to}} - {{/if}} -
- {{#if this.theme.provider.additionalProviders}} - {{additional-provider-list additionalProviders=this.theme.provider.additionalProviders}} - {{else}} - {{/if}} -
-
-
-
-
- - {{#unless this.theme.isProvider}} - {{!SERVICES}} -
-
-
-
-

{{t 'preprints.services.top.heading' documentType=this.theme.provider.content.documentType}}

-

- {{t 'preprints.services.top.paragraph' documentType=this.theme.provider.content.documentType}} -

-
-
-
-
- {{#each this.model.brandedProviders as |provider| }} - {{#if (not-eq provider.id this.livedata) }} - - {{/if}} - {{/each}} -
-
-
-
-

- {{t 'preprints.services.bottom.p1' documentType=this.theme.provider.content.documentType}} -

- {{t 'preprints.services.bottom.div.line1'}} - - {{t 'preprints.services.bottom.div.linkText1'}} - - {{t 'preprints.services.bottom.div.line2'}} - - {{t 'preprints.services.bottom.div.linkText2'}} - - {{t 'preprints.services.bottom.div.line3'}} -
-

- - {{t 'prints.services.bottom.contact'}} - -
-
-
-
- {{/unless}} - - - {{!ADVISORY GROUP}} - {{#if this.theme.provider.advisoryBoard.length}} -
-
-
- {{html-safe this.theme.provider.advisoryBoard 'advisory-board'}} -
-
-
- {{/if}} -
-{{!END INDEX}} diff --git a/app/preprints/index/route.ts b/app/preprints/index/route.ts index bbcdb118e7a..565010db3a7 100644 --- a/app/preprints/index/route.ts +++ b/app/preprints/index/route.ts @@ -13,11 +13,13 @@ export default class Preprints extends Route { @service theme!: Theme; @service router!: RouterService; - async model() { + async model(params: { provider_id : string }) { try { - const provider = await this.store.findRecord('preprint-provider', 'osf'); + const provider_id = params.provider_id ? params.provider_id : 'osf'; + + const provider = await this.store.findRecord('preprint-provider', provider_id); this.theme.set('providerType', 'preprint'); - this.theme.set('id', 'osf'); + this.theme.set('id', provider_id); const taxonomies = await this.theme.provider?.queryHasMany('highlightedSubjects', { page: { diff --git a/app/router.ts b/app/router.ts index 8eddbedff2c..53313279a2d 100644 --- a/app/router.ts +++ b/app/router.ts @@ -28,7 +28,7 @@ Router.map(function() { this.route('preprints', function() { this.route('index', { path: '/' }); - this.route('branded', { path: '/:provider_id' }); + this.route('index', { path: '/:provider_id' }); this.route('discover', { path: '/:provider_id/discover' }); }); From 4306233be4a7781eee2136c5f925358fcb640706 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Wed, 26 Jul 2023 12:42:25 -0600 Subject: [PATCH 032/170] Updates to remove unused variables and added branding --- app/preprints/index/controller.ts | 5 ----- app/preprints/index/styles.scss | 17 ++++++++------- app/preprints/index/template.hbs | 21 ++++++++----------- .../components/branded-header/component.ts | 4 ---- .../components/branded-header/styles.scss | 9 ++------ .../components/branded-header/template.hbs | 2 +- .../preprints/taxonomy-top-list/styles.scss | 7 +++++++ .../addon/modifiers/with-branding.ts | 4 ++-- mirage/fixtures/preprint-providers.ts | 18 +++++++++------- 9 files changed, 41 insertions(+), 46 deletions(-) diff --git a/app/preprints/index/controller.ts b/app/preprints/index/controller.ts index 07a7c86bcf5..7549e3b2a5d 100644 --- a/app/preprints/index/controller.ts +++ b/app/preprints/index/controller.ts @@ -10,11 +10,6 @@ export default class Preprints extends Controller { @service theme!: Theme; @service router!: RouterService; - livedata = 'livedata'; - providerAsset = 'https://localhost:4200'; - routePrefix = 'https://localhost:4200'; - brandedPreprintUrl = 'http://localhost:4200'; - @action onSearch(query: string) { let route = 'search'; diff --git a/app/preprints/index/styles.scss b/app/preprints/index/styles.scss index ccd3fedb26c..10d50bd6cad 100644 --- a/app/preprints/index/styles.scss +++ b/app/preprints/index/styles.scss @@ -8,28 +8,31 @@ align-items: center; .preprint-header { - background: #214661 url('img/preprints-bg.jpg') top center; - background-position-y: -50px; - border-bottom: 1px solid #ddd; - color: $color-text-white; + border-bottom: 1px solid var(--primary-color); width: 100%; + background-color: var(--secondary-color); + color: var(--primary-color) !important; a:not(:global(.btn)) { - color: $color-link-blue; + color: var(--primary-color); text-decoration: underline; } + .description { + color: var(--primary-color); + } + .btn-info { color: $color-text-white; } - .submit-container { width: 100%; display: flex; flex-direction: column; justify-content: center; align-items: center; + color: var(--primary-color); .example-container { display: flex; @@ -126,7 +129,7 @@ .preprint-contact-container { flex-direction: column; align-items: center; - + .lead { font-size: 21px; line-height: 1.4; diff --git a/app/preprints/index/template.hbs b/app/preprints/index/template.hbs index 579e26122c4..409910dce5f 100644 --- a/app/preprints/index/template.hbs +++ b/app/preprints/index/template.hbs @@ -1,6 +1,6 @@ {{page-title (t 'preprints.title')}} -
+
{{!HEADER}}
@@ -10,9 +10,8 @@ @showHelp=true as |branded-header| > -
{{#branded-header.lead}} -
+
{{html-safe this.theme.provider.description}}
@@ -28,7 +27,7 @@ {{#branded-header.row}} {{#if this.theme.provider.allowSubmissions}}
-

{{t 'preprints.header.or'}}

+
{{t 'preprints.header.or'}}
{{t 'preprints.header.example'}} @@ -67,7 +66,7 @@ {{t 'preprints.subjects.links.seeAllSubjects'}} @@ -92,17 +91,15 @@

{{#each this.model.brandedProviders as |provider| }} - {{#if (not-eq provider.id this.livedata) }} + {{#if (not-eq provider.id 'livedata') }} - {{ provider.name }} - + style={{html-safe (concat 'background-image: url(' provider.assets.wide_white ')' )}} + > {{/if}} {{/each}}
diff --git a/lib/osf-components/addon/components/branded-header/component.ts b/lib/osf-components/addon/components/branded-header/component.ts index c80f3376207..9003e40b5c1 100644 --- a/lib/osf-components/addon/components/branded-header/component.ts +++ b/lib/osf-components/addon/components/branded-header/component.ts @@ -32,10 +32,6 @@ export default class BrandedHeader extends Component { return this.args.showHelp; } - get brandLogo(): string { - return this.args.translationParent === 'preprints' ? 'preprints-brand-logo' : 'registries-brand-logo'; - } - @computed('providerModel.name', 'args.translationParent') get headerAriaLabel() { return this.providerModel ? diff --git a/lib/osf-components/addon/components/branded-header/styles.scss b/lib/osf-components/addon/components/branded-header/styles.scss index 195ddee63c4..9b5dbf7bad3 100644 --- a/lib/osf-components/addon/components/branded-header/styles.scss +++ b/lib/osf-components/addon/components/branded-header/styles.scss @@ -39,13 +39,8 @@ height: 70px; width: 100%; - &.registries-brand-logo { - background: var(--hero-logo-registries-img-url) top center no-repeat; - background-size: contain; - } - - &.preprints-brand-logo { - background: var(--hero-logo-preprints-img-url) top center no-repeat; + &.brand-logo { + background: var(--hero-logo-img-url) top center no-repeat; background-size: contain; } } diff --git a/lib/osf-components/addon/components/branded-header/template.hbs b/lib/osf-components/addon/components/branded-header/template.hbs index ef65a2f66a1..4b089bd06d8 100644 --- a/lib/osf-components/addon/components/branded-header/template.hbs +++ b/lib/osf-components/addon/components/branded-header/template.hbs @@ -1,7 +1,7 @@
> = [ id: 'osf', name: 'Open Science Framework', preprintWord: 'preprint', - assets: randomAssets(), + assets: randomAssets(1), }, { id: 'thesiscommons', name: 'Thesis Commons', preprintWord: 'thesis', - assets: randomAssets(), + assets: randomAssets(2), }, { id: 'preprintrxiv', name: 'PreprintrXiv', preprintWord: 'preprint', - assets: randomAssets(), + assets: randomAssets(3), }, { id: 'paperxiv', name: 'PaperXiv', preprintWord: 'paper', - assets: randomAssets(), + assets: randomAssets(4), }, { id: 'thesisrxiv', name: 'ThesisrXiv', preprintWord: 'thesis', - assets: randomAssets(), + assets: randomAssets(5), }, { id: 'workrxiv', name: 'WorkrXiv', preprintWord: 'work', - assets: randomAssets(), + assets: randomAssets(6), }, { id: 'docrxiv', name: 'DocrXiv', preprintWord: 'default', - assets: randomAssets(), + assets: randomAssets(7), }, { id: 'agrixiv', From cd4022d66c3c453091138ab2e969b90b7f7941f7 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Thu, 27 Jul 2023 10:16:31 -0600 Subject: [PATCH 033/170] Fixed the css for the steering committee --- app/preprints/index/controller.ts | 4 ++++ app/preprints/index/styles.scss | 27 +++++++++++++++++++++++++++ app/preprints/index/template.hbs | 8 +++----- 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/app/preprints/index/controller.ts b/app/preprints/index/controller.ts index 7549e3b2a5d..a74bd9141a3 100644 --- a/app/preprints/index/controller.ts +++ b/app/preprints/index/controller.ts @@ -10,6 +10,10 @@ export default class Preprints extends Controller { @service theme!: Theme; @service router!: RouterService; + get isOsf(): boolean { + return this.theme?.provider?.id === 'osf'; + } + @action onSearch(query: string) { let route = 'search'; diff --git a/app/preprints/index/styles.scss b/app/preprints/index/styles.scss index 10d50bd6cad..610fb832e85 100644 --- a/app/preprints/index/styles.scss +++ b/app/preprints/index/styles.scss @@ -154,4 +154,31 @@ } } + + .preprint-advisory-container { + background-color: $color-bg-gray-lighter; + border-bottom: 1px solid #6d8a98; + padding-top: 15px; + padding-bottom: 15px; + width: 100%; + flex-direction: column; + display: flex; + justify-content: center; + align-items: center; + + &.provider { + background-color: var(--secondary-color); + color: var(--primary-color); + } + + .preprint-advisory-inner-container { + padding-right: 30px; + padding-left: 30px; + width: calc(100% - 60px); + flex-direction: column; + display: flex; + justify-content: flex-start; + align-items: flex-start; + } + } } diff --git a/app/preprints/index/template.hbs b/app/preprints/index/template.hbs index 409910dce5f..b3f3eb94c05 100644 --- a/app/preprints/index/template.hbs +++ b/app/preprints/index/template.hbs @@ -150,11 +150,9 @@ {{!ADVISORY GROUP}} {{#if this.theme.provider.advisoryBoard.length}} -
-
-
- {{html-safe this.theme.provider.advisoryBoard 'advisory-board'}} -
+
+
+ {{html-safe this.theme.provider.advisoryBoard 'advisory-board'}}
{{/if}} From 30c6d1f41052d6e9aea376d1ad5fc4382066bb03 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Fri, 28 Jul 2023 13:43:05 -0600 Subject: [PATCH 034/170] Updates for comments from PR --- app/preprints/index/route.ts | 4 +++- app/preprints/index/styles.scss | 4 ++++ app/preprints/index/template.hbs | 24 ++++++++++--------- .../components/branded-header/template.hbs | 4 +++- .../preprints/taxonomy-top-list/component.ts | 3 --- .../components/search-help-modal/component.ts | 1 + .../components/search-help-modal/template.hbs | 2 +- lib/registries/addon/discover/template.hbs | 16 ++++++------- mirage/scenarios/preprints.ts | 5 +++- 9 files changed, 37 insertions(+), 26 deletions(-) diff --git a/app/preprints/index/route.ts b/app/preprints/index/route.ts index 565010db3a7..ffaebdfcdc6 100644 --- a/app/preprints/index/route.ts +++ b/app/preprints/index/route.ts @@ -3,6 +3,7 @@ import Route from '@ember/routing/route'; import RouterService from '@ember/routing/router-service'; import { inject as service } from '@ember/service'; import Theme from 'ember-osf-web/services/theme'; +import captureException from 'ember-osf-web/utils/capture-exception'; /** * Loads all disciplines and preprint providers to the index page @@ -38,7 +39,8 @@ export default class Preprints extends Route { brandedProviders, }; - } catch (e) { + } catch (error) { + captureException(error); this.router.transitionTo('not-found', 'preprints'); return null; } diff --git a/app/preprints/index/styles.scss b/app/preprints/index/styles.scss index 610fb832e85..94a18ffdbc9 100644 --- a/app/preprints/index/styles.scss +++ b/app/preprints/index/styles.scss @@ -13,6 +13,10 @@ background-color: var(--secondary-color); color: var(--primary-color) !important; + &.osf { + background: url('images/default-brand/bg-dark.jpg'); + } + a:not(:global(.btn)) { color: var(--primary-color); text-decoration: underline; diff --git a/app/preprints/index/template.hbs b/app/preprints/index/template.hbs index b3f3eb94c05..ab16190782c 100644 --- a/app/preprints/index/template.hbs +++ b/app/preprints/index/template.hbs @@ -1,9 +1,11 @@ {{page-title (t 'preprints.title')}} -
+
{{!HEADER}} -
+
{{t 'preprints.header.powered_by'}} @@ -30,7 +32,7 @@
{{t 'preprints.header.or'}}
{{t 'preprints.header.example'}} @@ -65,7 +67,7 @@ {{#if this.theme.provider.hasHighlightedSubjects}} {{t 'preprints.subjects.links.seeAllSubjects'}} @@ -94,7 +96,7 @@ {{#if (not-eq provider.id 'livedata') }} {{t 'preprints.services.bottom.div.linkText1'}} @@ -123,7 +125,7 @@ @@ -135,7 +137,7 @@
diff --git a/lib/osf-components/addon/components/branded-header/template.hbs b/lib/osf-components/addon/components/branded-header/template.hbs index 4b089bd06d8..d25e05b54bc 100644 --- a/lib/osf-components/addon/components/branded-header/template.hbs +++ b/lib/osf-components/addon/components/branded-header/template.hbs @@ -58,6 +58,8 @@ {{yield (hash row=(element ''))}}
- +
diff --git a/lib/osf-components/addon/components/preprints/taxonomy-top-list/component.ts b/lib/osf-components/addon/components/preprints/taxonomy-top-list/component.ts index 7addf545d5d..40a6daa2610 100644 --- a/lib/osf-components/addon/components/preprints/taxonomy-top-list/component.ts +++ b/lib/osf-components/addon/components/preprints/taxonomy-top-list/component.ts @@ -1,5 +1,4 @@ import Component from '@glimmer/component'; -import { computed } from '@ember/object'; import SubjectModel from 'ember-osf-web/models/subject'; interface InputArgs { @@ -14,8 +13,6 @@ interface PairModel { export default class TaxonomyTopList extends Component { routerPrefix = 'http://localhost:4200'; - - @computed('args.list') get sortedList() { if (!this.args.list) { return; diff --git a/lib/osf-components/addon/components/search-help-modal/component.ts b/lib/osf-components/addon/components/search-help-modal/component.ts index 28c40dfc0c2..c6b4ce0aa37 100644 --- a/lib/osf-components/addon/components/search-help-modal/component.ts +++ b/lib/osf-components/addon/components/search-help-modal/component.ts @@ -15,6 +15,7 @@ import { inject as service } from '@ember/service'; interface InputArgs { isOpen: false; + onClose: () => void; } export default class SearchHelpModal extends Component { diff --git a/lib/osf-components/addon/components/search-help-modal/template.hbs b/lib/osf-components/addon/components/search-help-modal/template.hbs index ee3b226eeab..79ff2f6e039 100644 --- a/lib/osf-components/addon/components/search-help-modal/template.hbs +++ b/lib/osf-components/addon/components/search-help-modal/template.hbs @@ -1,7 +1,7 @@
diff --git a/lib/registries/addon/discover/template.hbs b/lib/registries/addon/discover/template.hbs index da00795fcd5..d26027f5d4c 100644 --- a/lib/registries/addon/discover/template.hbs +++ b/lib/registries/addon/discover/template.hbs @@ -14,15 +14,15 @@ searchable=this.searchable }} - {{#registries-discover-search - results=this.results - isLoading=this.doSearch.isIdle - searchOptions=this.searchOptions - additionalFilters=this.additionalFilters - provider=this.providerModel +
{{#if this.searchOptions}} @@ -104,5 +104,5 @@
- {{/registries-discover-search}} +
diff --git a/mirage/scenarios/preprints.ts b/mirage/scenarios/preprints.ts index 3abe4f19076..c0485cfed9a 100644 --- a/mirage/scenarios/preprints.ts +++ b/mirage/scenarios/preprints.ts @@ -16,7 +16,10 @@ function buildOSF( currentUser: ModelInstance, ) { const osf = server.schema.preprintProviders.find('osf') as ModelInstance; - const brand = server.create('brand'); + const brand = server.create('brand', { + primaryColor: '#286090', + secondaryColor: '#fff', + }); const currentUserModerator = server.create('moderator', { id: currentUser.id, user: currentUser, provider: osf }, 'asAdmin'); From 9bf17c3fd9bb089f63debb9b505e2721695864d0 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Thu, 3 Aug 2023 09:09:03 -0600 Subject: [PATCH 035/170] Fixed some css and updated the mirage for global classes --- app/preprints/index/styles.scss | 26 ---------- app/preprints/index/template.hbs | 8 +-- app/styles/_preprint.scss | 49 +++++++++++++++++++ app/styles/headers.scss | 3 ++ .../components/branded-header/component.ts | 1 + mirage/scenarios/preprints.ts | 2 +- 6 files changed, 58 insertions(+), 31 deletions(-) create mode 100644 app/styles/_preprint.scss diff --git a/app/preprints/index/styles.scss b/app/preprints/index/styles.scss index 94a18ffdbc9..c0155983a2d 100644 --- a/app/preprints/index/styles.scss +++ b/app/preprints/index/styles.scss @@ -159,30 +159,4 @@ } - .preprint-advisory-container { - background-color: $color-bg-gray-lighter; - border-bottom: 1px solid #6d8a98; - padding-top: 15px; - padding-bottom: 15px; - width: 100%; - flex-direction: column; - display: flex; - justify-content: center; - align-items: center; - - &.provider { - background-color: var(--secondary-color); - color: var(--primary-color); - } - - .preprint-advisory-inner-container { - padding-right: 30px; - padding-left: 30px; - width: calc(100% - 60px); - flex-direction: column; - display: flex; - justify-content: flex-start; - align-items: flex-start; - } - } } diff --git a/app/preprints/index/template.hbs b/app/preprints/index/template.hbs index ab16190782c..cdfdfc9fa39 100644 --- a/app/preprints/index/template.hbs +++ b/app/preprints/index/template.hbs @@ -5,7 +5,7 @@ > {{!HEADER}} -
+
{{t 'preprints.header.submit_label' documentType=this.theme.provider.content.documentType}} @@ -152,8 +152,8 @@ {{!ADVISORY GROUP}} {{#if this.theme.provider.advisoryBoard.length}} -
-
+
+
{{html-safe this.theme.provider.advisoryBoard 'advisory-board'}}
diff --git a/app/styles/_preprint.scss b/app/styles/_preprint.scss new file mode 100644 index 00000000000..3b08daf4256 --- /dev/null +++ b/app/styles/_preprint.scss @@ -0,0 +1,49 @@ +// stylelint-disable max-nesting-depth, selector-max-compound-selectors + +.preprint-advisory-container { + background-color: $color-bg-gray-lighter; + border-bottom: 1px solid #6d8a98; + padding-top: 15px; + padding-bottom: 15px; + width: 100%; + flex-direction: column; + display: flex; + justify-content: center; + align-items: center; + + .preprint-advisory-inner-container { + padding-right: 30px; + padding-left: 30px; + width: calc(100% - 60px); + flex-direction: column; + display: flex; + justify-content: flex-start; + align-items: flex-start; + + .preprint-advisory-header { + width: 100%; + } + + .preprint-advisory-list { + width: 100%; + flex-direction: row; + display: flex; + justify-content: flex-start; + align-items: flex-start; + margin-top: 25px; + + .preprint-advisory-list-column { + width: 50%; + + ul { + list-style: none; + + li { + padding-top: 5px; + font-size: 16px; + } + } + } + } + } +} diff --git a/app/styles/headers.scss b/app/styles/headers.scss index ce654bede9b..5663ca4d799 100644 --- a/app/styles/headers.scss +++ b/app/styles/headers.scss @@ -19,6 +19,9 @@ // Branding @import 'branding'; +// Preprints +@import 'preprint'; + .theme-dropdown .dropdown-menu { position: static; display: block; diff --git a/lib/osf-components/addon/components/branded-header/component.ts b/lib/osf-components/addon/components/branded-header/component.ts index 9003e40b5c1..6be7bfe057f 100644 --- a/lib/osf-components/addon/components/branded-header/component.ts +++ b/lib/osf-components/addon/components/branded-header/component.ts @@ -7,6 +7,7 @@ import Media from 'ember-responsive'; import ProviderModel from 'ember-osf-web/models/provider'; import Analytics from 'ember-osf-web/services/analytics'; import { tracked } from '@glimmer/tracking'; +import { requiredAction } from 'ember-osf-web/decorators/component'; interface InputArgs { onSearch: (value: string) => void; diff --git a/mirage/scenarios/preprints.ts b/mirage/scenarios/preprints.ts index c0485cfed9a..925e8d08c19 100644 --- a/mirage/scenarios/preprints.ts +++ b/mirage/scenarios/preprints.ts @@ -33,7 +33,7 @@ function buildOSF( allowSubmissions: true, highlightedSubjects: subjects, // eslint-disable-next-line max-len - advisory_board: '
\n

Advisory Group

\n

Our advisory group includes leaders in preprints and scholarly communication

\n
\n
\n
    \n
  • Devin Berg : engrXiv, University of Wisconsin-Stout
  • \n
  • Pete Binfield : PeerJ PrePrints
  • \n
  • Benjamin Brown : PsyArXiv, Georgia Gwinnett College
  • \n
  • Philip Cohen : SocArXiv, University of Maryland
  • \n
  • Kathleen Fitzpatrick : Modern Language Association
  • \n
\n
\n
\n
    \n
  • John Inglis : bioRxiv, Cold Spring Harbor Laboratory Press
  • \n
  • Rebecca Kennison : K | N Consultants
  • \n
  • Kristen Ratan : CoKo Foundation
  • \n
  • Oya Rieger : Ithaka S+R
  • \n
  • Judy Ruttenberg : SHARE, Association of Research Libraries
  • \n
\n
', + advisory_board: '
\n

Advisory Group

\n

Our advisory group includes leaders in preprints and scholarly communication\n

\n
\n
    \n
  • Devin Berg : engrXiv, University of Wisconsin-Stout
  • \n
  • Pete Binfield : PeerJ PrePrints
  • \n
  • Benjamin Brown : PsyArXiv, Georgia Gwinnett College
  • \n
  • Philip Cohen : SocArXiv, University of Maryland
  • \n
  • Kathleen Fitzpatrick : Modern Language Association
  • \n
\n
\n
\n
    \n
  • John Inglis : bioRxiv, Cold Spring Harbor Laboratory Press
  • \n
  • Rebecca Kennison : K | N Consultants
  • \n
  • Kristen Ratan : CoKo Foundation
  • \n
  • Oya Rieger : Ithaka S+R
  • \n
  • Judy Ruttenberg : SHARE, Association of Research Libraries
  • \n
\n
\n
', brand, moderators: [currentUserModerator], preprints, From 5d77c5fcdb448b260407bc53671b72c130781ff0 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Fri, 4 Aug 2023 11:24:41 -0600 Subject: [PATCH 036/170] Updates for branding --- app/preprints/index/route.ts | 3 ++- app/preprints/index/styles.scss | 26 +++++++++++++------ app/preprints/index/template.hbs | 11 +++++--- app/styles/_branding.scss | 3 +-- app/styles/_preprint.scss | 1 + .../components/branded-header/styles.scss | 1 + .../addon/components/search-page/styles.scss | 2 +- mirage/scenarios/preprints.ts | 2 ++ 8 files changed, 33 insertions(+), 16 deletions(-) diff --git a/app/preprints/index/route.ts b/app/preprints/index/route.ts index ffaebdfcdc6..75cc66f5114 100644 --- a/app/preprints/index/route.ts +++ b/app/preprints/index/route.ts @@ -18,7 +18,7 @@ export default class Preprints extends Route { try { const provider_id = params.provider_id ? params.provider_id : 'osf'; - const provider = await this.store.findRecord('preprint-provider', provider_id); + const provider = await this.store.findRecord('preprint-provider', provider_id, {include: 'brand'}); this.theme.set('providerType', 'preprint'); this.theme.set('id', provider_id); @@ -37,6 +37,7 @@ export default class Preprints extends Route { provider, taxonomies, brandedProviders, + brand: provider.brand.content, }; } catch (error) { diff --git a/app/preprints/index/styles.scss b/app/preprints/index/styles.scss index c0155983a2d..f499dd4fc2f 100644 --- a/app/preprints/index/styles.scss +++ b/app/preprints/index/styles.scss @@ -13,10 +13,6 @@ background-color: var(--secondary-color); color: var(--primary-color) !important; - &.osf { - background: url('images/default-brand/bg-dark.jpg'); - } - a:not(:global(.btn)) { color: var(--primary-color); text-decoration: underline; @@ -38,6 +34,20 @@ align-items: center; color: var(--primary-color); + .or-container { + font-size: 21px; + margin-bottom: 20px; + font-weight: 300; + line-height: 1.4; + color: $color-text-white; + + width: 100%; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + } + .example-container { display: flex; justify-content: center; @@ -83,7 +93,7 @@ /* Preprint providers and become provider */ .preprint-tool-container { - background: url('images/default-brand/bg-dark.jpg'); + background: var(--hero-background-img-url); color: $color-text-white; text-shadow: 0 0 5px #506069; background-size: cover; @@ -142,9 +152,7 @@ .links { color: $color-text-white; text-decoration: underline; - } - } .contact { @@ -156,7 +164,9 @@ h2 { text-transform: capitalize; } - } + .osf-preprint-advisory-container { + background-image: none; + } } diff --git a/app/preprints/index/template.hbs b/app/preprints/index/template.hbs index cdfdfc9fa39..e8f2b796777 100644 --- a/app/preprints/index/template.hbs +++ b/app/preprints/index/template.hbs @@ -1,9 +1,9 @@ {{page-title (t 'preprints.title')}} -
- {{!HEADER}}
-
{{t 'preprints.header.or'}}
+
{{t 'preprints.header.or'}}
+
{{html-safe this.theme.provider.advisoryBoard 'advisory-board'}}
diff --git a/app/styles/_branding.scss b/app/styles/_branding.scss index 1143a5cb24a..48d67e835f1 100644 --- a/app/styles/_branding.scss +++ b/app/styles/_branding.scss @@ -2,8 +2,7 @@ --primary-color: #{$color-osf-primary}; --secondary-color: #{$color-osf-secondary}; --navbar-logo-img-url: url('images/default-brand/cos-logo-white.svg'); - --hero-logo-registries-img-url: url('images/default-brand/osf-registries-white.png'); - --hero-logo-preprints-img-url: url('images/default-brand/osf-preprints-white.png'); + --hero-logo-img-url: url('images/default-brand/osf-registries-white.png'); --hero-background-img-url: url('images/default-brand/bg-dark.jpg'); } diff --git a/app/styles/_preprint.scss b/app/styles/_preprint.scss index 3b08daf4256..bdc1cf7d6c1 100644 --- a/app/styles/_preprint.scss +++ b/app/styles/_preprint.scss @@ -1,6 +1,7 @@ // stylelint-disable max-nesting-depth, selector-max-compound-selectors .preprint-advisory-container { + background: var(--hero-background-img-url); background-color: $color-bg-gray-lighter; border-bottom: 1px solid #6d8a98; padding-top: 15px; diff --git a/lib/osf-components/addon/components/branded-header/styles.scss b/lib/osf-components/addon/components/branded-header/styles.scss index 9b5dbf7bad3..8b15380e376 100644 --- a/lib/osf-components/addon/components/branded-header/styles.scss +++ b/lib/osf-components/addon/components/branded-header/styles.scss @@ -8,6 +8,7 @@ justify-content: center; align-items: center; color: $color-text-white; + background: var(--hero-background-img-url); .lead { font-size: 21px; diff --git a/lib/osf-components/addon/components/search-page/styles.scss b/lib/osf-components/addon/components/search-page/styles.scss index 20de014b98a..71e99fcfd0c 100644 --- a/lib/osf-components/addon/components/search-page/styles.scss +++ b/lib/osf-components/addon/components/search-page/styles.scss @@ -117,7 +117,7 @@ } .provider-logo { - background: var(--hero-logo-registries-img-url) top center no-repeat; + background: var(--hero-logo-img-url) top center no-repeat; background-size: contain; height: 70px; margin: 2em 0 1em; diff --git a/mirage/scenarios/preprints.ts b/mirage/scenarios/preprints.ts index 925e8d08c19..81fc0f4dec4 100644 --- a/mirage/scenarios/preprints.ts +++ b/mirage/scenarios/preprints.ts @@ -19,6 +19,8 @@ function buildOSF( const brand = server.create('brand', { primaryColor: '#286090', secondaryColor: '#fff', + heroLogoImage: 'images/default-brand/osf-preprints-white.png', + heroBackgroundImage: 'images/default-brand/bg-dark.jpg', }); const currentUserModerator = server.create('moderator', { id: currentUser.id, user: currentUser, provider: osf }, 'asAdmin'); From ba610247b69f03a5a63b1479a6cfd0d62662bae9 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Mon, 7 Aug 2023 12:12:44 -0600 Subject: [PATCH 037/170] Added more styling for mobile --- app/preprints/index/controller.ts | 6 ++ app/preprints/index/styles.scss | 69 +++++++++++++++---- app/preprints/index/template.hbs | 10 +-- app/styles/_preprint.scss | 25 +++++-- .../components/branded-header/component.ts | 4 ++ .../components/branded-header/styles.scss | 15 +++- .../components/branded-header/template.hbs | 4 +- .../preprints/taxonomy-top-list/component.ts | 55 ++++++++++----- .../preprints/taxonomy-top-list/styles.scss | 29 ++++++++ .../preprints/taxonomy-top-list/template.hbs | 7 +- 10 files changed, 175 insertions(+), 49 deletions(-) diff --git a/app/preprints/index/controller.ts b/app/preprints/index/controller.ts index a74bd9141a3..113394bd924 100644 --- a/app/preprints/index/controller.ts +++ b/app/preprints/index/controller.ts @@ -4,11 +4,17 @@ import { action } from '@ember/object'; import RouterService from '@ember/routing/router-service'; import { inject as service } from '@ember/service'; import Theme from 'ember-osf-web/services/theme'; +import Media from 'ember-responsive'; export default class Preprints extends Controller { @service store!: Store; @service theme!: Theme; @service router!: RouterService; + @service media!: Media; + + get isMobile(): boolean { + return this.media.isMobile; + } get isOsf(): boolean { return this.theme?.provider?.id === 'osf'; diff --git a/app/preprints/index/styles.scss b/app/preprints/index/styles.scss index f499dd4fc2f..e90e5bd0d33 100644 --- a/app/preprints/index/styles.scss +++ b/app/preprints/index/styles.scss @@ -13,7 +13,7 @@ background-color: var(--secondary-color); color: var(--primary-color) !important; - a:not(:global(.btn)) { + a:not(.btn) { color: var(--primary-color); text-decoration: underline; } @@ -22,10 +22,6 @@ color: var(--primary-color); } - .btn-info { - color: $color-text-white; - } - .submit-container { width: 100%; display: flex; @@ -62,8 +58,7 @@ .preprint-subjects-container { background-color: $color-bg-gray-lighter; border-bottom: 1px solid #6d8a98; - padding-top: 15px; - padding-bottom: 15px; + padding: 15px 0; width: 100%; flex-direction: column; display: flex; @@ -72,8 +67,7 @@ .preprint-subjects-inner-container { background-color: $color-bg-gray-lighter; - padding-right: 30px; - padding-left: 30px; + padding: 0 30px; width: calc(100% - 60px); flex-direction: column; display: flex; @@ -97,8 +91,7 @@ color: $color-text-white; text-shadow: 0 0 5px #506069; background-size: cover; - padding-top: 15px; - padding-bottom: 15px; + padding: 15px 0; min-width: 100%; min-height: 100%; width: 100%; @@ -148,6 +141,8 @@ font-size: 21px; line-height: 1.4; font-weight: 300; + padding-bottom: 10px; + text-align: center; .links { color: $color-text-white; @@ -160,13 +155,59 @@ } } } + } - h2 { - text-transform: capitalize; + .osf-preprint-advisory-container { + background-image: none; + } + + &.mobile { + .preprint-subjects-inner-container { + padding: 0; + background-color: $color-bg-gray-lighter; + padding: 0, 10px; + width: calc(100% - 20px); + + .subject-list-container { + padding: 25px 0; + width: 100%; + flex-direction: column; + } + } + + .preprint-tool-inner-container { + padding: 15px 10px; + width: calc(100% - 20px); } } - .osf-preprint-advisory-container { + .btn { + display: inline-block; + margin-bottom: 0; + font-weight: 400; + text-align: center; + white-space: nowrap; + touch-action: manipulation; + cursor: pointer; background-image: none; + border: 1px solid transparent; + border-radius: 2px; + padding: 6px 12px; + font-size: 14px; + line-height: 1.42857; + user-select: none; + vertical-align: middle; + color: $color-text-white; + } + + .btn-success { + background-color: #357935; + border-color: #2d672d; + } + + .btn-lg { + padding: 10px 16px; + font-size: 18px; + line-height: 1.33333; } } diff --git a/app/preprints/index/template.hbs b/app/preprints/index/template.hbs index e8f2b796777..a4aefb620d9 100644 --- a/app/preprints/index/template.hbs +++ b/app/preprints/index/template.hbs @@ -1,6 +1,6 @@ {{page-title (t 'preprints.title')}} -
@@ -33,8 +33,7 @@ {{t 'preprints.header.submit_label' documentType=this.theme.provider.content.documentType}} @@ -138,7 +137,8 @@ {{t 'preprints.services.bottom.contact'}} @@ -153,7 +153,7 @@ {{!ADVISORY GROUP}} {{#if this.theme.provider.advisoryBoard.length}}
diff --git a/app/styles/_preprint.scss b/app/styles/_preprint.scss index bdc1cf7d6c1..bb1767500fc 100644 --- a/app/styles/_preprint.scss +++ b/app/styles/_preprint.scss @@ -4,8 +4,7 @@ background: var(--hero-background-img-url); background-color: $color-bg-gray-lighter; border-bottom: 1px solid #6d8a98; - padding-top: 15px; - padding-bottom: 15px; + padding: 15px 0; width: 100%; flex-direction: column; display: flex; @@ -13,8 +12,7 @@ align-items: center; .preprint-advisory-inner-container { - padding-right: 30px; - padding-left: 30px; + padding: 0 30px; width: calc(100% - 60px); flex-direction: column; display: flex; @@ -47,4 +45,23 @@ } } } + + &.mobile { + .preprint-advisory-inner-container { + padding: 0 10px; + width: calc(100% - 20px); + + .preprint-advisory-list { + flex-direction: column; + + .preprint-advisory-list-column { + width: 100%; + + ul { + padding: 0; + } + } + } + } + } } diff --git a/lib/osf-components/addon/components/branded-header/component.ts b/lib/osf-components/addon/components/branded-header/component.ts index 6be7bfe057f..9cec891a9ee 100644 --- a/lib/osf-components/addon/components/branded-header/component.ts +++ b/lib/osf-components/addon/components/branded-header/component.ts @@ -33,6 +33,10 @@ export default class BrandedHeader extends Component { return this.args.showHelp; } + get isMobile(): boolean { + return this.media.isMobile; + } + @computed('providerModel.name', 'args.translationParent') get headerAriaLabel() { return this.providerModel ? diff --git a/lib/osf-components/addon/components/branded-header/styles.scss b/lib/osf-components/addon/components/branded-header/styles.scss index 8b15380e376..45874ae9aee 100644 --- a/lib/osf-components/addon/components/branded-header/styles.scss +++ b/lib/osf-components/addon/components/branded-header/styles.scss @@ -101,9 +101,6 @@ } } - .search-container.mobile { - width: 100%; - } .provider-description { justify-content: center; @@ -117,4 +114,16 @@ padding-top: 10px; padding-bottom: 10px; } + + &.mobile { + padding: 30px 10px; + + .search-container { + width: 100%; + + .form { + margin: 0; + } + } + } } diff --git a/lib/osf-components/addon/components/branded-header/template.hbs b/lib/osf-components/addon/components/branded-header/template.hbs index d25e05b54bc..c58f3889e6a 100644 --- a/lib/osf-components/addon/components/branded-header/template.hbs +++ b/lib/osf-components/addon/components/branded-header/template.hbs @@ -1,4 +1,4 @@ -
+
-
+
{ - routerPrefix = 'http://localhost:4200'; + @service media!: Media; + + get isMobile(): boolean { + return this.media.isMobile; + } get sortedList() { if (!this.args.list) { @@ -19,25 +25,40 @@ export default class TaxonomyTopList extends Component { } const sortedList = this.args.list.sortBy('text'); const pairedList = [] as PairModel[][]; - for (let i = 0; i < sortedList.get('length'); i += 2) { - const pair: PairModel[] = []; - // path in pair needs to be a list because that's what the - // subject param in the discover controller is expecting - const subjectOdd = sortedList.objectAt(i) as SubjectModel; - pair.pushObject({ - path: [subjectOdd?.taxonomyName], - text: subjectOdd?.text, - } as PairModel); - - if (sortedList.objectAt(i + 1)) { - const subjectEven = sortedList.objectAt(i + 1) as SubjectModel; + + if (this.isMobile) { + for (let i = 0; i < sortedList.get('length'); i += 1) { + const pair: PairModel[] = []; + const subject= sortedList.objectAt(i) as SubjectModel; + pair.pushObject({ + path: [subject?.taxonomyName], + text: subject?.text, + } as PairModel); + pairedList.pushObject(pair); + } + } else { + for (let i = 0; i < sortedList.get('length'); i += 2) { + const pair: PairModel[] = []; + // path in pair needs to be a list because that's what the + // subject param in the discover controller is expecting + const subjectOdd = sortedList.objectAt(i) as SubjectModel; pair.pushObject({ - path: [subjectEven?.taxonomyName], - text: subjectEven?.text, - }); + path: [subjectOdd?.taxonomyName], + text: subjectOdd?.text, + } as PairModel); + + if (sortedList.objectAt(i + 1)) { + const subjectEven = sortedList.objectAt(i + 1) as SubjectModel; + pair.pushObject({ + path: [subjectEven?.taxonomyName], + text: subjectEven?.text, + }); + } + pairedList.pushObject(pair); } - pairedList.pushObject(pair); + } + return pairedList; } } diff --git a/lib/osf-components/addon/components/preprints/taxonomy-top-list/styles.scss b/lib/osf-components/addon/components/preprints/taxonomy-top-list/styles.scss index c6a8188d477..4991ca1c5bf 100644 --- a/lib/osf-components/addon/components/preprints/taxonomy-top-list/styles.scss +++ b/lib/osf-components/addon/components/preprints/taxonomy-top-list/styles.scss @@ -11,18 +11,47 @@ .subject-item { width: calc(50% - 20px); + .btn { + display: inline-block; + margin-bottom: 0; + font-weight: 400; + text-align: center; + white-space: nowrap; + touch-action: manipulation; + cursor: pointer; + background-image: none; + border: 1px solid transparent; + border-radius: 2px; + padding: 6px 12px; + font-size: 14px; + line-height: 1.42857; + user-select: none; + vertical-align: middle; + color: $color-text-white; + } + .subject-button { width: 100%; font-size: 17px; overflow: hidden; text-overflow: ellipsis; background-color: var(--primary-color); + color: var(--secondary-color); border: 1px solid var(--secondary-color); &:hover { + color: var(--primary-color); background-color: var(--secondary-color); border: 1px solid var(--primary-color); } } } + + &.mobile { + flex-direction: column; + + .subject-item { + width: 100%; + } + } } diff --git a/lib/osf-components/addon/components/preprints/taxonomy-top-list/template.hbs b/lib/osf-components/addon/components/preprints/taxonomy-top-list/template.hbs index 28ee59d77ef..696223b5ef4 100644 --- a/lib/osf-components/addon/components/preprints/taxonomy-top-list/template.hbs +++ b/lib/osf-components/addon/components/preprints/taxonomy-top-list/template.hbs @@ -1,13 +1,12 @@ {{#each this.sortedList as |pair|}} -
+
{{#each pair as |subject|}}
{{subject.text}} From 99e189c6ec6a6421ee8badd5b2ad152a8c9142c0 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Tue, 8 Aug 2023 09:51:25 -0600 Subject: [PATCH 038/170] Added more information for preprints --- app/models/preprint-provider.ts | 1 + app/preprints/index/controller.ts | 9 +++++++++ app/preprints/index/template.hbs | 2 +- mirage/scenarios/preprints.ts | 1 + translations/en-us.yml | 2 ++ 5 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/models/preprint-provider.ts b/app/models/preprint-provider.ts index bdf21c91f48..bc3e23b8443 100644 --- a/app/models/preprint-provider.ts +++ b/app/models/preprint-provider.ts @@ -18,6 +18,7 @@ const { defaultProvider } = config; export default class PreprintProviderModel extends ProviderModel { @service intl!: Intl; + @attr('fixstring') email_support!: string | null; @attr('array') subjectsAcceptable!: string[]; @attr('array') additionalProviders!: string[]; @attr('string') shareSource!: string; diff --git a/app/preprints/index/controller.ts b/app/preprints/index/controller.ts index 113394bd924..8f6b536033a 100644 --- a/app/preprints/index/controller.ts +++ b/app/preprints/index/controller.ts @@ -5,12 +5,14 @@ import RouterService from '@ember/routing/router-service'; import { inject as service } from '@ember/service'; import Theme from 'ember-osf-web/services/theme'; import Media from 'ember-responsive'; +import Intl from 'ember-intl/services/intl'; export default class Preprints extends Controller { @service store!: Store; @service theme!: Theme; @service router!: RouterService; @service media!: Media; + @service intl!: Intl; get isMobile(): boolean { return this.media.isMobile; @@ -30,4 +32,11 @@ export default class Preprints extends Controller { this.router.transitionTo(route, { queryParams: { q: query } }); } + + get supportEmail(): string { + const { isProvider, provider } = this.theme; + + // eslint-disable-next-line max-len + return `mailto:${isProvider && provider && provider.emailSupport ? provider.emailSupport : this.intl.t('contact.email')}`; + } } diff --git a/app/preprints/index/template.hbs b/app/preprints/index/template.hbs index a4aefb620d9..fad0b32e9a4 100644 --- a/app/preprints/index/template.hbs +++ b/app/preprints/index/template.hbs @@ -139,7 +139,7 @@ data-analytics-name='Contact Email' local-class='btn btn-lg' class='btn-info' - @href='mailto:contact@osf.io' + @href={{this.supportEmail}} > {{t 'preprints.services.bottom.contact'}} diff --git a/mirage/scenarios/preprints.ts b/mirage/scenarios/preprints.ts index 81fc0f4dec4..a98c0a94609 100644 --- a/mirage/scenarios/preprints.ts +++ b/mirage/scenarios/preprints.ts @@ -40,6 +40,7 @@ function buildOSF( moderators: [currentUserModerator], preprints, description: 'This is the description for osf', + email_support: 'overwritten-email@osf.io', }); } diff --git a/translations/en-us.yml b/translations/en-us.yml index 6c494b8e55f..21b3ba88c23 100644 --- a/translations/en-us.yml +++ b/translations/en-us.yml @@ -24,6 +24,8 @@ documentType: pluralCapitalized: Theses singular: thesis singularCapitalized: Thesis +contact: + email: support@osf.io general: OSF: OSF share: Share From d207ff22c323134039d2f518b5c11db61474dce6 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Tue, 8 Aug 2023 10:04:01 -0600 Subject: [PATCH 039/170] Added more information for the taxomony --- app/preprints/index/template.hbs | 5 ++++- .../preprints/taxonomy-top-list/component.ts | 11 +++++++---- .../preprints/taxonomy-top-list/template.hbs | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/preprints/index/template.hbs b/app/preprints/index/template.hbs index fad0b32e9a4..4898446fc78 100644 --- a/app/preprints/index/template.hbs +++ b/app/preprints/index/template.hbs @@ -76,7 +76,10 @@ {{#if this.theme.provider.additionalProviders}} {{additional-provider-list additionalProviders=this.theme.provider.additionalProviders}} {{else}} - + {{/if}}
diff --git a/lib/osf-components/addon/components/preprints/taxonomy-top-list/component.ts b/lib/osf-components/addon/components/preprints/taxonomy-top-list/component.ts index 7a61d75b1e1..029bb65c61e 100644 --- a/lib/osf-components/addon/components/preprints/taxonomy-top-list/component.ts +++ b/lib/osf-components/addon/components/preprints/taxonomy-top-list/component.ts @@ -5,16 +5,19 @@ import { inject as service } from '@ember/service'; interface InputArgs { list: SubjectModel[]; + provider: string; } interface PairModel { - path: string[]; + queryParam: string; text: string; } export default class TaxonomyTopList extends Component { @service media!: Media; + provider = this.args.provider; + get isMobile(): boolean { return this.media.isMobile; } @@ -31,7 +34,7 @@ export default class TaxonomyTopList extends Component { const pair: PairModel[] = []; const subject= sortedList.objectAt(i) as SubjectModel; pair.pushObject({ - path: [subject?.taxonomyName], + queryParam: subject?.taxonomyName, text: subject?.text, } as PairModel); pairedList.pushObject(pair); @@ -43,14 +46,14 @@ export default class TaxonomyTopList extends Component { // subject param in the discover controller is expecting const subjectOdd = sortedList.objectAt(i) as SubjectModel; pair.pushObject({ - path: [subjectOdd?.taxonomyName], + queryParam: subjectOdd?.taxonomyName, text: subjectOdd?.text, } as PairModel); if (sortedList.objectAt(i + 1)) { const subjectEven = sortedList.objectAt(i + 1) as SubjectModel; pair.pushObject({ - path: [subjectEven?.taxonomyName], + queryParam: subjectEven?.taxonomyName, text: subjectEven?.text, }); } diff --git a/lib/osf-components/addon/components/preprints/taxonomy-top-list/template.hbs b/lib/osf-components/addon/components/preprints/taxonomy-top-list/template.hbs index 696223b5ef4..cabcea5f222 100644 --- a/lib/osf-components/addon/components/preprints/taxonomy-top-list/template.hbs +++ b/lib/osf-components/addon/components/preprints/taxonomy-top-list/template.hbs @@ -6,7 +6,7 @@ data-test-taxonomy-link data-analytics-name='Preprints taxonomy link' local-class='btn subject-button' - @href={{concat 'discover/' (query-params subject=subject.path) }} + @href='preprints/{{this.provider}}/discover?subject={{subject.queryParam}}' > {{subject.text}} From aeb0e981048da61f8fc51c3dee7ff65923412d04 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Tue, 8 Aug 2023 11:15:15 -0600 Subject: [PATCH 040/170] Added a branded footer for preprints --- app/models/preprint-provider.ts | 6 ++++-- app/preprints/index/template.hbs | 8 +++++++- .../preprints/branded-footer/component.ts | 13 +++++++++++++ .../preprints/branded-footer/styles.scss | 18 ++++++++++++++++++ .../preprints/branded-footer/template.hbs | 5 +++++ .../preprints/branded-footer/component.js | 1 + .../preprints/branded-footer/template.js | 1 + mirage/fixtures/preprint-providers.ts | 7 +++++++ mirage/scenarios/preprints.ts | 5 ++++- translations/en-us.yml | 1 - 10 files changed, 60 insertions(+), 5 deletions(-) create mode 100644 lib/osf-components/addon/components/preprints/branded-footer/component.ts create mode 100644 lib/osf-components/addon/components/preprints/branded-footer/styles.scss create mode 100644 lib/osf-components/addon/components/preprints/branded-footer/template.hbs create mode 100644 lib/osf-components/app/components/preprints/branded-footer/component.js create mode 100644 lib/osf-components/app/components/preprints/branded-footer/template.js diff --git a/app/models/preprint-provider.ts b/app/models/preprint-provider.ts index bc3e23b8443..e3c2ce97a5d 100644 --- a/app/models/preprint-provider.ts +++ b/app/models/preprint-provider.ts @@ -64,12 +64,14 @@ export default class PreprintProviderModel extends ProviderModel { get providerTitle() { if (this.id !== defaultProvider) { if (this.preprintWordInTitle) { + return this.name; + } else { return this.intl.t('preprints.provider-title', { name: this.name, pluralizedPreprintWord: this.documentType.pluralCapitalized }); } - return this.name; + } else { + return this.documentType.pluralCapitalized; } - return this.intl.t('preprints.osf-title'); } } diff --git a/app/preprints/index/template.hbs b/app/preprints/index/template.hbs index 4898446fc78..14568d93c63 100644 --- a/app/preprints/index/template.hbs +++ b/app/preprints/index/template.hbs @@ -1,4 +1,4 @@ -{{page-title (t 'preprints.title')}} +{{page-title this.theme.provider.providerTitle}}
{{/if}} + +
+ +
{{!END INDEX}} diff --git a/lib/osf-components/addon/components/preprints/branded-footer/component.ts b/lib/osf-components/addon/components/preprints/branded-footer/component.ts new file mode 100644 index 00000000000..e2119aa03eb --- /dev/null +++ b/lib/osf-components/addon/components/preprints/branded-footer/component.ts @@ -0,0 +1,13 @@ +import Component from '@glimmer/component'; + +interface InputArgs { + footerLinks: string; +} + +export default class BrandedFooter extends Component { + footerLinks = this.args.footerLinks; + + get hasFooters(): boolean { + return this.footerLinks !== ''; + } +} diff --git a/lib/osf-components/addon/components/preprints/branded-footer/styles.scss b/lib/osf-components/addon/components/preprints/branded-footer/styles.scss new file mode 100644 index 00000000000..95d12664ffb --- /dev/null +++ b/lib/osf-components/addon/components/preprints/branded-footer/styles.scss @@ -0,0 +1,18 @@ +// stylelint-disable max-nesting-depth, selector-max-compound-selectors + +.branded-footer-links { + width: 100%; + display: flex; + flex-direction: row; + justify-content: space-between; + align-items: flex-start; + margin: 2.5em 0; + + .social > a { + margin: 0 4px; + } + + .social > a:hover { + text-decoration: none; + } +} diff --git a/lib/osf-components/addon/components/preprints/branded-footer/template.hbs b/lib/osf-components/addon/components/preprints/branded-footer/template.hbs new file mode 100644 index 00000000000..af11557a710 --- /dev/null +++ b/lib/osf-components/addon/components/preprints/branded-footer/template.hbs @@ -0,0 +1,5 @@ +{{#if this.hasFooters}} +
+ {{html-safe this.footerLinks 'footer-links'}} +
+{{/if}} \ No newline at end of file diff --git a/lib/osf-components/app/components/preprints/branded-footer/component.js b/lib/osf-components/app/components/preprints/branded-footer/component.js new file mode 100644 index 00000000000..690d6fce346 --- /dev/null +++ b/lib/osf-components/app/components/preprints/branded-footer/component.js @@ -0,0 +1 @@ +export { default } from 'osf-components/components/preprints/branded-footer/component'; diff --git a/lib/osf-components/app/components/preprints/branded-footer/template.js b/lib/osf-components/app/components/preprints/branded-footer/template.js new file mode 100644 index 00000000000..116669ce481 --- /dev/null +++ b/lib/osf-components/app/components/preprints/branded-footer/template.js @@ -0,0 +1 @@ +export { default } from 'osf-components/components/preprints/branded-footer/template'; diff --git a/mirage/fixtures/preprint-providers.ts b/mirage/fixtures/preprint-providers.ts index 136734e5636..f362043c8fe 100644 --- a/mirage/fixtures/preprint-providers.ts +++ b/mirage/fixtures/preprint-providers.ts @@ -16,42 +16,49 @@ const preprintProviders: Array> = [ name: 'Open Science Framework', preprintWord: 'preprint', assets: randomAssets(1), + footerLinks: 'fake footer links', }, { id: 'thesiscommons', name: 'Thesis Commons', preprintWord: 'thesis', assets: randomAssets(2), + footerLinks: 'fake footer links', }, { id: 'preprintrxiv', name: 'PreprintrXiv', preprintWord: 'preprint', assets: randomAssets(3), + footerLinks: 'fake footer links', }, { id: 'paperxiv', name: 'PaperXiv', preprintWord: 'paper', assets: randomAssets(4), + footerLinks: 'fake footer links', }, { id: 'thesisrxiv', name: 'ThesisrXiv', preprintWord: 'thesis', assets: randomAssets(5), + footerLinks: 'fake footer links', }, { id: 'workrxiv', name: 'WorkrXiv', preprintWord: 'work', assets: randomAssets(6), + footerLinks: 'fake footer links', }, { id: 'docrxiv', name: 'DocrXiv', preprintWord: 'default', assets: randomAssets(7), + footerLinks: 'fake footer links', }, { id: 'agrixiv', diff --git a/mirage/scenarios/preprints.ts b/mirage/scenarios/preprints.ts index a98c0a94609..3c0aec202d1 100644 --- a/mirage/scenarios/preprints.ts +++ b/mirage/scenarios/preprints.ts @@ -36,11 +36,11 @@ function buildOSF( highlightedSubjects: subjects, // eslint-disable-next-line max-len advisory_board: '
\n

Advisory Group

\n

Our advisory group includes leaders in preprints and scholarly communication\n

\n
\n
    \n
  • Devin Berg : engrXiv, University of Wisconsin-Stout
  • \n
  • Pete Binfield : PeerJ PrePrints
  • \n
  • Benjamin Brown : PsyArXiv, Georgia Gwinnett College
  • \n
  • Philip Cohen : SocArXiv, University of Maryland
  • \n
  • Kathleen Fitzpatrick : Modern Language Association
  • \n
\n
\n
\n
    \n
  • John Inglis : bioRxiv, Cold Spring Harbor Laboratory Press
  • \n
  • Rebecca Kennison : K | N Consultants
  • \n
  • Kristen Ratan : CoKo Foundation
  • \n
  • Oya Rieger : Ithaka S+R
  • \n
  • Judy Ruttenberg : SHARE, Association of Research Libraries
  • \n
\n
\n
', + footer_links: '', brand, moderators: [currentUserModerator], preprints, description: 'This is the description for osf', - email_support: 'overwritten-email@osf.io', }); } @@ -71,6 +71,9 @@ function buildThesisCommons( description: '

This is the description for Thesis Commons and it has an inline-style!

', // eslint-disable-next-line max-len advisory_board: '

Steering Committee

\n
\n
    \n
  • Obasegun Ayodele, Vilsquare.org, Nigeria
  • \n
  • Fayza Mahmoud, Alexandria University, Egypt
  • \n
  • Johanssen Obanda, Jabulani Youths for Transformation (JAY4T), Kenya
  • \n
  • Umar Ahmad, University Putra Malaysia (UPM) and the Malaysia Genome Institute (MGI)
  • \n
  • Michael Cary, West Virginia University, USA
  • \n
  • Nada Fath, Mohamed V University & Hassan II Institute of Agronomy and Veterinary Medicine, Rabat, Morocco
  • \n
  • Greg Simpson, Cranfield University, England & South Africa
  • \n
\n
\n
    \n
  • Hisham Arafat, EMEA Applications Consulting, Egypt
  • \n
  • Justin Sègbédji Ahinon, AfricArXiv co-founder, IGDORE, Bénin
  • \n
  • Mahmoud M Ibrahim, Uniklinik RWTH Aachen, Germany & Egypt
  • \n
  • Luke Okelo, Technical University of Kenya
  • \n
  • Ryszard Auksztulewicz, MPI of Empirical Aesthetics, Germany & City University of Hong Kong
  • \n
  • Osman Aldirdiri, University of Khartoum, Sudan
  • \n
  • Jo Havemann, AfricArXiv co-founder, Access 2 Perspectives‘, IGDORE, Germany & Kenya
  • \n
', + // eslint-disable-next-line max-len + footer_links: '

AfricArXiv: About | Submission Guidelines | Support | Contact |

', + email_support: 'overwritten-email@osf.io', }); const agrixiv = server.schema.preprintProviders.find('agrixiv') as ModelInstance; diff --git a/translations/en-us.yml b/translations/en-us.yml index 21b3ba88c23..4c01f025dd5 100644 --- a/translations/en-us.yml +++ b/translations/en-us.yml @@ -1117,7 +1117,6 @@ collections: reject: rejected remove: 'removed' preprints: - osf-title: 'OSF Preprints' provider-title: '{name} {pluralizedPreprintWord}' discover: title: 'Search' From 054bf95bf851ea879d737aca15f38e2e829b8bc1 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Tue, 8 Aug 2023 11:19:26 -0600 Subject: [PATCH 041/170] Fixed the preprint provider logic ... again --- app/models/preprint-provider.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/models/preprint-provider.ts b/app/models/preprint-provider.ts index e3c2ce97a5d..d927ec94e51 100644 --- a/app/models/preprint-provider.ts +++ b/app/models/preprint-provider.ts @@ -55,7 +55,7 @@ export default class PreprintProviderModel extends ProviderModel { @computed('id') get preprintWordInTitle() { - return this.id !== 'thesiscommons'; + return this.id === 'thesiscommons'; } // Is either OSF Preprints if provider is the default provider, @@ -65,10 +65,9 @@ export default class PreprintProviderModel extends ProviderModel { if (this.id !== defaultProvider) { if (this.preprintWordInTitle) { return this.name; - } else { - return this.intl.t('preprints.provider-title', - { name: this.name, pluralizedPreprintWord: this.documentType.pluralCapitalized }); } + return this.intl.t('preprints.provider-title', + { name: this.name, pluralizedPreprintWord: this.documentType.pluralCapitalized }); } else { return this.documentType.pluralCapitalized; } From 6783e527684e93ed34d3dcb293fd1bae736dc27b Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Tue, 8 Aug 2023 11:46:18 -0600 Subject: [PATCH 042/170] Fixed the branded header search --- app/models/preprint-provider.ts | 6 ++++++ app/preprints/index/template.hbs | 1 + .../addon/components/branded-header/component.ts | 6 ++++++ .../addon/components/branded-header/template.hbs | 2 +- translations/en-us.yml | 2 +- 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/models/preprint-provider.ts b/app/models/preprint-provider.ts index d927ec94e51..ecf9ce5a1a8 100644 --- a/app/models/preprint-provider.ts +++ b/app/models/preprint-provider.ts @@ -53,6 +53,12 @@ export default class PreprintProviderModel extends ProviderModel { }; } + @computed('documentType.plural') + get searchPlaceholder(): string { + return this.intl.t('preprints.header.search_placeholder', + { placeholder: this.documentType.plural}); + } + @computed('id') get preprintWordInTitle() { return this.id === 'thesiscommons'; diff --git a/app/preprints/index/template.hbs b/app/preprints/index/template.hbs index 14568d93c63..e3afa6eac85 100644 --- a/app/preprints/index/template.hbs +++ b/app/preprints/index/template.hbs @@ -10,6 +10,7 @@ @translationParent='preprints' @onSearch={{action this.onSearch}} @showHelp=true + @searchPlaceholder={{this.theme.provider.searchPlaceholder}} as |branded-header| > {{#branded-header.lead}} diff --git a/lib/osf-components/addon/components/branded-header/component.ts b/lib/osf-components/addon/components/branded-header/component.ts index 9cec891a9ee..82d03c32182 100644 --- a/lib/osf-components/addon/components/branded-header/component.ts +++ b/lib/osf-components/addon/components/branded-header/component.ts @@ -13,6 +13,7 @@ interface InputArgs { onSearch: (value: string) => void; translationParent?: string; showHelp: false; + searchPlaceholder?: string; } export default class BrandedHeader extends Component { @@ -37,6 +38,11 @@ export default class BrandedHeader extends Component { return this.media.isMobile; } + get searchPlaceholder() { + return this.args.searchPlaceholder ? this.args.searchPlaceholder + : this.intl.t(`${this.args.translationParent}.header.search_placeholder`); + } + @computed('providerModel.name', 'args.translationParent') get headerAriaLabel() { return this.providerModel ? diff --git a/lib/osf-components/addon/components/branded-header/template.hbs b/lib/osf-components/addon/components/branded-header/template.hbs index c58f3889e6a..0c69f16b8a6 100644 --- a/lib/osf-components/addon/components/branded-header/template.hbs +++ b/lib/osf-components/addon/components/branded-header/template.hbs @@ -33,7 +33,7 @@ id='search' @value={{this.value}} @class='form-control' - @placeholder={{t (concat @translationParent '.header.search_placeholder') }} + @placeholder={{this.searchPlaceholder}} /> {{#if this.showHelp}}
@@ -165,9 +165,9 @@ {{/if}}
- + >
{{!END INDEX}} diff --git a/lib/osf-components/app/components/preprints/branded-footer/component.js b/lib/osf-components/app/components/preprints/branded-footer/component.js deleted file mode 100644 index 690d6fce346..00000000000 --- a/lib/osf-components/app/components/preprints/branded-footer/component.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from 'osf-components/components/preprints/branded-footer/component'; diff --git a/lib/osf-components/app/components/preprints/branded-footer/template.js b/lib/osf-components/app/components/preprints/branded-footer/template.js deleted file mode 100644 index 116669ce481..00000000000 --- a/lib/osf-components/app/components/preprints/branded-footer/template.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from 'osf-components/components/preprints/branded-footer/template'; diff --git a/lib/osf-components/app/components/preprints/taxonomy-top-list/component.js b/lib/osf-components/app/components/preprints/taxonomy-top-list/component.js deleted file mode 100644 index 90bed31d38d..00000000000 --- a/lib/osf-components/app/components/preprints/taxonomy-top-list/component.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from 'osf-components/components/preprints/taxonomy-top-list/component'; diff --git a/lib/osf-components/app/components/preprints/taxonomy-top-list/template.js b/lib/osf-components/app/components/preprints/taxonomy-top-list/template.js deleted file mode 100644 index 40849b6fc92..00000000000 --- a/lib/osf-components/app/components/preprints/taxonomy-top-list/template.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from 'osf-components/components/preprints/taxonomy-top-list/template'; From 884868c42d6f722842b43af990be86f45654e705 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Fri, 11 Aug 2023 13:18:46 -0600 Subject: [PATCH 046/170] Added taxonomy tests --- .../-components/branded-footer/template.hbs | 2 +- .../taxonomy-top-list/component.ts | 4 + .../taxonomy-top-list/template.hbs | 4 +- app/preprints/index/template.hbs | 2 +- .../preprints/taxonomy-top-list-test.ts | 156 ++++++++++++++++++ 5 files changed, 164 insertions(+), 4 deletions(-) create mode 100644 tests/acceptance/preprints/taxonomy-top-list-test.ts diff --git a/app/preprints/-components/branded-footer/template.hbs b/app/preprints/-components/branded-footer/template.hbs index af11557a710..ffee3b5b5a9 100644 --- a/app/preprints/-components/branded-footer/template.hbs +++ b/app/preprints/-components/branded-footer/template.hbs @@ -1,5 +1,5 @@ {{#if this.hasFooters}}
- {{html-safe this.footerLinks 'footer-links'}} + {{html-safe this.footerLinks}}
{{/if}} \ No newline at end of file diff --git a/app/preprints/-components/taxonomy-top-list/component.ts b/app/preprints/-components/taxonomy-top-list/component.ts index 029bb65c61e..7928328c241 100644 --- a/app/preprints/-components/taxonomy-top-list/component.ts +++ b/app/preprints/-components/taxonomy-top-list/component.ts @@ -62,6 +62,10 @@ export default class TaxonomyTopList extends Component { } + if (pairedList.length > 0 && typeof this.args.provider !== 'string') { + throw new Error('A provider string must be provided with a valid list'); + } + return pairedList; } } diff --git a/app/preprints/-components/taxonomy-top-list/template.hbs b/app/preprints/-components/taxonomy-top-list/template.hbs index cabcea5f222..d49088def37 100644 --- a/app/preprints/-components/taxonomy-top-list/template.hbs +++ b/app/preprints/-components/taxonomy-top-list/template.hbs @@ -1,7 +1,7 @@ {{#each this.sortedList as |pair|}} -
+
{{#each pair as |subject|}} -
+
- {{html-safe this.theme.provider.advisoryBoard 'advisory-board'}} + {{html-safe this.theme.provider.advisoryBoard}}
{{/if}} diff --git a/tests/acceptance/preprints/taxonomy-top-list-test.ts b/tests/acceptance/preprints/taxonomy-top-list-test.ts new file mode 100644 index 00000000000..bf7c42fe770 --- /dev/null +++ b/tests/acceptance/preprints/taxonomy-top-list-test.ts @@ -0,0 +1,156 @@ +import { render } from '@ember/test-helpers'; +import Ember from 'ember'; +import { hbs } from 'ember-cli-htmlbars'; +import { EnginesTestContext } from 'ember-engines/test-support'; +import SubjectModel from 'ember-osf-web/models/subject'; +import { setupRenderingTest } from 'ember-qunit'; +import { module, test } from 'qunit'; + +module('Acceptance | preprints | taxonomy-top-list', hooks => { + setupRenderingTest(hooks); + + test('it creates no rows when the list is undefined', async function(this: EnginesTestContext,assert) { + // Given no list is provided + // When the component is rendered + await render(hbs` + + + `); + + // Then the subject container is verified + assert.dom('[data-test-subject-container]').doesNotExist('no subjects are displayed'); + }); + + test('it creates no rows when the list is empty', async function(this: EnginesTestContext,assert) { + // Given the taxonomy list is created with two subjects + this.set('list', [ ]); + + // When the component is rendered + await render(hbs` + + + `); + + // Then the subject container is verified + assert.dom('[data-test-subject-container]').doesNotExist('no subjects are displayed'); + }); + + test('it throws an error with a list and no provider', async function(this: EnginesTestContext,assert) { + Ember.onerror = (error: Error) => { + assert.equal(error.message, + 'A provider string must be provided with a valid list'); + }; + + // Given the taxonomy list is created with two subjects + this.set('list', [ + { + text: 'elephant', + taxonomyName: 'forgetful', + } as SubjectModel, + ]); + + // When the component is rendered + await render(hbs` + + + `); + }); + + test('it creates a row of two subjects in desktop mode', async function(this: EnginesTestContext,assert) { + // Given the taxonomy list is created with two subjects + this.set('list', [ + { + text: 'elephant', + taxonomyName: 'forgetful', + } as SubjectModel, + { + text: 'deer', + taxonomyName: 'The sneaky', + } as SubjectModel, + ]); + + // When the component is rendered + await render(hbs` + + + `); + + // Then the subject container is verified + const subjectContainers = this.element.querySelectorAll('[data-test-subject-container]'); + assert.equal(subjectContainers.length, 1, 'The subject container has 1 container'); + + // And the link containers are verified + const linkContainers = subjectContainers[0].querySelectorAll('[data-test-taxonomy-container]'); + assert.equal(linkContainers.length, 2, 'The link container is grouped in two'); + + // And the first link is verified to be sorted correctly + const links = linkContainers[0].querySelectorAll('[data-test-taxonomy-link]'); + assert.dom(links[0]).hasText('deer', 'The first link is deer'); + // And the href is corrected + // eslint-disable-next-line max-len + assert.dom(links[0]).hasAttribute('href', 'preprints/outdoorLife/discover?subject=The sneaky', 'The href is blank'); + }); + + test('it creates two rows of two and one subject in desktop mode', async function(this: EnginesTestContext,assert) { + // Given the taxonomy list is created with two subjects + this.set('list', [ + { + text: 'elephant', + taxonomyName: 'forgetful', + } as SubjectModel, + { + text: 'bamboon', + taxonomyName: 'The great red bum', + } as SubjectModel, + { + text: 'deer', + taxonomyName: 'The sneaky', + } as SubjectModel, + ]); + + // When the component is rendered + await render(hbs` + + + `); + + + // Then the subject container is verified + const subjectContainers = this.element.querySelectorAll('[data-test-subject-container]'); + assert.equal(subjectContainers.length, 2, 'The subject container has 1 container'); + + // And the link containers are verified + let linkContainers = subjectContainers[0].querySelectorAll('[data-test-taxonomy-container]'); + assert.equal(linkContainers.length, 2, 'The link container is grouped in two'); + + // And the first link is verified to be sorted correctly + let links = linkContainers[1].querySelectorAll('[data-test-taxonomy-link]'); + assert.dom(links[0]).hasText('deer', 'The first link is deer'); + // And the href is corrected + // eslint-disable-next-line max-len + assert.dom(links[0]).hasAttribute('href', 'preprints/outdoorLife/discover?subject=The sneaky', 'The href is blank'); + + linkContainers = subjectContainers[1].querySelectorAll('[data-test-taxonomy-container]'); + assert.equal(linkContainers.length, 1, 'The link container is grouped in one'); + + // And the third link is verified to be sorted correctly + links = linkContainers[0].querySelectorAll('[data-test-taxonomy-link]'); + assert.dom(links[0]).hasText('elephant', 'The first link is elephant'); + // And the href is corrected + // eslint-disable-next-line max-len + assert.dom(links[0]).hasAttribute('href', 'preprints/outdoorLife/discover?subject=forgetful', 'The href is blank'); + }); +}); From 4418e68b5ed75d52ee7afc2cabff95c7a97c7bb5 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Fri, 11 Aug 2023 13:55:53 -0600 Subject: [PATCH 047/170] Added another test --- .../preprints/taxonomy-top-list-test.ts | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/tests/acceptance/preprints/taxonomy-top-list-test.ts b/tests/acceptance/preprints/taxonomy-top-list-test.ts index bf7c42fe770..81b3c6e64bd 100644 --- a/tests/acceptance/preprints/taxonomy-top-list-test.ts +++ b/tests/acceptance/preprints/taxonomy-top-list-test.ts @@ -1,3 +1,4 @@ +import Service from '@ember/service'; import { render } from '@ember/test-helpers'; import Ember from 'ember'; import { hbs } from 'ember-cli-htmlbars'; @@ -153,4 +154,61 @@ module('Acceptance | preprints | taxonomy-top-list', hooks => { // eslint-disable-next-line max-len assert.dom(links[0]).hasAttribute('href', 'preprints/outdoorLife/discover?subject=forgetful', 'The href is blank'); }); + + test('it creates a 2 rows and one subjects in mobile mode', async function(this: EnginesTestContext,assert) { + + const mediaServiceStub = Service.extend({ + isMobile: true, + isDesktop: false, + }); + + this.owner.register('service:media', mediaServiceStub); + + // Given the taxonomy list is created with two subjects + this.set('list', [ + { + text: 'elephant', + taxonomyName: 'forgetful', + } as SubjectModel, + { + text: 'deer', + taxonomyName: 'The sneaky', + } as SubjectModel, + ]); + + // When the component is rendered + await render(hbs` + + + `); + + // Then the subject container is verified + const subjectContainers = this.element.querySelectorAll('[data-test-subject-container]'); + assert.equal(subjectContainers.length, 2, 'The subject container has 1 container'); + + // And the link containers are verified + let linkContainers = subjectContainers[0].querySelectorAll('[data-test-taxonomy-container]'); + assert.equal(linkContainers.length, 1, 'The link container is grouped in one'); + + // And the first link is verified to be sorted correctly + let links = linkContainers[0].querySelectorAll('[data-test-taxonomy-link]'); + assert.dom(links[0]).hasText('deer', 'The first link is deer'); + // And the href is corrected + // eslint-disable-next-line max-len + assert.dom(links[0]).hasAttribute('href', 'preprints/outdoorLife/discover?subject=The sneaky', 'The href is blank'); + + // And the link containers are verified + linkContainers = subjectContainers[1].querySelectorAll('[data-test-taxonomy-container]'); + assert.equal(linkContainers.length, 1, 'The link container is grouped in one'); + + // And the first link is verified to be sorted correctly + links = linkContainers[0].querySelectorAll('[data-test-taxonomy-link]'); + assert.dom(links[0]).hasText('elephant', 'The first link is elephant'); + // And the href is corrected + // eslint-disable-next-line max-len + assert.dom(links[0]).hasAttribute('href', 'preprints/outdoorLife/discover?subject=forgetful', 'The href is blank'); + }); }); From 27308061fcb0d4af54e302bf484405c4c6e9c039 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Mon, 14 Aug 2023 15:06:12 -0600 Subject: [PATCH 048/170] Added another test --- .../components/branded-header/template.hbs | 7 +-- .../branded-header/component-test.ts | 53 +++++++++++++++++++ 2 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 tests/integration/components/branded-header/component-test.ts diff --git a/lib/osf-components/addon/components/branded-header/template.hbs b/lib/osf-components/addon/components/branded-header/template.hbs index 0c69f16b8a6..64a7fba6e7c 100644 --- a/lib/osf-components/addon/components/branded-header/template.hbs +++ b/lib/osf-components/addon/components/branded-header/template.hbs @@ -1,6 +1,7 @@ -
+
- + { + setupRenderingTest(hooks); + setupMirage(hooks); + + hooks.beforeEach(function(this: TestContext) { + // this.store = this.owner.lookup('service:store'); + }); + + test('default display', async function(assert) { + // Given the input variablies are set + this.set('onSearch', sinon.fake()); + this.set('searchPlaceholder', 'preprints.header.search_placeholder'); + + // When the component is rendered + await render(hbs` + `); + + // Then the header container is verified + const headerContainer = this.element.querySelector('[data-test-header-container]'); + assert.dom(headerContainer).exists(); + + // Then the header container is verified + assert.dom(this.element.querySelector('[data-test-brand-logo]')).hasAttribute('aria-label', 'OSF Preprints'); + + // eslint-disable-next-line max-len + assert.dom(this.element.querySelector('[data-test-perform-search-button]')).hasAttribute('aria-label', 'Perform search'); + assert.dom(this.element.querySelector('[data-test-perform-search-button]')).hasAttribute('type', 'button'); + + // eslint-disable-next-line max-len + assert.dom(this.element.querySelector('[data-test-search-icon]')).hasAttribute('data-icon', 'search'); + + // eslint-disable-next-line max-len + assert.dom(this.element.querySelector('[data-test-search-box]')).hasAttribute('placeholder', 'preprints.header.search_placeholder'); + + // eslint-disable-next-line max-len + assert.dom(this.element.querySelector('[data-test-search-help-button]')).hasAttribute('aria-label', 'Search help'); + assert.dom(this.element.querySelector('[data-test-search-help-button]')).hasAttribute('type', 'button'); + }); +}); From eaf0d97c9ec761e0adfbcfc047fe9fdcc49df655 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Tue, 15 Aug 2023 11:38:48 -0600 Subject: [PATCH 049/170] Added additional tests for the branded header --- .../branded-header/component-test.ts | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/tests/integration/components/branded-header/component-test.ts b/tests/integration/components/branded-header/component-test.ts index 56fa054ebb4..fab059978f5 100644 --- a/tests/integration/components/branded-header/component-test.ts +++ b/tests/integration/components/branded-header/component-test.ts @@ -26,28 +26,51 @@ module('Integration | Component | branded-header', hooks => { @showHelp=true @searchPlaceholder={{this.searchPlaceholder}} as |branded-header| - > + > + {{#branded-header.lead}} +
+ This is the lead +
+ {{/branded-header.lead}} + {{#branded-header.row}} +
+ This is the row +
+ {{/branded-header.row}} + `); // Then the header container is verified const headerContainer = this.element.querySelector('[data-test-header-container]'); assert.dom(headerContainer).exists(); - // Then the header container is verified + // And the brand logo container is verified assert.dom(this.element.querySelector('[data-test-brand-logo]')).hasAttribute('aria-label', 'OSF Preprints'); + // And the perform search button is verified // eslint-disable-next-line max-len assert.dom(this.element.querySelector('[data-test-perform-search-button]')).hasAttribute('aria-label', 'Perform search'); assert.dom(this.element.querySelector('[data-test-perform-search-button]')).hasAttribute('type', 'button'); + // And the search icon is verified // eslint-disable-next-line max-len assert.dom(this.element.querySelector('[data-test-search-icon]')).hasAttribute('data-icon', 'search'); + // And the search box is verified // eslint-disable-next-line max-len assert.dom(this.element.querySelector('[data-test-search-box]')).hasAttribute('placeholder', 'preprints.header.search_placeholder'); + // And the search help button is verified // eslint-disable-next-line max-len assert.dom(this.element.querySelector('[data-test-search-help-button]')).hasAttribute('aria-label', 'Search help'); assert.dom(this.element.querySelector('[data-test-search-help-button]')).hasAttribute('type', 'button'); + + // And the lead yield is verified + // eslint-disable-next-line max-len + assert.dom(this.element.querySelector('[data-test-lead-yield]')).hasText('This is the lead', 'The lead in yielded correctly'); + + // And the row yield is verified + // eslint-disable-next-line max-len + assert.dom(this.element.querySelector('[data-test-row-yield]')).hasText('This is the row', 'The lead in yielded correctly'); }); }); From eb5dd1175f29e5d36d46dd3f8621576e3d4c8505 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Tue, 15 Aug 2023 11:55:23 -0600 Subject: [PATCH 050/170] Added Branded footer tests --- .../-components/branded-footer/component.ts | 2 +- .../-components/branded-footer/template.hbs | 2 +- .../preprints/branded-footer-test.ts | 45 +++++++++++++++++++ 3 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 tests/acceptance/preprints/branded-footer-test.ts diff --git a/app/preprints/-components/branded-footer/component.ts b/app/preprints/-components/branded-footer/component.ts index e2119aa03eb..97f70031bcd 100644 --- a/app/preprints/-components/branded-footer/component.ts +++ b/app/preprints/-components/branded-footer/component.ts @@ -8,6 +8,6 @@ export default class BrandedFooter extends Component { footerLinks = this.args.footerLinks; get hasFooters(): boolean { - return this.footerLinks !== ''; + return this.footerLinks !== '' && this.footerLinks !== undefined; } } diff --git a/app/preprints/-components/branded-footer/template.hbs b/app/preprints/-components/branded-footer/template.hbs index ffee3b5b5a9..b431f780d88 100644 --- a/app/preprints/-components/branded-footer/template.hbs +++ b/app/preprints/-components/branded-footer/template.hbs @@ -1,5 +1,5 @@ {{#if this.hasFooters}} -
+
{{html-safe this.footerLinks}}
{{/if}} \ No newline at end of file diff --git a/tests/acceptance/preprints/branded-footer-test.ts b/tests/acceptance/preprints/branded-footer-test.ts new file mode 100644 index 00000000000..d5319026146 --- /dev/null +++ b/tests/acceptance/preprints/branded-footer-test.ts @@ -0,0 +1,45 @@ +import { render } from '@ember/test-helpers'; +import { hbs } from 'ember-cli-htmlbars'; +import { setupRenderingTest } from 'ember-qunit'; +import { module, test } from 'qunit'; + +module('Acceptance | preprints | branded-footer', hooks => { + setupRenderingTest(hooks); + + test('it inserts the footerLink when present', async function(assert) { + // Given no list is provided + // When the component is rendered + await render(hbs` + + + `); + + // Then the footer links are verified + assert.dom('[data-test-footer-links]').hasText('these are the footer links', 'The footer links are present'); + }); + + test('it does not insert the footerLink when undefined', async function(assert) { + // Given no list is provided + // When the component is rendered + await render(hbs``); + + // Then the footer links are verified + assert.dom('[data-test-footer-links]').doesNotExist('The footer links are not present'); + }); + + test('it does no insert the footerLink when it an empty string', async function(assert) { + // Given no list is provided + // When the component is rendered + await render(hbs` + + + `); + + // Then the footer links are verified + assert.dom('[data-test-footer-links]').doesNotExist('The footer links are not present'); + }); +}); From 6dc867638edaaf478abeb416bcdf35f6044358fc Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Tue, 15 Aug 2023 11:57:27 -0600 Subject: [PATCH 051/170] Pruned an unused providerModel from the branded-header --- .../components/branded-header/component.ts | 20 ++++--------------- .../components/branded-header/template.hbs | 5 ----- 2 files changed, 4 insertions(+), 21 deletions(-) diff --git a/lib/osf-components/addon/components/branded-header/component.ts b/lib/osf-components/addon/components/branded-header/component.ts index 82d03c32182..ef88ea8663d 100644 --- a/lib/osf-components/addon/components/branded-header/component.ts +++ b/lib/osf-components/addon/components/branded-header/component.ts @@ -4,7 +4,6 @@ import { inject as service } from '@ember/service'; import Intl from 'ember-intl/services/intl'; import Media from 'ember-responsive'; -import ProviderModel from 'ember-osf-web/models/provider'; import Analytics from 'ember-osf-web/services/analytics'; import { tracked } from '@glimmer/tracking'; import { requiredAction } from 'ember-osf-web/decorators/component'; @@ -23,7 +22,6 @@ export default class BrandedHeader extends Component { @requiredAction onSearch!: (value: string) => void; @tracked showingHelp = false; - providerModel?: ProviderModel; notBranded = true; localClassNameBindings = ['notBranded:Header']; today = new Date(); @@ -43,20 +41,14 @@ export default class BrandedHeader extends Component { : this.intl.t(`${this.args.translationParent}.header.search_placeholder`); } - @computed('providerModel.name', 'args.translationParent') + @computed('args.translationParent') get headerAriaLabel() { - return this.providerModel ? - this.providerModel.name.concat(' ', this.intl.t(`${this.args.translationParent}.header.registrations`)) - : this.intl.t(`${this.args.translationParent}.header.osf_registrations`); + return this.intl.t(`${this.args.translationParent}.header.osf_registrations`); } @action onSubmit() { - if (this.providerModel) { - this.analytics.click('link', `Discover - Search ${this.providerModel.name}`, this.value); - } else { - this.analytics.click('link', 'Discover - Search', this.value); - } + this.analytics.click('link', 'Discover - Search', this.value); this.args.onSearch(this.value); } @@ -68,11 +60,7 @@ export default class BrandedHeader extends Component { @action keyPress(event: KeyboardEvent) { if (event.keyCode !== 13) { - if (this.providerModel) { - this.analytics.track('input', 'onkeyup', `Discover - Search ${this.providerModel.name}`, this.value); - } else { - this.analytics.track('input', 'onkeyup', 'Discover - Search', this.value); - } + this.analytics.track('input', 'onkeyup', 'Discover - Search', this.value); } } } diff --git a/lib/osf-components/addon/components/branded-header/template.hbs b/lib/osf-components/addon/components/branded-header/template.hbs index 64a7fba6e7c..395d29e4157 100644 --- a/lib/osf-components/addon/components/branded-header/template.hbs +++ b/lib/osf-components/addon/components/branded-header/template.hbs @@ -49,11 +49,6 @@ {{/if}}
- {{#if @providerModel.htmlSafeDescription}} -
- {{@providerModel.htmlSafeDescription}} -
- {{/if}}
{{yield (hash row=(element ''))}} From 49540488fd1fb4d3564970b8f094c6c06ccfc647 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Fri, 18 Aug 2023 11:05:48 -0600 Subject: [PATCH 052/170] Added more tests --- app/preprints/index/template.hbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/preprints/index/template.hbs b/app/preprints/index/template.hbs index 57c90a2a5a3..a453800fc2b 100644 --- a/app/preprints/index/template.hbs +++ b/app/preprints/index/template.hbs @@ -12,7 +12,7 @@ as |branded-header| > {{#branded-header.lead}} -
+
{{html-safe this.theme.provider.description}}
From 0b93b4030ca18f452e87a1cec6d3432ee6854e69 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Fri, 18 Aug 2023 11:56:49 -0600 Subject: [PATCH 053/170] Added a test file --- tests/acceptance/preprints/index-test.ts | 37 ++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tests/acceptance/preprints/index-test.ts diff --git a/tests/acceptance/preprints/index-test.ts b/tests/acceptance/preprints/index-test.ts new file mode 100644 index 00000000000..c686d31a3f8 --- /dev/null +++ b/tests/acceptance/preprints/index-test.ts @@ -0,0 +1,37 @@ +import { currentRouteName } from '@ember/test-helpers'; +import { ModelInstance } from 'ember-cli-mirage'; +import { setupMirage } from 'ember-cli-mirage/test-support'; +import { TestContext } from 'ember-test-helpers'; +import { module, test } from 'qunit'; + +import { setupOSFApplicationTest, visit } from 'ember-osf-web/tests/helpers'; +import PreprintProviderModel from 'ember-osf-web/models/preprint-provider'; + +interface PreprintIndexTestContext extends TestContext { + provider: ModelInstance; +} + +module('Acceptance | preprints | index', hooks => { + setupOSFApplicationTest(hooks); + setupMirage(hooks); + + hooks.beforeEach(async function(this: PreprintIndexTestContext) { + server.loadFixtures('preprint-providers'); + const provider = server.schema.preprintProviders.find('osf') as ModelInstance; + const brand = server.create('brand'); + provider.update({ + brand, + description: 'This is the description for OSF', + }); + this.provider = provider; + }); + + test('OSF - Provider', async function(this: PreprintIndexTestContext, assert) { + await visit('/preprints'); + assert.equal(currentRouteName(), 'preprints.index', 'Current route is preprints'); + + const pageTitle = document.getElementsByTagName('title')[0].innerText; + assert.equal(pageTitle, 'OSF Preprints', 'Page title is correct'); + assert.dom('[data-test-provider-description]').exists('This is the description for OSF'); + }); +}); From 80aedb6856dd7f5e3720a7a87ced3ea4cb360697 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Fri, 18 Aug 2023 12:23:00 -0600 Subject: [PATCH 054/170] Added the initial template and attempt to have it compiled --- app/preprints/detail/template.hbs | 312 ++++++++++++++++++++++++++++++ 1 file changed, 312 insertions(+) create mode 100644 app/preprints/detail/template.hbs diff --git a/app/preprints/detail/template.hbs b/app/preprints/detail/template.hbs new file mode 100644 index 00000000000..184442fb860 --- /dev/null +++ b/app/preprints/detail/template.hbs @@ -0,0 +1,312 @@ +{{title this.model.title}} + +
+ {{!HEADER ROW}} +
+ {{!CONTAINER DIV}} +
+
+
+

{{this.model.title}}

+ {{#unless this.isWithdrawn}} +
+ {{#if (and this.userIsContrib (not this.isPendingWithdrawal))}} + + {{t @editButtonLabel documentType=this.model.provider.documentType}} + + {{/if}} +
+
+ {{/unless}} +
+
+
+
+
+
+ {{t 'content.header.authors_label'}} +
+
    + {{#if this.authors}} + {{#each this.authors as |author| ~}} + {{#if author.bibliographic}} + {{#if author.unregisteredContributor}} + {{claim-user author=author preprintId=this.model.id isLoggedIn=(if this.currentUser.currentUserId true false) currentUser=this.currentUser.user.content}} + {{else if (user-errors author)}} +
  • {{disabled-user-name author}}
  • + {{else}} +
  • {{author.users.fullName}}
  • + {{/if}} + {{/if}} + {{~/each}} + {{else}} +
    +
    +
    +
    +
    + {{/if}} +
+
+
+
+ {{author-assertions preprint=this.model}} +
+ {{!END CONTAINER DIV}} +
+ {{!END HEADER ROW}} + {{#if (or this.showStatusBanner this.isWithdrawn)}} + {{preprint-status-banner submission=this.model isWithdrawn=this.isWithdrawn}} + {{/if}} + {{!CONTAINER DIV}} +
+ {{#if this.isWithdrawn}} + {{! TOMBSTONE PAGE}} +
+
+ {{#if this.model.withdrawalJustification}} +
+

{{t 'global.reason_for_withdrawal'}}

+

+ {{this.model.withdrawalJustification}} +

+
+ {{/if}} + +
+

{{t 'global.abstract'}}

+

+ {{~if this.useShortenedDescription this.description this.model.description~}} +

+ +
+ +
+

{{t 'content.preprint_doi' documentType=this.model.provider.documentType}}

+ {{#if this.model.preprintDoiUrl}} +

{{extract-doi this.model.preprintDoiUrl}}

+ {{/if}} +
+ + {{#if this.model.license.name}} +
+

{{t 'global.license'}}

+ {{this.model.license.name}} + + {{#if this.showLicenseText }} + {{fa-icon 'caret-down' click=(action 'toggleLicenseText')}} + {{else}} + {{fa-icon 'caret-right' click=(action 'toggleLicenseText')}} + {{/if}} + + {{#if this.showLicenseText}} +
{{this.fullLicenseText}}
+ {{/if}} +
+ {{/if}} +
+

{{t 'content.disciplines'}}

+ {{#each this.disciplineReduced as |subject|}} + {{subject.text}} + {{/each}} +
+ +
+

{{t 'global.tags'}}

+ {{#if this.hasTag}} + {{#each this.model.tags as |tag|}} + {{fix-special-char tag}} + {{/each}} + {{else}} + {{t 'global.none'}} + {{/if}} +
+
+
+ {{! END TOMBSTONE PAGE}} + {{else}} + {{!CONTENT ROW}} +
+ {{!LEFT COL DIV}} +
+ {{#if this.model.isPreprintOrphan}} + + {{else}} + {{#unless this.model.public}} + + {{/unless}} + {{preprint-file-renderer provider=this.model.provider preprint=this.model primaryFile=this.primaryFile}} +
+ {{t this.dateLabel}}: {{moment-format this.relevantDate 'MMMM DD, YYYY'}} + {{#if this.isWithdrawn}} + | {{t 'content.header.withdrawn_on'}}: {{moment-format this.model.dateWithdrawn 'MMMM DD, YYYY'}} + {{else}} + | {{t 'content.header.last_edited'}}: {{moment-format this.model.dateModified 'MMMM DD, YYYY'}} + {{/if}} +
+ + {{/if}} +
+ {{!END LEFT COL DIV}} + {{#unless this.fullScreenMFR}} + {{!RIGHT SIDE COL}} +
+ {{!SHARE ROW}} + +
+
+ {{#if this.isPlauditReady}} + {{! plaudit-widget }} + {{/if}} +
+ +
+ + {{#if (and this.isChronosProvider this.features.enableChronos)}} +
+ {{#chronos-widget preprint=this.model isContributor=this.userIsContrib isAdmin=this.isAdmin as | preprint submissions isAllowSubmissions isContributor | }} + {{chronos-submission-status-list submissions=submissions isContributor=isContributor}} + {{#if isAllowSubmissions }} +
+ {{chronos-submission-panel preprint=preprint publisherFilterKeyword='American Psychological Association'}} +
+ {{/if}} + {{/chronos-widget}} +
+ {{/if}} +
+

{{t 'global.abstract'}}

+

+ {{~if this.useShortenedDescription this.description this.model.description~}} +

+ +
+ + {{#if this.node}} +
+

{{t 'content.supplemental_materials.title'}}

+ + {{this.supplementalMaterialDisplayLink}} + + +
+ {{/if}} + +
+

{{t 'content.preprint_doi' documentType=this.model.provider.documentType}}

+ {{#if this.model.preprintDoiUrl}} + {{#if this.model.preprintDoiCreated}} + {{extract-doi this.model.preprintDoiUrl}} + {{else}} +

{{extract-doi this.model.preprintDoiUrl}}

+

{{t 'content.preprint_pending_doi_minted'}}

+ {{/if}} + {{else}} + {{#if (not this.model.public)}} + {{t 'content.preprint_pending_doi' documentType=this.model.provider.documentType }} + {{else if (and this.model.provider.reviewsWorkflow (not this.model.isPublished))}} + {{t 'content.preprint_pending_doi_moderation'}} + {{/if}} + {{/if}} +
+ + {{#if this.model.articleDoiUrl}} +
+

{{t 'content.article_doi'}}

+ {{extract-doi this.model.articleDoiUrl}} +
+ {{/if}} + + {{#if this.model.license.name}} +
+

{{t 'global.license'}}

+ {{this.model.license.name}} + + {{#if this.showLicenseText }} + {{fa-icon 'caret-down' click=(action 'toggleLicenseText')}} + {{else}} + {{fa-icon 'caret-right' click=(action 'toggleLicenseText')}} + {{/if}} + + {{#if this.showLicenseText}} +
{{this.fullLicenseText}}
+ {{/if}} +
+ {{/if}} + +
+

{{t 'content.disciplines'}}

+ {{#each this.disciplineReduced as |subject|}} + {{subject.text}} + {{/each}} +
+
+

{{t 'global.tags'}}

+ {{#if this.hasTag}} + {{#each this.model.tags as |tag|}} + {{fix-special-char tag}} + {{/each}} + {{else}} + {{t 'global.none'}} + {{/if}} +
+ + {{#if this.model.originalPublicationDate}} +
+

{{t 'content.original_publication_date'}}

+

+ {{moment-format this.model.originalPublicationDate 'YYYY-MM-DD'}} +

+
+ {{/if}} + +
+

{{t 'content.citations'}}

+ {{citation-widget node=this.model}} +
+
+ {{!END RIGHT SIDE COL}} + {{/unless}} +
+ {{!END CONTENT ROW}} + {{/if}} +
+ {{!END DIV CONTAINER}} +
From f024470bacabb47993447c1fdf1d628bb0af942a Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Fri, 18 Aug 2023 13:03:28 -0600 Subject: [PATCH 055/170] Added the controller and the styles -- first pass --- app/preprints/detail/controller.ts | 236 +++++++++++++++++++++++++++++ app/preprints/detail/styles.scss | 67 ++++++++ app/preprints/detail/template.hbs | 10 +- 3 files changed, 308 insertions(+), 5 deletions(-) create mode 100644 app/preprints/detail/controller.ts create mode 100644 app/preprints/detail/styles.scss diff --git a/app/preprints/detail/controller.ts b/app/preprints/detail/controller.ts new file mode 100644 index 00000000000..8917ff80c61 --- /dev/null +++ b/app/preprints/detail/controller.ts @@ -0,0 +1,236 @@ +import Controller from '@ember/controller'; +// import { A } from '@ember/array'; +import { computed } from '@ember/object'; +import { inject as service } from '@ember/service'; +// import DS from 'ember-data'; +// import loadAll from 'ember-osf/utils/load-relationship'; +import config from 'ember-get-config'; +// import permissions from 'ember-osf/const/permissions'; +import Theme from 'ember-osf-web/services/theme'; +import CurrentUserService from 'ember-osf-web/services/current-user'; +import Features from 'ember-feature-flags'; +import ContributorModel from 'ember-osf-web/models/contributor'; + + +// const { PromiseArray } = DS; + +/** + * Takes an object with query parameter name as the key and value, + * or [value, maxLength] as the values. + * + * @method queryStringify + * @param queryParams {!object} + * @param queryParams.key {!array|!string} + * @param queryParams.key[0] {!string} + * @param queryParams.key[1] {int} + * @return {string} + */ + +const DATE_LABEL = { + created: 'content.date_label.created_on', + submitted: 'content.date_label.submitted_on', +}; +const PRE_MODERATION = 'pre-moderation'; +const REJECTED = 'rejected'; +const INITIAL = 'initial'; + +/** + * @module ember-preprints + * @submodule controllers + */ + +/** + * @class Content Controller + */ +export default class PrePrintsDetailController extends Controller { + @service theme!: Theme; + @service currentUser!: CurrentUserService; + @service features!: Features; + + queryParams_Altered = { + chosenFile: 'file', + }; + + fullScreenMFR = false; + expandedAuthors = true; + showLicenseText = false; + primaryFile = null; + showModalClaimUser = false; + isPendingWithdrawal = false; + isWithdrawn = null; + isPlauditReady = false; + expandedAbstract = navigator.userAgent.includes('Prerender'); + + + get hyperlink(): string { + return window.location.href; + } + + @computed('model') + fileDownloadURL() { + return fileDownloadPath(this.model.primaryFile, this.model); + } + + @computed('model') + facebookAppId() { + return this.model.provider.facebookAppId ? this.model.provider.facebookAppId : config.FB_APP_ID; + } + + @computed('node.links.html') + supplementalMaterialDisplayLink(): string { + return this.isChronosProvider.links.html.replace(/^https?:\/\//i, ''); + } + + @computed('model.provider.reviewsWorkflow') + dateLabel(): string { + return this.model.provider.reviewsWorkflow === PRE_MODERATION ? + DATE_LABEL.submitted : + DATE_LABEL.created; + } + + @computed('model.provider.reviewsWorkflow') + editButtonLabel(): string { + const editPreprint = 'content.project_button.edit_preprint'; + const editResubmitPreprint = 'content.project_button.edit_resubmit_preprint'; + return this.model.provider.reviewsWorkflow === PRE_MODERATION + && this.model.provider.reviewsWorkflow.reviewsState === REJECTED && this.isAdmin() + ? editResubmitPreprint : editPreprint; + } + + @computed('model.currentUserPermissions') + isAdmin(): boolean{ + // True if the current user has admin permissions for the node that contains the preprint + return (this.model.currentUserPermissions || []).includes(permissions.ADMIN); + } + + @computed('model.contributors', 'isAdmin', 'currentUser.currentUserId') + userIsContrib(): boolean { + if (this.isAdmin()) { + return true; + } else if (this.model.contributors.length) { + const authorIds = this.model.contributors.forEach((author: ContributorModel) => author.id); + return this.currentUser.currentUserId ? authorIds.includes(this.currentUser.currentUserId) : false; + } + return false; + } + + @computed('model.{public,provider.reviewsWorkflow,reviewsState}', 'userIsContrib', 'isPendingWithdrawal') + showStatusBanner(): boolean { + return ( + this.model.provider.reviewsWorkflow + && this.model.public + && this.userIsContrib() + && this.model.reviewsState !== INITIAL + ) || this.isPendingWithdrawal; + } + + /* + disciplineReduced: computed('model.subjects', function() { + // Preprint disciplines are displayed in collapsed form on content page + return this.get('model.subjects').reduce((acc, val) => acc.concat(val), []).uniqBy('id'); + }), + /* eslint-disable ember/named-functions-in-promises * / + authors: computed('model', function() { + // Cannot be called until node has loaded! + const model = this.get('model'); + const contributors = A(); + return PromiseArray.create({ + promise: loadAll(model, 'contributors', contributors) + .then(() => contributors), + }); + }), + /* eslint-enable ember/named-functions-in-promises * / + fullLicenseText: computed('model.{license.text,licenseRecord}', function() { + const text = this.get('model.license.text') || ''; + // eslint-disable-line camelcase + const { year = '', copyright_holders = [] } = this.get('model.licenseRecord'); + return text + .replace(/({{year}})/g, year) + .replace(/({{copyrightHolders}})/g, copyright_holders.join(', ')); + }), + + hasShortenedDescription: computed('model.description', function() { + const description = this.get('model.description'); + + return description && description.length > 350; + }), + + useShortenedDescription: computed('expandedAbstract', 'hasShortenedDescription', function() { + return this.get('hasShortenedDescription') && !this.get('expandedAbstract'); + }), + + description: computed('model.description', function() { + // Get a shortened version of the abstract, but doesn't cut in the middle of word by going + // to the last space. + return this.get('model.description') + .slice(0, 350) + .replace(/\s+\S*$/, ''); + }), + + emailHref: computed('model', function() { + const titleEncoded = encodeURIComponent(this.get('model.title')); + const hrefEncoded = encodeURIComponent(window.location.href); + return `mailto:?subject=${titleEncoded}&body=${hrefEncoded}`; + }), + + isChronosProvider: computed('model.provider.id', function() { + const { chronosProviders } = config; + return Array.isArray(chronosProviders) && chronosProviders.includes(this.get('model.provider.id')); + }), + + actions: { + toggleLicenseText() { + const licenseState = this.toggleProperty('showLicenseText') ? 'Expand' : 'Contract'; + this.get('metrics') + .trackEvent({ + category: 'button', + action: 'click', + label: `Content - License ${licenseState}`, + }); + }, + expandMFR() { + // State of fullScreenMFR before the transition (what the user perceives as the action) + const beforeState = this.toggleProperty('fullScreenMFR') ? 'Expand' : 'Contract'; + + this.get('metrics') + .trackEvent({ + category: 'button', + action: 'click', + label: `Content - MFR ${beforeState}`, + }); + }, + expandAbstract() { + this.toggleProperty('expandedAbstract'); + }, + shareLink(href, category, action, label, extra) { + const metrics = this.get('metrics'); + + // TODO submit PR to ember-metrics for a trackSocial function for Google Analytics. + // For now, we'll use trackEvent. + metrics.trackEvent({ + category, + action, + label, + extra, + }); + + if (label.includes('email')) { return; } + + window.open(href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,width=600,height=400'); + return false; + }, + // Sends Event to GA. Previously sent a second event to Keen to track non-contributor + // downloads, but that functionality has been removed. Stub left in place in case we want + // to double-log later. + trackNonContributors(category, label, url) { + this.send('click', category, label, url); + }, + }, + + _returnContributors(contributors) { + return contributors; + }, + + metricsStartDate = this.config.OSF.metricsStartDate; + */ +} diff --git a/app/preprints/detail/styles.scss b/app/preprints/detail/styles.scss new file mode 100644 index 00000000000..7ff72b38fa3 --- /dev/null +++ b/app/preprints/detail/styles.scss @@ -0,0 +1,67 @@ +// stylelint-disable max-nesting-depth, selector-max-compound-selectors + +.bottom-margin { + margin-bottom: 50px; +} + +.pointer { + cursor: pointer; +} + +.popover { + max-width: 100%; +} + +.popover-button { + margin-left: 7px; + height: 34px; +} + +.popover-content { + background: #000; + overflow: auto; + + .form-group { + margin-bottom: 0; + width: 150px; + } +} + +.flexbox { + justify-content: flex-end; + display: flex; + align-items: center; +} + +.social-icons { + padding: 15px; +} + +.plaudit-widget { + flex: auto; + padding-right: 33px; +} + +.preprint-title-container { + display: flex; + align-items: flex-start; + + .preprintTitle { + flex-basis: 80%; + } + + .edit-preprint-button { + margin-top: 25px; + } +} + +@media (max-width: 768px) { + .preprint-title-container { + flex-direction: column; + align-items: center; + } + + .edit-preprint-button { + margin-top: 0; + } +} diff --git a/app/preprints/detail/template.hbs b/app/preprints/detail/template.hbs index 184442fb860..24709953e2d 100644 --- a/app/preprints/detail/template.hbs +++ b/app/preprints/detail/template.hbs @@ -147,7 +147,7 @@ {{/unless}} {{preprint-file-renderer provider=this.model.provider preprint=this.model primaryFile=this.primaryFile}}
- {{t this.dateLabel}}: {{moment-format this.relevantDate 'MMMM DD, YYYY'}} + {{t this.dateLabel}}: {{moment-format this.model.dateCreated 'MMMM DD, YYYY'}} {{#if this.isWithdrawn}} | {{t 'content.header.withdrawn_on'}}: {{moment-format this.model.dateWithdrawn 'MMMM DD, YYYY'}} {{else}} @@ -188,11 +188,11 @@
@@ -279,7 +279,7 @@

{{t 'global.tags'}}

- {{#if this.hasTag}} + {{#if this.model.tags.length}} {{#each this.model.tags as |tag|}} {{fix-special-char tag}} {{/each}} From 9c46c9cc632a64c3893375d914b314406ac0fa0e Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Mon, 21 Aug 2023 10:56:58 -0600 Subject: [PATCH 056/170] Added a router and continued to clean-up the controller --- app/preprints/detail/controller.ts | 82 +++++++++--------- app/preprints/detail/route.ts | 134 +++++++++++++++++++++++++++++ app/router.ts | 1 + 3 files changed, 174 insertions(+), 43 deletions(-) create mode 100644 app/preprints/detail/route.ts diff --git a/app/preprints/detail/controller.ts b/app/preprints/detail/controller.ts index 8917ff80c61..bf0a50d0cd5 100644 --- a/app/preprints/detail/controller.ts +++ b/app/preprints/detail/controller.ts @@ -10,6 +10,7 @@ import Theme from 'ember-osf-web/services/theme'; import CurrentUserService from 'ember-osf-web/services/current-user'; import Features from 'ember-feature-flags'; import ContributorModel from 'ember-osf-web/models/contributor'; +import SubjectModel from 'ember-osf-web/models/subject'; // const { PromiseArray } = DS; @@ -97,10 +98,10 @@ export default class PrePrintsDetailController extends Controller { ? editResubmitPreprint : editPreprint; } - @computed('model.currentUserPermissions') + @computed('model.{currentUserPermissions,permissions}') isAdmin(): boolean{ // True if the current user has admin permissions for the node that contains the preprint - return (this.model.currentUserPermissions || []).includes(permissions.ADMIN); + return (this.model.currentUserPermissions || []).includes(this.model.permissions.ADMIN); } @computed('model.contributors', 'isAdmin', 'currentUser.currentUserId') @@ -124,59 +125,54 @@ export default class PrePrintsDetailController extends Controller { ) || this.isPendingWithdrawal; } - /* - disciplineReduced: computed('model.subjects', function() { + @computed('model.subjects') + disciplineReduced(): [] { // Preprint disciplines are displayed in collapsed form on content page - return this.get('model.subjects').reduce((acc, val) => acc.concat(val), []).uniqBy('id'); - }), - /* eslint-disable ember/named-functions-in-promises * / - authors: computed('model', function() { - // Cannot be called until node has loaded! - const model = this.get('model'); - const contributors = A(); - return PromiseArray.create({ - promise: loadAll(model, 'contributors', contributors) - .then(() => contributors), - }); - }), - /* eslint-enable ember/named-functions-in-promises * / - fullLicenseText: computed('model.{license.text,licenseRecord}', function() { - const text = this.get('model.license.text') || ''; - // eslint-disable-line camelcase - const { year = '', copyright_holders = [] } = this.get('model.licenseRecord'); - return text - .replace(/({{year}})/g, year) - .replace(/({{copyrightHolders}})/g, copyright_holders.join(', ')); - }), - - hasShortenedDescription: computed('model.description', function() { - const description = this.get('model.description'); - - return description && description.length > 350; - }), + return this.model.subjects.reduce((acc: SubjectModel[], val: SubjectModel) => acc.concat(val), []).uniqBy('id'); + } + + authors(): ContributorModel[] { + return this.model.contributors; + } + + fullLicenseText(): string { + return this.model.licenseRecord; + } + + hasShortenedDescription(): String { + return this.model.description && this.model.description.length > 350; + } + /* useShortenedDescription: computed('expandedAbstract', 'hasShortenedDescription', function() { return this.get('hasShortenedDescription') && !this.get('expandedAbstract'); - }), + }) + */ - description: computed('model.description', function() { - // Get a shortened version of the abstract, but doesn't cut in the middle of word by going - // to the last space. - return this.get('model.description') + /** + * description + * + * @description Get a shortened version of the abstract, but doesn't cut in the middle of word + * by going to the last space. + * @returns string + */ + description(): string { + return this.model.description .slice(0, 350) .replace(/\s+\S*$/, ''); - }), + } - emailHref: computed('model', function() { - const titleEncoded = encodeURIComponent(this.get('model.title')); + emailHref(): string { + const titleEncoded = encodeURIComponent(this.model.title); const hrefEncoded = encodeURIComponent(window.location.href); return `mailto:?subject=${titleEncoded}&body=${hrefEncoded}`; - }), + } - isChronosProvider: computed('model.provider.id', function() { + isChronosProvider(): boolean { const { chronosProviders } = config; - return Array.isArray(chronosProviders) && chronosProviders.includes(this.get('model.provider.id')); - }), + return Array.isArray(chronosProviders) && chronosProviders.includes(this.model.provider.id); + } + /* actions: { toggleLicenseText() { diff --git a/app/preprints/detail/route.ts b/app/preprints/detail/route.ts new file mode 100644 index 00000000000..812ef0113fb --- /dev/null +++ b/app/preprints/detail/route.ts @@ -0,0 +1,134 @@ +import Store from '@ember-data/store'; +import Route from '@ember/routing/route'; +import RouterService from '@ember/routing/router-service'; +import { inject as service } from '@ember/service'; +import CurrentUserService from 'ember-osf-web/services/current-user'; +import Theme from 'ember-osf-web/services/theme'; +import captureException from 'ember-osf-web/utils/capture-exception'; + +// Error handling for API +/* +const handlers = new Map([ + // format: ['Message detail', 'page'] + ['Authentication credentials were not provided.', 'page-not-found'], // 401 + ['You do not have permission to perform this action.', 'page-not-found'], // 403 + ['Not found.', 'page-not-found'], // 404 + ['The requested node is no longer available.', 'resource-deleted'], // 410 +]); +*/ + +/** + * @module ember-preprints + * @submodule routes + */ + +/** + * @class Content Route Handler + */ + + +/** + * Loads all disciplines and preprint providers to the index page + * @class Index Route Handler + */ +export default class PreprintsDetail extends Route { + @service store!: Store; + @service theme!: Theme; + @service router!: RouterService; + @service currentUser!: CurrentUserService; + + async model(params: { guid : string }) { + try { + const guid = params.guid; + + const preprint = await this.store.findRecord('preprint', guid); + + + // const preprint = await this.store.findRecord('preprint', guid, {include: 'brand'}); + + const contributors = await preprint?.queryHasMany('contributors'); + + const license = await preprint?.queryHasMany('license'); + + /* + const blank = await preprint?.queryHasMany('blank', { + page: { + size: 20, + }, + }); + */ + + /* + const brandedProviders = this.theme.id === 'osf' ? await this.store + .findAll('preprint-provider', { reload: true }) + .then(result => result + .filter(item => item.id !== 'osf')) : []; + */ + + return { + preprint, + contributors, + license, + }; + + } catch (error) { + captureException(error); + this.router.transitionTo('not-found', 'preprints'); + return null; + } + } +} + +/* +export default Route.extend({ + currentUser: service(), + features: service(), + model(params) { + const opts = { + method: 'GET', + url: `${config.OSF.apiUrl}/${config.OSF.apiNamespace}/`, + dataType: 'json', + contentType: 'application/json', + xhrFields: { + withCredentials: true, + }, + }; + + this.get('currentUser').authenticatedAJAX(opts).then((res) => { + if (Array.isArray(res.meta.active_flags)) { + this.get('features').setup(res.meta.active_flags.reduce(function(acc, flag) { + acc[flag] = true; + return acc; + }, {})); + } + }); + + return this.store.findRecord( + 'preprint', params.preprint_id, + { + adapterOptions: { + query: { + 'metrics[views]': 'total', + 'metrics[downloads]': 'total', + }, + }, + }, + ); + }, + actions: { + error(error) { + // Handle API Errors + if (error && !(error instanceof DS.AbortError) + && error.errors && isArray(error.errors)) { + // If the error is not a AbortError (no connection), we handle it here. + const { detail } = error.errors[0]; + const page = handlers.get(detail) || 'page-not-found'; + return this.intermediateTransitionTo(page); + } else { + // Otherwise, we bubble it to the error handler in our parent route. + return true; + } + }, + }, +}); +*/ diff --git a/app/router.ts b/app/router.ts index 53313279a2d..4003361dbb9 100644 --- a/app/router.ts +++ b/app/router.ts @@ -30,6 +30,7 @@ Router.map(function() { this.route('index', { path: '/' }); this.route('index', { path: '/:provider_id' }); this.route('discover', { path: '/:provider_id/discover' }); + this.route('detail', { path: '--preprint/:guid' }); }); this.route('register'); From 1733363cdf83c4da4118d768a5938b53dafa1c90 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Mon, 21 Aug 2023 11:02:16 -0600 Subject: [PATCH 057/170] Removed chronos --- app/preprints/detail/controller.ts | 9 --------- app/preprints/detail/template.hbs | 13 ------------- 2 files changed, 22 deletions(-) diff --git a/app/preprints/detail/controller.ts b/app/preprints/detail/controller.ts index bf0a50d0cd5..7b9a9914382 100644 --- a/app/preprints/detail/controller.ts +++ b/app/preprints/detail/controller.ts @@ -77,11 +77,6 @@ export default class PrePrintsDetailController extends Controller { return this.model.provider.facebookAppId ? this.model.provider.facebookAppId : config.FB_APP_ID; } - @computed('node.links.html') - supplementalMaterialDisplayLink(): string { - return this.isChronosProvider.links.html.replace(/^https?:\/\//i, ''); - } - @computed('model.provider.reviewsWorkflow') dateLabel(): string { return this.model.provider.reviewsWorkflow === PRE_MODERATION ? @@ -168,10 +163,6 @@ export default class PrePrintsDetailController extends Controller { return `mailto:?subject=${titleEncoded}&body=${hrefEncoded}`; } - isChronosProvider(): boolean { - const { chronosProviders } = config; - return Array.isArray(chronosProviders) && chronosProviders.includes(this.model.provider.id); - } /* actions: { diff --git a/app/preprints/detail/template.hbs b/app/preprints/detail/template.hbs index 24709953e2d..d33463de787 100644 --- a/app/preprints/detail/template.hbs +++ b/app/preprints/detail/template.hbs @@ -197,18 +197,6 @@
- {{#if (and this.isChronosProvider this.features.enableChronos)}} -
- {{#chronos-widget preprint=this.model isContributor=this.userIsContrib isAdmin=this.isAdmin as | preprint submissions isAllowSubmissions isContributor | }} - {{chronos-submission-status-list submissions=submissions isContributor=isContributor}} - {{#if isAllowSubmissions }} -
- {{chronos-submission-panel preprint=preprint publisherFilterKeyword='American Psychological Association'}} -
- {{/if}} - {{/chronos-widget}} -
- {{/if}}

{{t 'global.abstract'}}

@@ -223,7 +211,6 @@

{{t 'content.supplemental_materials.title'}}

- {{this.supplementalMaterialDisplayLink}}
From 6c1383a649afcd676a04c53c1bdd03df6e0c71ad Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Mon, 21 Aug 2023 11:16:26 -0600 Subject: [PATCH 058/170] Fixed an the computed and actions --- app/preprints/detail/controller.ts | 89 ++++++++++++------------------ 1 file changed, 35 insertions(+), 54 deletions(-) diff --git a/app/preprints/detail/controller.ts b/app/preprints/detail/controller.ts index 7b9a9914382..c45c8890cdc 100644 --- a/app/preprints/detail/controller.ts +++ b/app/preprints/detail/controller.ts @@ -1,6 +1,6 @@ import Controller from '@ember/controller'; // import { A } from '@ember/array'; -import { computed } from '@ember/object'; +import { action, computed } from '@ember/object'; import { inject as service } from '@ember/service'; // import DS from 'ember-data'; // import loadAll from 'ember-osf/utils/load-relationship'; @@ -48,6 +48,8 @@ export default class PrePrintsDetailController extends Controller { @service currentUser!: CurrentUserService; @service features!: Features; + // metricsStartDate = config.OSF.metricsStartDate; + queryParams_Altered = { chosenFile: 'file', }; @@ -138,11 +140,9 @@ export default class PrePrintsDetailController extends Controller { return this.model.description && this.model.description.length > 350; } - /* - useShortenedDescription: computed('expandedAbstract', 'hasShortenedDescription', function() { - return this.get('hasShortenedDescription') && !this.get('expandedAbstract'); - }) - */ + useShortenedDescription(): boolean { + return this.hasShortenedDescription() && !this.expandedAbstract; + } /** * description @@ -163,61 +163,42 @@ export default class PrePrintsDetailController extends Controller { return `mailto:?subject=${titleEncoded}&body=${hrefEncoded}`; } - /* - actions: { - toggleLicenseText() { - const licenseState = this.toggleProperty('showLicenseText') ? 'Expand' : 'Contract'; - this.get('metrics') + @action + toggleLicenseText(): void { + this.showLicenseText = !this.showLicenseText; + /* + this.get('metrics') .trackEvent({ category: 'button', action: 'click', label: `Content - License ${licenseState}`, }); - }, - expandMFR() { - // State of fullScreenMFR before the transition (what the user perceives as the action) - const beforeState = this.toggleProperty('fullScreenMFR') ? 'Expand' : 'Contract'; + */ + } - this.get('metrics') - .trackEvent({ - category: 'button', - action: 'click', - label: `Content - MFR ${beforeState}`, - }); - }, - expandAbstract() { - this.toggleProperty('expandedAbstract'); - }, - shareLink(href, category, action, label, extra) { - const metrics = this.get('metrics'); - - // TODO submit PR to ember-metrics for a trackSocial function for Google Analytics. - // For now, we'll use trackEvent. - metrics.trackEvent({ - category, - action, - label, - extra, + @action + expandMFR() { + // State of fullScreenMFR before the transition (what the user perceives as the action) + this.fullScreenMFR = !this.fullScreenMFR; + + /* + this.get('metrics') + .trackEvent({ + category: 'button', + action: 'click', + label: `Content - MFR ${beforeState}`, }); + */ + } - if (label.includes('email')) { return; } - - window.open(href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,width=600,height=400'); - return false; - }, - // Sends Event to GA. Previously sent a second event to Keen to track non-contributor - // downloads, but that functionality has been removed. Stub left in place in case we want - // to double-log later. - trackNonContributors(category, label, url) { - this.send('click', category, label, url); - }, - }, - - _returnContributors(contributors) { - return contributors; - }, - - metricsStartDate = this.config.OSF.metricsStartDate; - */ + @action + expandAbstract() { + this.expandedAbstract = !this.expandedAbstract; + } + + @action + trackNonContributors(category: string, label: string, url: string): void { + this.send('click', category, label, url); + } } From 8bfb63b736ad85f0722d95ba6e7cfaf7778c10e0 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Mon, 21 Aug 2023 11:18:27 -0600 Subject: [PATCH 059/170] Cleaned-up computed method --- app/preprints/detail/controller.ts | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/app/preprints/detail/controller.ts b/app/preprints/detail/controller.ts index c45c8890cdc..da72650fe4b 100644 --- a/app/preprints/detail/controller.ts +++ b/app/preprints/detail/controller.ts @@ -1,6 +1,6 @@ import Controller from '@ember/controller'; // import { A } from '@ember/array'; -import { action, computed } from '@ember/object'; +import { action } from '@ember/object'; import { inject as service } from '@ember/service'; // import DS from 'ember-data'; // import loadAll from 'ember-osf/utils/load-relationship'; @@ -69,24 +69,20 @@ export default class PrePrintsDetailController extends Controller { return window.location.href; } - @computed('model') fileDownloadURL() { - return fileDownloadPath(this.model.primaryFile, this.model); + // return fileDownloadPath(this.model.primaryFile, this.model); } - @computed('model') - facebookAppId() { + facebookAppId(): string { return this.model.provider.facebookAppId ? this.model.provider.facebookAppId : config.FB_APP_ID; } - @computed('model.provider.reviewsWorkflow') dateLabel(): string { return this.model.provider.reviewsWorkflow === PRE_MODERATION ? DATE_LABEL.submitted : DATE_LABEL.created; } - @computed('model.provider.reviewsWorkflow') editButtonLabel(): string { const editPreprint = 'content.project_button.edit_preprint'; const editResubmitPreprint = 'content.project_button.edit_resubmit_preprint'; @@ -95,13 +91,11 @@ export default class PrePrintsDetailController extends Controller { ? editResubmitPreprint : editPreprint; } - @computed('model.{currentUserPermissions,permissions}') - isAdmin(): boolean{ + isAdmin(): boolean { // True if the current user has admin permissions for the node that contains the preprint return (this.model.currentUserPermissions || []).includes(this.model.permissions.ADMIN); } - @computed('model.contributors', 'isAdmin', 'currentUser.currentUserId') userIsContrib(): boolean { if (this.isAdmin()) { return true; @@ -112,7 +106,6 @@ export default class PrePrintsDetailController extends Controller { return false; } - @computed('model.{public,provider.reviewsWorkflow,reviewsState}', 'userIsContrib', 'isPendingWithdrawal') showStatusBanner(): boolean { return ( this.model.provider.reviewsWorkflow @@ -122,7 +115,6 @@ export default class PrePrintsDetailController extends Controller { ) || this.isPendingWithdrawal; } - @computed('model.subjects') disciplineReduced(): [] { // Preprint disciplines are displayed in collapsed form on content page return this.model.subjects.reduce((acc: SubjectModel[], val: SubjectModel) => acc.concat(val), []).uniqBy('id'); From d71dfbcfaf5836d37272aa80fa220c2ab299c4a6 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Mon, 21 Aug 2023 11:32:39 -0600 Subject: [PATCH 060/170] Removed unused route code --- app/preprints/detail/route.ts | 7 ------- 1 file changed, 7 deletions(-) diff --git a/app/preprints/detail/route.ts b/app/preprints/detail/route.ts index 812ef0113fb..70f08f47f6f 100644 --- a/app/preprints/detail/route.ts +++ b/app/preprints/detail/route.ts @@ -58,13 +58,6 @@ export default class PreprintsDetail extends Route { }); */ - /* - const brandedProviders = this.theme.id === 'osf' ? await this.store - .findAll('preprint-provider', { reload: true }) - .then(result => result - .filter(item => item.id !== 'osf')) : []; - */ - return { preprint, contributors, From af42f6ac37c78b5fc3adef68ad19607f3cd6241d Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Tue, 22 Aug 2023 12:54:50 -0600 Subject: [PATCH 061/170] Added routing and a factory to mirage for preprints --- app/preprints/detail/controller.ts | 6 ------ app/router.ts | 5 +++-- mirage/config.ts | 5 +++++ mirage/factories/preprint.ts | 23 +++++++++++++++++++++++ mirage/fixtures/preprint-providers.ts | 6 +++--- mirage/scenarios/preprints.ts | 3 ++- 6 files changed, 36 insertions(+), 12 deletions(-) create mode 100644 mirage/factories/preprint.ts diff --git a/app/preprints/detail/controller.ts b/app/preprints/detail/controller.ts index da72650fe4b..21ec1e556e5 100644 --- a/app/preprints/detail/controller.ts +++ b/app/preprints/detail/controller.ts @@ -1,11 +1,7 @@ import Controller from '@ember/controller'; -// import { A } from '@ember/array'; import { action } from '@ember/object'; import { inject as service } from '@ember/service'; -// import DS from 'ember-data'; -// import loadAll from 'ember-osf/utils/load-relationship'; import config from 'ember-get-config'; -// import permissions from 'ember-osf/const/permissions'; import Theme from 'ember-osf-web/services/theme'; import CurrentUserService from 'ember-osf-web/services/current-user'; import Features from 'ember-feature-flags'; @@ -13,8 +9,6 @@ import ContributorModel from 'ember-osf-web/models/contributor'; import SubjectModel from 'ember-osf-web/models/subject'; -// const { PromiseArray } = DS; - /** * Takes an object with query parameter name as the key and value, * or [value, maxLength] as the values. diff --git a/app/router.ts b/app/router.ts index 4003361dbb9..89b210c9228 100644 --- a/app/router.ts +++ b/app/router.ts @@ -30,9 +30,11 @@ Router.map(function() { this.route('index', { path: '/' }); this.route('index', { path: '/:provider_id' }); this.route('discover', { path: '/:provider_id/discover' }); - this.route('detail', { path: '--preprint/:guid' }); + // this.route('detail', { path: '--preprint/:guid' }); }); + this.route('guid-preprint', { path: '--preprint/:guid' }); + this.route('register'); this.route('settings', function() { this.route('profile', function() { @@ -78,7 +80,6 @@ Router.map(function() { }); }); - this.route('guid-preprint', { path: '--preprint/:guid' }); this.route('guid-registration', { path: '--registration/:guid' }, function() { this.mount('analytics-page', { as: 'analytics' }); diff --git a/mirage/config.ts b/mirage/config.ts index c1a9b95f294..634ee2667f0 100644 --- a/mirage/config.ts +++ b/mirage/config.ts @@ -303,6 +303,11 @@ export default function(this: Server) { path: '/providers/preprints/:parentID/subjects/highlighted/', relatedModelName: 'subject', }); + osfNestedResource(this, 'preprint-provider', 'preprints', { + // only: ['index'], + path: '/providers/preprints/:parentID/preprints/', + relatedModelName: 'preprint', + }); osfResource(this, 'registration-provider', { path: '/providers/registrations' }); diff --git a/mirage/factories/preprint.ts b/mirage/factories/preprint.ts new file mode 100644 index 00000000000..479fd6cc046 --- /dev/null +++ b/mirage/factories/preprint.ts @@ -0,0 +1,23 @@ +import { Factory } from 'ember-cli-mirage'; +import faker from 'faker'; + +import PreprintModel from 'ember-osf-web/models/preprint'; + +import { guid} from './utils'; + +export default Factory.extend({ + id: guid('preprint'), + title: faker.lorem.sentence(), +}); + +declare module 'ember-cli-mirage/types/registries/model' { + export default interface MirageModelRegistry { + preprint: PreprintModel; + } // eslint-disable-line semi +} + +declare module 'ember-cli-mirage/types/registries/schema' { + export default interface MirageSchemaRegistry { + preprint: PreprintModel; + } // eslint-disable-line semi +} diff --git a/mirage/fixtures/preprint-providers.ts b/mirage/fixtures/preprint-providers.ts index f362043c8fe..2d03ae5c465 100644 --- a/mirage/fixtures/preprint-providers.ts +++ b/mirage/fixtures/preprint-providers.ts @@ -64,19 +64,19 @@ const preprintProviders: Array> = [ id: 'agrixiv', name: 'AgriXiv', preprintWord: 'preprint', - assets: randomAssets(), + assets: randomAssets(8), }, { id: 'biohackrxiv', name: 'BioHackrXiv', preprintWord: 'preprint', - assets: randomAssets(), + assets: randomAssets(9), }, { id: 'nutrixiv', name: 'NutriXiv', preprintWord: 'preprint', - assets: randomAssets(), + assets: randomAssets(10), }, ]; diff --git a/mirage/scenarios/preprints.ts b/mirage/scenarios/preprints.ts index 3c0aec202d1..0bf1b502cef 100644 --- a/mirage/scenarios/preprints.ts +++ b/mirage/scenarios/preprints.ts @@ -25,8 +25,9 @@ function buildOSF( const currentUserModerator = server.create('moderator', { id: currentUser.id, user: currentUser, provider: osf }, 'asAdmin'); - const preprints = server.createList('preprint', 4, { + const preprints = server.createList('preprint', 1, { provider: osf, + id: 'taco', }); const subjects = server.createList('subject', 7); From b92c931e58802833e93522a54bfdc6d37018471a Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Wed, 23 Aug 2023 11:25:47 -0600 Subject: [PATCH 062/170] Fixed the routing, mirage and prototyped the model is working --- app/preprints/detail/route.ts | 11 ++-- app/preprints/detail/template.hbs | 5 +- app/preprints/index/route.ts | 4 +- app/resolve-guid/route.ts | 2 +- app/router.ts | 2 +- mirage/config.ts | 1 + mirage/factories/preprint.ts | 6 ++- mirage/serializers/preprint.ts | 87 +++++++++++++++++++++++++++++++ 8 files changed, 108 insertions(+), 10 deletions(-) create mode 100644 mirage/serializers/preprint.ts diff --git a/app/preprints/detail/route.ts b/app/preprints/detail/route.ts index 70f08f47f6f..29080402b40 100644 --- a/app/preprints/detail/route.ts +++ b/app/preprints/detail/route.ts @@ -43,12 +43,15 @@ export default class PreprintsDetail extends Route { const preprint = await this.store.findRecord('preprint', guid); + const provider = await preprint?.get('provider'); - // const preprint = await this.store.findRecord('preprint', guid, {include: 'brand'}); + this.theme.set('providerType', 'preprint'); + this.theme.set('id', provider.id); - const contributors = await preprint?.queryHasMany('contributors'); - const license = await preprint?.queryHasMany('license'); + // const contributors = await preprint?.queryHasMany('contributors'); + + // const license = await preprint?.queryHasMany('license'); /* const blank = await preprint?.queryHasMany('blank', { @@ -60,8 +63,6 @@ export default class PreprintsDetail extends Route { return { preprint, - contributors, - license, }; } catch (error) { diff --git a/app/preprints/detail/template.hbs b/app/preprints/detail/template.hbs index d33463de787..edb9d071b0c 100644 --- a/app/preprints/detail/template.hbs +++ b/app/preprints/detail/template.hbs @@ -1,4 +1,7 @@ -{{title this.model.title}} +{{page-title this.model.preprint.title replace=true}} +{{ this.theme.provider.id}} +{{ this.theme.provider.brand.primaryColor}} +
{{!HEADER ROW}} diff --git a/app/preprints/index/route.ts b/app/preprints/index/route.ts index 75cc66f5114..efdaf9bb5a5 100644 --- a/app/preprints/index/route.ts +++ b/app/preprints/index/route.ts @@ -18,7 +18,9 @@ export default class Preprints extends Route { try { const provider_id = params.provider_id ? params.provider_id : 'osf'; - const provider = await this.store.findRecord('preprint-provider', provider_id, {include: 'brand'}); + const provider = await this.store.findRecord('preprint-provider', provider_id, { + include: 'brand', + }); this.theme.set('providerType', 'preprint'); this.theme.set('id', provider_id); diff --git a/app/resolve-guid/route.ts b/app/resolve-guid/route.ts index 111dbaef86f..3ec11fd5a36 100644 --- a/app/resolve-guid/route.ts +++ b/app/resolve-guid/route.ts @@ -36,7 +36,7 @@ export default class ResolveGuid extends Route { return { file: 'guid-file', node: 'guid-node', - preprint: 'guid-preprint', + preprint: 'preprints.detail', registration: this.features.isEnabled(routes['registries.overview']) ? 'registries.overview' : 'guid-registration', diff --git a/app/router.ts b/app/router.ts index 89b210c9228..dadcb7284df 100644 --- a/app/router.ts +++ b/app/router.ts @@ -31,9 +31,9 @@ Router.map(function() { this.route('index', { path: '/:provider_id' }); this.route('discover', { path: '/:provider_id/discover' }); // this.route('detail', { path: '--preprint/:guid' }); + this.route('detail', { path: '../:guid' }); }); - this.route('guid-preprint', { path: '--preprint/:guid' }); this.route('register'); this.route('settings', function() { diff --git a/mirage/config.ts b/mirage/config.ts index 634ee2667f0..70c01bd6cb1 100644 --- a/mirage/config.ts +++ b/mirage/config.ts @@ -308,6 +308,7 @@ export default function(this: Server) { path: '/providers/preprints/:parentID/preprints/', relatedModelName: 'preprint', }); + osfResource(this, 'preprint'); osfResource(this, 'registration-provider', { path: '/providers/registrations' }); diff --git a/mirage/factories/preprint.ts b/mirage/factories/preprint.ts index 479fd6cc046..d89600f91ff 100644 --- a/mirage/factories/preprint.ts +++ b/mirage/factories/preprint.ts @@ -3,10 +3,14 @@ import faker from 'faker'; import PreprintModel from 'ember-osf-web/models/preprint'; -import { guid} from './utils'; +import { guid, guidAfterCreate} from './utils'; export default Factory.extend({ id: guid('preprint'), + afterCreate(newPreprint, server) { + guidAfterCreate(newPreprint, server); + }, + title: faker.lorem.sentence(), }); diff --git a/mirage/serializers/preprint.ts b/mirage/serializers/preprint.ts new file mode 100644 index 00000000000..48b44888946 --- /dev/null +++ b/mirage/serializers/preprint.ts @@ -0,0 +1,87 @@ +import { ModelInstance } from 'ember-cli-mirage'; +import config from 'ember-get-config'; +import PreprintModel from 'ember-osf-web/models/preprint'; +import ApplicationSerializer, { SerializedRelationships } from './application'; + +const { OSF: { apiUrl } } = config; + +export default class PreprintSerializer extends ApplicationSerializer { + buildNormalLinks(model: ModelInstance) { + return { + self: `${apiUrl}/v2/${model.id}/`, + }; + } + + buildRelationships(model: ModelInstance) { + const relationships: SerializedRelationships = { + provider: { + links: { + related: { + href: `${apiUrl}/v2/providers/preprints/${model.provider.id}`, + meta: {}, + }, + }, + }, + /* + subjects: { + links: { + related: { + href: `${apiUrl}/v2/providers/preprints/${model.id}/subjects/`, + meta: this.buildRelatedLinkMeta(model, 'subjects'), + }, + }, + }, + highlightedSubjects: { + links: { + related: { + href: `${apiUrl}/v2/providers/preprints/${model.id}/subjects/highlighted/`, + meta: { + has_highlighted_subjects, + }, + }, + }, + }, + licensesAcceptable: { + links: { + related: { + href: `${apiUrl}/v2/providers/preprints/${model.id}/licenses/`, + meta: {}, + }, + }, + }, + moderators: { + links: { + related: { + href: `${apiUrl}/v2/providers/preprints/${model.id}/moderators/`, + meta: this.buildRelatedLinkMeta(model, 'moderators'), + }, + }, + }, + preprints: { + links: { + related: { + href: `${apiUrl}/v2/providers/preprints/${model.id}/preprints/`, + meta: {}, + }, + }, + }, + // TODO: subscriptions when we move ember-osf-reviews¥ + */ + }; + + /* + if (model.brand) { + relationships.brand = { + links: { + related: { + href: `${apiUrl}/v2/brands/${model.brand.id}/`, + meta: {}, + }, + }, + }; + } + */ + + return relationships; + } +} From 222c9780b4c53add010837474b4d3ea72de7dcb9 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Wed, 23 Aug 2023 12:13:13 -0600 Subject: [PATCH 063/170] Initial steps to update the template --- app/preprints/detail/controller.ts | 2 +- app/preprints/detail/route.ts | 10 ---------- app/preprints/detail/template.hbs | 16 +++++++--------- translations/en-us.yml | 6 ++++++ 4 files changed, 14 insertions(+), 20 deletions(-) diff --git a/app/preprints/detail/controller.ts b/app/preprints/detail/controller.ts index 21ec1e556e5..e9e146a7fde 100644 --- a/app/preprints/detail/controller.ts +++ b/app/preprints/detail/controller.ts @@ -115,7 +115,7 @@ export default class PrePrintsDetailController extends Controller { } authors(): ContributorModel[] { - return this.model.contributors; + return this.model.preprint.contributors; } fullLicenseText(): string { diff --git a/app/preprints/detail/route.ts b/app/preprints/detail/route.ts index 29080402b40..22de66e39f8 100644 --- a/app/preprints/detail/route.ts +++ b/app/preprints/detail/route.ts @@ -75,7 +75,6 @@ export default class PreprintsDetail extends Route { /* export default Route.extend({ - currentUser: service(), features: service(), model(params) { const opts = { @@ -88,15 +87,6 @@ export default Route.extend({ }, }; - this.get('currentUser').authenticatedAJAX(opts).then((res) => { - if (Array.isArray(res.meta.active_flags)) { - this.get('features').setup(res.meta.active_flags.reduce(function(acc, flag) { - acc[flag] = true; - return acc; - }, {})); - } - }); - return this.store.findRecord( 'preprint', params.preprint_id, { diff --git a/app/preprints/detail/template.hbs b/app/preprints/detail/template.hbs index edb9d071b0c..b791eca490e 100644 --- a/app/preprints/detail/template.hbs +++ b/app/preprints/detail/template.hbs @@ -1,6 +1,4 @@ -{{page-title this.model.preprint.title replace=true}} -{{ this.theme.provider.id}} -{{ this.theme.provider.brand.primaryColor}} +{{page-title this.model.preprint.title replace=false}}
@@ -10,14 +8,14 @@
-

{{this.model.title}}

+

{{this.model.preprint.title}}

{{#unless this.isWithdrawn}}
{{#if (and this.userIsContrib (not this.isPendingWithdrawal))}} {{t @editButtonLabel documentType=this.model.provider.documentType}} @@ -31,7 +29,7 @@
- {{t 'content.header.authors_label'}} + {{t 'preprints.detail.header.authors_label'}}
    {{#if this.authors}} @@ -57,7 +55,7 @@
- {{author-assertions preprint=this.model}} + {{!author-assertions preprint=this.model.preprint}}
{{!END CONTAINER DIV}}
@@ -152,9 +150,9 @@
{{t this.dateLabel}}: {{moment-format this.model.dateCreated 'MMMM DD, YYYY'}} {{#if this.isWithdrawn}} - | {{t 'content.header.withdrawn_on'}}: {{moment-format this.model.dateWithdrawn 'MMMM DD, YYYY'}} + | {{t 'preprint.detail.header.withdrawn_on'}}: {{moment-format this.model.dateWithdrawn 'MMMM DD, YYYY'}} {{else}} - | {{t 'content.header.last_edited'}}: {{moment-format this.model.dateModified 'MMMM DD, YYYY'}} + | {{t 'preprint.detail.header.last_edited'}}: {{moment-format this.model.dateModified 'MMMM DD, YYYY'}} {{/if}}
-
- -
-

{{t 'content.preprint_doi' documentType=this.model.provider.documentType}}

- {{#if this.model.preprintDoiUrl}} -

{{extract-doi this.model.preprintDoiUrl}}

- {{/if}} -
- - {{#if this.model.license.name}} -
-

{{t 'global.license'}}

- {{this.model.license.name}} - - {{#if this.showLicenseText }} - {{fa-icon 'caret-down' click=(action 'toggleLicenseText')}} - {{else}} - {{fa-icon 'caret-right' click=(action 'toggleLicenseText')}} - {{/if}} - - {{#if this.showLicenseText}} -
{{this.fullLicenseText}}
- {{/if}} -
- {{/if}} -
-

{{t 'content.disciplines'}}

- {{#each this.disciplineReduced as |subject|}} - {{subject.text}} - {{/each}} -
+ {{! removed }} +
+ {{! removed }} +
+ {{#if this.model.preprint.isPreprintOrphan}} + + {{t 'preprints.detail.orphan_preprint'}} + + {{else}} + {{#if this.model.public}} + -
-

{{t 'global.tags'}}

- {{#if this.hasTag}} - {{#each this.model.tags as |tag|}} - {{fix-special-char tag}} - {{/each}} + {{! preprint-file-renderer provider=this.model.provider preprint=this.model primaryFile=this.primaryFile}} +
+ {{t this.dateLabel}}: {{moment-format this.model.dateCreated 'MMMM DD, YYYY'}} + {{#if this.isWithdrawn}} + | {{t 'preprint.detail.header.withdrawn_on'}}: {{moment-format this.model.dateWithdrawn 'MMMM DD, YYYY'}} {{else}} - {{t 'global.none'}} - {{/if}} -
-
-
- {{! END TOMBSTONE PAGE}} - {{else}} - {{!CONTENT ROW}} -
- {{!LEFT COL DIV}} -
- {{#if this.model.isPreprintOrphan}} - - {{else}} - {{#unless this.model.public}} - - {{/unless}} - {{preprint-file-renderer provider=this.model.provider preprint=this.model primaryFile=this.primaryFile}} -
- {{t this.dateLabel}}: {{moment-format this.model.dateCreated 'MMMM DD, YYYY'}} - {{#if this.isWithdrawn}} - | {{t 'preprint.detail.header.withdrawn_on'}}: {{moment-format this.model.dateWithdrawn 'MMMM DD, YYYY'}} - {{else}} - | {{t 'preprint.detail.header.last_edited'}}: {{moment-format this.model.dateModified 'MMMM DD, YYYY'}} - {{/if}} -
- - {{/if}} -
- {{!END LEFT COL DIV}} - {{#unless this.fullScreenMFR}} - {{!RIGHT SIDE COL}} -
- {{!SHARE ROW}} - -
-
- {{#if this.isPlauditReady}} - {{! plaudit-widget }} - {{/if}} -
- -
- -
-

{{t 'global.abstract'}}

-

- {{~if this.useShortenedDescription this.description this.model.description~}} -

- -
- - {{#if this.node}} -
-

{{t 'content.supplemental_materials.title'}}

- - - -
- {{/if}} - -
-

{{t 'content.preprint_doi' documentType=this.model.provider.documentType}}

- {{#if this.model.preprintDoiUrl}} - {{#if this.model.preprintDoiCreated}} - {{extract-doi this.model.preprintDoiUrl}} - {{else}} -

{{extract-doi this.model.preprintDoiUrl}}

-

{{t 'content.preprint_pending_doi_minted'}}

- {{/if}} - {{else}} - {{#if (not this.model.public)}} - {{t 'content.preprint_pending_doi' documentType=this.model.provider.documentType }} - {{else if (and this.model.provider.reviewsWorkflow (not this.model.isPublished))}} - {{t 'content.preprint_pending_doi_moderation'}} - {{/if}} - {{/if}} -
- - {{#if this.model.articleDoiUrl}} -
-

{{t 'content.article_doi'}}

- {{extract-doi this.model.articleDoiUrl}} -
- {{/if}} - - {{#if this.model.license.name}} -
-

{{t 'global.license'}}

- {{this.model.license.name}} - - {{#if this.showLicenseText }} - {{fa-icon 'caret-down' click=(action 'toggleLicenseText')}} - {{else}} - {{fa-icon 'caret-right' click=(action 'toggleLicenseText')}} - {{/if}} - - {{#if this.showLicenseText}} -
{{this.fullLicenseText}}
- {{/if}} -
- {{/if}} - -
-

{{t 'content.disciplines'}}

- {{#each this.disciplineReduced as |subject|}} - {{subject.text}} - {{/each}} -
-
-

{{t 'global.tags'}}

- {{#if this.model.tags.length}} - {{#each this.model.tags as |tag|}} - {{fix-special-char tag}} - {{/each}} - {{else}} - {{t 'global.none'}} - {{/if}} -
- - {{#if this.model.originalPublicationDate}} -
-

{{t 'content.original_publication_date'}}

-

- {{moment-format this.model.originalPublicationDate 'YYYY-MM-DD'}} -

-
+ | {{t 'preprint.detail.header.last_edited'}}: {{moment-format this.model.dateModified 'MMMM DD, YYYY'}} {{/if}} - -
-

{{t 'content.citations'}}

- {{citation-widget node=this.model}} -
- {{!END RIGHT SIDE COL}} - {{/unless}} -
- {{!END CONTENT ROW}} - {{/if}} + + {{else}} + + {{t 'preprints.detail.private_preprint_warning' documentType=this.model.provider.documentType.singular supportEmail='support@osf.io'}} + + {{/if}} + {{/if}} +
+
+ {{! Right}} +
+ {{! removed - 1 }} + {{! removed - 2 }}
{{!END DIV CONTAINER}}
diff --git a/mirage/factories/preprint.ts b/mirage/factories/preprint.ts index 9fdc01fa135..01fdf5cafe3 100644 --- a/mirage/factories/preprint.ts +++ b/mirage/factories/preprint.ts @@ -15,6 +15,10 @@ export default Factory.extend({ reviewsState: ReviewsState.REJECTED, + public: true, + + isPreprintOrphan: false, + afterCreate(newPreprint, server) { guidAfterCreate(newPreprint, server); diff --git a/mirage/scenarios/preprints.ts b/mirage/scenarios/preprints.ts index c8b860e492e..3c5b85b8a15 100644 --- a/mirage/scenarios/preprints.ts +++ b/mirage/scenarios/preprints.ts @@ -59,6 +59,24 @@ function buildOSF( reviewsState: ReviewsState.APPROVED, }); + const orphanedPreprint = server.create('preprint', { + provider: osf, + id: 'osf-orphan', + title: 'Preprint RWF: Pre-moderation, Non-Admin and Approved', + currentUserPermissions: [], + reviewsState: ReviewsState.APPROVED, + isPreprintOrphan: true, + }); + + const privatePreprint = server.create('preprint', { + provider: osf, + id: 'osf-private', + title: 'Preprint RWF: Pre-moderation, Non-Admin and Approved', + currentUserPermissions: [], + reviewsState: ReviewsState.APPROVED, + public: false, + }); + const subjects = server.createList('subject', 7); osf.update({ @@ -69,7 +87,14 @@ function buildOSF( footer_links: '', brand, moderators: [currentUserModerator], - preprints: [rejectedAdminPreprint, approvedAdminPreprint, approvedPreprint, rejectedPreprint], + preprints: [ + rejectedAdminPreprint, + approvedAdminPreprint, + approvedPreprint, + rejectedPreprint, + orphanedPreprint, + privatePreprint, + ], description: 'This is the description for osf', }); } diff --git a/translations/en-us.yml b/translations/en-us.yml index 9e71d246b8e..8abf095642a 100644 --- a/translations/en-us.yml +++ b/translations/en-us.yml @@ -1129,6 +1129,8 @@ preprints: project_button: edit_preprint: 'Edit {documentType}' edit_resubmit_preprint: 'Edit and resubmit' + orphan_preprint: 'The user has removed this file.' + private_preprint_warning: 'This {documentType} is private. Contact {supportEmail} if this is in error.' header: osf_registrations: 'OSF Preprints' registrations: 'Preprints' From 6bc11da99d1b263876aa367543092b8703032953 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Wed, 6 Sep 2023 17:29:50 -0600 Subject: [PATCH 069/170] Added information for the primaryFile --- app/models/file.ts | 4 +++- app/models/preprint.ts | 3 +++ app/preprints/detail/controller.ts | 2 +- app/preprints/detail/route.ts | 6 +++++- app/preprints/detail/template.hbs | 7 ++++--- mirage/config.ts | 10 ++++++++++ mirage/factories/preprint.ts | 4 ++++ mirage/serializers/preprint.ts | 16 ++++++++++++++++ 8 files changed, 46 insertions(+), 6 deletions(-) diff --git a/app/models/file.ts b/app/models/file.ts index 88dbeaff84d..2ce2b9db46a 100644 --- a/app/models/file.ts +++ b/app/models/file.ts @@ -5,6 +5,7 @@ import { Link } from 'jsonapi-typescript'; import { FileReference } from 'ember-osf-web/packages/registration-schema'; import getHref from 'ember-osf-web/utils/get-href'; +import PreprintModel from 'ember-osf-web/models/preprint'; import AbstractNodeModel from './abstract-node'; import BaseFileItem, { BaseFileLinks } from './base-file-item'; import CommentModel from './comment'; @@ -57,7 +58,8 @@ export default class FileModel extends BaseFileItem { comments!: AsyncHasMany; @belongsTo('abstract-node', { polymorphic: true }) - target!: (AsyncBelongsTo & AbstractNodeModel) | (AsyncBelongsTo & DraftNode); + // eslint-disable-next-line max-len + target!: (AsyncBelongsTo & AbstractNodeModel) | (AsyncBelongsTo & PreprintModel) | (AsyncBelongsTo & DraftNode); // BaseFileItem override isFileModel = true; diff --git a/app/models/preprint.ts b/app/models/preprint.ts index 4bbf59cab2a..a15d94bf542 100644 --- a/app/models/preprint.ts +++ b/app/models/preprint.ts @@ -42,6 +42,9 @@ export default class PreprintModel extends OsfModel { @hasMany('review-action', { inverse: 'target' }) reviewActions!: AsyncHasMany; + @hasMany('files', { inverse: null}) + files!: AsyncHasMany & FileModel; + @hasMany('contributors', { inverse: 'preprint'}) contributors!: AsyncHasMany & ContributorModel; diff --git a/app/preprints/detail/controller.ts b/app/preprints/detail/controller.ts index f30fe7791d4..353e451f332 100644 --- a/app/preprints/detail/controller.ts +++ b/app/preprints/detail/controller.ts @@ -72,7 +72,7 @@ export default class PrePrintsDetailController extends Controller { return this.model.provider.facebookAppId ? this.model.provider.facebookAppId : config.FB_APP_ID; } - dateLabel(): string { + get dateLabel(): string { return this.model.provider.reviewsWorkflow === ReviewsWorkFlow.PRE_MODERATION ? DATE_LABEL.submitted : DATE_LABEL.created; diff --git a/app/preprints/detail/route.ts b/app/preprints/detail/route.ts index a2979aa5507..7c7d8ce416c 100644 --- a/app/preprints/detail/route.ts +++ b/app/preprints/detail/route.ts @@ -39,10 +39,13 @@ export default class PreprintsDetail extends Route { try { const guid = params.guid; - const preprint = await this.store.findRecord('preprint', guid, {include: 'bibliographicContributors'}); + // eslint-disable-next-line max-len + const preprint = await this.store.findRecord('preprint', guid, {include: 'bibliographicContributors' }); const provider = await preprint?.get('provider'); + const primaryFile = await preprint?.get('primaryFile'); + this.theme.set('providerType', 'preprint'); this.theme.set('id', provider.id); @@ -64,6 +67,7 @@ export default class PreprintsDetail extends Route { brand: provider.brand.content, contributors, provider, + primaryFile, }; } catch (error) { diff --git a/app/preprints/detail/template.hbs b/app/preprints/detail/template.hbs index 6e5835bc2a6..59a0c51d675 100644 --- a/app/preprints/detail/template.hbs +++ b/app/preprints/detail/template.hbs @@ -46,9 +46,11 @@ data-analytics-scope='preprints detail page' {{t 'preprints.detail.orphan_preprint'}} {{else}} - {{#if this.model.public}} + {{#if this.model.preprint.public}} + {{this.model.primaryFile.links.download}} + {{this.model.primaryFile.links.self}} @@ -67,7 +69,6 @@ data-analytics-scope='preprints detail page' {{action 'expandMFR'}} aria-label={{if this.fullScreenMFR (t 'global.collapse') (t 'global.expand')}} > - {{else}} ({ afterCreate(newPreprint, server) { guidAfterCreate(newPreprint, server); + const file = server.create('file', {id: 'afile', target: newPreprint}); + const contributorUser = server.create('user', { givenName: 'Emmit', familyName: 'Stud', @@ -42,6 +44,8 @@ export default Factory.extend({ newPreprint.update({ contributors: allContributors, bibliographicContributors: allContributors, + files: [file], + primaryFile: file, }); }, diff --git a/mirage/serializers/preprint.ts b/mirage/serializers/preprint.ts index ff3e467b25d..bb54235d8cf 100644 --- a/mirage/serializers/preprint.ts +++ b/mirage/serializers/preprint.ts @@ -38,6 +38,22 @@ export default class PreprintSerializer extends ApplicationSerializer Date: Thu, 7 Sep 2023 10:23:25 -0600 Subject: [PATCH 070/170] Added the ability to display a pdf from a local assets --- app/config/environment.d.ts | 1 + app/preprints/detail/controller.ts | 17 ++----- app/preprints/detail/styles.scss | 35 +++++++++++++ app/preprints/detail/template.hbs | 51 ++++++++++--------- config/environment.js | 2 + .../components/file-renderer/component.ts | 7 ++- mirage/factories/preprint.ts | 25 ++++++++- mirage/serializers/file.ts | 33 ++++++++---- translations/en-us.yml | 5 ++ 9 files changed, 128 insertions(+), 48 deletions(-) diff --git a/app/config/environment.d.ts b/app/config/environment.d.ts index a04a23a875a..edbdf06bf75 100644 --- a/app/config/environment.d.ts +++ b/app/config/environment.d.ts @@ -18,6 +18,7 @@ export interface KeenConfig { } declare const config: { + WATER_BUTLER_ENABLED: any; environment: any; lintOnBuild: boolean; testsEnabled: boolean; diff --git a/app/preprints/detail/controller.ts b/app/preprints/detail/controller.ts index 353e451f332..6559d3413ed 100644 --- a/app/preprints/detail/controller.ts +++ b/app/preprints/detail/controller.ts @@ -10,6 +10,7 @@ import SubjectModel from 'ember-osf-web/models/subject'; import Intl from 'ember-intl/services/intl'; import { Permission } from 'ember-osf-web/models/osf-model'; import { ReviewsState, ReviewsWorkFlow } from 'ember-osf-web/models/provider'; +import { tracked } from '@glimmer/tracking'; /** @@ -25,8 +26,8 @@ import { ReviewsState, ReviewsWorkFlow } from 'ember-osf-web/models/provider'; */ const DATE_LABEL = { - created: 'content.date_label.created_on', - submitted: 'content.date_label.submitted_on', + created: 'preprints.detail.date_label.created_on', + submitted: 'preprints.detail.date_label.submitted_on', }; /** @@ -49,7 +50,7 @@ export default class PrePrintsDetailController extends Controller { chosenFile: 'file', }; - fullScreenMFR = false; + @tracked fullScreenMFR = false; expandedAuthors = true; showLicenseText = false; primaryFile = null; @@ -173,17 +174,7 @@ export default class PrePrintsDetailController extends Controller { @action expandMFR() { - // State of fullScreenMFR before the transition (what the user perceives as the action) this.fullScreenMFR = !this.fullScreenMFR; - - /* - this.get('metrics') - .trackEvent({ - category: 'button', - action: 'click', - label: `Content - MFR ${beforeState}`, - }); - */ } @action diff --git a/app/preprints/detail/styles.scss b/app/preprints/detail/styles.scss index d2a8b4290c1..09b69dfca91 100644 --- a/app/preprints/detail/styles.scss +++ b/app/preprints/detail/styles.scss @@ -80,11 +80,46 @@ .data-container-right { padding: 0 15px; width: 50%; + height: 700px; display: flex; flex-direction: column; justify-content: flex-start; align-items: flex-start; } + + .data-container-left { + &.expanded { + width: 100%; + } + + &.collapsed { + width: 50%; + } + + } + + .data-container-left { + .file-description-container { + display: flex; + flex-direction: row; + justify-content: flex-start; + align-items: flex-start; + width: 100%; + padding-top: 15px; + + .file-description { + width: 75%; + } + + .toggle-button { + width: 25%; + min-width: 100px; + display: flex; + justify-content: flex-end; + align-items: flex-start; + } + } + } } } diff --git a/app/preprints/detail/template.hbs b/app/preprints/detail/template.hbs index 59a0c51d675..adc38619d4a 100644 --- a/app/preprints/detail/template.hbs +++ b/app/preprints/detail/template.hbs @@ -36,7 +36,7 @@ data-analytics-scope='preprints detail page' {{! removed }}
{{! removed }} -
+
{{#if this.model.preprint.isPreprintOrphan}} {{else}} {{#if this.model.preprint.public}} - {{this.model.primaryFile.links.download}} - {{this.model.primaryFile.links.self}} - - {{! preprint-file-renderer provider=this.model.provider preprint=this.model primaryFile=this.primaryFile}} -
- {{t this.dateLabel}}: {{moment-format this.model.dateCreated 'MMMM DD, YYYY'}} - {{#if this.isWithdrawn}} - | {{t 'preprint.detail.header.withdrawn_on'}}: {{moment-format this.model.dateWithdrawn 'MMMM DD, YYYY'}} - {{else}} - | {{t 'preprint.detail.header.last_edited'}}: {{moment-format this.model.dateModified 'MMMM DD, YYYY'}} - {{/if}} +
+
+ {{t this.dateLabel}}: {{moment-format this.model.dateCreated 'MMMM DD, YYYY'}} + {{#if this.isWithdrawn}} + | {{t 'preprints.detail.header.withdrawn_on'}}: {{moment-format this.model.dateWithdrawn 'MMMM DD, YYYY'}} + {{else}} + | {{t 'preprints.detail.header.last_edited'}}: {{moment-format this.model.dateModified 'MMMM DD, YYYY'}} + {{/if}} +
+
+ +
- {{else}} -
- {{! Right}} -
+ {{#unless this.fullScreenMFR }} +
+ {{! Right}} +
+ {{/unless}} {{! removed - 1 }} {{! removed - 2 }}
diff --git a/config/environment.js b/config/environment.js index e802090a825..3e32b095b11 100644 --- a/config/environment.js +++ b/config/environment.js @@ -28,6 +28,7 @@ const { GOOGLE_TAG_MANAGER_ID, KEEN_CONFIG: keenConfig, LINT_ON_BUILD: lintOnBuild = false, + WATER_BUTLER_ENABLED = true, MIRAGE_ENABLED = false, MIRAGE_SCENARIOS = [ 'loggedIn', @@ -69,6 +70,7 @@ module.exports = function(environment) { const ENV = { modulePrefix: 'ember-osf-web', + WATER_BUTLER_ENABLED, environment, lintOnBuild, testsEnabled: false, // Disable tests by default. diff --git a/lib/osf-components/addon/components/file-renderer/component.ts b/lib/osf-components/addon/components/file-renderer/component.ts index d93c39bd54d..178d41d781c 100644 --- a/lib/osf-components/addon/components/file-renderer/component.ts +++ b/lib/osf-components/addon/components/file-renderer/component.ts @@ -69,7 +69,12 @@ export default class FileRenderer extends Component { // This is most apparent in 3D files const urlWithParams = new URL(renderUrl); urlWithParams.searchParams.set('url', this.downloadUrl); - return this.isLoading ? '' : urlWithParams.toString(); + if (config.WATER_BUTLER_ENABLED) { + return this.isLoading ? '' : urlWithParams.toString(); + } else { + return this.isLoading ? '' : this.downloadUrl; + + } } didReceiveAttrs(): void { diff --git a/mirage/factories/preprint.ts b/mirage/factories/preprint.ts index 97f688a2201..6501c97ee1f 100644 --- a/mirage/factories/preprint.ts +++ b/mirage/factories/preprint.ts @@ -22,7 +22,30 @@ export default Factory.extend({ afterCreate(newPreprint, server) { guidAfterCreate(newPreprint, server); - const file = server.create('file', {id: 'afile', target: newPreprint}); + const file = server.create('file', { + id: 'afile', + target: newPreprint, + links: { + info: 'http://localhost:4200/assets/osf-assets/mfr-test.pdf', + move: 'http://localhost:4200/assets/osf-assets/mfr-test.pdf', + delete: 'http://localhost:4200/assets/osf-assets/mfr-test.pdf', + html: 'http://localhost:4200/assets/osf-assets/mfr-test.pdf', + upload: 'http://localhost:4200/assets/osf-assets/mfr-test.pdf', + download: 'http://localhost:4200/assets/osf-assets/mfr-test.pdf', + }, + }); + + /* + fileReference: () => ({ + file_id: this.id as string, + file_name: this.name as string, + file_urls: { + }, + file_hashes: { + sha256: this.extra.hashes.sha256, + }, + }), + */ const contributorUser = server.create('user', { givenName: 'Emmit', diff --git a/mirage/serializers/file.ts b/mirage/serializers/file.ts index 3ca9150cc08..bef1b6c93cb 100644 --- a/mirage/serializers/file.ts +++ b/mirage/serializers/file.ts @@ -66,15 +66,28 @@ export default class FileSerializer extends ApplicationSerializer { buildNormalLinks(model: ModelInstance) { const { id } = model; - return { - ...super.buildNormalLinks(model), - new_folder: model.kind === 'folder' ? `${apiUrl}/wb/files/${id}/upload/?kind=folder` : undefined, - upload: `${apiUrl}/wb/files/${id}/upload/`, - download: `${apiUrl}/wb/files/${id}/download/`, - move: `${apiUrl}/wb/files/${id}/move/`, - delete: `${apiUrl}/wb/files/${id}/delete/`, - info: `${apiUrl}/v2/files/${id}/`, - html: `/${id}/`, - }; + if (model.links) { + return { + ...super.buildNormalLinks(model), + new_folder: model.kind === 'folder' ? `${apiUrl}/wb/files/${id}/upload/?kind=folder` : undefined, + upload: model.links.upload, + download: model.links.download, + move: model.links.move, + delete: `${apiUrl}/${model.links.delete}`, + info: model.links.info, + html: model.links.html, + }; + } else { + return { + ...super.buildNormalLinks(model), + new_folder: model.kind === 'folder' ? `${apiUrl}/wb/files/${id}/upload/?kind=folder` : undefined, + upload: `${apiUrl}/wb/files/${id}/upload/`, + download: `${apiUrl}/wb/files/${id}/download/`, + move: `${apiUrl}/wb/files/${id}/move/`, + delete: `${apiUrl}/wb/files/${id}/delete/`, + info: `${apiUrl}/v2/files/${id}/`, + html: `/${id}/`, + }; + } } } diff --git a/translations/en-us.yml b/translations/en-us.yml index 8abf095642a..429dc609c86 100644 --- a/translations/en-us.yml +++ b/translations/en-us.yml @@ -1131,6 +1131,11 @@ preprints: edit_resubmit_preprint: 'Edit and resubmit' orphan_preprint: 'The user has removed this file.' private_preprint_warning: 'This {documentType} is private. Contact {supportEmail} if this is in error.' + date_label: + created_on: 'Created' + submitted_on: 'Submitted' + collapse: 'Collapse' + expand: 'Expand' header: osf_registrations: 'OSF Preprints' registrations: 'Preprints' From 103c644b0ada9af2cfb25f841c3583409836a66e Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Thu, 7 Sep 2023 11:50:03 -0600 Subject: [PATCH 071/170] Finished the abstract section --- app/models/preprint.ts | 1 + app/preprints/detail/controller.ts | 22 ++++++++------ app/preprints/detail/styles.scss | 13 ++++++++ app/preprints/detail/template.hbs | 48 +++++++++++++++++++++++++++++- mirage/factories/preprint.ts | 2 ++ mirage/scenarios/preprints.ts | 2 ++ translations/en-us.yml | 3 ++ 7 files changed, 81 insertions(+), 10 deletions(-) diff --git a/app/models/preprint.ts b/app/models/preprint.ts index a15d94bf542..bd79239db2b 100644 --- a/app/models/preprint.ts +++ b/app/models/preprint.ts @@ -23,6 +23,7 @@ export default class PreprintModel extends OsfModel { @attr('boolean') isPreprintOrphan!: boolean; @attr('object') licenseRecord!: any; @attr('string') reviewsState!: string; + @attr('string') description!: string; @attr('date') dateLastTransitioned!: Date; @attr('date') preprintDoiCreated!: Date; @attr('array') currentUserPermissions!: string[]; diff --git a/app/preprints/detail/controller.ts b/app/preprints/detail/controller.ts index 6559d3413ed..77c6e7239fa 100644 --- a/app/preprints/detail/controller.ts +++ b/app/preprints/detail/controller.ts @@ -58,7 +58,7 @@ export default class PrePrintsDetailController extends Controller { isPendingWithdrawal = false; isWithdrawn = null; isPlauditReady = false; - expandedAbstract = navigator.userAgent.includes('Prerender'); + @tracked expandedAbstract = navigator.userAgent.includes('Prerender'); get hyperlink(): string { @@ -131,12 +131,12 @@ export default class PrePrintsDetailController extends Controller { return this.model.licenseRecord; } - hasShortenedDescription(): String { - return this.model.description && this.model.description.length > 350; + get hasShortenedDescription(): String { + return this.model.preprint.description && this.model.preprint.description.length > 350; } - useShortenedDescription(): boolean { - return this.hasShortenedDescription() && !this.expandedAbstract; + get useShortenedDescription(): boolean { + return this.hasShortenedDescription && !this.expandedAbstract; } /** @@ -146,10 +146,14 @@ export default class PrePrintsDetailController extends Controller { * by going to the last space. * @returns string */ - description(): string { - return this.model.description - .slice(0, 350) - .replace(/\s+\S*$/, ''); + get description(): string { + if (this.useShortenedDescription) { + return this.model.preprint.description + .slice(0, 350) + .replace(/\s+\S*$/, ''); + } else { + return this.model.preprint.description; + } } emailHref(): string { diff --git a/app/preprints/detail/styles.scss b/app/preprints/detail/styles.scss index 09b69dfca91..7b82a24c2b5 100644 --- a/app/preprints/detail/styles.scss +++ b/app/preprints/detail/styles.scss @@ -120,6 +120,19 @@ } } } + + .data-container-right { + .abstract-truncated::after { + content: ' \2026'; + } + + h4 { + padding-bottom: 15px; + padding-top: 15px; + margin-top: 10px; + margin-bottom: 10px; + } + } } } diff --git a/app/preprints/detail/template.hbs b/app/preprints/detail/template.hbs index adc38619d4a..4b853e4e0a7 100644 --- a/app/preprints/detail/template.hbs +++ b/app/preprints/detail/template.hbs @@ -86,7 +86,53 @@ data-analytics-scope='preprints detail page'
{{#unless this.fullScreenMFR }}
- {{! Right}} +
+ {{!Download}} +
+
+ {{!Plaudit }} +
+
+

{{t 'preprints.detail.abstract'}}

+

+ {{this.description}} +

+ {{#if this.hasShortenedDescription}} + + {{/if}} +
+
+ {{!Supplement Materials}} +
+
+ {{!Preprint DOI}} +
+
+ {{!Peer Review}} +
+
+ {{!License}} +
+
+ {{!Disciplines}} +
+
+ {{!Tags}} +
+
+ {{!Original Publication Date}} +
+
+ {{!Citations}} +
{{/unless}} {{! removed - 1 }} diff --git a/mirage/factories/preprint.ts b/mirage/factories/preprint.ts index 6501c97ee1f..9be895b29d6 100644 --- a/mirage/factories/preprint.ts +++ b/mirage/factories/preprint.ts @@ -19,6 +19,8 @@ export default Factory.extend({ isPreprintOrphan: false, + description: faker.lorem.sentence(), + afterCreate(newPreprint, server) { guidAfterCreate(newPreprint, server); diff --git a/mirage/scenarios/preprints.ts b/mirage/scenarios/preprints.ts index 3c5b85b8a15..4674245cfab 100644 --- a/mirage/scenarios/preprints.ts +++ b/mirage/scenarios/preprints.ts @@ -4,6 +4,7 @@ import { Permission } from 'ember-osf-web/models/osf-model'; import PreprintProvider from 'ember-osf-web/models/preprint-provider'; import { ReviewsState } from 'ember-osf-web/models/provider'; import User from 'ember-osf-web/models/user'; +import faker from 'faker'; export function preprintsScenario( server: Server, @@ -57,6 +58,7 @@ function buildOSF( title: 'Preprint RWF: Pre-moderation, Non-Admin and Approved', currentUserPermissions: [], reviewsState: ReviewsState.APPROVED, + description: `${faker.lorem.sentence(200)}\n${faker.lorem.sentence(300)}`, }); const orphanedPreprint = server.create('preprint', { diff --git a/translations/en-us.yml b/translations/en-us.yml index 429dc609c86..ce878e56539 100644 --- a/translations/en-us.yml +++ b/translations/en-us.yml @@ -1136,6 +1136,9 @@ preprints: submitted_on: 'Submitted' collapse: 'Collapse' expand: 'Expand' + abstract: 'Abstract' + see_more: 'See more' + see_less: 'See less' header: osf_registrations: 'OSF Preprints' registrations: 'Preprints' From 99560db396ba9960765ae9ce4f527c7f5463991f Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Fri, 8 Sep 2023 10:59:39 -0600 Subject: [PATCH 072/170] Added the license information --- app/preprints/detail/controller.ts | 28 +++++++++++------------- app/preprints/detail/route.ts | 3 +++ app/preprints/detail/styles.scss | 25 ++++++++++++++++++++++ app/preprints/detail/template.hbs | 34 ++++++++++++++++++++++++------ mirage/factories/preprint.ts | 12 +++++++++++ mirage/scenarios/preprints.ts | 18 ++++++++++++++++ mirage/serializers/preprint.ts | 32 +++++++++++++++++++++------- translations/en-us.yml | 2 ++ 8 files changed, 123 insertions(+), 31 deletions(-) diff --git a/app/preprints/detail/controller.ts b/app/preprints/detail/controller.ts index 77c6e7239fa..acc417d2f38 100644 --- a/app/preprints/detail/controller.ts +++ b/app/preprints/detail/controller.ts @@ -52,7 +52,7 @@ export default class PrePrintsDetailController extends Controller { @tracked fullScreenMFR = false; expandedAuthors = true; - showLicenseText = false; + @tracked showLicenseText = false; primaryFile = null; showModalClaimUser = false; isPendingWithdrawal = false; @@ -127,8 +127,17 @@ export default class PrePrintsDetailController extends Controller { return this.model.contributors; } - fullLicenseText(): string { - return this.model.licenseRecord; + @action + toggleLicenseText(): void { + this.showLicenseText = !this.showLicenseText; + } + + get fullLicenseText(): string { + const text = this.model.license.text || ''; + const { year = '', copyright_holders = [] } = this.model.preprint.licenseRecord; + return text + .replace(/({{year}})/g, year) + .replace(/({{copyrightHolders}})/g, copyright_holders.join(', ')); } get hasShortenedDescription(): String { @@ -163,19 +172,6 @@ export default class PrePrintsDetailController extends Controller { } - @action - toggleLicenseText(): void { - this.showLicenseText = !this.showLicenseText; - /* - this.get('metrics') - .trackEvent({ - category: 'button', - action: 'click', - label: `Content - License ${licenseState}`, - }); - */ - } - @action expandMFR() { this.fullScreenMFR = !this.fullScreenMFR; diff --git a/app/preprints/detail/route.ts b/app/preprints/detail/route.ts index 7c7d8ce416c..3855995ff1c 100644 --- a/app/preprints/detail/route.ts +++ b/app/preprints/detail/route.ts @@ -52,6 +52,8 @@ export default class PreprintsDetail extends Route { const contributors = await preprint?.queryHasMany('contributors'); + const license = await preprint?.get('license'); + // const license = await preprint?.queryHasMany('license'); /* @@ -68,6 +70,7 @@ export default class PreprintsDetail extends Route { contributors, provider, primaryFile, + license, }; } catch (error) { diff --git a/app/preprints/detail/styles.scss b/app/preprints/detail/styles.scss index 7b82a24c2b5..ec7979cb0ff 100644 --- a/app/preprints/detail/styles.scss +++ b/app/preprints/detail/styles.scss @@ -131,6 +131,31 @@ padding-top: 15px; margin-top: 10px; margin-bottom: 10px; + font-weight: bold; + } + + .license-text { + pre { + white-space: pre-wrap; + font-size: 75%; + width: 100%; + text-align: justify; + max-height: 300px; + word-break: normal; + overflow: auto; + display: block; + padding: 9.5px; + margin: 0 0 10px; + line-height: 1.42857; + word-wrap: break-word; + background-color: #f5f5f5; + border: 1px solid #ccc; + border-radius: 4px; + } + + span { + cursor: pointer; + } } } } diff --git a/app/preprints/detail/template.hbs b/app/preprints/detail/template.hbs index 4b853e4e0a7..1105f89b58e 100644 --- a/app/preprints/detail/template.hbs +++ b/app/preprints/detail/template.hbs @@ -93,7 +93,7 @@ data-analytics-scope='preprints detail page' {{!Plaudit }}
-

{{t 'preprints.detail.abstract'}}

+

{{t 'preprints.detail.abstract'}}

{{this.description}}

@@ -115,12 +115,32 @@ data-analytics-scope='preprints detail page'
{{!Preprint DOI}}
-
- {{!Peer Review}} -
-
- {{!License}} -
+ {{#if this.model.preprint.articleDoiUrl}} +
+

{{t 'preprints.detail.article_doi'}}

+ + {{extract-doi this.model.preprint.articleDoiUrl}} + +
+ {{/if}} + {{#if this.model.preprint.license.name}} +
+

{{t 'preprints.detail.license'}}

+ {{this.model.preprint.license.name}} + + + + {{#if this.showLicenseText}} +
{{this.fullLicenseText}}
+ {{/if}} +
+ {{/if}}
{{!Disciplines}}
diff --git a/mirage/factories/preprint.ts b/mirage/factories/preprint.ts index 9be895b29d6..2bbf1e1b48f 100644 --- a/mirage/factories/preprint.ts +++ b/mirage/factories/preprint.ts @@ -21,6 +21,18 @@ export default Factory.extend({ description: faker.lorem.sentence(), + license: null, + + licenseRecord: { + copyright_holders: [ + 'Futa', + 'Yuhuai', + 'Brian G.', + ], + year: '2023', + }, + + afterCreate(newPreprint, server) { guidAfterCreate(newPreprint, server); diff --git a/mirage/scenarios/preprints.ts b/mirage/scenarios/preprints.ts index 4674245cfab..2c491633c93 100644 --- a/mirage/scenarios/preprints.ts +++ b/mirage/scenarios/preprints.ts @@ -14,6 +14,14 @@ export function preprintsScenario( buildThesisCommons(server, currentUser); } +function buildLicenseText(): string { + let text = faker.lorem.sentence(100); + [250, 100, 250, 300].map((length: number) => { + text = `${text}\n\n${faker.lorem.sentence(length)}`; + }); + return text; +} + function buildOSF( server: Server, currentUser: ModelInstance, @@ -28,6 +36,14 @@ function buildOSF( const currentUserModerator = server.create('moderator', { id: currentUser.id, user: currentUser, provider: osf }, 'asAdmin'); + const license = server.create('license', { + id: 'asdksusslsh', + name: 'Mozilla Public License 2.0', + text: buildLicenseText(), + url: 'https://creativecommons.org/licenses/by/4.0/legalcode', + requiredFields: [], + }); + const rejectedAdminPreprint = server.create('preprint', { provider: osf, id: 'osf-rejected-admin', @@ -42,6 +58,7 @@ function buildOSF( title: 'Preprint RWF: Pre-moderation, Admin and Approved', currentUserPermissions: [Permission.Admin], reviewsState: ReviewsState.APPROVED, + license, }); const rejectedPreprint = server.create('preprint', { @@ -59,6 +76,7 @@ function buildOSF( currentUserPermissions: [], reviewsState: ReviewsState.APPROVED, description: `${faker.lorem.sentence(200)}\n${faker.lorem.sentence(300)}`, + license, }); const orphanedPreprint = server.create('preprint', { diff --git a/mirage/serializers/preprint.ts b/mirage/serializers/preprint.ts index bb54235d8cf..a2b0c49c115 100644 --- a/mirage/serializers/preprint.ts +++ b/mirage/serializers/preprint.ts @@ -54,6 +54,14 @@ export default class PreprintSerializer extends ApplicationSerializer Date: Fri, 8 Sep 2023 11:18:56 -0600 Subject: [PATCH 073/170] Added some miscellaneous logic for licenses --- app/preprints/detail/controller.ts | 5 +++++ app/preprints/detail/template.hbs | 2 +- mirage/factories/preprint.ts | 21 +++++++++++++++++++-- mirage/scenarios/preprints.ts | 19 +------------------ mirage/serializers/preprint.ts | 1 + 5 files changed, 27 insertions(+), 21 deletions(-) diff --git a/app/preprints/detail/controller.ts b/app/preprints/detail/controller.ts index acc417d2f38..5990f8057dc 100644 --- a/app/preprints/detail/controller.ts +++ b/app/preprints/detail/controller.ts @@ -11,6 +11,7 @@ import Intl from 'ember-intl/services/intl'; import { Permission } from 'ember-osf-web/models/osf-model'; import { ReviewsState, ReviewsWorkFlow } from 'ember-osf-web/models/provider'; import { tracked } from '@glimmer/tracking'; +import { extractDoi } from 'ember-osf-web/utils/doi'; /** @@ -127,6 +128,10 @@ export default class PrePrintsDetailController extends Controller { return this.model.contributors; } + get doi(): string { + return extractDoi(this.model.preprint.articleDoiUrl) || ''; + } + @action toggleLicenseText(): void { this.showLicenseText = !this.showLicenseText; diff --git a/app/preprints/detail/template.hbs b/app/preprints/detail/template.hbs index 1105f89b58e..fc0c618031e 100644 --- a/app/preprints/detail/template.hbs +++ b/app/preprints/detail/template.hbs @@ -123,7 +123,7 @@ data-analytics-scope='preprints detail page' data-analytics-name='peer review publication doi' @href={{this.model.preprint.articleDoiUrl}} > - {{extract-doi this.model.preprint.articleDoiUrl}} + {{this.doi}}
{{/if}} diff --git a/mirage/factories/preprint.ts b/mirage/factories/preprint.ts index 2bbf1e1b48f..4e93f9e653a 100644 --- a/mirage/factories/preprint.ts +++ b/mirage/factories/preprint.ts @@ -7,6 +7,15 @@ import { ReviewsState } from 'ember-osf-web/models/provider'; import { guid, guidAfterCreate} from './utils'; +function buildLicenseText(): string { + let text = faker.lorem.sentence(100); + [250, 100, 250, 300].map((length: number) => { + text = `${text}\n\n${faker.lorem.sentence(length)}`; + }); + return text; +} + + export default Factory.extend({ id: guid('preprint'), title: faker.lorem.sentence(), @@ -21,8 +30,6 @@ export default Factory.extend({ description: faker.lorem.sentence(), - license: null, - licenseRecord: { copyright_holders: [ 'Futa', @@ -32,6 +39,7 @@ export default Factory.extend({ year: '2023', }, + doi: null, afterCreate(newPreprint, server) { guidAfterCreate(newPreprint, server); @@ -72,6 +80,14 @@ export default Factory.extend({ index: 0, }); + const license = server.create('license', { + id: 'asdksusslsh', + name: 'Mozilla Public License 2.0', + text: buildLicenseText(), + url: 'https://creativecommons.org/licenses/by/4.0/legalcode', + requiredFields: [], + }); + const secondContributor = server.create('contributor'); const unregisteredContributor = server.create('contributor', 'unregistered'); @@ -83,6 +99,7 @@ export default Factory.extend({ bibliographicContributors: allContributors, files: [file], primaryFile: file, + license, }); }, diff --git a/mirage/scenarios/preprints.ts b/mirage/scenarios/preprints.ts index 2c491633c93..67900eb3935 100644 --- a/mirage/scenarios/preprints.ts +++ b/mirage/scenarios/preprints.ts @@ -14,14 +14,6 @@ export function preprintsScenario( buildThesisCommons(server, currentUser); } -function buildLicenseText(): string { - let text = faker.lorem.sentence(100); - [250, 100, 250, 300].map((length: number) => { - text = `${text}\n\n${faker.lorem.sentence(length)}`; - }); - return text; -} - function buildOSF( server: Server, currentUser: ModelInstance, @@ -36,14 +28,6 @@ function buildOSF( const currentUserModerator = server.create('moderator', { id: currentUser.id, user: currentUser, provider: osf }, 'asAdmin'); - const license = server.create('license', { - id: 'asdksusslsh', - name: 'Mozilla Public License 2.0', - text: buildLicenseText(), - url: 'https://creativecommons.org/licenses/by/4.0/legalcode', - requiredFields: [], - }); - const rejectedAdminPreprint = server.create('preprint', { provider: osf, id: 'osf-rejected-admin', @@ -58,7 +42,7 @@ function buildOSF( title: 'Preprint RWF: Pre-moderation, Admin and Approved', currentUserPermissions: [Permission.Admin], reviewsState: ReviewsState.APPROVED, - license, + doi: '10.30822/artk.v1i1.79', }); const rejectedPreprint = server.create('preprint', { @@ -76,7 +60,6 @@ function buildOSF( currentUserPermissions: [], reviewsState: ReviewsState.APPROVED, description: `${faker.lorem.sentence(200)}\n${faker.lorem.sentence(300)}`, - license, }); const orphanedPreprint = server.create('preprint', { diff --git a/mirage/serializers/preprint.ts b/mirage/serializers/preprint.ts index a2b0c49c115..956d59926c2 100644 --- a/mirage/serializers/preprint.ts +++ b/mirage/serializers/preprint.ts @@ -9,6 +9,7 @@ export default class PreprintSerializer extends ApplicationSerializer Date: Fri, 8 Sep 2023 11:50:19 -0600 Subject: [PATCH 074/170] Added original date published --- app/models/preprint.ts | 3 ++- app/preprints/detail/controller.ts | 10 +--------- app/preprints/detail/route.ts | 12 ++---------- app/preprints/detail/styles.scss | 13 +++++++++++-- app/preprints/detail/template.hbs | 22 +++++++++++++++------- mirage/config.ts | 5 +++++ mirage/factories/preprint.ts | 28 ++++++++++++++++++++-------- mirage/scenarios/preprints.ts | 2 ++ mirage/serializers/preprint.ts | 4 ++-- translations/en-us.yml | 2 ++ 10 files changed, 62 insertions(+), 39 deletions(-) diff --git a/app/models/preprint.ts b/app/models/preprint.ts index bd79239db2b..c5c02391e83 100644 --- a/app/models/preprint.ts +++ b/app/models/preprint.ts @@ -15,6 +15,7 @@ export default class PreprintModel extends OsfModel { @attr('fixstring') title!: string; @attr('date') dateCreated!: Date; @attr('date') datePublished!: Date; + @attr('date') dateWithdrawn!: Date; @attr('date') originalPublicationDate!: Date | null; @attr('date') dateModified!: Date; @attr('fixstring') doi!: string | null; @@ -52,7 +53,7 @@ export default class PreprintModel extends OsfModel { @hasMany('contributor', { inverse: null }) bibliographicContributors!: AsyncHasMany; - @hasMany('subject', { inverse: null, async: false }) + @hasMany('subject', { inverse: null}) subjects!: SyncHasMany; @alias('links.doi') articleDoiUrl!: string | null; diff --git a/app/preprints/detail/controller.ts b/app/preprints/detail/controller.ts index 5990f8057dc..b8fd1efcf0d 100644 --- a/app/preprints/detail/controller.ts +++ b/app/preprints/detail/controller.ts @@ -119,7 +119,7 @@ export default class PrePrintsDetailController extends Controller { ) || this.isPendingWithdrawal; } - disciplineReduced(): [] { + get disciplineReduced(): [] { // Preprint disciplines are displayed in collapsed form on content page return this.model.subjects.reduce((acc: SubjectModel[], val: SubjectModel) => acc.concat(val), []).uniqBy('id'); } @@ -137,14 +137,6 @@ export default class PrePrintsDetailController extends Controller { this.showLicenseText = !this.showLicenseText; } - get fullLicenseText(): string { - const text = this.model.license.text || ''; - const { year = '', copyright_holders = [] } = this.model.preprint.licenseRecord; - return text - .replace(/({{year}})/g, year) - .replace(/({{copyrightHolders}})/g, copyright_holders.join(', ')); - } - get hasShortenedDescription(): String { return this.model.preprint.description && this.model.preprint.description.length > 350; } diff --git a/app/preprints/detail/route.ts b/app/preprints/detail/route.ts index 3855995ff1c..5ed2bce7254 100644 --- a/app/preprints/detail/route.ts +++ b/app/preprints/detail/route.ts @@ -49,20 +49,11 @@ export default class PreprintsDetail extends Route { this.theme.set('providerType', 'preprint'); this.theme.set('id', provider.id); - const contributors = await preprint?.queryHasMany('contributors'); const license = await preprint?.get('license'); - // const license = await preprint?.queryHasMany('license'); - - /* - const blank = await preprint?.queryHasMany('blank', { - page: { - size: 20, - }, - }); - */ + const subjects = await preprint?.queryHasMany('subjects'); return { preprint, @@ -71,6 +62,7 @@ export default class PreprintsDetail extends Route { provider, primaryFile, license, + subjects, }; } catch (error) { diff --git a/app/preprints/detail/styles.scss b/app/preprints/detail/styles.scss index ec7979cb0ff..1aceb835a0c 100644 --- a/app/preprints/detail/styles.scss +++ b/app/preprints/detail/styles.scss @@ -47,7 +47,7 @@ .btn-primary { color: $color-text-white; - background-color: #337ab7; + background-color: $color-bg-blue-dark; border-color: #2e6da4; } @@ -149,7 +149,7 @@ line-height: 1.42857; word-wrap: break-word; background-color: #f5f5f5; - border: 1px solid #ccc; + border: 1px solid $color-shadow-gray-light; border-radius: 4px; } @@ -157,6 +157,15 @@ cursor: pointer; } } + + .subject-preview { + display: inline-block; + background-color: $bg-light; + border-radius: 3px; + border: 1px solid $color-light; + padding: 1px 7px; + margin-bottom: 4px; + } } } } diff --git a/app/preprints/detail/template.hbs b/app/preprints/detail/template.hbs index fc0c618031e..979e0682317 100644 --- a/app/preprints/detail/template.hbs +++ b/app/preprints/detail/template.hbs @@ -55,9 +55,9 @@ data-analytics-scope='preprints detail page'
{{t this.dateLabel}}: {{moment-format this.model.dateCreated 'MMMM DD, YYYY'}} {{#if this.isWithdrawn}} - | {{t 'preprints.detail.header.withdrawn_on'}}: {{moment-format this.model.dateWithdrawn 'MMMM DD, YYYY'}} + | {{t 'preprints.detail.header.withdrawn_on'}}: {{moment-format this.model.preprint.dateWithdrawn 'MMMM DD, YYYY'}} {{else}} - | {{t 'preprints.detail.header.last_edited'}}: {{moment-format this.model.dateModified 'MMMM DD, YYYY'}} + | {{t 'preprints.detail.header.last_edited'}}: {{moment-format this.model.preprint.dateModified 'MMMM DD, YYYY'}} {{/if}}
@@ -137,19 +137,27 @@ data-analytics-scope='preprints detail page' /> {{#if this.showLicenseText}} -
{{this.fullLicenseText}}
+
{{this.model.preprint.licenseText}}
{{/if}}
{{/if}}
- {{!Disciplines}} +

{{t 'preprints.detail.disciplines'}}

+ {{#each this.disciplineReduced as |subject|}} + {{subject.text}} + {{/each}}
{{!Tags}}
-
- {{!Original Publication Date}} -
+ {{#if this.model.preprint.originalPublicationDate}} +
+

{{t 'preprints.detail.original_publication_date'}}

+

+ {{moment-format this.model.preprint.originalPublicationDate 'YYYY-MM-DD'}} +

+
+ {{/if}}
{{!Citations}}
diff --git a/mirage/config.ts b/mirage/config.ts index 3480a057d91..fc6271093d2 100644 --- a/mirage/config.ts +++ b/mirage/config.ts @@ -334,6 +334,11 @@ export default function(this: Server) { defaultSortKey: 'index', relatedModelName: 'file', }); + osfNestedResource(this, 'preprint', 'subjects', { + path: '/preprints/:parentID/subjects/', + defaultSortKey: 'index', + relatedModelName: 'subject', + }); osfResource(this, 'registration-provider', { path: '/providers/registrations' }); diff --git a/mirage/factories/preprint.ts b/mirage/factories/preprint.ts index 4e93f9e653a..604731159be 100644 --- a/mirage/factories/preprint.ts +++ b/mirage/factories/preprint.ts @@ -39,6 +39,8 @@ export default Factory.extend({ year: '2023', }, + dateWithdrawn: null, + doi: null, afterCreate(newPreprint, server) { @@ -69,6 +71,20 @@ export default Factory.extend({ }), */ + const license = server.create('license', { + id: 'asdksusslsh', + name: 'Mozilla Public License 2.0', + text: buildLicenseText(), + url: 'https://creativecommons.org/licenses/by/4.0/legalcode', + requiredFields: [], + }); + + const subjects = [ + server.create('subject', 'withChildren'), + server.create('subject'), + server.create('subject', 'withChildren'), + ]; + const contributorUser = server.create('user', { givenName: 'Emmit', familyName: 'Stud', @@ -80,14 +96,6 @@ export default Factory.extend({ index: 0, }); - const license = server.create('license', { - id: 'asdksusslsh', - name: 'Mozilla Public License 2.0', - text: buildLicenseText(), - url: 'https://creativecommons.org/licenses/by/4.0/legalcode', - requiredFields: [], - }); - const secondContributor = server.create('contributor'); const unregisteredContributor = server.create('contributor', 'unregistered'); @@ -100,6 +108,10 @@ export default Factory.extend({ files: [file], primaryFile: file, license, + subjects, + date_created: new Date('2018-05-05T14:49:27.746938Z'), + date_modified: new Date('2018-07-02T11:51:07.837747Z'), + date_published: new Date('2018-05-05T14:54:01.681202Z'), }); }, diff --git a/mirage/scenarios/preprints.ts b/mirage/scenarios/preprints.ts index 67900eb3935..a005f338a3a 100644 --- a/mirage/scenarios/preprints.ts +++ b/mirage/scenarios/preprints.ts @@ -43,6 +43,7 @@ function buildOSF( currentUserPermissions: [Permission.Admin], reviewsState: ReviewsState.APPROVED, doi: '10.30822/artk.v1i1.79', + originalPublicationDate: new Date('2016-11-30T16:00:00.000000Z'), }); const rejectedPreprint = server.create('preprint', { @@ -60,6 +61,7 @@ function buildOSF( currentUserPermissions: [], reviewsState: ReviewsState.APPROVED, description: `${faker.lorem.sentence(200)}\n${faker.lorem.sentence(300)}`, + originalPublicationDate: new Date('2016-11-30T16:00:00.000000Z'), }); const orphanedPreprint = server.create('preprint', { diff --git a/mirage/serializers/preprint.ts b/mirage/serializers/preprint.ts index 956d59926c2..f63990f865f 100644 --- a/mirage/serializers/preprint.ts +++ b/mirage/serializers/preprint.ts @@ -63,15 +63,15 @@ export default class PreprintSerializer extends ApplicationSerializer Date: Mon, 11 Sep 2023 10:09:32 -0600 Subject: [PATCH 075/170] Added tags to the preprint detail page --- app/models/preprint.ts | 1 + app/preprints/detail/styles.scss | 1 + app/preprints/detail/template.hbs | 9 ++++++++- mirage/factories/preprint.ts | 4 ++++ mirage/scenarios/preprints.ts | 2 ++ translations/en-us.yml | 2 ++ 6 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/models/preprint.ts b/app/models/preprint.ts index c5c02391e83..444ba1d3de1 100644 --- a/app/models/preprint.ts +++ b/app/models/preprint.ts @@ -28,6 +28,7 @@ export default class PreprintModel extends OsfModel { @attr('date') dateLastTransitioned!: Date; @attr('date') preprintDoiCreated!: Date; @attr('array') currentUserPermissions!: string[]; + @attr('fixstringarray') tags!: string[]; @belongsTo('node', { inverse: 'preprint' }) node!: AsyncBelongsTo & NodeModel; diff --git a/app/preprints/detail/styles.scss b/app/preprints/detail/styles.scss index 1aceb835a0c..633b84e80e7 100644 --- a/app/preprints/detail/styles.scss +++ b/app/preprints/detail/styles.scss @@ -158,6 +158,7 @@ } } + .badge, .subject-preview { display: inline-block; background-color: $bg-light; diff --git a/app/preprints/detail/template.hbs b/app/preprints/detail/template.hbs index 979e0682317..1e45a913a42 100644 --- a/app/preprints/detail/template.hbs +++ b/app/preprints/detail/template.hbs @@ -148,7 +148,14 @@ data-analytics-scope='preprints detail page' {{/each}}
- {{!Tags}} +

{{t 'preprints.detail.tags'}}

+ {{#if this.model.preprint.tags.length}} + {{#each this.model.preprint.tags as |tag|}} + {{tag}} + {{/each}} + {{else}} + {{t 'preprints.detail.none'}} + {{/if}}
{{#if this.model.preprint.originalPublicationDate}}
diff --git a/mirage/factories/preprint.ts b/mirage/factories/preprint.ts index 604731159be..14314d1341d 100644 --- a/mirage/factories/preprint.ts +++ b/mirage/factories/preprint.ts @@ -43,6 +43,10 @@ export default Factory.extend({ doi: null, + tags() { + return faker.lorem.words(5).split(' '); + }, + afterCreate(newPreprint, server) { guidAfterCreate(newPreprint, server); diff --git a/mirage/scenarios/preprints.ts b/mirage/scenarios/preprints.ts index a005f338a3a..337a3c64d44 100644 --- a/mirage/scenarios/preprints.ts +++ b/mirage/scenarios/preprints.ts @@ -34,6 +34,7 @@ function buildOSF( title: 'Preprint RWF: Pre-moderation, Admin and Rejected', currentUserPermissions: [Permission.Admin], reviewsState: ReviewsState.REJECTED, + tags: [], }); const approvedAdminPreprint = server.create('preprint', { @@ -52,6 +53,7 @@ function buildOSF( title: 'Preprint RWF: Pre-moderation, Non-Admin and Rejected', currentUserPermissions: [], reviewsState: ReviewsState.REJECTED, + tags: [], }); const approvedPreprint = server.create('preprint', { diff --git a/translations/en-us.yml b/translations/en-us.yml index ccf4c37b979..f0a61feda12 100644 --- a/translations/en-us.yml +++ b/translations/en-us.yml @@ -1143,6 +1143,8 @@ preprints: license: 'License' disciplines: 'Disciplines' original_publication_date: 'Original publication date' + tags: 'Tags' + none: 'None' header: osf_registrations: 'OSF Preprints' registrations: 'Preprints' From 14955bf5075897d8ca555857c4b07d96328e0955 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Mon, 11 Sep 2023 11:46:58 -0600 Subject: [PATCH 076/170] Added citations and a lot of stuff that I have no idea about without Futa --- app/models/preprint.ts | 4 +++ app/preprints/detail/route.ts | 3 +- app/preprints/detail/styles.scss | 8 ++--- app/preprints/detail/template.hbs | 3 +- .../components/citation-viewer/component.ts | 3 +- mirage/config.ts | 2 +- mirage/factories/preprint.ts | 2 ++ mirage/scenarios/preprints.ts | 2 ++ mirage/serializers/preprint.ts | 27 ++--------------- translations/en-us.yml | 29 ++++++++++--------- 10 files changed, 37 insertions(+), 46 deletions(-) diff --git a/app/models/preprint.ts b/app/models/preprint.ts index 444ba1d3de1..8f2f84da48e 100644 --- a/app/models/preprint.ts +++ b/app/models/preprint.ts @@ -1,6 +1,7 @@ import { attr, belongsTo, hasMany, SyncHasMany, AsyncBelongsTo, AsyncHasMany } from '@ember-data/model'; import { computed } from '@ember/object'; import { alias } from '@ember/object/computed'; +import CitationModel from 'ember-osf-web/models/citation'; import ContributorModel from './contributor'; import FileModel from './file'; @@ -54,6 +55,9 @@ export default class PreprintModel extends OsfModel { @hasMany('contributor', { inverse: null }) bibliographicContributors!: AsyncHasMany; + @belongsTo('citation', { inverse: null }) + citation!: AsyncBelongsTo; + @hasMany('subject', { inverse: null}) subjects!: SyncHasMany; diff --git a/app/preprints/detail/route.ts b/app/preprints/detail/route.ts index 5ed2bce7254..d6578bcef16 100644 --- a/app/preprints/detail/route.ts +++ b/app/preprints/detail/route.ts @@ -40,7 +40,8 @@ export default class PreprintsDetail extends Route { const guid = params.guid; // eslint-disable-next-line max-len - const preprint = await this.store.findRecord('preprint', guid, {include: 'bibliographicContributors' }); + const preprint = await this.store.findRecord('preprint', guid, {include: ['bibliographicContributors', 'citation'] }); + const provider = await preprint?.get('provider'); diff --git a/app/preprints/detail/styles.scss b/app/preprints/detail/styles.scss index 633b84e80e7..f885382e8e3 100644 --- a/app/preprints/detail/styles.scss +++ b/app/preprints/detail/styles.scss @@ -80,7 +80,6 @@ .data-container-right { padding: 0 15px; width: 50%; - height: 700px; display: flex; flex-direction: column; justify-content: flex-start; @@ -88,6 +87,8 @@ } .data-container-left { + height: 700px; + &.expanded { width: 100%; } @@ -96,9 +97,6 @@ width: 50%; } - } - - .data-container-left { .file-description-container { display: flex; flex-direction: row; @@ -122,6 +120,8 @@ } .data-container-right { + height: 100%; + .abstract-truncated::after { content: ' \2026'; } diff --git a/app/preprints/detail/template.hbs b/app/preprints/detail/template.hbs index 1e45a913a42..950caaaba41 100644 --- a/app/preprints/detail/template.hbs +++ b/app/preprints/detail/template.hbs @@ -166,7 +166,8 @@ data-analytics-scope='preprints detail page'
{{/if}}
- {{!Citations}} +

{{t 'preprints.detail.citations'}}

+
{{/unless}} diff --git a/lib/osf-components/addon/components/citation-viewer/component.ts b/lib/osf-components/addon/components/citation-viewer/component.ts index 484a24de0ee..c4b16a8c20f 100644 --- a/lib/osf-components/addon/components/citation-viewer/component.ts +++ b/lib/osf-components/addon/components/citation-viewer/component.ts @@ -29,7 +29,7 @@ const defaultCitations: DefaultCitation[] = [ ]; function citationUrl(citable: Node | Preprint, citationStyleId: string) { - const relatedHref = getRelatedHref(citable.links.relationships!.citation); + const relatedHref = getRelatedHref(citable?.links.relationships!.citation); if (!relatedHref) { throw Error('Error getting citation URL'); @@ -46,6 +46,7 @@ export default class CitationViewer extends Component { // Required parameter citable!: Node | Preprint; + // Private properties @service store!: Store; @service currentUser!: CurrentUser; diff --git a/mirage/config.ts b/mirage/config.ts index fc6271093d2..679729d2c2d 100644 --- a/mirage/config.ts +++ b/mirage/config.ts @@ -339,7 +339,7 @@ export default function(this: Server) { defaultSortKey: 'index', relatedModelName: 'subject', }); - + this.get('/preprints/:guid/citation/:citationStyleID', getCitation); osfResource(this, 'registration-provider', { path: '/providers/registrations' }); osfNestedResource(this, 'registration-provider', 'moderators', { diff --git a/mirage/factories/preprint.ts b/mirage/factories/preprint.ts index 14314d1341d..7b19848404a 100644 --- a/mirage/factories/preprint.ts +++ b/mirage/factories/preprint.ts @@ -47,6 +47,8 @@ export default Factory.extend({ return faker.lorem.words(5).split(' '); }, + citation: null, + afterCreate(newPreprint, server) { guidAfterCreate(newPreprint, server); diff --git a/mirage/scenarios/preprints.ts b/mirage/scenarios/preprints.ts index 337a3c64d44..a3dcca36697 100644 --- a/mirage/scenarios/preprints.ts +++ b/mirage/scenarios/preprints.ts @@ -28,6 +28,7 @@ function buildOSF( const currentUserModerator = server.create('moderator', { id: currentUser.id, user: currentUser, provider: osf }, 'asAdmin'); + const rejectedAdminPreprint = server.create('preprint', { provider: osf, id: 'osf-rejected-admin', @@ -37,6 +38,7 @@ function buildOSF( tags: [], }); + const approvedAdminPreprint = server.create('preprint', { provider: osf, id: 'osf-approved-admin', diff --git a/mirage/serializers/preprint.ts b/mirage/serializers/preprint.ts index f63990f865f..df51895f1d5 100644 --- a/mirage/serializers/preprint.ts +++ b/mirage/serializers/preprint.ts @@ -58,7 +58,7 @@ export default class PreprintSerializer extends ApplicationSerializer Date: Tue, 12 Sep 2023 11:58:41 -0600 Subject: [PATCH 077/170] Added the preprint doi --- app/preprints/detail/controller.ts | 6 +++++- app/preprints/detail/route.ts | 1 - app/preprints/detail/styles.scss | 2 +- app/preprints/detail/template.hbs | 24 ++++++++++++++++++++++-- mirage/factories/preprint.ts | 2 ++ mirage/scenarios/preprints.ts | 14 ++++++++++++++ mirage/serializers/preprint.ts | 1 + translations/en-us.yml | 4 ++++ 8 files changed, 49 insertions(+), 5 deletions(-) diff --git a/app/preprints/detail/controller.ts b/app/preprints/detail/controller.ts index b8fd1efcf0d..5bbee717fd4 100644 --- a/app/preprints/detail/controller.ts +++ b/app/preprints/detail/controller.ts @@ -128,7 +128,11 @@ export default class PrePrintsDetailController extends Controller { return this.model.contributors; } - get doi(): string { + get preprintDoi(): string { + return extractDoi(this.model.preprint.preprintDoiUrl) || ''; + } + + get articleDoi(): string { return extractDoi(this.model.preprint.articleDoiUrl) || ''; } diff --git a/app/preprints/detail/route.ts b/app/preprints/detail/route.ts index d6578bcef16..4ddaaee39e1 100644 --- a/app/preprints/detail/route.ts +++ b/app/preprints/detail/route.ts @@ -42,7 +42,6 @@ export default class PreprintsDetail extends Route { // eslint-disable-next-line max-len const preprint = await this.store.findRecord('preprint', guid, {include: ['bibliographicContributors', 'citation'] }); - const provider = await preprint?.get('provider'); const primaryFile = await preprint?.get('primaryFile'); diff --git a/app/preprints/detail/styles.scss b/app/preprints/detail/styles.scss index f885382e8e3..198e1135d9b 100644 --- a/app/preprints/detail/styles.scss +++ b/app/preprints/detail/styles.scss @@ -87,7 +87,7 @@ } .data-container-left { - height: 700px; + height: 1150px; &.expanded { width: 100%; diff --git a/app/preprints/detail/template.hbs b/app/preprints/detail/template.hbs index 950caaaba41..7ed936febd4 100644 --- a/app/preprints/detail/template.hbs +++ b/app/preprints/detail/template.hbs @@ -113,7 +113,27 @@ data-analytics-scope='preprints detail page' {{!Supplement Materials}}
- {{!Preprint DOI}} +

{{t 'preprints.detail.preprint_doi' documentType=this.model.provider.documentType.singular}}

+ {{#if this.model.preprint.preprintDoiUrl}} + {{#if this.model.preprint.preprintDoiCreated}} + + {{this.preprintDoi}} + + {{else}} +

{{this.preprintDoi}}

+

{{t 'preprints.detail.preprint_pending_doi_minted'}}

+ {{/if}} + {{else}} + {{#if (not this.model.preprint.public)}} + {{t 'preprints.detail.preprint_pending_doi' documentType=this.model.provider.documentType.singular }} + {{else if (and this.model.provider.reviewsWorkflow (not this.model.preprint.isPublished))}} + {{t 'preprints.detail.preprint_pending_doi_moderation'}} + {{/if}} + {{/if}}
{{#if this.model.preprint.articleDoiUrl}}
@@ -123,7 +143,7 @@ data-analytics-scope='preprints detail page' data-analytics-name='peer review publication doi' @href={{this.model.preprint.articleDoiUrl}} > - {{this.doi}} + {{this.articleDoi}}
{{/if}} diff --git a/mirage/factories/preprint.ts b/mirage/factories/preprint.ts index 7b19848404a..70ccc52652b 100644 --- a/mirage/factories/preprint.ts +++ b/mirage/factories/preprint.ts @@ -49,6 +49,8 @@ export default Factory.extend({ citation: null, + isPublished: true, + afterCreate(newPreprint, server) { guidAfterCreate(newPreprint, server); diff --git a/mirage/scenarios/preprints.ts b/mirage/scenarios/preprints.ts index a3dcca36697..349977118e5 100644 --- a/mirage/scenarios/preprints.ts +++ b/mirage/scenarios/preprints.ts @@ -45,8 +45,10 @@ function buildOSF( title: 'Preprint RWF: Pre-moderation, Admin and Approved', currentUserPermissions: [Permission.Admin], reviewsState: ReviewsState.APPROVED, + description: `${faker.lorem.sentence(200)}\n${faker.lorem.sentence(100)}`, doi: '10.30822/artk.v1i1.79', originalPublicationDate: new Date('2016-11-30T16:00:00.000000Z'), + preprintDoiCreated: new Date('2016-11-30T16:00:00.000000Z'), }); const rejectedPreprint = server.create('preprint', { @@ -63,9 +65,11 @@ function buildOSF( id: 'osf-approved', title: 'Preprint RWF: Pre-moderation, Non-Admin and Approved', currentUserPermissions: [], + doi: '10.30822/artk.v1i1.79', reviewsState: ReviewsState.APPROVED, description: `${faker.lorem.sentence(200)}\n${faker.lorem.sentence(300)}`, originalPublicationDate: new Date('2016-11-30T16:00:00.000000Z'), + preprintDoiCreated: new Date('2016-11-30T16:00:00.000000Z'), }); const orphanedPreprint = server.create('preprint', { @@ -86,6 +90,15 @@ function buildOSF( public: false, }); + const notPublishedPreprint = server.create('preprint', { + provider: osf, + id: 'osf-not-published', + title: 'Preprint RWF: Pre-moderation, Non-Admin and Approved', + currentUserPermissions: [], + reviewsState: ReviewsState.APPROVED, + isPublished: false, + }); + const subjects = server.createList('subject', 7); osf.update({ @@ -103,6 +116,7 @@ function buildOSF( rejectedPreprint, orphanedPreprint, privatePreprint, + notPublishedPreprint, ], description: 'This is the description for osf', }); diff --git a/mirage/serializers/preprint.ts b/mirage/serializers/preprint.ts index df51895f1d5..36d6c9447e7 100644 --- a/mirage/serializers/preprint.ts +++ b/mirage/serializers/preprint.ts @@ -10,6 +10,7 @@ export default class PreprintSerializer extends ApplicationSerializer Date: Tue, 12 Sep 2023 12:24:56 -0600 Subject: [PATCH 078/170] Added the supplemental material --- app/models/preprint.ts | 2 +- app/preprints/detail/route.ts | 49 +++---------------------------- app/preprints/detail/template.hbs | 16 ++++++++-- mirage/factories/preprint.ts | 13 ++------ mirage/serializers/preprint.ts | 10 ++++++- translations/en-us.yml | 1 + 6 files changed, 30 insertions(+), 61 deletions(-) diff --git a/app/models/preprint.ts b/app/models/preprint.ts index 8f2f84da48e..33fb52cb903 100644 --- a/app/models/preprint.ts +++ b/app/models/preprint.ts @@ -31,7 +31,7 @@ export default class PreprintModel extends OsfModel { @attr('array') currentUserPermissions!: string[]; @attr('fixstringarray') tags!: string[]; - @belongsTo('node', { inverse: 'preprint' }) + @belongsTo('node', { inverse: 'preprints' }) node!: AsyncBelongsTo & NodeModel; @belongsTo('license', { inverse: null }) diff --git a/app/preprints/detail/route.ts b/app/preprints/detail/route.ts index 4ddaaee39e1..bd11e05299f 100644 --- a/app/preprints/detail/route.ts +++ b/app/preprints/detail/route.ts @@ -40,7 +40,7 @@ export default class PreprintsDetail extends Route { const guid = params.guid; // eslint-disable-next-line max-len - const preprint = await this.store.findRecord('preprint', guid, {include: ['bibliographicContributors', 'citation'] }); + const preprint = await this.store.findRecord('preprint', guid, {include: ['bibliographicContributors'] }); const provider = await preprint?.get('provider'); @@ -53,6 +53,8 @@ export default class PreprintsDetail extends Route { const license = await preprint?.get('license'); + const node = await preprint?.get('node'); + const subjects = await preprint?.queryHasMany('subjects'); return { @@ -63,6 +65,7 @@ export default class PreprintsDetail extends Route { primaryFile, license, subjects, + node, }; } catch (error) { @@ -72,47 +75,3 @@ export default class PreprintsDetail extends Route { } } } - -/* -export default Route.extend({ - features: service(), - model(params) { - const opts = { - method: 'GET', - url: `${config.OSF.apiUrl}/${config.OSF.apiNamespace}/`, - dataType: 'json', - contentType: 'application/json', - xhrFields: { - withCredentials: true, - }, - }; - - return this.store.findRecord( - 'preprint', params.preprint_id, - { - adapterOptions: { - query: { - 'metrics[views]': 'total', - 'metrics[downloads]': 'total', - }, - }, - }, - ); - }, - actions: { - error(error) { - // Handle API Errors - if (error && !(error instanceof DS.AbortError) - && error.errors && isArray(error.errors)) { - // If the error is not a AbortError (no connection), we handle it here. - const { detail } = error.errors[0]; - const page = handlers.get(detail) || 'page-not-found'; - return this.intermediateTransitionTo(page); - } else { - // Otherwise, we bubble it to the error handler in our parent route. - return true; - } - }, - }, -}); -*/ diff --git a/app/preprints/detail/template.hbs b/app/preprints/detail/template.hbs index 7ed936febd4..d17ad8cd096 100644 --- a/app/preprints/detail/template.hbs +++ b/app/preprints/detail/template.hbs @@ -109,9 +109,19 @@ data-analytics-scope='preprints detail page' {{/if}}
-
- {{!Supplement Materials}} -
+ {{#if this.model.node}} +
+

{{t 'preprints.detail.supplemental_materials'}}

+ + {{this.model.node.links.html}} + + +
+ {{/if}}

{{t 'preprints.detail.preprint_doi' documentType=this.model.provider.documentType.singular}}

{{#if this.model.preprint.preprintDoiUrl}} diff --git a/mirage/factories/preprint.ts b/mirage/factories/preprint.ts index 70ccc52652b..77339eb3335 100644 --- a/mirage/factories/preprint.ts +++ b/mirage/factories/preprint.ts @@ -67,17 +67,7 @@ export default Factory.extend({ }, }); - /* - fileReference: () => ({ - file_id: this.id as string, - file_name: this.name as string, - file_urls: { - }, - file_hashes: { - sha256: this.extra.hashes.sha256, - }, - }), - */ + const node = server.create('node'); const license = server.create('license', { id: 'asdksusslsh', @@ -120,6 +110,7 @@ export default Factory.extend({ date_created: new Date('2018-05-05T14:49:27.746938Z'), date_modified: new Date('2018-07-02T11:51:07.837747Z'), date_published: new Date('2018-05-05T14:54:01.681202Z'), + node, }); }, diff --git a/mirage/serializers/preprint.ts b/mirage/serializers/preprint.ts index 36d6c9447e7..2ad2a81b03e 100644 --- a/mirage/serializers/preprint.ts +++ b/mirage/serializers/preprint.ts @@ -10,7 +10,7 @@ export default class PreprintSerializer extends ApplicationSerializer Date: Wed, 13 Sep 2023 11:38:37 -0600 Subject: [PATCH 079/170] Added the download option, with metrics --- app/preprints/detail/controller.ts | 8 ++-- app/preprints/detail/route.ts | 10 ++++- app/preprints/detail/styles.scss | 62 +++++++++++++++++------------- app/preprints/detail/template.hbs | 17 +++++++- mirage/config.ts | 4 ++ mirage/factories/preprint.ts | 7 ++++ mirage/serializers/preprint.ts | 13 ------- translations/en-us.yml | 6 +++ 8 files changed, 82 insertions(+), 45 deletions(-) diff --git a/app/preprints/detail/controller.ts b/app/preprints/detail/controller.ts index 5bbee717fd4..090d2025df4 100644 --- a/app/preprints/detail/controller.ts +++ b/app/preprints/detail/controller.ts @@ -66,8 +66,10 @@ export default class PrePrintsDetailController extends Controller { return window.location.href; } - fileDownloadURL() { - // return fileDownloadPath(this.model.primaryFile, this.model); + get fileDownloadUrl(): string { + const version = this.model.primaryFile.version; + const path = `${this.model.preprint.id}/download/?`; + return `${config.OSF.url}${path}${version ? `version=${version}` : ''}`.replace(/[&?]$/, ''); } facebookAppId(): string { @@ -92,7 +94,7 @@ export default class PrePrintsDetailController extends Controller { }); } - isAdmin(): boolean { + private isAdmin(): boolean { // True if the current user has admin permissions for the node that contains the preprint return (this.model.preprint.currentUserPermissions).includes(Permission.Admin); } diff --git a/app/preprints/detail/route.ts b/app/preprints/detail/route.ts index bd11e05299f..d390000d4ba 100644 --- a/app/preprints/detail/route.ts +++ b/app/preprints/detail/route.ts @@ -40,7 +40,15 @@ export default class PreprintsDetail extends Route { const guid = params.guid; // eslint-disable-next-line max-len - const preprint = await this.store.findRecord('preprint', guid, {include: ['bibliographicContributors'] }); + const preprint = await this.store.findRecord('preprint', guid, { + include: ['bibliographicContributors'], + adapterOptions: { + query: { + 'metrics[views]': 'total', + 'metrics[downloads]': 'total', + }, + }, + }); const provider = await preprint?.get('provider'); diff --git a/app/preprints/detail/styles.scss b/app/preprints/detail/styles.scss index 198e1135d9b..47dcc33383b 100644 --- a/app/preprints/detail/styles.scss +++ b/app/preprints/detail/styles.scss @@ -7,6 +7,31 @@ justify-content: center; align-items: center; + .btn { + display: inline-block; + margin-bottom: 0; + font-weight: 400; + text-align: center; + white-space: nowrap; + touch-action: manipulation; + cursor: pointer; + background-image: none; + border: 1px solid transparent; + border-radius: 2px; + padding: 6px 12px; + font-size: 14px; + line-height: 1.42857; + user-select: none; + vertical-align: middle; + color: $color-text-white; + } + + .btn-primary { + color: $color-text-white; + background-color: $color-bg-blue-dark; + border-color: #2e6da4; + } + .header-container { padding: 30px 0; width: 100%; @@ -26,31 +51,6 @@ align-items: flex-start; justify-content: center; - .btn { - display: inline-block; - margin-bottom: 0; - font-weight: 400; - text-align: center; - white-space: nowrap; - touch-action: manipulation; - cursor: pointer; - background-image: none; - border: 1px solid transparent; - border-radius: 2px; - padding: 6px 12px; - font-size: 14px; - line-height: 1.42857; - user-select: none; - vertical-align: middle; - color: $color-text-white; - } - - .btn-primary { - color: $color-text-white; - background-color: $color-bg-blue-dark; - border-color: #2e6da4; - } - .view-authors { color: $color-text-white; padding-bottom: 15px; @@ -125,6 +125,16 @@ .abstract-truncated::after { content: ' \2026'; } + + .download-container { + background-color: $bg-light; + display: flex; + flex-direction: row; + justify-content: space-between; + align-items: center; + width: 100%; + padding: 10px; + } h4 { padding-bottom: 15px; @@ -148,7 +158,7 @@ margin: 0 0 10px; line-height: 1.42857; word-wrap: break-word; - background-color: #f5f5f5; + background-color: $bg-light; border: 1px solid $color-shadow-gray-light; border-radius: 4px; } diff --git a/app/preprints/detail/template.hbs b/app/preprints/detail/template.hbs index d17ad8cd096..9e3abab55fd 100644 --- a/app/preprints/detail/template.hbs +++ b/app/preprints/detail/template.hbs @@ -86,8 +86,21 @@ data-analytics-scope='preprints detail page'
{{#unless this.fullScreenMFR }}
-
- {{!Download}} +
+ + {{t 'preprints.detail.share.download' documentType=this.model.provider.documentType.singular}} + +
+ {{t 'preprints.detail.share.views'}}: {{this.model.preprint.apiMeta.metrics.views}} | {{t 'preprints.detail.share.downloads'}}: {{this.model.preprint.apiMeta.metrics.downloads}} + + {{t 'preprints.detail.share.metrics_disclaimer'}} {{moment-format this.metricsStartDate 'YYYY-MM-DD'}} + +
{{!Plaudit }} diff --git a/mirage/config.ts b/mirage/config.ts index 679729d2c2d..f21719a2913 100644 --- a/mirage/config.ts +++ b/mirage/config.ts @@ -341,6 +341,10 @@ export default function(this: Server) { }); this.get('/preprints/:guid/citation/:citationStyleID', getCitation); + /** + * End Preprint Details + */ + osfResource(this, 'registration-provider', { path: '/providers/registrations' }); osfNestedResource(this, 'registration-provider', 'moderators', { only: ['index', 'show', 'update', 'delete'], diff --git a/mirage/factories/preprint.ts b/mirage/factories/preprint.ts index 77339eb3335..2c5a6805adc 100644 --- a/mirage/factories/preprint.ts +++ b/mirage/factories/preprint.ts @@ -51,6 +51,13 @@ export default Factory.extend({ isPublished: true, + apiMeta: { + metrics: { + downloads: faker.random.number(1000), + views: faker.random.number(10000), + }, + }, + afterCreate(newPreprint, server) { guidAfterCreate(newPreprint, server); diff --git a/mirage/serializers/preprint.ts b/mirage/serializers/preprint.ts index 2ad2a81b03e..a22f98440c5 100644 --- a/mirage/serializers/preprint.ts +++ b/mirage/serializers/preprint.ts @@ -106,19 +106,6 @@ export default class PreprintSerializer extends ApplicationSerializer Date: Wed, 13 Sep 2023 12:29:07 -0600 Subject: [PATCH 080/170] Initial work on the social icons --- app/preprints/detail/controller.ts | 2 +- app/preprints/detail/styles.scss | 23 +++++++++++++++++ app/preprints/detail/template.hbs | 25 ++++++++++++++++++- .../components/sharing-icons/component.ts | 12 +++++++++ .../components/sharing-icons/template.hbs | 8 ++++++ 5 files changed, 68 insertions(+), 2 deletions(-) diff --git a/app/preprints/detail/controller.ts b/app/preprints/detail/controller.ts index 090d2025df4..cbf67aa1a0d 100644 --- a/app/preprints/detail/controller.ts +++ b/app/preprints/detail/controller.ts @@ -72,7 +72,7 @@ export default class PrePrintsDetailController extends Controller { return `${config.OSF.url}${path}${version ? `version=${version}` : ''}`.replace(/[&?]$/, ''); } - facebookAppId(): string { + get facebookAppId(): string { return this.model.provider.facebookAppId ? this.model.provider.facebookAppId : config.FB_APP_ID; } diff --git a/app/preprints/detail/styles.scss b/app/preprints/detail/styles.scss index 47dcc33383b..d4d397c7fb8 100644 --- a/app/preprints/detail/styles.scss +++ b/app/preprints/detail/styles.scss @@ -126,6 +126,29 @@ content: ' \2026'; } + .plaudit-container { + display: flex; + flex-direction: row; + justify-content: flex-start; + align-items: center; + width: 100%; + height: 90px; + + .plaudit { + width: calc(100% - 145px); + padding-right: 30px; + } + + .sharing-icons { + font-size: 1.5rem; + display: flex; + flex-direction: row; + justify-content: space-between; + align-items: flex-start; + width: 145px; + } + } + .download-container { background-color: $bg-light; display: flex; diff --git a/app/preprints/detail/template.hbs b/app/preprints/detail/template.hbs index 9e3abab55fd..8502040cbee 100644 --- a/app/preprints/detail/template.hbs +++ b/app/preprints/detail/template.hbs @@ -102,7 +102,30 @@ data-analytics-scope='preprints detail page'
-
+
+
+ +
+ {{links.email}} +
+
+ {{links.twitter}} +
+
+ {{links.facebook}} +
+
+ {{links.linkedIn}} +
+
{{!Plaudit }}
diff --git a/lib/osf-components/addon/components/sharing-icons/component.ts b/lib/osf-components/addon/components/sharing-icons/component.ts index 5c0feb796c7..e87995a9b68 100644 --- a/lib/osf-components/addon/components/sharing-icons/component.ts +++ b/lib/osf-components/addon/components/sharing-icons/component.ts @@ -49,4 +49,16 @@ export default class SharingIcons extends Component { }; return `mailto:?${param(queryParams)}`; } + + @computed('hyperlink', 'title', 'description') + get linkedInHref(): string { + const queryParams = { + url: this.hyperlink, + mini: true, + title: this.title, + summary: this.description || this.title, + source: 'OSF', + }; + return `https://www.linkedin.com/shareArticle?${param(queryParams)}`; + } } diff --git a/lib/osf-components/addon/components/sharing-icons/template.hbs b/lib/osf-components/addon/components/sharing-icons/template.hbs index 951e985e9f7..e9c61fb57a6 100644 --- a/lib/osf-components/addon/components/sharing-icons/template.hbs +++ b/lib/osf-components/addon/components/sharing-icons/template.hbs @@ -13,6 +13,13 @@ icon='facebook-square' showText=@showText ) + linkedIn=(component 'sharing-icons/sharing-anchor' + href=this.linkedInHref + medium='LinkedIn' + analyticsName='Share - linkedIn' + icon='linkedin' + showText=@showText + ) email=(component 'sharing-icons/sharing-anchor' href=this.emailHref medium='Email' @@ -25,6 +32,7 @@ {{else}} {{links.twitter}} {{links.facebook}} + {{links.linkedIn}} {{links.email}} {{/if}} {{/let}} From 1e4a9e037a57a0acf7a4e000460b81ade5b6e21c Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Thu, 14 Sep 2023 11:33:05 -0600 Subject: [PATCH 081/170] Added the plaudit widget --- app/config/environment.d.ts | 3 ++- app/preprints/-components/plaudit-widget/component.ts | 6 ++++++ app/preprints/-components/plaudit-widget/template.hbs | 4 ++++ app/preprints/detail/template.hbs | 4 +++- config/environment.js | 2 ++ 5 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 app/preprints/-components/plaudit-widget/component.ts create mode 100644 app/preprints/-components/plaudit-widget/template.hbs diff --git a/app/config/environment.d.ts b/app/config/environment.d.ts index edbdf06bf75..431a071b310 100644 --- a/app/config/environment.d.ts +++ b/app/config/environment.d.ts @@ -18,7 +18,8 @@ export interface KeenConfig { } declare const config: { - WATER_BUTLER_ENABLED: any; + WATER_BUTLER_ENABLED: boolean; + PLAUDIT_WIDGET_URL: string, environment: any; lintOnBuild: boolean; testsEnabled: boolean; diff --git a/app/preprints/-components/plaudit-widget/component.ts b/app/preprints/-components/plaudit-widget/component.ts new file mode 100644 index 00000000000..17424d53ba6 --- /dev/null +++ b/app/preprints/-components/plaudit-widget/component.ts @@ -0,0 +1,6 @@ +import Component from '@glimmer/component'; +import config from 'ember-get-config'; + +export default class PlauditWidget extends Component { + plauditWidgetUrl = config.PLAUDIT_WIDGET_URL; +} diff --git a/app/preprints/-components/plaudit-widget/template.hbs b/app/preprints/-components/plaudit-widget/template.hbs new file mode 100644 index 00000000000..a2877ce8cb8 --- /dev/null +++ b/app/preprints/-components/plaudit-widget/template.hbs @@ -0,0 +1,4 @@ + \ No newline at end of file diff --git a/app/preprints/detail/template.hbs b/app/preprints/detail/template.hbs index 8502040cbee..28f0dafe11f 100644 --- a/app/preprints/detail/template.hbs +++ b/app/preprints/detail/template.hbs @@ -103,7 +103,9 @@ data-analytics-scope='preprints detail page'
-
+
+ +
Date: Fri, 15 Sep 2023 10:10:14 -0600 Subject: [PATCH 082/170] Added the final touches for mobile views --- app/preprints/detail/controller.ts | 6 +++ app/preprints/detail/styles.scss | 86 +++++++++++++++++++++++++++++- app/preprints/detail/template.hbs | 55 ++++++++++--------- mirage/factories/preprint.ts | 4 +- 4 files changed, 125 insertions(+), 26 deletions(-) diff --git a/app/preprints/detail/controller.ts b/app/preprints/detail/controller.ts index cbf67aa1a0d..c31c59e5523 100644 --- a/app/preprints/detail/controller.ts +++ b/app/preprints/detail/controller.ts @@ -12,6 +12,7 @@ import { Permission } from 'ember-osf-web/models/osf-model'; import { ReviewsState, ReviewsWorkFlow } from 'ember-osf-web/models/provider'; import { tracked } from '@glimmer/tracking'; import { extractDoi } from 'ember-osf-web/utils/doi'; +import Media from 'ember-responsive'; /** @@ -44,6 +45,7 @@ export default class PrePrintsDetailController extends Controller { @service currentUser!: CurrentUserService; @service features!: Features; @service intl!: Intl; + @service media!: Media; // metricsStartDate = config.OSF.metricsStartDate; @@ -189,4 +191,8 @@ export default class PrePrintsDetailController extends Controller { trackNonContributors(category: string, label: string, url: string): void { this.send('click', category, label, url); } + + get isMobile() { + return this.media.isMobile; + } } diff --git a/app/preprints/detail/styles.scss b/app/preprints/detail/styles.scss index d4d397c7fb8..b2617734014 100644 --- a/app/preprints/detail/styles.scss +++ b/app/preprints/detail/styles.scss @@ -106,6 +106,10 @@ padding-top: 15px; .file-description { + display: flex; + flex-direction: row; + justify-content: flex-start; + align-items: flex-start; width: 75%; } @@ -132,7 +136,7 @@ justify-content: flex-start; align-items: center; width: 100%; - height: 90px; + min-height: 90px; .plaudit { width: calc(100% - 145px); @@ -202,6 +206,86 @@ } } } + + &.mobile { + .header-container { + padding: 0; + flex-direction: column; + + .preprint-author-container, + .preprint-title-container { + width: 100%; + padding: 0 10px; + } + } + + .data-container { + padding: 10px; + flex-direction: column; + justify-content: flex-start; + align-items: center; + + .data-container-left, + .data-container-right { + width: 100%; + padding: 0; + } + + .data-container-left { + height: 481px; + + .file-description-container { + flex-direction: column; + justify-content: flex-start; + margin-bottom: 20px; + + & > div { + margin-top: 10px; + } + + .file-description { + width: 100%; + flex-direction: column; + } + + .toggle-button { + width: 100%; + align-items: flex-end; + } + } + } + + .data-container-right { + .download-container { + flex-direction: column; + align-items: flex-start; + + & > div { + margin-top: 10px; + } + } + + .plaudit-container { + flex-direction: column; + align-items: flex-start; + + .plaudit { + width: 100%; + padding-right: 0; + height: 90px; + } + + .sharing-icons { + padding: 10px; + justify-content: space-between; + align-items: flex-start; + width: 145px; + } + } + } + } + } + } .bottom-margin { diff --git a/app/preprints/detail/template.hbs b/app/preprints/detail/template.hbs index 28f0dafe11f..815183279e2 100644 --- a/app/preprints/detail/template.hbs +++ b/app/preprints/detail/template.hbs @@ -1,7 +1,7 @@ {{page-title this.model.preprint.title replace=false}} -
@@ -53,25 +53,30 @@ data-analytics-scope='preprints detail page' />
- {{t this.dateLabel}}: {{moment-format this.model.dateCreated 'MMMM DD, YYYY'}} +
{{t this.dateLabel}}: {{moment-format this.model.dateCreated 'MMMM DD, YYYY'}}
+ {{#unless this.isMobile}} +
|
+ {{/unless}} {{#if this.isWithdrawn}} - | {{t 'preprints.detail.header.withdrawn_on'}}: {{moment-format this.model.preprint.dateWithdrawn 'MMMM DD, YYYY'}} +
{{t 'preprints.detail.header.withdrawn_on'}}: {{moment-format this.model.preprint.dateWithdrawn 'MMMM DD, YYYY'}}
{{else}} - | {{t 'preprints.detail.header.last_edited'}}: {{moment-format this.model.preprint.dateModified 'MMMM DD, YYYY'}} +
{{t 'preprints.detail.header.last_edited'}}: {{moment-format this.model.preprint.dateModified 'MMMM DD, YYYY'}}
{{/if}}
-
- -
+ {{#unless this.isMobile}} +
+ +
+ {{/unless}}
{{else}}
- - {{t 'preprints.detail.share.download' documentType=this.model.provider.documentType.singular}} - +
+ + {{t 'preprints.detail.share.download' documentType=this.model.provider.documentType.singular}} + +
{{t 'preprints.detail.share.views'}}: {{this.model.preprint.apiMeta.metrics.views}} | {{t 'preprints.detail.share.downloads'}}: {{this.model.preprint.apiMeta.metrics.downloads}} diff --git a/mirage/factories/preprint.ts b/mirage/factories/preprint.ts index 2c5a6805adc..fcc2abaa80c 100644 --- a/mirage/factories/preprint.ts +++ b/mirage/factories/preprint.ts @@ -105,7 +105,9 @@ export default Factory.extend({ const unregisteredContributor = server.create('contributor', 'unregistered'); - const allContributors = [contributor, unregisteredContributor, secondContributor]; + const thirdContributor = server.create('contributor'); + + const allContributors = [contributor, unregisteredContributor, secondContributor, thirdContributor]; newPreprint.update({ contributors: allContributors, From c5bf733ec541a07b27feab88697a0c9d1a747f8c Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Fri, 15 Sep 2023 10:58:55 -0600 Subject: [PATCH 083/170] Initial pass for withdrawn preprints --- app/models/preprint.ts | 5 + app/preprints/detail/controller.ts | 5 - app/preprints/detail/styles.scss | 26 ++- app/preprints/detail/template.hbs | 350 +++++++++++++++++------------ mirage/scenarios/preprints.ts | 12 +- 5 files changed, 246 insertions(+), 152 deletions(-) diff --git a/app/models/preprint.ts b/app/models/preprint.ts index 33fb52cb903..4e7d98d66d3 100644 --- a/app/models/preprint.ts +++ b/app/models/preprint.ts @@ -64,6 +64,11 @@ export default class PreprintModel extends OsfModel { @alias('links.doi') articleDoiUrl!: string | null; @alias('links.preprint_doi') preprintDoiUrl!: string; + @computed('dateWithdrawn') + get isWithdrawn(): boolean{ + return this.dateWithdrawn !== null; + } + @computed('license', 'licenseRecord') get licenseText(): string { const text = this.license.get('text') || ''; diff --git a/app/preprints/detail/controller.ts b/app/preprints/detail/controller.ts index c31c59e5523..7c4a0d7711e 100644 --- a/app/preprints/detail/controller.ts +++ b/app/preprints/detail/controller.ts @@ -54,13 +54,8 @@ export default class PrePrintsDetailController extends Controller { }; @tracked fullScreenMFR = false; - expandedAuthors = true; @tracked showLicenseText = false; - primaryFile = null; - showModalClaimUser = false; isPendingWithdrawal = false; - isWithdrawn = null; - isPlauditReady = false; @tracked expandedAbstract = navigator.userAgent.includes('Prerender'); diff --git a/app/preprints/detail/styles.scss b/app/preprints/detail/styles.scss index b2617734014..f7ae3c066bd 100644 --- a/app/preprints/detail/styles.scss +++ b/app/preprints/detail/styles.scss @@ -75,6 +75,15 @@ flex-direction: row; justify-content: flex-start; align-items: flex-start; + + .withdrawn-container { + padding: 0 15px; + width: 100%; + display: flex; + flex-direction: column; + justify-content: flex-start; + align-items: flex-start; + } .data-container-left, .data-container-right { @@ -123,9 +132,18 @@ } } + .withdrawn-container, .data-container-right { height: 100%; + h4 { + padding-bottom: 15px; + padding-top: 15px; + margin-top: 10px; + margin-bottom: 10px; + font-weight: bold; + } + .abstract-truncated::after { content: ' \2026'; } @@ -162,14 +180,6 @@ width: 100%; padding: 10px; } - - h4 { - padding-bottom: 15px; - padding-top: 15px; - margin-top: 10px; - margin-bottom: 10px; - font-weight: bold; - } .license-text { pre { diff --git a/app/preprints/detail/template.hbs b/app/preprints/detail/template.hbs index 815183279e2..790f83982da 100644 --- a/app/preprints/detail/template.hbs +++ b/app/preprints/detail/template.hbs @@ -7,7 +7,7 @@ data-analytics-scope='preprints detail page'

{{this.model.preprint.title}}

- {{#unless this.isWithdrawn}} + {{#unless this.model.preprint.isWithdrawn}}
{{#if (and this.userIsContrib (not this.isPendingWithdrawal))}} {{! removed }}
- {{! removed }} -
- {{#if this.model.preprint.isPreprintOrphan}} - - {{t 'preprints.detail.orphan_preprint'}} - - {{else}} - {{#if this.model.preprint.public}} - -
-
-
{{t this.dateLabel}}: {{moment-format this.model.dateCreated 'MMMM DD, YYYY'}}
- {{#unless this.isMobile}} -
|
- {{/unless}} - {{#if this.isWithdrawn}} -
{{t 'preprints.detail.header.withdrawn_on'}}: {{moment-format this.model.preprint.dateWithdrawn 'MMMM DD, YYYY'}}
- {{else}} -
{{t 'preprints.detail.header.last_edited'}}: {{moment-format this.model.preprint.dateModified 'MMMM DD, YYYY'}}
- {{/if}} -
- {{#unless this.isMobile}} -
- -
- {{/unless}} -
- {{else}} - - {{t 'preprints.detail.private_preprint_warning' documentType=this.model.provider.documentType.singular supportEmail='support@osf.io'}} - - {{/if}} - {{/if}} -
- {{#unless this.fullScreenMFR }} -
-
-
- - {{t 'preprints.detail.share.download' documentType=this.model.provider.documentType.singular}} - -
-
- {{t 'preprints.detail.share.views'}}: {{this.model.preprint.apiMeta.metrics.views}} | {{t 'preprints.detail.share.downloads'}}: {{this.model.preprint.apiMeta.metrics.downloads}} - - {{t 'preprints.detail.share.metrics_disclaimer'}} {{moment-format this.metricsStartDate 'YYYY-MM-DD'}} - -
-
-
-
- -
- -
- {{links.email}} -
-
- {{links.twitter}} -
-
- {{links.facebook}} -
-
- {{links.linkedIn}} -
-
- {{!Plaudit }} -
+ {{#if this.model.preprint.isWithdrawn}} +

{{t 'preprints.detail.abstract'}}

@@ -154,19 +54,6 @@ data-analytics-scope='preprints detail page' {{/if}}

- {{#if this.model.node}} -
-

{{t 'preprints.detail.supplemental_materials'}}

- - {{this.model.node.links.html}} - - -
- {{/if}}

{{t 'preprints.detail.preprint_doi' documentType=this.model.provider.documentType.singular}}

{{#if this.model.preprint.preprintDoiUrl}} @@ -190,18 +77,6 @@ data-analytics-scope='preprints detail page' {{/if}} {{/if}}
- {{#if this.model.preprint.articleDoiUrl}} -
-

{{t 'preprints.detail.article_doi'}}

- - {{this.articleDoi}} - -
- {{/if}} {{#if this.model.preprint.license.name}}

{{t 'preprints.detail.license'}}

@@ -232,20 +107,219 @@ data-analytics-scope='preprints detail page' {{t 'preprints.detail.none'}} {{/if}}
- {{#if this.model.preprint.originalPublicationDate}} +
+ {{else}} +
+ {{#if this.model.preprint.isPreprintOrphan}} + + {{t 'preprints.detail.orphan_preprint'}} + + {{else}} + {{#if this.model.preprint.public}} + +
+
+
{{t this.dateLabel}}: {{moment-format this.model.dateCreated 'MMMM DD, YYYY'}}
+ {{#unless this.isMobile}} +
|
+ {{/unless}} + {{#if this.isWithdrawn}} +
{{t 'preprints.detail.header.withdrawn_on'}}: {{moment-format this.model.preprint.dateWithdrawn 'MMMM DD, YYYY'}}
+ {{else}} +
{{t 'preprints.detail.header.last_edited'}}: {{moment-format this.model.preprint.dateModified 'MMMM DD, YYYY'}}
+ {{/if}} +
+ {{#unless this.isMobile}} +
+ +
+ {{/unless}} +
+ {{else}} + + {{t 'preprints.detail.private_preprint_warning' documentType=this.model.provider.documentType.singular supportEmail='support@osf.io'}} + + {{/if}} + {{/if}} +
+ {{#unless this.fullScreenMFR }} +
+
+
+ + {{t 'preprints.detail.share.download' documentType=this.model.provider.documentType.singular}} + +
+
+ {{t 'preprints.detail.share.views'}}: {{this.model.preprint.apiMeta.metrics.views}} | {{t 'preprints.detail.share.downloads'}}: {{this.model.preprint.apiMeta.metrics.downloads}} + + {{t 'preprints.detail.share.metrics_disclaimer'}} {{moment-format this.metricsStartDate 'YYYY-MM-DD'}} + +
+
+
+
+ +
+ +
+ {{links.email}} +
+
+ {{links.twitter}} +
+
+ {{links.facebook}} +
+
+ {{links.linkedIn}} +
+
+ {{!Plaudit }} +
-

{{t 'preprints.detail.original_publication_date'}}

-

- {{moment-format this.model.preprint.originalPublicationDate 'YYYY-MM-DD'}} +

{{t 'preprints.detail.abstract'}}

+

+ {{this.description}}

+ {{#if this.hasShortenedDescription}} + + {{/if}} +
+ {{#if this.model.node}} +
+

{{t 'preprints.detail.supplemental_materials'}}

+ + {{this.model.node.links.html}} + + +
+ {{/if}} +
+

{{t 'preprints.detail.preprint_doi' documentType=this.model.provider.documentType.singular}}

+ {{#if this.model.preprint.preprintDoiUrl}} + {{#if this.model.preprint.preprintDoiCreated}} + + {{this.preprintDoi}} + + {{else}} +

{{this.preprintDoi}}

+

{{t 'preprints.detail.preprint_pending_doi_minted'}}

+ {{/if}} + {{else}} + {{#if (not this.model.preprint.public)}} + {{t 'preprints.detail.preprint_pending_doi' documentType=this.model.provider.documentType.singular }} + {{else if (and this.model.provider.reviewsWorkflow (not this.model.preprint.isPublished))}} + {{t 'preprints.detail.preprint_pending_doi_moderation'}} + {{/if}} + {{/if}} +
+ {{#if this.model.preprint.articleDoiUrl}} +
+

{{t 'preprints.detail.article_doi'}}

+ + {{this.articleDoi}} + +
+ {{/if}} + {{#if this.model.preprint.license.name}} +
+

{{t 'preprints.detail.license'}}

+ {{this.model.preprint.license.name}} + + + + {{#if this.showLicenseText}} +
{{this.model.preprint.licenseText}}
+ {{/if}} +
+ {{/if}} +
+

{{t 'preprints.detail.disciplines'}}

+ {{#each this.disciplineReduced as |subject|}} + {{subject.text}} + {{/each}} +
+
+

{{t 'preprints.detail.tags'}}

+ {{#if this.model.preprint.tags.length}} + {{#each this.model.preprint.tags as |tag|}} + {{tag}} + {{/each}} + {{else}} + {{t 'preprints.detail.none'}} + {{/if}} +
+ {{#if this.model.preprint.originalPublicationDate}} +
+

{{t 'preprints.detail.original_publication_date'}}

+

+ {{moment-format this.model.preprint.originalPublicationDate 'YYYY-MM-DD'}} +

+
+ {{/if}} +
+

{{t 'preprints.detail.citations'}}

+
- {{/if}} -
-

{{t 'preprints.detail.citations'}}

-
-
- {{/unless}} + {{/unless}} + {{/if}} {{! removed - 1 }} {{! removed - 2 }}
diff --git a/mirage/scenarios/preprints.ts b/mirage/scenarios/preprints.ts index 349977118e5..e0866d428f0 100644 --- a/mirage/scenarios/preprints.ts +++ b/mirage/scenarios/preprints.ts @@ -38,7 +38,6 @@ function buildOSF( tags: [], }); - const approvedAdminPreprint = server.create('preprint', { provider: osf, id: 'osf-approved-admin', @@ -99,6 +98,16 @@ function buildOSF( isPublished: false, }); + const withdrawnPreprint = server.create('preprint', { + provider: osf, + id: 'osf-withdrawn', + title: 'Preprint Non-Admin, Not Published and withdrawn', + currentUserPermissions: [], + reviewsState: ReviewsState.APPROVED, + isPublished: false, + dateWithdrawn: new Date(), + }); + const subjects = server.createList('subject', 7); osf.update({ @@ -117,6 +126,7 @@ function buildOSF( orphanedPreprint, privatePreprint, notPublishedPreprint, + withdrawnPreprint, ], description: 'This is the description for osf', }); From e93251accd9ee3a1bb6153c3e4c9c65e263db971 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Tue, 26 Sep 2023 12:42:48 -0600 Subject: [PATCH 084/170] Initial commit for the preprint-status-banner component --- app/models/provider.ts | 2 + .../preprint-status-banner/component.ts | 198 ++++++++++++++++++ .../preprint-status-banner/styles.scss | 152 ++++++++++++++ .../preprint-status-banner/template.hbs | 47 +++++ app/preprints/detail/controller.ts | 4 +- app/preprints/detail/template.hbs | 4 +- translations/en-us.yml | 3 + 7 files changed, 406 insertions(+), 4 deletions(-) create mode 100644 app/preprints/-components/preprint-status-banner/component.ts create mode 100644 app/preprints/-components/preprint-status-banner/styles.scss create mode 100644 app/preprints/-components/preprint-status-banner/template.hbs diff --git a/app/models/provider.ts b/app/models/provider.ts index 0b3ee976d48..aeb63bbfe8f 100644 --- a/app/models/provider.ts +++ b/app/models/provider.ts @@ -30,6 +30,8 @@ export enum ReviewsState { INITIAL = 'initial', PENDING = 'pending', REJECTED = 'rejected', + WITHDRAWN = 'withdrawn', + PENDING_WITHDRAWAL = 'pending_withdrawal', } export enum ReviewPermissions { diff --git a/app/preprints/-components/preprint-status-banner/component.ts b/app/preprints/-components/preprint-status-banner/component.ts new file mode 100644 index 00000000000..f4110944eb6 --- /dev/null +++ b/app/preprints/-components/preprint-status-banner/component.ts @@ -0,0 +1,198 @@ +import Component from '@glimmer/component'; +import { inject as service } from '@ember/service'; +import Theme from 'ember-osf-web/services/theme'; +import Intl from 'ember-intl/services/intl'; +import PreprintModel from 'ember-osf-web/models/preprint'; + +const PENDING = 'pending'; +const ACCEPTED = 'accepted'; +const REJECTED = 'rejected'; +const PENDING_WITHDRAWAL = 'pendingWithdrawal'; +const WITHDRAWAL_REJECTED = 'withdrawalRejected'; +const WITHDRAWN = 'withdrawn'; + +const PRE_MODERATION = 'pre-moderation'; +const POST_MODERATION = 'post-moderation'; + +const ICONS = { + [PENDING]: 'fa-hourglass-o', + [ACCEPTED]: 'fa-check-circle-o', + [REJECTED]: 'fa-times-circle-o', + [PENDING_WITHDRAWAL]: 'fa-hourglass-o', + [WITHDRAWAL_REJECTED]: 'fa-times-circle-o', + [WITHDRAWN]: 'fa-exclamation-triangle', +}; + +const STATUS = { + [PENDING]: 'components.preprint-status-banner.pending', + [ACCEPTED]: 'components.preprint-status-banner.accepted', + [REJECTED]: 'components.preprint-status-banner.rejected', + [PENDING_WITHDRAWAL]: 'components.preprint-status-banner.pending_withdrawal', + [WITHDRAWAL_REJECTED]: 'components.preprint-status-banner.withdrawal_rejected', +}; + +const MESSAGE = { + [PRE_MODERATION]: 'components.preprint-status-banner.message.pending_pre', + [POST_MODERATION]: 'components.preprint-status-banner.message.pending_post', + [ACCEPTED]: 'components.preprint-status-banner.message.accepted', + [REJECTED]: 'components.preprint-status-banner.message.rejected', + [PENDING_WITHDRAWAL]: 'components.preprint-status-banner.message.pending_withdrawal', + [WITHDRAWAL_REJECTED]: 'components.preprint-status-banner.message.withdrawal_rejected', + [WITHDRAWN]: 'components.preprint-status-banner.message.withdrawn', +}; + +const WORKFLOW = { + [PRE_MODERATION]: 'global.pre_moderation', + [POST_MODERATION]: 'global.post_moderation', +}; + +const CLASS_NAMES = { + PRE_MODERATION: 'preprint-status-pending-pre', + POST_MODERATION: 'preprint-status-pending-post', + ACCEPTED: 'preprint-status-accepted', + REJECTED: 'preprint-status-rejected', + PENDING_WITHDRAWAL: 'preprint-status-rejected', + WITHDRAWAL_REJECTED: 'preprint-status-rejected', + WITHDRAWN: 'preprint-status-withdrawn', +}; + +interface InputArgs { + submission: PreprintModel; + isWithdrawn: boolean; +} + +export default class PreprintStatusBanner extends Component{ + @service intl!: Intl; + @service theme!: Theme; + + submission = this.args.submission; + isWithdrawn = this.args.isWithdrawn; + + isPendingWithdrawal = false; + isWithdrawalRejected = false; + + // translations + labelModeratorFeedback = 'components.preprint-status-banner.feedback.moderator_feedback'; + moderator = 'components.preprint-status-banner.feedback.moderator'; + baseMessage = 'components.preprint-status-banner.message.base'; + + classNames = ['preprint-status-component']; + classNameBindings = ['getClassName']; + + latestAction = null; + + reviewerComment = alias('latestAction.comment'); + reviewerName = alias('latestAction.creator.fullName'); + + public getClassName(): string { + if (this.isPendingWithdrawal) { + return CLASS_NAMES['PENDING_WITHDRAWAL']; + } else if (this.isWithdrawn) { + return CLASS_NAMES['WITHDRAWN']; + } else if (this.isWithdrawalRejected) { + return CLASS_NAMES['WITHDRAWAL_REJECTED']; + } else { + return this.submission.reviewsState === PENDING ? + CLASS_NAMES[this.submission.provider.reviewsWorkflow] : + CLASS_NAMES[this.submission.reviewsState]; + } + } + + public bannerContent(): string { + if (this.isPendingWithdrawal) { + return this.intl.t(this.statusExplanation, { documentType: this.submission.provider.documentType }); + } else if (this.isWithdrawn) { + return this.intl.t(MESSAGE[WITHDRAWN], { documentType: this.submission.provider.documentType }); + } else if (this.isWithdrawalRejected) { + return this.intl.t(MESSAGE[WITHDRAWAL_REJECTED], { documentType: this.submission.provider.documentType }); + } else { + const tName = this.theme.isProvider ? + this.theme.provider?.name : + this.intl.t('global.brand_name'); + const tWorkflow = this.intl.t(this.workflow); + const tStatusExplanation = this.intl.t(this.statusExplanation); + // eslint-disable-next-line max-len + return `${this.intl.t(this.baseMessage), { name: tName, reviewsWorkflow: tWorkflow, documentType: this.submission.provider.documentType }} ${tStatusExplanation}`; + } + } + + feedbackBaseMessage(): string { + if (this.isWithdrawalRejected) { + return ''; + } + // eslint-disable-next-line max-len + return this.intl.t('components.preprint-status-banner.feedback.base', { documentType: this.submission.provider.documentType }); + } + + private get statusExplanation(): string { + if (this.isPendingWithdrawal) { + return MESSAGE[PENDING_WITHDRAWAL]; + } else if (this.isWithdrawalRejected) { + return MESSAGE[WITHDRAWAL_REJECTED]; + } else { + return this.submission.reviewsState === PENDING ? + MESSAGE[this.submission.provider.reviewsWorkflow] : + MESSAGE[this.submission.reviewsState]; + } + } + + status(): string { + let currentState = this.submission.reviewsState; + if (this.isPendingWithdrawal) { + currentState = PENDING_WITHDRAWAL; + } else if (this.isWithdrawalRejected) { + currentState = WITHDRAWAL_REJECTED; + } + return STATUS[currentState]; + } + + icon(): string { + let currentState = this.submission.reviewsState; + if (this.isPendingWithdrawal) { + currentState = PENDING_WITHDRAWAL; + } else if (this.isWithdrawalRejected) { + currentState = WITHDRAWAL_REJECTED; + } else if (this.isWithdrawn) { + currentState = WITHDRAWN; + } + return ICONS[currentState]; + } + + private get workflow(): string { + return WORKFLOW[this.submission.provider.reviewsWorkflow]; + } + + didReceiveAttrs() { + this._loadPreprintState.perform(); + } + + /* + _loadPreprintState: task(function* () { + if (this.isWithdrawn) { + return; + } + const submissionActions = yield this.submission.reviewActions; + const latestSubmissionAction = submissionActions.firstObject; + const withdrawalRequests = yield this.submission.requests; + const withdrawalRequest = withdrawalRequests.firstObject; + if (withdrawalRequest) { + const requestActions = yield withdrawalRequest.queryHasMany('actions', { + sort: '-modified', + }); + const latestRequestAction = requestActions.firstObject; + if (latestRequestAction && latestRequestAction.actionTrigger === 'reject') { + this.isWithdrawalRejected = true; + this.latestAction = latestRequestAction; + return; + } else { + this.isPendingWithdrawal = true; + return; + } + } + if (this.submission.provider.reviewsCommentsPrivate) { + return; + } + this.latestAction = latestSubmissionAction; + } + */ +} diff --git a/app/preprints/-components/preprint-status-banner/styles.scss b/app/preprints/-components/preprint-status-banner/styles.scss new file mode 100644 index 00000000000..dfb43ae069f --- /dev/null +++ b/app/preprints/-components/preprint-status-banner/styles.scss @@ -0,0 +1,152 @@ +/* Import variables before bootstrap so that boostrap variables can be overridden */ + +$color-alert-bg-warning: #fcf8e3; +$color-alert-border-warning: #faebcc; +$color-alert-text-warning: #8a6d3b; + +$color-alert-bg-success: #dff0d8; +$color-alert-border-success: #d6e9c6; +$color-alert-text-success: #3c763d; + +$color-alert-bg-danger: #f2dede; +$color-alert-border-danger: #ebccd1; +$color-alert-text-danger: #a94442; + +$color-alert-bg-info: #d9edf7; +$color-alert-border-info: #bce8f1; +$color-alert-text-info: #31708f; + +$color-bg-color-grey: #333; +$color-bg-color-light: #eee; +$color-border-light: #ddd; + +.preprint-status-pending-pre { + background-color: $color-alert-bg-warning; + border: 1px solid $color-alert-border-warning; + color: $color-alert-text-warning; + + .status-icon { + -webkit-text-stroke: 1px $color-alert-text-warning; + font-size: 14px; + } +} + +.preprint-status-pending-post { + background-color: $color-alert-bg-info; + border: 1px solid $color-alert-border-info; + color: $color-alert-text-info; + + .status-icon { + -webkit-text-stroke: 1px $color-alert-text-info; + font-size: 14px; + } +} + +.preprint-status-accepted { + background-color: $color-alert-bg-success; + border: 1px solid $color-alert-border-success; + color: $color-alert-text-success; + + .status-icon { + -webkit-text-stroke: 0; + font-size: 16px; + } +} + +.preprint-status-rejected { + background-color: $color-alert-bg-danger; + border: 1px solid $color-alert-border-danger; + color: $color-alert-text-danger; + + .status-icon { + -webkit-text-stroke: 0; + font-size: 16px; + } +} + +.preprint-status-withdrawn { + background-color: $color-alert-bg-warning; + border: 1px solid $color-alert-border-warning; + color: $color-alert-text-warning; + + .status-icon { + -webkit-text-stroke: 1px $color-alert-text-warning; + font-size: 14px; + } +} + +.preprint-status-component { + margin-top: -15px; + margin-bottom: 15px; +} + +/* +#preprint-status { + .flex-container { + font-size: 16px; + display: flex; + align-items: center; + flex-direction: row; + align-content: space-between; + + strong { + display: inline-block; // required for the text-transform + } + strong::first-letter { + text-transform: uppercase; + } + .status-explanation { + padding-right: 15px; + + .banner-content { + padding-left: 5px; + } + } + .reviewer-feedback { + margin-left: auto; + padding-right: 15px; + + .dropdown-menu { + font-size:62.5%; + background-color: $color-bg-color-light; + color: $color-bg-color-grey; + border: 1px solid $color-border-light; + width: 445px; + left: auto; + right: 15px; + margin-top: 0px; + z-index: 98; // prevent dropdown from scrolling over navbar + + .status { + font-size: 1.4em; + } + + .moderator-comment { + font-size: 1.8em; + background-color: white; + padding: 30px 15px; + + p { + padding-bottom: 5px; + } + } + + .feedback-header { + font-size: 2.0em; + border-bottom: 1px solid $color-border-light; + padding: 5px 15px 8px 15px; + + a { + color: grey; + float: right; + } + } + + .feedback-footer { + border-top: 1px solid $color-border-light; + } + } + } + } +} +*/ diff --git a/app/preprints/-components/preprint-status-banner/template.hbs b/app/preprints/-components/preprint-status-banner/template.hbs new file mode 100644 index 00000000000..70931b1c39e --- /dev/null +++ b/app/preprints/-components/preprint-status-banner/template.hbs @@ -0,0 +1,47 @@ +
+
+ {{#if (or this.submission.provider.isPending this._loadPreprintState.isRunning) }} + {{ t 'preprints.status_banner.loading' }} + {{else}} + {{#if this.isWithdrawn}} +
+ + {{this.bannerContent}} +
+ {{else}} +
+ + {{t this.status}}: + {{this.bannerContent}} +
+ {{#if (and this.reviewerComment (not this.submission.provider.reviewsCommentsPrivate))}} +
+ +
+
+ {{t this.labelModeratorFeedback}} + + + +
+
+ {{t this.status}} +
{{this.feedbackBaseMessage}} {{t this.statusExplanation documentType=this.submission.provider.documentType}}
+
+
+

{{this.reviewerComment}}

+ {{#unless this.submission.provider.reviewsCommentsAnonymous}} +
{{this.reviewerName}}
+ {{/unless}} + {{if this.theme.isProvider this.theme.provider.name (t 'global.brand_name')}} {{t this.moderator}} +
+
+
+
+ {{/if}} + {{/if}} + {{/if}} +
+
diff --git a/app/preprints/detail/controller.ts b/app/preprints/detail/controller.ts index 7c4a0d7711e..36059175315 100644 --- a/app/preprints/detail/controller.ts +++ b/app/preprints/detail/controller.ts @@ -112,9 +112,9 @@ export default class PrePrintsDetailController extends Controller { showStatusBanner(): boolean { return ( this.model.provider.reviewsWorkflow - && this.model.public + && this.model.preprint.public && this.userIsContrib - && this.model.reviewsState !== ReviewsState.INITIAL + && this.model.preprint.reviewsState !== ReviewsState.INITIAL ) || this.isPendingWithdrawal; } diff --git a/app/preprints/detail/template.hbs b/app/preprints/detail/template.hbs index 790f83982da..8c09c9b87d0 100644 --- a/app/preprints/detail/template.hbs +++ b/app/preprints/detail/template.hbs @@ -47,7 +47,7 @@ data-analytics-scope='preprints detail page' data-test-toggle-abstract data-analytics-name='Expand Abstract' {{on 'click' (action this.expandAbstract)}} - aria-label={{if this.expandedAbstract 'preprints.detail.see_less' 'preprints.detail.see_more'}} + aria-label={{if this.expandedAbstract ( t 'preprints.detail.see_less') (t 'preprints.detail.see_more')}} @type='default' > {{~t (if this.expandedAbstract 'preprints.detail.see_less' 'preprints.detail.see_more')~}} @@ -220,7 +220,7 @@ data-analytics-scope='preprints detail page' data-test-toggle-abstract data-analytics-name='Expand Abstract' {{on 'click' (action this.expandAbstract)}} - aria-label={{if this.expandedAbstract 'preprints.detail.see_less' 'preprints.detail.see_more'}} + aria-label={{if this.expandedAbstract (t 'preprints.detail.see_less') ( t 'preprints.detail.see_more')}} @type='default' > {{~t (if this.expandedAbstract 'preprints.detail.see_less' 'preprints.detail.see_more')~}} diff --git a/translations/en-us.yml b/translations/en-us.yml index 5d718045f64..095bfb96d6b 100644 --- a/translations/en-us.yml +++ b/translations/en-us.yml @@ -1157,6 +1157,9 @@ preprints: metrics_disclaimer: 'Metrics collected since:' supplemental_materials: 'Supplemental Materials' tags: 'Tags' + status_banner: + loading: 'Loading...' + close: 'Close' header: osf_registrations: 'OSF Preprints' registrations: 'Preprints' From a0012407418d44c7c5cfaa3842ee8ce84a595dd8 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Wed, 27 Sep 2023 09:25:05 -0600 Subject: [PATCH 085/170] Additional refactors to bring the ts file up-to-date with latest ember --- .../preprint-status-banner/component.ts | 40 +++++++++++++------ .../preprint-status-banner/template.hbs | 2 +- app/preprints/index/template.hbs | 6 --- app/preprints/template.hbs | 6 +++ 4 files changed, 34 insertions(+), 20 deletions(-) diff --git a/app/preprints/-components/preprint-status-banner/component.ts b/app/preprints/-components/preprint-status-banner/component.ts index f4110944eb6..d8ed7061d74 100644 --- a/app/preprints/-components/preprint-status-banner/component.ts +++ b/app/preprints/-components/preprint-status-banner/component.ts @@ -3,6 +3,10 @@ import { inject as service } from '@ember/service'; import Theme from 'ember-osf-web/services/theme'; import Intl from 'ember-intl/services/intl'; import PreprintModel from 'ember-osf-web/models/preprint'; +import { task } from 'ember-concurrency'; +import { waitFor } from '@ember/test-waiters'; +import ReviewActionModel from 'ember-osf-web/models/review-action'; +import { alias } from '@ember/object/computed'; const PENDING = 'pending'; const ACCEPTED = 'accepted'; @@ -79,10 +83,24 @@ export default class PreprintStatusBanner extends Component{ classNames = ['preprint-status-component']; classNameBindings = ['getClassName']; - latestAction = null; + latestAction: ReviewActionModel | undefined; - reviewerComment = alias('latestAction.comment'); - reviewerName = alias('latestAction.creator.fullName'); + @alias('latestAction.comment') reviewerComment: string | undefined; + @alias('latestAction.creator.fullName') reviewerName: string | undefined; + + /** + * + * @param owner The owner + * @param args The args + */ + constructor(owner: unknown, args: InputArgs) { + super(owner, args); + + this.latestAction = undefined; + + this.loadPreprintState(); + + } public getClassName(): string { if (this.isPendingWithdrawal) { @@ -162,21 +180,18 @@ export default class PreprintStatusBanner extends Component{ return WORKFLOW[this.submission.provider.reviewsWorkflow]; } - didReceiveAttrs() { - this._loadPreprintState.perform(); - } - - /* - _loadPreprintState: task(function* () { + @task + @waitFor + async loadPreprintState() { if (this.isWithdrawn) { return; } - const submissionActions = yield this.submission.reviewActions; + const submissionActions = await this.submission.reviewActions; const latestSubmissionAction = submissionActions.firstObject; - const withdrawalRequests = yield this.submission.requests; + const withdrawalRequests = await this.submission.requests; const withdrawalRequest = withdrawalRequests.firstObject; if (withdrawalRequest) { - const requestActions = yield withdrawalRequest.queryHasMany('actions', { + const requestActions = await withdrawalRequest.queryHasMany('actions', { sort: '-modified', }); const latestRequestAction = requestActions.firstObject; @@ -194,5 +209,4 @@ export default class PreprintStatusBanner extends Component{ } this.latestAction = latestSubmissionAction; } - */ } diff --git a/app/preprints/-components/preprint-status-banner/template.hbs b/app/preprints/-components/preprint-status-banner/template.hbs index 70931b1c39e..b3f1408b554 100644 --- a/app/preprints/-components/preprint-status-banner/template.hbs +++ b/app/preprints/-components/preprint-status-banner/template.hbs @@ -1,6 +1,6 @@
- {{#if (or this.submission.provider.isPending this._loadPreprintState.isRunning) }} + {{#if (or this.submission.provider.isPending this.loadPreprintState.isRunning) }} {{ t 'preprints.status_banner.loading' }} {{else}} {{#if this.isWithdrawn}} diff --git a/app/preprints/index/template.hbs b/app/preprints/index/template.hbs index a453800fc2b..02e41c20efd 100644 --- a/app/preprints/index/template.hbs +++ b/app/preprints/index/template.hbs @@ -163,11 +163,5 @@
{{/if}} - -
- -
{{!END INDEX}} diff --git a/app/preprints/template.hbs b/app/preprints/template.hbs index 5c74b906e29..d97d4b43d85 100644 --- a/app/preprints/template.hbs +++ b/app/preprints/template.hbs @@ -10,3 +10,9 @@
{{/if}} {{outlet}} + +
+ +
\ No newline at end of file From 4525d6565036d639cc897c30b97cc8f6507785e5 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Wed, 27 Sep 2023 09:46:13 -0600 Subject: [PATCH 086/170] Added a current state icon method --- .../preprint-status-banner/component.ts | 44 ++++++++++++++----- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/app/preprints/-components/preprint-status-banner/component.ts b/app/preprints/-components/preprint-status-banner/component.ts index d8ed7061d74..9a95ed6a1d2 100644 --- a/app/preprints/-components/preprint-status-banner/component.ts +++ b/app/preprints/-components/preprint-status-banner/component.ts @@ -18,15 +18,6 @@ const WITHDRAWN = 'withdrawn'; const PRE_MODERATION = 'pre-moderation'; const POST_MODERATION = 'post-moderation'; -const ICONS = { - [PENDING]: 'fa-hourglass-o', - [ACCEPTED]: 'fa-check-circle-o', - [REJECTED]: 'fa-times-circle-o', - [PENDING_WITHDRAWAL]: 'fa-hourglass-o', - [WITHDRAWAL_REJECTED]: 'fa-times-circle-o', - [WITHDRAWN]: 'fa-exclamation-triangle', -}; - const STATUS = { [PENDING]: 'components.preprint-status-banner.pending', [ACCEPTED]: 'components.preprint-status-banner.accepted', @@ -164,7 +155,7 @@ export default class PreprintStatusBanner extends Component{ return STATUS[currentState]; } - icon(): string { + public get icon(): string { let currentState = this.submission.reviewsState; if (this.isPendingWithdrawal) { currentState = PENDING_WITHDRAWAL; @@ -173,7 +164,7 @@ export default class PreprintStatusBanner extends Component{ } else if (this.isWithdrawn) { currentState = WITHDRAWN; } - return ICONS[currentState]; + return this.getIcon(currentState); } private get workflow(): string { @@ -209,4 +200,35 @@ export default class PreprintStatusBanner extends Component{ } this.latestAction = latestSubmissionAction; } + + /** + * getIcon + * + * @description Determines the correct icon from the current state + * @param currentState The current state as a string + * @returns the icon associated with the current state + */ + private getIcon(currentState: string): string { + switch(currentState) { + case PENDING: { + return 'fa-hourglass-o'; + } + case ACCEPTED: { + return 'fa-check-circle-o'; + } + case REJECTED: { + return 'fa-times-circle-o'; + } + case PENDING_WITHDRAWAL: { + return 'fa-hourglass-o'; + } + case WITHDRAWAL_REJECTED: { + return 'fa-times-circle-o'; + } + default: { + // [WITHDRAWN]: 'fa-exclamation-triangle', + return 'fa-exclamation-triangle'; + } + } + } } From 700b05e2ab0c95e695254b1fc0e86b988db63cef Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Wed, 27 Sep 2023 10:40:21 -0600 Subject: [PATCH 087/170] Refactored all the constants to be typescript compatible --- app/models/preprint-request-action.ts | 25 ++++ app/models/preprint-request.ts | 30 +++++ app/models/preprint.ts | 4 + .../preprint-status-banner/component.ts | 111 +++++++----------- 4 files changed, 104 insertions(+), 66 deletions(-) create mode 100644 app/models/preprint-request-action.ts create mode 100644 app/models/preprint-request.ts diff --git a/app/models/preprint-request-action.ts b/app/models/preprint-request-action.ts new file mode 100644 index 00000000000..fa39f4b4442 --- /dev/null +++ b/app/models/preprint-request-action.ts @@ -0,0 +1,25 @@ +import { AsyncBelongsTo, attr, belongsTo } from '@ember-data/model'; +import PreprintRequestModel from 'ember-osf-web/models/preprint-request'; +import UserModel from 'ember-osf-web/models/user'; + +import OsfModel from './osf-model'; + +export default class PreprintRequestActionModel extends OsfModel { + @attr('string') comment!: String; + @attr('string') actionTrigger!: String; + @attr('date') dateModified!: Date; + @attr('boolean') auto!: boolean; + + // Relationships + @belongsTo('preprint-request', { polymorphic: false, inverse: 'actions', async: true}) + target!: (AsyncBelongsTo & PreprintRequestModel); + + @belongsTo('user', { inverse: null, async: true }) + creator!: AsyncBelongsTo & UserModel; +} + +declare module 'ember-data/types/registries/model' { + export default interface ModelRegistry { + preprintRequestAction: PreprintRequestActionModel; + } // eslint-disable-line semi +} diff --git a/app/models/preprint-request.ts b/app/models/preprint-request.ts new file mode 100644 index 00000000000..c9f97405a15 --- /dev/null +++ b/app/models/preprint-request.ts @@ -0,0 +1,30 @@ +import { AsyncBelongsTo, attr, belongsTo, hasMany } from '@ember-data/model'; +import PreprintModel from 'ember-osf-web/models/preprint'; +import UserModel from 'ember-osf-web/models/user'; +import PreprintRequestActionModel from 'ember-osf-web/models/preprint-request-action'; + +import OsfModel from './osf-model'; + +export default class PreprintRequestModel extends OsfModel { + @attr('string') comment!: String; + @attr('date') dateLastTransitioned!: Date; + @attr('date') created!: Date; + @attr('date') modified!: Date; + @attr('string') machineState!: String; + @attr('string') requestType!: String; + + @belongsTo('preprint', { polymorphic: false, inverse: 'requests', async: true}) + target!: (AsyncBelongsTo & PreprintModel); + + @belongsTo('user', { inverse: null, async: true }) + creator!: AsyncBelongsTo & UserModel; + + @hasMany('preprint-request-action', { inverse: 'target', async: true }) + actions!: AsyncBelongsTo & PreprintRequestActionModel; +} + +declare module 'ember-data/types/registries/model' { + export default interface ModelRegistry { + preprintRequest: PreprintRequestModel; + } // eslint-disable-line semi +} diff --git a/app/models/preprint.ts b/app/models/preprint.ts index 4e7d98d66d3..31f7ad827c7 100644 --- a/app/models/preprint.ts +++ b/app/models/preprint.ts @@ -2,6 +2,7 @@ import { attr, belongsTo, hasMany, SyncHasMany, AsyncBelongsTo, AsyncHasMany } f import { computed } from '@ember/object'; import { alias } from '@ember/object/computed'; import CitationModel from 'ember-osf-web/models/citation'; +import PreprintRequestModel from 'ember-osf-web/models/preprint-request'; import ContributorModel from './contributor'; import FileModel from './file'; @@ -61,6 +62,9 @@ export default class PreprintModel extends OsfModel { @hasMany('subject', { inverse: null}) subjects!: SyncHasMany; + @hasMany('requests', { inverse: null}) + requests!: SyncHasMany; + @alias('links.doi') articleDoiUrl!: string | null; @alias('links.preprint_doi') preprintDoiUrl!: string; diff --git a/app/preprints/-components/preprint-status-banner/component.ts b/app/preprints/-components/preprint-status-banner/component.ts index 9a95ed6a1d2..371c1af9d11 100644 --- a/app/preprints/-components/preprint-status-banner/component.ts +++ b/app/preprints/-components/preprint-status-banner/component.ts @@ -8,6 +8,7 @@ import { waitFor } from '@ember/test-waiters'; import ReviewActionModel from 'ember-osf-web/models/review-action'; import { alias } from '@ember/object/computed'; +const UNKNOWN = 'unknown'; const PENDING = 'pending'; const ACCEPTED = 'accepted'; const REJECTED = 'rejected'; @@ -18,38 +19,46 @@ const WITHDRAWN = 'withdrawn'; const PRE_MODERATION = 'pre-moderation'; const POST_MODERATION = 'post-moderation'; -const STATUS = { - [PENDING]: 'components.preprint-status-banner.pending', - [ACCEPTED]: 'components.preprint-status-banner.accepted', - [REJECTED]: 'components.preprint-status-banner.rejected', - [PENDING_WITHDRAWAL]: 'components.preprint-status-banner.pending_withdrawal', - [WITHDRAWAL_REJECTED]: 'components.preprint-status-banner.withdrawal_rejected', -}; - -const MESSAGE = { - [PRE_MODERATION]: 'components.preprint-status-banner.message.pending_pre', - [POST_MODERATION]: 'components.preprint-status-banner.message.pending_post', - [ACCEPTED]: 'components.preprint-status-banner.message.accepted', - [REJECTED]: 'components.preprint-status-banner.message.rejected', - [PENDING_WITHDRAWAL]: 'components.preprint-status-banner.message.pending_withdrawal', - [WITHDRAWAL_REJECTED]: 'components.preprint-status-banner.message.withdrawal_rejected', - [WITHDRAWN]: 'components.preprint-status-banner.message.withdrawn', -}; - -const WORKFLOW = { - [PRE_MODERATION]: 'global.pre_moderation', - [POST_MODERATION]: 'global.post_moderation', -}; - -const CLASS_NAMES = { - PRE_MODERATION: 'preprint-status-pending-pre', - POST_MODERATION: 'preprint-status-pending-post', - ACCEPTED: 'preprint-status-accepted', - REJECTED: 'preprint-status-rejected', - PENDING_WITHDRAWAL: 'preprint-status-rejected', - WITHDRAWAL_REJECTED: 'preprint-status-rejected', - WITHDRAWN: 'preprint-status-withdrawn', -}; +const STATUS = Object({}); +STATUS[PENDING]= 'components.preprint-status-banner.pending'; +STATUS[ACCEPTED]= 'components.preprint-status-banner.accepted'; +STATUS[REJECTED]= 'components.preprint-status-banner.rejected'; +STATUS[PENDING_WITHDRAWAL]= 'components.preprint-status-banner.pending_withdrawal'; +STATUS[WITHDRAWAL_REJECTED]= 'components.preprint-status-banner.withdrawal_rejected'; + +const MESSAGE = Object({}); +MESSAGE[PRE_MODERATION] = 'components.preprint-status-banner.message.pending_pre'; +MESSAGE[POST_MODERATION] = 'components.preprint-status-banner.message.pending_post'; +MESSAGE[ACCEPTED] = 'components.preprint-status-banner.message.accepted'; +MESSAGE[REJECTED] = 'components.preprint-status-banner.message.rejected'; +MESSAGE[PENDING_WITHDRAWAL] = 'components.preprint-status-banner.message.pending_withdrawal'; +MESSAGE[WITHDRAWAL_REJECTED] = 'components.preprint-status-banner.message.withdrawal_rejected'; +MESSAGE[WITHDRAWN] = 'components.preprint-status-banner.message.withdrawn'; +MESSAGE[UNKNOWN] = 'components.preprint-status-banner.message.withdrawn'; + +const WORKFLOW = Object({}); +WORKFLOW[PRE_MODERATION] = 'global.pre_moderation'; +WORKFLOW[POST_MODERATION] = 'global.post_moderation'; +WORKFLOW[UNKNOWN] = 'global.post_moderation'; + +const CLASS_NAMES = Object({}); +CLASS_NAMES[PRE_MODERATION] = 'preprint-status-pending-pre'; +CLASS_NAMES[POST_MODERATION] = 'preprint-status-pending-post'; +CLASS_NAMES[ACCEPTED] = 'preprint-status-accepted'; +CLASS_NAMES[REJECTED] = 'preprint-status-rejected'; +CLASS_NAMES[PENDING_WITHDRAWAL] = 'preprint-status-rejected'; +CLASS_NAMES[WITHDRAWAL_REJECTED] = 'preprint-status-rejected'; +CLASS_NAMES[WITHDRAWN] = 'preprint-status-withdrawn'; +CLASS_NAMES[UNKNOWN] = 'preprint-status-withdrawn'; + +const ICONS = Object({}); +ICONS[PENDING] = 'fa-hourglass-o'; +ICONS[ACCEPTED] = 'fa-check-circle-o'; +ICONS[REJECTED] = 'fa-times-circle-o'; +ICONS[PENDING_WITHDRAWAL] = 'fa-hourglass-o'; +ICONS[WITHDRAWAL_REJECTED] = 'fa-times-circle-o'; +ICONS[WITHDRAWN] = 'fa-exclamation-triangle'; +ICONS[UNKNOWN] = 'fa-exclamation-triangle'; interface InputArgs { submission: PreprintModel; @@ -102,7 +111,7 @@ export default class PreprintStatusBanner extends Component{ return CLASS_NAMES['WITHDRAWAL_REJECTED']; } else { return this.submission.reviewsState === PENDING ? - CLASS_NAMES[this.submission.provider.reviewsWorkflow] : + CLASS_NAMES[this.submission?.provider?.reviewsWorkflow || UNKNOWN] : CLASS_NAMES[this.submission.reviewsState]; } } @@ -140,7 +149,7 @@ export default class PreprintStatusBanner extends Component{ return MESSAGE[WITHDRAWAL_REJECTED]; } else { return this.submission.reviewsState === PENDING ? - MESSAGE[this.submission.provider.reviewsWorkflow] : + MESSAGE[this.submission?.provider?.reviewsWorkflow || UNKNOWN ] : MESSAGE[this.submission.reviewsState]; } } @@ -164,11 +173,11 @@ export default class PreprintStatusBanner extends Component{ } else if (this.isWithdrawn) { currentState = WITHDRAWN; } - return this.getIcon(currentState); + return ICONS[currentState]; } private get workflow(): string { - return WORKFLOW[this.submission.provider.reviewsWorkflow]; + return WORKFLOW[this.submission?.provider?.reviewsWorkflow || UNKNOWN]; } @task @@ -201,34 +210,4 @@ export default class PreprintStatusBanner extends Component{ this.latestAction = latestSubmissionAction; } - /** - * getIcon - * - * @description Determines the correct icon from the current state - * @param currentState The current state as a string - * @returns the icon associated with the current state - */ - private getIcon(currentState: string): string { - switch(currentState) { - case PENDING: { - return 'fa-hourglass-o'; - } - case ACCEPTED: { - return 'fa-check-circle-o'; - } - case REJECTED: { - return 'fa-times-circle-o'; - } - case PENDING_WITHDRAWAL: { - return 'fa-hourglass-o'; - } - case WITHDRAWAL_REJECTED: { - return 'fa-times-circle-o'; - } - default: { - // [WITHDRAWN]: 'fa-exclamation-triangle', - return 'fa-exclamation-triangle'; - } - } - } } From 3c45bc9d2ef0a1230174c7f740eede9a07b403ee Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Wed, 27 Sep 2023 10:47:21 -0600 Subject: [PATCH 088/170] Appears the preprint status banner will now compile --- app/models/preprint-request.ts | 4 ++-- app/models/preprint.ts | 4 ++-- app/preprints/-components/preprint-status-banner/component.ts | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/models/preprint-request.ts b/app/models/preprint-request.ts index c9f97405a15..79238e7689a 100644 --- a/app/models/preprint-request.ts +++ b/app/models/preprint-request.ts @@ -1,4 +1,4 @@ -import { AsyncBelongsTo, attr, belongsTo, hasMany } from '@ember-data/model'; +import { AsyncBelongsTo, SyncHasMany, attr, belongsTo, hasMany } from '@ember-data/model'; import PreprintModel from 'ember-osf-web/models/preprint'; import UserModel from 'ember-osf-web/models/user'; import PreprintRequestActionModel from 'ember-osf-web/models/preprint-request-action'; @@ -20,7 +20,7 @@ export default class PreprintRequestModel extends OsfModel { creator!: AsyncBelongsTo & UserModel; @hasMany('preprint-request-action', { inverse: 'target', async: true }) - actions!: AsyncBelongsTo & PreprintRequestActionModel; + actions!: SyncHasMany & PreprintRequestActionModel; } declare module 'ember-data/types/registries/model' { diff --git a/app/models/preprint.ts b/app/models/preprint.ts index 31f7ad827c7..484426d1615 100644 --- a/app/models/preprint.ts +++ b/app/models/preprint.ts @@ -3,6 +3,7 @@ import { computed } from '@ember/object'; import { alias } from '@ember/object/computed'; import CitationModel from 'ember-osf-web/models/citation'; import PreprintRequestModel from 'ember-osf-web/models/preprint-request'; +import PreprintRequestActionModel from 'ember-osf-web/models/preprint-request-action'; import ContributorModel from './contributor'; import FileModel from './file'; @@ -10,7 +11,6 @@ import LicenseModel from './license'; import NodeModel from './node'; import OsfModel from './osf-model'; import PreprintProviderModel from './preprint-provider'; -import ReviewActionModel from './review-action'; import SubjectModel from './subject'; export default class PreprintModel extends OsfModel { @@ -45,7 +45,7 @@ export default class PreprintModel extends OsfModel { provider!: AsyncBelongsTo & PreprintProviderModel; @hasMany('review-action', { inverse: 'target' }) - reviewActions!: AsyncHasMany; + reviewActions!: AsyncHasMany; @hasMany('files', { inverse: null}) files!: AsyncHasMany & FileModel; diff --git a/app/preprints/-components/preprint-status-banner/component.ts b/app/preprints/-components/preprint-status-banner/component.ts index 371c1af9d11..ddf5fbe9c77 100644 --- a/app/preprints/-components/preprint-status-banner/component.ts +++ b/app/preprints/-components/preprint-status-banner/component.ts @@ -5,8 +5,8 @@ import Intl from 'ember-intl/services/intl'; import PreprintModel from 'ember-osf-web/models/preprint'; import { task } from 'ember-concurrency'; import { waitFor } from '@ember/test-waiters'; -import ReviewActionModel from 'ember-osf-web/models/review-action'; import { alias } from '@ember/object/computed'; +import PreprintRequestActionModel from 'ember-osf-web/models/preprint-request-action'; const UNKNOWN = 'unknown'; const PENDING = 'pending'; @@ -83,7 +83,7 @@ export default class PreprintStatusBanner extends Component{ classNames = ['preprint-status-component']; classNameBindings = ['getClassName']; - latestAction: ReviewActionModel | undefined; + latestAction: PreprintRequestActionModel | undefined; @alias('latestAction.comment') reviewerComment: string | undefined; @alias('latestAction.creator.fullName') reviewerName: string | undefined; From d1a35383bb1c8d62e5466669261d6979df68fbc2 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Wed, 27 Sep 2023 14:55:12 -0600 Subject: [PATCH 089/170] Fixed mirage logic and some refactors --- app/models/preprint-request-action.ts | 4 +- app/models/preprint-request.ts | 6 +-- app/models/preprint.ts | 2 +- .../preprint-status-banner/component.ts | 32 +++++++------- .../preprint-status-banner/template.hbs | 2 +- app/preprints/detail/template.hbs | 5 +++ app/preprints/template.hbs | 4 +- mirage/config.ts | 19 ++++++++ mirage/scenarios/preprints.ts | 1 - mirage/serializers/preprint-request-action.ts | 36 +++++++++++++++ mirage/serializers/preprint-request.ts | 44 +++++++++++++++++++ mirage/serializers/preprint.ts | 18 ++++++++ 12 files changed, 148 insertions(+), 25 deletions(-) create mode 100644 mirage/serializers/preprint-request-action.ts create mode 100644 mirage/serializers/preprint-request.ts diff --git a/app/models/preprint-request-action.ts b/app/models/preprint-request-action.ts index fa39f4b4442..fe90842d13d 100644 --- a/app/models/preprint-request-action.ts +++ b/app/models/preprint-request-action.ts @@ -11,7 +11,7 @@ export default class PreprintRequestActionModel extends OsfModel { @attr('boolean') auto!: boolean; // Relationships - @belongsTo('preprint-request', { polymorphic: false, inverse: 'actions', async: true}) + @belongsTo('preprint-request', { inverse: 'actions' }) target!: (AsyncBelongsTo & PreprintRequestModel); @belongsTo('user', { inverse: null, async: true }) @@ -20,6 +20,6 @@ export default class PreprintRequestActionModel extends OsfModel { declare module 'ember-data/types/registries/model' { export default interface ModelRegistry { - preprintRequestAction: PreprintRequestActionModel; + 'preprint-request-action': PreprintRequestActionModel; } // eslint-disable-line semi } diff --git a/app/models/preprint-request.ts b/app/models/preprint-request.ts index 79238e7689a..167bbce4f56 100644 --- a/app/models/preprint-request.ts +++ b/app/models/preprint-request.ts @@ -13,18 +13,18 @@ export default class PreprintRequestModel extends OsfModel { @attr('string') machineState!: String; @attr('string') requestType!: String; - @belongsTo('preprint', { polymorphic: false, inverse: 'requests', async: true}) + @belongsTo('preprint', { inverse: 'requests'}) target!: (AsyncBelongsTo & PreprintModel); @belongsTo('user', { inverse: null, async: true }) creator!: AsyncBelongsTo & UserModel; - @hasMany('preprint-request-action', { inverse: 'target', async: true }) + @hasMany('preprint-request-action', { inverse: 'target'}) actions!: SyncHasMany & PreprintRequestActionModel; } declare module 'ember-data/types/registries/model' { export default interface ModelRegistry { - preprintRequest: PreprintRequestModel; + 'preprint-request': PreprintRequestModel; } // eslint-disable-line semi } diff --git a/app/models/preprint.ts b/app/models/preprint.ts index 484426d1615..377e6770388 100644 --- a/app/models/preprint.ts +++ b/app/models/preprint.ts @@ -62,7 +62,7 @@ export default class PreprintModel extends OsfModel { @hasMany('subject', { inverse: null}) subjects!: SyncHasMany; - @hasMany('requests', { inverse: null}) + @hasMany('preprint-request', { inverse: 'target'}) requests!: SyncHasMany; @alias('links.doi') articleDoiUrl!: string | null; diff --git a/app/preprints/-components/preprint-status-banner/component.ts b/app/preprints/-components/preprint-status-banner/component.ts index ddf5fbe9c77..90cd45986a6 100644 --- a/app/preprints/-components/preprint-status-banner/component.ts +++ b/app/preprints/-components/preprint-status-banner/component.ts @@ -7,6 +7,8 @@ import { task } from 'ember-concurrency'; import { waitFor } from '@ember/test-waiters'; import { alias } from '@ember/object/computed'; import PreprintRequestActionModel from 'ember-osf-web/models/preprint-request-action'; +import { taskFor } from 'ember-concurrency-ts'; +import PreprintProviderModel from 'ember-osf-web/models/preprint-provider'; const UNKNOWN = 'unknown'; const PENDING = 'pending'; @@ -72,6 +74,8 @@ export default class PreprintStatusBanner extends Component{ submission = this.args.submission; isWithdrawn = this.args.isWithdrawn; + provider: PreprintProviderModel | undefined; + isPendingWithdrawal = false; isWithdrawalRejected = false; @@ -96,10 +100,7 @@ export default class PreprintStatusBanner extends Component{ constructor(owner: unknown, args: InputArgs) { super(owner, args); - this.latestAction = undefined; - - this.loadPreprintState(); - + taskFor(this.loadPreprintState).perform(); } public getClassName(): string { @@ -111,18 +112,18 @@ export default class PreprintStatusBanner extends Component{ return CLASS_NAMES['WITHDRAWAL_REJECTED']; } else { return this.submission.reviewsState === PENDING ? - CLASS_NAMES[this.submission?.provider?.reviewsWorkflow || UNKNOWN] : + CLASS_NAMES[this.provider?.reviewsWorkflow || UNKNOWN] : CLASS_NAMES[this.submission.reviewsState]; } } - public bannerContent(): string { + public get bannerContent(): string { if (this.isPendingWithdrawal) { - return this.intl.t(this.statusExplanation, { documentType: this.submission.provider.documentType }); + return this.intl.t(this.statusExplanation, { documentType: this.provider?.documentType }); } else if (this.isWithdrawn) { - return this.intl.t(MESSAGE[WITHDRAWN], { documentType: this.submission.provider.documentType }); + return this.intl.t(MESSAGE[WITHDRAWN], { documentType: this.provider?.documentType }); } else if (this.isWithdrawalRejected) { - return this.intl.t(MESSAGE[WITHDRAWAL_REJECTED], { documentType: this.submission.provider.documentType }); + return this.intl.t(MESSAGE[WITHDRAWAL_REJECTED], { documentType: this.provider?.documentType }); } else { const tName = this.theme.isProvider ? this.theme.provider?.name : @@ -130,7 +131,7 @@ export default class PreprintStatusBanner extends Component{ const tWorkflow = this.intl.t(this.workflow); const tStatusExplanation = this.intl.t(this.statusExplanation); // eslint-disable-next-line max-len - return `${this.intl.t(this.baseMessage), { name: tName, reviewsWorkflow: tWorkflow, documentType: this.submission.provider.documentType }} ${tStatusExplanation}`; + return `${this.intl.t(this.baseMessage), { name: tName, reviewsWorkflow: tWorkflow, documentType: this.provider?.documentType }} ${tStatusExplanation}`; } } @@ -139,7 +140,7 @@ export default class PreprintStatusBanner extends Component{ return ''; } // eslint-disable-next-line max-len - return this.intl.t('components.preprint-status-banner.feedback.base', { documentType: this.submission.provider.documentType }); + return this.intl.t('components.preprint-status-banner.feedback.base', { documentType: this.provider?.documentType }); } private get statusExplanation(): string { @@ -149,12 +150,12 @@ export default class PreprintStatusBanner extends Component{ return MESSAGE[WITHDRAWAL_REJECTED]; } else { return this.submission.reviewsState === PENDING ? - MESSAGE[this.submission?.provider?.reviewsWorkflow || UNKNOWN ] : + MESSAGE[this.provider?.reviewsWorkflow || UNKNOWN ] : MESSAGE[this.submission.reviewsState]; } } - status(): string { + public get status(): string { let currentState = this.submission.reviewsState; if (this.isPendingWithdrawal) { currentState = PENDING_WITHDRAWAL; @@ -177,7 +178,7 @@ export default class PreprintStatusBanner extends Component{ } private get workflow(): string { - return WORKFLOW[this.submission?.provider?.reviewsWorkflow || UNKNOWN]; + return WORKFLOW[this.provider?.reviewsWorkflow || UNKNOWN]; } @task @@ -186,6 +187,7 @@ export default class PreprintStatusBanner extends Component{ if (this.isWithdrawn) { return; } + this.provider = await this.submission.provider; const submissionActions = await this.submission.reviewActions; const latestSubmissionAction = submissionActions.firstObject; const withdrawalRequests = await this.submission.requests; @@ -204,7 +206,7 @@ export default class PreprintStatusBanner extends Component{ return; } } - if (this.submission.provider.reviewsCommentsPrivate) { + if (this.provider.reviewsCommentsPrivate) { return; } this.latestAction = latestSubmissionAction; diff --git a/app/preprints/-components/preprint-status-banner/template.hbs b/app/preprints/-components/preprint-status-banner/template.hbs index b3f1408b554..11d19896cd6 100644 --- a/app/preprints/-components/preprint-status-banner/template.hbs +++ b/app/preprints/-components/preprint-status-banner/template.hbs @@ -11,7 +11,7 @@ {{else}}
- {{t this.status}}: + {{!-- {{t this.status }}: --}} {{this.bannerContent}}
{{#if (and this.reviewerComment (not this.submission.provider.reviewsCommentsPrivate))}} diff --git a/app/preprints/detail/template.hbs b/app/preprints/detail/template.hbs index 8c09c9b87d0..40ad0ca4f3d 100644 --- a/app/preprints/detail/template.hbs +++ b/app/preprints/detail/template.hbs @@ -33,6 +33,11 @@ data-analytics-scope='preprints detail page'
{{! removed }}
+ {{#if (or this.showStatusBanner this.isWithdrawn)}} + + {{/if}} {{! removed }}
{{#if this.model.preprint.isWithdrawn}} diff --git a/app/preprints/template.hbs b/app/preprints/template.hbs index d97d4b43d85..017f18d4ced 100644 --- a/app/preprints/template.hbs +++ b/app/preprints/template.hbs @@ -12,7 +12,7 @@ {{outlet}}
- + >
\ No newline at end of file diff --git a/mirage/config.ts b/mirage/config.ts index f21719a2913..9f40e696b5e 100644 --- a/mirage/config.ts +++ b/mirage/config.ts @@ -341,6 +341,25 @@ export default function(this: Server) { }); this.get('/preprints/:guid/citation/:citationStyleID', getCitation); + /** + * Preprint Requests + */ + + osfNestedResource(this, 'preprint', 'requests', { + path: '/preprints/:parentID/requests/', + defaultSortKey: 'index', + relatedModelName: 'preprint-request', + }); + + /** + * Preprint Request Actions + */ + osfResource(this, 'requests'); + osfNestedResource(this, 'requests', 'actions', { + path: '/requests/:parentID/actions', + relatedModelName: 'preprint-request-action', + }); + /** * End Preprint Details */ diff --git a/mirage/scenarios/preprints.ts b/mirage/scenarios/preprints.ts index e0866d428f0..8f698179155 100644 --- a/mirage/scenarios/preprints.ts +++ b/mirage/scenarios/preprints.ts @@ -28,7 +28,6 @@ function buildOSF( const currentUserModerator = server.create('moderator', { id: currentUser.id, user: currentUser, provider: osf }, 'asAdmin'); - const rejectedAdminPreprint = server.create('preprint', { provider: osf, id: 'osf-rejected-admin', diff --git a/mirage/serializers/preprint-request-action.ts b/mirage/serializers/preprint-request-action.ts new file mode 100644 index 00000000000..4e700d41ce0 --- /dev/null +++ b/mirage/serializers/preprint-request-action.ts @@ -0,0 +1,36 @@ +import { ModelInstance } from 'ember-cli-mirage'; +import config from 'ember-get-config'; +import PreprintRequestActionModel from 'ember-osf-web/models/preprint-request-action'; +import ApplicationSerializer, { SerializedRelationships } from './application'; + +const { OSF: { apiUrl } } = config; + +export default class PreprintRequestActionSerializer extends ApplicationSerializer { + buildNormalLinks(model: ModelInstance) { + return { + self: `${apiUrl}/v2/actions/${model.id}`, + }; + } + + buildRelationships(model: ModelInstance) { + const relationships: SerializedRelationships = { + creator: { + links: { + related: { + href: `${apiUrl}/v2/users/${model.creator.id}`, + meta: {}, + }, + }, + }, + target: { + links: { + related: { + href: `${apiUrl}/v2/requests/${model.target.id}`, + meta: {}, + }, + }, + }, + }; + return relationships; + } +} diff --git a/mirage/serializers/preprint-request.ts b/mirage/serializers/preprint-request.ts new file mode 100644 index 00000000000..a292973bd9d --- /dev/null +++ b/mirage/serializers/preprint-request.ts @@ -0,0 +1,44 @@ +import { ModelInstance } from 'ember-cli-mirage'; +import config from 'ember-get-config'; +import PreprintRequestModel from 'ember-osf-web/models/preprint-request'; +import ApplicationSerializer, { SerializedRelationships } from './application'; + +const { OSF: { apiUrl } } = config; + +export default class PreprintRequestSerializer extends ApplicationSerializer { + buildNormalLinks(model: ModelInstance) { + return { + self: `${apiUrl}/v2/requests/${model.id}`, + }; + } + + buildRelationships(model: ModelInstance) { + const relationships: SerializedRelationships = { + creator: { + links: { + related: { + href: `${apiUrl}/v2/users/${model.creator.id}`, + meta: {}, + }, + }, + }, + target: { + links: { + related: { + href: `${apiUrl}/v2/preprints/${model.target.id}`, + meta: {}, + }, + }, + }, + actions: { + links: { + related: { + href: `${apiUrl}/v2/requests/${model.id}/actions`, + meta: {}, + }, + }, + }, + }; + return relationships; + } +} diff --git a/mirage/serializers/preprint.ts b/mirage/serializers/preprint.ts index a22f98440c5..ddaa3c39824 100644 --- a/mirage/serializers/preprint.ts +++ b/mirage/serializers/preprint.ts @@ -72,6 +72,24 @@ export default class PreprintSerializer extends ApplicationSerializer Date: Thu, 28 Sep 2023 14:21:38 -0600 Subject: [PATCH 090/170] Added more styling and translations --- app/models/provider.ts | 6 +- .../preprint-status-banner/component.ts | 67 ++++++++++--------- .../preprint-status-banner/styles.scss | 41 ++++++------ .../preprint-status-banner/template.hbs | 25 +++---- mirage/scenarios/preprints.ts | 12 ++-- translations/en-us.yml | 21 ++++++ 6 files changed, 99 insertions(+), 73 deletions(-) diff --git a/app/models/provider.ts b/app/models/provider.ts index aeb63bbfe8f..4e95368802b 100644 --- a/app/models/provider.ts +++ b/app/models/provider.ts @@ -26,12 +26,12 @@ export enum ReviewsWorkFlow{ } export enum ReviewsState { - APPROVED = 'approved', - INITIAL = 'initial', PENDING = 'pending', + ACCEPTED = 'accepted', REJECTED = 'rejected', + PENDING_WITHDRAWAL = 'pendingWithdrawal', + WITHDRAWAL_REJECTED = 'withdrawalRejected', WITHDRAWN = 'withdrawn', - PENDING_WITHDRAWAL = 'pending_withdrawal', } export enum ReviewPermissions { diff --git a/app/preprints/-components/preprint-status-banner/component.ts b/app/preprints/-components/preprint-status-banner/component.ts index 90cd45986a6..d9ba076d252 100644 --- a/app/preprints/-components/preprint-status-banner/component.ts +++ b/app/preprints/-components/preprint-status-banner/component.ts @@ -22,26 +22,26 @@ const PRE_MODERATION = 'pre-moderation'; const POST_MODERATION = 'post-moderation'; const STATUS = Object({}); -STATUS[PENDING]= 'components.preprint-status-banner.pending'; -STATUS[ACCEPTED]= 'components.preprint-status-banner.accepted'; -STATUS[REJECTED]= 'components.preprint-status-banner.rejected'; -STATUS[PENDING_WITHDRAWAL]= 'components.preprint-status-banner.pending_withdrawal'; -STATUS[WITHDRAWAL_REJECTED]= 'components.preprint-status-banner.withdrawal_rejected'; +STATUS[PENDING]= 'preprints.detail.status_banner.pending'; +STATUS[ACCEPTED]= 'preprints.detail.status_banner.accepted'; +STATUS[REJECTED]= 'preprints.detail.status_banner.rejected'; +STATUS[PENDING_WITHDRAWAL]= 'preprints.detail.status_banner.pending_withdrawal'; +STATUS[WITHDRAWAL_REJECTED]= 'preprints.detail.status_banner.withdrawal_rejected'; const MESSAGE = Object({}); -MESSAGE[PRE_MODERATION] = 'components.preprint-status-banner.message.pending_pre'; -MESSAGE[POST_MODERATION] = 'components.preprint-status-banner.message.pending_post'; -MESSAGE[ACCEPTED] = 'components.preprint-status-banner.message.accepted'; -MESSAGE[REJECTED] = 'components.preprint-status-banner.message.rejected'; -MESSAGE[PENDING_WITHDRAWAL] = 'components.preprint-status-banner.message.pending_withdrawal'; -MESSAGE[WITHDRAWAL_REJECTED] = 'components.preprint-status-banner.message.withdrawal_rejected'; -MESSAGE[WITHDRAWN] = 'components.preprint-status-banner.message.withdrawn'; -MESSAGE[UNKNOWN] = 'components.preprint-status-banner.message.withdrawn'; +MESSAGE[PRE_MODERATION] = 'preprints.detail.status_banner.message.pending_pre'; +MESSAGE[POST_MODERATION] = 'preprints.detail.status_banner.message.pending_post'; +MESSAGE[ACCEPTED] = 'preprints.detail.status_banner.message.accepted'; +MESSAGE[REJECTED] = 'preprints.detail.status_banner.message.rejected'; +MESSAGE[PENDING_WITHDRAWAL] = 'preprints.detail.status_banner.message.pending_withdrawal'; +MESSAGE[WITHDRAWAL_REJECTED] = 'preprints.detail.status_banner.message.withdrawal_rejected'; +MESSAGE[WITHDRAWN] = 'preprints.detail.status_banner.message.withdrawn'; +MESSAGE[UNKNOWN] = 'preprints.detail.status_banner.message.withdrawn'; const WORKFLOW = Object({}); -WORKFLOW[PRE_MODERATION] = 'global.pre_moderation'; -WORKFLOW[POST_MODERATION] = 'global.post_moderation'; -WORKFLOW[UNKNOWN] = 'global.post_moderation'; +WORKFLOW[PRE_MODERATION] = 'preprints.detail.status_banner.pre_moderation'; +WORKFLOW[POST_MODERATION] = 'preprints.detail.status_banner.post_moderation'; +WORKFLOW[UNKNOWN] = 'preprints.detail.status_banner.post_moderation'; const CLASS_NAMES = Object({}); CLASS_NAMES[PRE_MODERATION] = 'preprint-status-pending-pre'; @@ -54,13 +54,13 @@ CLASS_NAMES[WITHDRAWN] = 'preprint-status-withdrawn'; CLASS_NAMES[UNKNOWN] = 'preprint-status-withdrawn'; const ICONS = Object({}); -ICONS[PENDING] = 'fa-hourglass-o'; -ICONS[ACCEPTED] = 'fa-check-circle-o'; -ICONS[REJECTED] = 'fa-times-circle-o'; -ICONS[PENDING_WITHDRAWAL] = 'fa-hourglass-o'; -ICONS[WITHDRAWAL_REJECTED] = 'fa-times-circle-o'; -ICONS[WITHDRAWN] = 'fa-exclamation-triangle'; -ICONS[UNKNOWN] = 'fa-exclamation-triangle'; +ICONS[PENDING] = 'hourglass'; +ICONS[ACCEPTED] = 'check-circle'; +ICONS[REJECTED] = 'times-circle'; +ICONS[PENDING_WITHDRAWAL] = 'hourglass'; +ICONS[WITHDRAWAL_REJECTED] = 'times-circle'; +ICONS[WITHDRAWN] = 'exclamation-triangle'; +ICONS[UNKNOWN] = 'exclamation-triangle'; interface InputArgs { submission: PreprintModel; @@ -80,9 +80,9 @@ export default class PreprintStatusBanner extends Component{ isWithdrawalRejected = false; // translations - labelModeratorFeedback = 'components.preprint-status-banner.feedback.moderator_feedback'; - moderator = 'components.preprint-status-banner.feedback.moderator'; - baseMessage = 'components.preprint-status-banner.message.base'; + labelModeratorFeedback = 'preprints.detail.status_banner.feedback.moderator_feedback'; + moderator = 'preprints.detail.status_banner.feedback.moderator'; + baseMessage = 'preprints.detail.status_banner.message.base'; classNames = ['preprint-status-component']; classNameBindings = ['getClassName']; @@ -103,7 +103,7 @@ export default class PreprintStatusBanner extends Component{ taskFor(this.loadPreprintState).perform(); } - public getClassName(): string { + public get getClassName(): string { if (this.isPendingWithdrawal) { return CLASS_NAMES['PENDING_WITHDRAWAL']; } else if (this.isWithdrawn) { @@ -119,19 +119,20 @@ export default class PreprintStatusBanner extends Component{ public get bannerContent(): string { if (this.isPendingWithdrawal) { - return this.intl.t(this.statusExplanation, { documentType: this.provider?.documentType }); + return this.intl.t(this.statusExplanation, { documentType: this.provider?.documentType.singular }); } else if (this.isWithdrawn) { - return this.intl.t(MESSAGE[WITHDRAWN], { documentType: this.provider?.documentType }); + return this.intl.t(MESSAGE[WITHDRAWN], { documentType: this.provider?.documentType.singular }); } else if (this.isWithdrawalRejected) { - return this.intl.t(MESSAGE[WITHDRAWAL_REJECTED], { documentType: this.provider?.documentType }); + return this.intl.t(MESSAGE[WITHDRAWAL_REJECTED], { documentType: this.provider?.documentType.singular }); } else { const tName = this.theme.isProvider ? this.theme.provider?.name : - this.intl.t('global.brand_name'); + this.intl.t('preprints.detail.status_banner.brand_name'); const tWorkflow = this.intl.t(this.workflow); const tStatusExplanation = this.intl.t(this.statusExplanation); // eslint-disable-next-line max-len - return `${this.intl.t(this.baseMessage), { name: tName, reviewsWorkflow: tWorkflow, documentType: this.provider?.documentType }} ${tStatusExplanation}`; + const base = (this.intl.t(this.baseMessage, { name: tName, reviewsWorkflow: tWorkflow, documentType: this.provider?.documentType.singular })); + return `${base} ${tStatusExplanation}`; } } @@ -140,7 +141,7 @@ export default class PreprintStatusBanner extends Component{ return ''; } // eslint-disable-next-line max-len - return this.intl.t('components.preprint-status-banner.feedback.base', { documentType: this.provider?.documentType }); + return this.intl.t('preprints.detail.status_banner.feedback.base', { documentType: this.provider?.documentType.singular }); } private get statusExplanation(): string { diff --git a/app/preprints/-components/preprint-status-banner/styles.scss b/app/preprints/-components/preprint-status-banner/styles.scss index dfb43ae069f..0be61a3dc2e 100644 --- a/app/preprints/-components/preprint-status-banner/styles.scss +++ b/app/preprints/-components/preprint-status-banner/styles.scss @@ -1,4 +1,5 @@ /* Import variables before bootstrap so that boostrap variables can be overridden */ +// stylelint-disable max-nesting-depth, selector-max-compound-selectors $color-alert-bg-warning: #fcf8e3; $color-alert-border-warning: #faebcc; @@ -80,41 +81,44 @@ $color-border-light: #ddd; margin-bottom: 15px; } -/* -#preprint-status { - .flex-container { - font-size: 16px; +.preprint-banner-status-container { + height: 75px; + width: 100%; + display: flex; + flex-direction: row; + align-items: center; + justify-content: center; + font-size: 16px; + margin-bottom: 15px; + + .display-container { display: flex; - align-items: center; flex-direction: row; - align-content: space-between; + align-items: center; + justify-content: center; + padding: 10px; strong { display: inline-block; // required for the text-transform } + strong::first-letter { text-transform: uppercase; } - .status-explanation { - padding-right: 15px; - .banner-content { - padding-left: 5px; - } - } .reviewer-feedback { margin-left: auto; padding-right: 15px; .dropdown-menu { - font-size:62.5%; + font-size: 62.5%; background-color: $color-bg-color-light; color: $color-bg-color-grey; border: 1px solid $color-border-light; width: 445px; left: auto; right: 15px; - margin-top: 0px; + margin-top: 0; z-index: 98; // prevent dropdown from scrolling over navbar .status { @@ -123,7 +127,7 @@ $color-border-light: #ddd; .moderator-comment { font-size: 1.8em; - background-color: white; + background-color: $white; padding: 30px 15px; p { @@ -132,12 +136,12 @@ $color-border-light: #ddd; } .feedback-header { - font-size: 2.0em; + font-size: 2em; border-bottom: 1px solid $color-border-light; - padding: 5px 15px 8px 15px; + padding: 5px 15px 8px; a { - color: grey; + color: #333; float: right; } } @@ -149,4 +153,3 @@ $color-border-light: #ddd; } } } -*/ diff --git a/app/preprints/-components/preprint-status-banner/template.hbs b/app/preprints/-components/preprint-status-banner/template.hbs index 11d19896cd6..4047b714015 100644 --- a/app/preprints/-components/preprint-status-banner/template.hbs +++ b/app/preprints/-components/preprint-status-banner/template.hbs @@ -1,29 +1,30 @@ -
-
+
+
{{#if (or this.submission.provider.isPending this.loadPreprintState.isRunning) }} - {{ t 'preprints.status_banner.loading' }} + {{ t 'preprints.detail.status_banner.loading' }} {{else}} {{#if this.isWithdrawn}} -
- +
+
{{else}} -
- - {{!-- {{t this.status }}: --}} +
+
{{#if (and this.reviewerComment (not this.submission.provider.reviewsCommentsPrivate))}}
{{t this.labelModeratorFeedback}} - - + +
@@ -35,7 +36,7 @@ {{#unless this.submission.provider.reviewsCommentsAnonymous}}
{{this.reviewerName}}
{{/unless}} - {{if this.theme.isProvider this.theme.provider.name (t 'global.brand_name')}} {{t this.moderator}} + {{if this.theme.isProvider this.theme.provider.name (t 'preprints.detail.status_banner.brand_name')}} {{t this.moderator}}
diff --git a/mirage/scenarios/preprints.ts b/mirage/scenarios/preprints.ts index 8f698179155..646b7b97346 100644 --- a/mirage/scenarios/preprints.ts +++ b/mirage/scenarios/preprints.ts @@ -42,7 +42,7 @@ function buildOSF( id: 'osf-approved-admin', title: 'Preprint RWF: Pre-moderation, Admin and Approved', currentUserPermissions: [Permission.Admin], - reviewsState: ReviewsState.APPROVED, + reviewsState: ReviewsState.ACCEPTED, description: `${faker.lorem.sentence(200)}\n${faker.lorem.sentence(100)}`, doi: '10.30822/artk.v1i1.79', originalPublicationDate: new Date('2016-11-30T16:00:00.000000Z'), @@ -64,7 +64,7 @@ function buildOSF( title: 'Preprint RWF: Pre-moderation, Non-Admin and Approved', currentUserPermissions: [], doi: '10.30822/artk.v1i1.79', - reviewsState: ReviewsState.APPROVED, + reviewsState: ReviewsState.ACCEPTED, description: `${faker.lorem.sentence(200)}\n${faker.lorem.sentence(300)}`, originalPublicationDate: new Date('2016-11-30T16:00:00.000000Z'), preprintDoiCreated: new Date('2016-11-30T16:00:00.000000Z'), @@ -75,7 +75,7 @@ function buildOSF( id: 'osf-orphan', title: 'Preprint RWF: Pre-moderation, Non-Admin and Approved', currentUserPermissions: [], - reviewsState: ReviewsState.APPROVED, + reviewsState: ReviewsState.ACCEPTED, isPreprintOrphan: true, }); @@ -84,7 +84,7 @@ function buildOSF( id: 'osf-private', title: 'Preprint RWF: Pre-moderation, Non-Admin and Approved', currentUserPermissions: [], - reviewsState: ReviewsState.APPROVED, + reviewsState: ReviewsState.ACCEPTED, public: false, }); @@ -93,7 +93,7 @@ function buildOSF( id: 'osf-not-published', title: 'Preprint RWF: Pre-moderation, Non-Admin and Approved', currentUserPermissions: [], - reviewsState: ReviewsState.APPROVED, + reviewsState: ReviewsState.ACCEPTED, isPublished: false, }); @@ -102,7 +102,7 @@ function buildOSF( id: 'osf-withdrawn', title: 'Preprint Non-Admin, Not Published and withdrawn', currentUserPermissions: [], - reviewsState: ReviewsState.APPROVED, + reviewsState: ReviewsState.ACCEPTED, isPublished: false, dateWithdrawn: new Date(), }); diff --git a/translations/en-us.yml b/translations/en-us.yml index 095bfb96d6b..58dd1bfe720 100644 --- a/translations/en-us.yml +++ b/translations/en-us.yml @@ -1158,8 +1158,29 @@ preprints: supplemental_materials: 'Supplemental Materials' tags: 'Tags' status_banner: + pre_moderation: 'pre-moderation' + post_moderation: 'post-moderation' + brand_name: 'OSF' loading: 'Loading...' close: 'Close' + message: + base: '{name} uses {reviewsWorkflow}. This {documentType}' + pending_pre: 'is not publicly available or searchable until approved by a moderator.' + pending_post: 'is publicly available and searchable but is subject to removal by a moderator.' + accepted: 'has been accepted by a moderator and is publicly available and searchable.' + rejected: 'has been rejected by a moderator and is not publicly available or searchable.' + pending_withdrawal: 'This {documentType} has been requested by the authors to be withdrawn. It will still be publicly searchable until the request has been approved.' + withdrawn: 'This {documentType} has been withdrawn.' + withdrawal_rejected: 'Your request to withdraw this {documentType} from the service has been denied by the moderator.' + pending: 'pending' + accepted: 'accepted' + rejected: 'rejected' + pending_withdrawal: 'pending withdrawal' + withdrawal_rejected: 'withdrawal rejected' + feedback: + moderator_feedback: 'Moderator feedback' + moderator: 'Moderator' + base: 'This {documentType}' header: osf_registrations: 'OSF Preprints' registrations: 'Preprints' From 913f591eb971a22cd284ceba03fd3db0c381cc95 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Fri, 29 Sep 2023 13:39:41 -0600 Subject: [PATCH 091/170] Added a bunch of serializer, mirage and scenario logic --- app/models/preprint-request-action.ts | 7 + app/models/preprint-request.ts | 10 ++ .../preprint-status-banner/component.ts | 24 +-- .../preprint-status-banner/styles.scss | 164 +++++++++--------- .../preprint-status-banner/template.hbs | 98 ++++++----- app/preprints/detail/controller.ts | 3 +- app/preprints/detail/template.hbs | 4 +- app/serializers/preprint-request-action.ts | 14 ++ app/serializers/preprint-request.ts | 10 ++ mirage/config.ts | 4 +- mirage/factories/preprint-request-action.ts | 37 ++++ mirage/factories/preprint-request.ts | 71 ++++++++ mirage/factories/preprint.ts | 28 ++- mirage/scenarios/preprints.ts | 20 +++ 14 files changed, 350 insertions(+), 144 deletions(-) create mode 100644 app/serializers/preprint-request-action.ts create mode 100644 app/serializers/preprint-request.ts create mode 100644 mirage/factories/preprint-request-action.ts create mode 100644 mirage/factories/preprint-request.ts diff --git a/app/models/preprint-request-action.ts b/app/models/preprint-request-action.ts index fe90842d13d..c23da894604 100644 --- a/app/models/preprint-request-action.ts +++ b/app/models/preprint-request-action.ts @@ -4,6 +4,13 @@ import UserModel from 'ember-osf-web/models/user'; import OsfModel from './osf-model'; + +export enum PreprintRequestActionTriggerEnum { + SUBMIT= 'submit', + ACCEPT = 'accept', + REJECT = 'reject', +} + export default class PreprintRequestActionModel extends OsfModel { @attr('string') comment!: String; @attr('string') actionTrigger!: String; diff --git a/app/models/preprint-request.ts b/app/models/preprint-request.ts index 167bbce4f56..6a379701037 100644 --- a/app/models/preprint-request.ts +++ b/app/models/preprint-request.ts @@ -5,6 +5,16 @@ import PreprintRequestActionModel from 'ember-osf-web/models/preprint-request-ac import OsfModel from './osf-model'; +export enum PreprintRequestType{ + WITHDRAWAL = 'withdrawal', +} + +export enum PreprintRequestMachineState { + PENDING = 'pending', + ACCEPTED = 'accepted', + REJECTED = 'rejected', +} + export default class PreprintRequestModel extends OsfModel { @attr('string') comment!: String; @attr('date') dateLastTransitioned!: Date; diff --git a/app/preprints/-components/preprint-status-banner/component.ts b/app/preprints/-components/preprint-status-banner/component.ts index d9ba076d252..1dc2e37d987 100644 --- a/app/preprints/-components/preprint-status-banner/component.ts +++ b/app/preprints/-components/preprint-status-banner/component.ts @@ -14,7 +14,7 @@ const UNKNOWN = 'unknown'; const PENDING = 'pending'; const ACCEPTED = 'accepted'; const REJECTED = 'rejected'; -const PENDING_WITHDRAWAL = 'pendingWithdrawal'; +const PENDING_WITHDRAWAL = 'endingWithdrawal'; const WITHDRAWAL_REJECTED = 'withdrawalRejected'; const WITHDRAWN = 'withdrawn'; @@ -64,7 +64,6 @@ ICONS[UNKNOWN] = 'exclamation-triangle'; interface InputArgs { submission: PreprintModel; - isWithdrawn: boolean; } export default class PreprintStatusBanner extends Component{ @@ -72,7 +71,7 @@ export default class PreprintStatusBanner extends Component{ @service theme!: Theme; submission = this.args.submission; - isWithdrawn = this.args.isWithdrawn; + isWithdrawn = this.args.submission.isWithdrawn; provider: PreprintProviderModel | undefined; @@ -84,9 +83,6 @@ export default class PreprintStatusBanner extends Component{ moderator = 'preprints.detail.status_banner.feedback.moderator'; baseMessage = 'preprints.detail.status_banner.message.base'; - classNames = ['preprint-status-component']; - classNameBindings = ['getClassName']; - latestAction: PreprintRequestActionModel | undefined; @alias('latestAction.comment') reviewerComment: string | undefined; @@ -105,12 +101,13 @@ export default class PreprintStatusBanner extends Component{ public get getClassName(): string { if (this.isPendingWithdrawal) { - return CLASS_NAMES['PENDING_WITHDRAWAL']; + return CLASS_NAMES[PENDING_WITHDRAWAL]; } else if (this.isWithdrawn) { - return CLASS_NAMES['WITHDRAWN']; + return CLASS_NAMES[WITHDRAWN]; } else if (this.isWithdrawalRejected) { - return CLASS_NAMES['WITHDRAWAL_REJECTED']; + return CLASS_NAMES[WITHDRAWAL_REJECTED]; } else { + // console.log(5, this.submission.reviewsState === PENDING); return this.submission.reviewsState === PENDING ? CLASS_NAMES[this.provider?.reviewsWorkflow || UNKNOWN] : CLASS_NAMES[this.submission.reviewsState]; @@ -125,6 +122,7 @@ export default class PreprintStatusBanner extends Component{ } else if (this.isWithdrawalRejected) { return this.intl.t(MESSAGE[WITHDRAWAL_REJECTED], { documentType: this.provider?.documentType.singular }); } else { + // console.log(25, this.theme.isProvider === true); const tName = this.theme.isProvider ? this.theme.provider?.name : this.intl.t('preprints.detail.status_banner.brand_name'); @@ -136,10 +134,11 @@ export default class PreprintStatusBanner extends Component{ } } - feedbackBaseMessage(): string { + public get feedbackBaseMessage(): string { if (this.isWithdrawalRejected) { return ''; } + // console.log(33); // eslint-disable-next-line max-len return this.intl.t('preprints.detail.status_banner.feedback.base', { documentType: this.provider?.documentType.singular }); } @@ -150,6 +149,7 @@ export default class PreprintStatusBanner extends Component{ } else if (this.isWithdrawalRejected) { return MESSAGE[WITHDRAWAL_REJECTED]; } else { + // console.log(44, this.submission.reviewsState === PENDING); return this.submission.reviewsState === PENDING ? MESSAGE[this.provider?.reviewsWorkflow || UNKNOWN ] : MESSAGE[this.submission.reviewsState]; @@ -197,6 +197,7 @@ export default class PreprintStatusBanner extends Component{ const requestActions = await withdrawalRequest.queryHasMany('actions', { sort: '-modified', }); + const latestRequestAction = requestActions.firstObject; if (latestRequestAction && latestRequestAction.actionTrigger === 'reject') { this.isWithdrawalRejected = true; @@ -208,9 +209,12 @@ export default class PreprintStatusBanner extends Component{ } } if (this.provider.reviewsCommentsPrivate) { + // console.log(88); return; } + // console.log(89); this.latestAction = latestSubmissionAction; + // console.log(90); } } diff --git a/app/preprints/-components/preprint-status-banner/styles.scss b/app/preprints/-components/preprint-status-banner/styles.scss index 0be61a3dc2e..002d393d362 100644 --- a/app/preprints/-components/preprint-status-banner/styles.scss +++ b/app/preprints/-components/preprint-status-banner/styles.scss @@ -43,44 +43,6 @@ $color-border-light: #ddd; } } -.preprint-status-accepted { - background-color: $color-alert-bg-success; - border: 1px solid $color-alert-border-success; - color: $color-alert-text-success; - - .status-icon { - -webkit-text-stroke: 0; - font-size: 16px; - } -} - -.preprint-status-rejected { - background-color: $color-alert-bg-danger; - border: 1px solid $color-alert-border-danger; - color: $color-alert-text-danger; - - .status-icon { - -webkit-text-stroke: 0; - font-size: 16px; - } -} - -.preprint-status-withdrawn { - background-color: $color-alert-bg-warning; - border: 1px solid $color-alert-border-warning; - color: $color-alert-text-warning; - - .status-icon { - -webkit-text-stroke: 1px $color-alert-text-warning; - font-size: 14px; - } -} - -.preprint-status-component { - margin-top: -15px; - margin-bottom: 15px; -} - .preprint-banner-status-container { height: 75px; width: 100%; @@ -89,65 +51,107 @@ $color-border-light: #ddd; align-items: center; justify-content: center; font-size: 16px; - margin-bottom: 15px; - .display-container { + .preprint-banner-status { + height: 75px; + width: 100%; display: flex; flex-direction: row; align-items: center; justify-content: center; - padding: 10px; + font-size: 16px; - strong { - display: inline-block; // required for the text-transform + &.preprint-status-accepted { + background-color: $color-alert-bg-success; + border: 1px solid $color-alert-border-success; + color: $color-alert-text-success; + + .status-icon { + -webkit-text-stroke: 0; + font-size: 16px; + } } - strong::first-letter { - text-transform: uppercase; + &.preprint-status-rejected { + background-color: $color-alert-bg-danger; + border: 1px solid $color-alert-border-danger; + color: $color-alert-text-danger; + + .status-icon { + -webkit-text-stroke: 0; + font-size: 16px; + } } - .reviewer-feedback { - margin-left: auto; - padding-right: 15px; - - .dropdown-menu { - font-size: 62.5%; - background-color: $color-bg-color-light; - color: $color-bg-color-grey; - border: 1px solid $color-border-light; - width: 445px; - left: auto; - right: 15px; - margin-top: 0; - z-index: 98; // prevent dropdown from scrolling over navbar - - .status { - font-size: 1.4em; - } + &.preprint-status-withdrawn { + background-color: $color-alert-bg-warning; + border: 1px solid $color-alert-border-warning; + color: $color-alert-text-warning; + + .status-icon { + -webkit-text-stroke: 1px $color-alert-text-warning; + font-size: 14px; + } + } - .moderator-comment { - font-size: 1.8em; - background-color: $white; - padding: 30px 15px; + .display-container { + display: flex; + flex-direction: row; + align-items: center; + justify-content: center; + padding: 10px; - p { - padding-bottom: 5px; + strong { + display: inline-block; // required for the text-transform + } + + strong::first-letter { + text-transform: uppercase; + } + + .reviewer-feedback { + margin-left: auto; + padding-right: 15px; + + .dropdown-menu { + font-size: 62.5%; + background-color: $color-bg-color-light; + color: $color-bg-color-grey; + border: 1px solid $color-border-light; + width: 445px; + left: auto; + right: 15px; + margin-top: 0; + z-index: 98; // prevent dropdown from scrolling over navbar + + .status { + font-size: 1.4em; } - } - .feedback-header { - font-size: 2em; - border-bottom: 1px solid $color-border-light; - padding: 5px 15px 8px; + .moderator-comment { + font-size: 1.8em; + background-color: $color-text-white; + padding: 30px 15px; - a { - color: #333; - float: right; + p { + padding-bottom: 5px; + } } - } - .feedback-footer { - border-top: 1px solid $color-border-light; + .feedback-header { + font-size: 2em; + border-bottom: 1px solid $color-border-light; + padding: 5px 15px 8px; + + a { + color: #333; + float: right; + } + } + + .feedback-footer { + border-top: 1px solid $color-border-light; + } } } } diff --git a/app/preprints/-components/preprint-status-banner/template.hbs b/app/preprints/-components/preprint-status-banner/template.hbs index 4047b714015..f4596a4c2c0 100644 --- a/app/preprints/-components/preprint-status-banner/template.hbs +++ b/app/preprints/-components/preprint-status-banner/template.hbs @@ -1,48 +1,58 @@
-
- {{#if (or this.submission.provider.isPending this.loadPreprintState.isRunning) }} - {{ t 'preprints.detail.status_banner.loading' }} - {{else}} - {{#if this.isWithdrawn}} -
-
- {{else}} -
-
- {{#if (and this.reviewerComment (not this.submission.provider.reviewsCommentsPrivate))}} -
- -
-
- {{t this.labelModeratorFeedback}} - - -
-
- {{t this.status}} -
{{this.feedbackBaseMessage}} {{t this.statusExplanation documentType=this.submission.provider.documentType}}
-
-
-

{{this.reviewerComment}}

- {{#unless this.submission.provider.reviewsCommentsAnonymous}} -
{{this.reviewerName}}
- {{/unless}} - {{if this.theme.isProvider this.theme.provider.name (t 'preprints.detail.status_banner.brand_name')}} {{t this.moderator}} + {{#if (or this.submission.provider?.isPending this.loadPreprintState.isRunning) }} + {{ t 'preprints.detail.status_banner.loading' }} + {{else}} +
+
+ {{!{{this.getClassName - after load}} + {{#if this.isWithdrawn}} +
+
+ {{else}} +
+
+ {{#if (and this.reviewerComment (not this.submission.provider.reviewsCommentsPrivate))}} + {{!comments}} +
+ +
+
+ {{t this.labelModeratorFeedback}} + + +
+
+ {{t this.status}} +
{{this.feedbackBaseMessage}} {{t this.statusExplanation documentType=this.submission.provider.documentType}}
+
+
+

{{this.reviewerComment}}

+ {{#unless this.submission.provider.reviewsCommentsAnonymous}} + {{!reviewer name}} +
{{this.reviewerName}}
+ {{/unless}} + {{!#if this.theme.isProvider}} + {{!isProvider}} + {{!else}} + {{!not isProvider}} + {{!/if}} + {{if this.theme.isProvider this.theme.provider.name (t 'preprints.detail.status_banner.brand_name')}} {{t this.moderator}} +
+
-
-
+ {{/if}} {{/if}} - {{/if}} - {{/if}} -
-
+
+
+ {{/if}} +
\ No newline at end of file diff --git a/app/preprints/detail/controller.ts b/app/preprints/detail/controller.ts index 36059175315..0a073b7dc1f 100644 --- a/app/preprints/detail/controller.ts +++ b/app/preprints/detail/controller.ts @@ -110,11 +110,12 @@ export default class PrePrintsDetailController extends Controller { } showStatusBanner(): boolean { + // console.log('okay'); return ( this.model.provider.reviewsWorkflow && this.model.preprint.public && this.userIsContrib - && this.model.preprint.reviewsState !== ReviewsState.INITIAL + && this.model.preprint.reviewsState !== ReviewsState.PENDING ) || this.isPendingWithdrawal; } diff --git a/app/preprints/detail/template.hbs b/app/preprints/detail/template.hbs index 40ad0ca4f3d..41d0bdec988 100644 --- a/app/preprints/detail/template.hbs +++ b/app/preprints/detail/template.hbs @@ -34,9 +34,7 @@ data-analytics-scope='preprints detail page' {{! removed }}
{{#if (or this.showStatusBanner this.isWithdrawn)}} - + {{/if}} {{! removed }}
diff --git a/app/serializers/preprint-request-action.ts b/app/serializers/preprint-request-action.ts new file mode 100644 index 00000000000..2b9d3a4fd52 --- /dev/null +++ b/app/serializers/preprint-request-action.ts @@ -0,0 +1,14 @@ +import OsfSerializer from './osf-serializer'; + +export default class PreprintRequestActionSerializer extends OsfSerializer { + attrs: any = { + ...this.attrs, // from OsfSerializer + actionTrigger: 'trigger', + }; +} + +declare module 'ember-data/types/registries/serializer' { + export default interface SerializerRegistry { + 'preprint-request-action': PreprintRequestActionSerializer; + } // eslint-disable-line semi +} diff --git a/app/serializers/preprint-request.ts b/app/serializers/preprint-request.ts new file mode 100644 index 00000000000..18319f8c50a --- /dev/null +++ b/app/serializers/preprint-request.ts @@ -0,0 +1,10 @@ +import OsfSerializer from './osf-serializer'; + +export default class PreprintRequestSerializer extends OsfSerializer { +} + +declare module 'ember-data/types/registries/serializer' { + export default interface SerializerRegistry { + 'preprint-request': PreprintRequestSerializer; + } // eslint-disable-line semi +} diff --git a/mirage/config.ts b/mirage/config.ts index 9f40e696b5e..c822b842ace 100644 --- a/mirage/config.ts +++ b/mirage/config.ts @@ -354,8 +354,8 @@ export default function(this: Server) { /** * Preprint Request Actions */ - osfResource(this, 'requests'); - osfNestedResource(this, 'requests', 'actions', { + osfResource(this, 'preprint-request', {path: '/requests'}); + osfNestedResource(this, 'preprint-request', 'actions', { path: '/requests/:parentID/actions', relatedModelName: 'preprint-request-action', }); diff --git a/mirage/factories/preprint-request-action.ts b/mirage/factories/preprint-request-action.ts new file mode 100644 index 00000000000..8c6c72810d9 --- /dev/null +++ b/mirage/factories/preprint-request-action.ts @@ -0,0 +1,37 @@ +import { Factory } from 'ember-cli-mirage'; +import faker from 'faker'; +import PreprintRequestActionModel, +{ PreprintRequestActionTriggerEnum } from 'ember-osf-web/models/preprint-request-action'; + + +import { guid, guidAfterCreate } from './utils'; + +export default Factory.extend({ + id: guid('preprint'), + + comment: faker.lorem.sentence(100), + actionTrigger: PreprintRequestActionTriggerEnum.SUBMIT, + dateModified: new Date('2023-08-29T10:35:27.746938Z'), + auto: false, + + afterCreate(preprintRequestAction, server) { + guidAfterCreate(preprintRequestAction, server); + + preprintRequestAction.update({ + creator: preprintRequestAction.target.creator, + target: preprintRequestAction.target, + }); + }, +}); + +declare module 'ember-cli-mirage/types/registries/model' { + export default interface MirageModelRegistry { + 'preprint-request-action': PreprintRequestActionModel; + } // eslint-disable-line semi +} + +declare module 'ember-cli-mirage/types/registries/schema' { + export default interface MirageSchemaRegistry { + 'preprint-request-action': PreprintRequestActionModel; + } // eslint-disable-line semi +} diff --git a/mirage/factories/preprint-request.ts b/mirage/factories/preprint-request.ts new file mode 100644 index 00000000000..74202fc95ce --- /dev/null +++ b/mirage/factories/preprint-request.ts @@ -0,0 +1,71 @@ +import { Factory, Trait, trait } from 'ember-cli-mirage'; +import faker from 'faker'; +import PreprintRequestModel, +{ PreprintRequestMachineState, PreprintRequestType } from 'ember-osf-web/models/preprint-request'; +import { PreprintRequestActionTriggerEnum } from 'ember-osf-web/models/preprint-request-action'; + +import { guid, guidAfterCreate} from './utils'; + +export interface PreprintRequestTraits { + pending: Trait; + reject: Trait; +} + +export default Factory.extend({ + id: guid('preprint'), + + comment: faker.lorem.sentence(100), + machineState: PreprintRequestMachineState.PENDING, + requestType: PreprintRequestType.WITHDRAWAL, + dateLastTransitioned: new Date('2023-08-29T10:35:27.746938Z'), + created: new Date('2023-08-29T10:35:27.746938Z'), + modified: new Date('2023-08-29T10:35:27.746938Z'), + + afterCreate(preprintRequest, server) { + guidAfterCreate(preprintRequest, server); + + const creator = server.create('user', { + givenName: 'Trio', + familyName: 'Lipa', + }); + + preprintRequest.update({ + creator, + target: preprintRequest.target, + }); + }, + + pending: trait({ + afterCreate(preprintRequest, server) { + const preprintRequestAction = server.create('preprintRequestAction', + { + actionTrigger: PreprintRequestActionTriggerEnum.SUBMIT, + target: preprintRequest, + }); + preprintRequest.update({ actions: [preprintRequestAction ]}); + }, + }), + + reject: trait({ + afterCreate(preprintRequest, server) { + const preprintRequestAction = server.create('preprintRequestAction', + { + actionTrigger: PreprintRequestActionTriggerEnum.REJECT, + target: preprintRequest, + }); + preprintRequest.update({ actions: [preprintRequestAction ]}); + }, + }), +}); + +declare module 'ember-cli-mirage/types/registries/model' { + export default interface MirageModelRegistry { + 'preprint-request': PreprintRequestModel; + } // eslint-disable-line semi +} + +declare module 'ember-cli-mirage/types/registries/schema' { + export default interface MirageSchemaRegistry { + 'preprint-request': PreprintRequestModel; + } // eslint-disable-line semi +} diff --git a/mirage/factories/preprint.ts b/mirage/factories/preprint.ts index fcc2abaa80c..8220df36e21 100644 --- a/mirage/factories/preprint.ts +++ b/mirage/factories/preprint.ts @@ -1,4 +1,4 @@ -import { Factory } from 'ember-cli-mirage'; +import { Factory, Trait, trait } from 'ember-cli-mirage'; import faker from 'faker'; import PreprintModel from 'ember-osf-web/models/preprint'; @@ -15,8 +15,12 @@ function buildLicenseText(): string { return text; } +export interface PreprintTraits { + pendingWithdrawal: Trait; + rejectedWithdrawal: Trait; +} -export default Factory.extend({ +export default Factory.extend({ id: guid('preprint'), title: faker.lorem.sentence(), @@ -49,8 +53,6 @@ export default Factory.extend({ citation: null, - isPublished: true, - apiMeta: { metrics: { downloads: faker.random.number(1000), @@ -123,6 +125,24 @@ export default Factory.extend({ }); }, + pendingWithdrawal: trait({ + afterCreate(newPreprint, server) { + const preprintRequest = server.create('preprintRequest', { + target: newPreprint, + }, 'pending'); + newPreprint.update({ requests: [preprintRequest ]}); + }, + }), + + rejectedWithdrawal: trait({ + afterCreate(newPreprint, server) { + const preprintRequest = server.create('preprintRequest', { + target: newPreprint, + }, 'reject'); + newPreprint.update({ requests: [preprintRequest ]}); + }, + }), + }); declare module 'ember-cli-mirage/types/registries/model' { diff --git a/mirage/scenarios/preprints.ts b/mirage/scenarios/preprints.ts index 646b7b97346..a176624165d 100644 --- a/mirage/scenarios/preprints.ts +++ b/mirage/scenarios/preprints.ts @@ -107,6 +107,24 @@ function buildOSF( dateWithdrawn: new Date(), }); + const pendingWithdrawalPreprint = server.create('preprint', { + provider: osf, + id: 'osf-pending-withdrawal', + title: 'Preprint Non-Admin, Not Published and Pending Withdrawal', + currentUserPermissions: [], + reviewsState: ReviewsState.ACCEPTED, + isPublished: false, + }, 'pendingWithdrawal'); + + const rejectedWithdrawalPreprint = server.create('preprint', { + provider: osf, + id: 'osf-rejected-withdrawal', + title: 'Preprint Non-Admin, Not Published and Rejected Withdrawal', + currentUserPermissions: [], + reviewsState: ReviewsState.ACCEPTED, + isPublished: false, + }, 'rejectedWithdrawal'); + const subjects = server.createList('subject', 7); osf.update({ @@ -126,6 +144,8 @@ function buildOSF( privatePreprint, notPublishedPreprint, withdrawnPreprint, + pendingWithdrawalPreprint, + rejectedWithdrawalPreprint, ], description: 'This is the description for osf', }); From 71fe1228dab1d636a30ce6ee0be5a6d153a62ad1 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Tue, 3 Oct 2023 15:09:28 -0600 Subject: [PATCH 092/170] Added a bunch of mirage love --- .../preprint-status-banner/component.ts | 9 +- .../preprint-status-banner/styles.scss | 74 ++++------ .../preprint-status-banner/template.hbs | 67 +++++----- .../components/branded-navbar/template.hbs | 1 + mirage/factories/preprint-request-action.ts | 3 - mirage/factories/preprint-request.ts | 31 ++++- mirage/factories/preprint.ts | 26 +++- mirage/fixtures/preprint-providers.ts | 3 + mirage/scenarios/preprints.ts | 126 +++++++++++++++++- 9 files changed, 239 insertions(+), 101 deletions(-) diff --git a/app/preprints/-components/preprint-status-banner/component.ts b/app/preprints/-components/preprint-status-banner/component.ts index 1dc2e37d987..ca892ebae22 100644 --- a/app/preprints/-components/preprint-status-banner/component.ts +++ b/app/preprints/-components/preprint-status-banner/component.ts @@ -9,6 +9,7 @@ import { alias } from '@ember/object/computed'; import PreprintRequestActionModel from 'ember-osf-web/models/preprint-request-action'; import { taskFor } from 'ember-concurrency-ts'; import PreprintProviderModel from 'ember-osf-web/models/preprint-provider'; +import { tracked } from '@glimmer/tracking'; const UNKNOWN = 'unknown'; const PENDING = 'pending'; @@ -75,6 +76,7 @@ export default class PreprintStatusBanner extends Component{ provider: PreprintProviderModel | undefined; + @tracked displayComment = false; isPendingWithdrawal = false; isWithdrawalRejected = false; @@ -107,7 +109,6 @@ export default class PreprintStatusBanner extends Component{ } else if (this.isWithdrawalRejected) { return CLASS_NAMES[WITHDRAWAL_REJECTED]; } else { - // console.log(5, this.submission.reviewsState === PENDING); return this.submission.reviewsState === PENDING ? CLASS_NAMES[this.provider?.reviewsWorkflow || UNKNOWN] : CLASS_NAMES[this.submission.reviewsState]; @@ -122,7 +123,6 @@ export default class PreprintStatusBanner extends Component{ } else if (this.isWithdrawalRejected) { return this.intl.t(MESSAGE[WITHDRAWAL_REJECTED], { documentType: this.provider?.documentType.singular }); } else { - // console.log(25, this.theme.isProvider === true); const tName = this.theme.isProvider ? this.theme.provider?.name : this.intl.t('preprints.detail.status_banner.brand_name'); @@ -149,7 +149,6 @@ export default class PreprintStatusBanner extends Component{ } else if (this.isWithdrawalRejected) { return MESSAGE[WITHDRAWAL_REJECTED]; } else { - // console.log(44, this.submission.reviewsState === PENDING); return this.submission.reviewsState === PENDING ? MESSAGE[this.provider?.reviewsWorkflow || UNKNOWN ] : MESSAGE[this.submission.reviewsState]; @@ -208,13 +207,11 @@ export default class PreprintStatusBanner extends Component{ return; } } + if (this.provider.reviewsCommentsPrivate) { - // console.log(88); return; } - // console.log(89); this.latestAction = latestSubmissionAction; - // console.log(90); } } diff --git a/app/preprints/-components/preprint-status-banner/styles.scss b/app/preprints/-components/preprint-status-banner/styles.scss index 002d393d362..3b4cd1ddda8 100644 --- a/app/preprints/-components/preprint-status-banner/styles.scss +++ b/app/preprints/-components/preprint-status-banner/styles.scss @@ -101,59 +101,33 @@ $color-border-light: #ddd; justify-content: center; padding: 10px; - strong { - display: inline-block; // required for the text-transform - } + .reviewer-feedback { + margin-left: 15px; - strong::first-letter { - text-transform: uppercase; } + } + } +} - .reviewer-feedback { - margin-left: auto; - padding-right: 15px; - - .dropdown-menu { - font-size: 62.5%; - background-color: $color-bg-color-light; - color: $color-bg-color-grey; - border: 1px solid $color-border-light; - width: 445px; - left: auto; - right: 15px; - margin-top: 0; - z-index: 98; // prevent dropdown from scrolling over navbar - - .status { - font-size: 1.4em; - } - - .moderator-comment { - font-size: 1.8em; - background-color: $color-text-white; - padding: 30px 15px; - - p { - padding-bottom: 5px; - } - } - - .feedback-header { - font-size: 2em; - border-bottom: 1px solid $color-border-light; - padding: 5px 15px 8px; - - a { - color: #333; - float: right; - } - } - - .feedback-footer { - border-top: 1px solid $color-border-light; - } - } - } +.status-banner-dialog { + .status { + font-size: 1.4em; + + strong { + display: inline-block; // required for the text-transform + } + + strong::first-letter { + text-transform: uppercase; + } + } + + .moderator-comment { + font-size: 1.8em; + padding: 30px 15px; + + p { + padding-bottom: 5px; } } } diff --git a/app/preprints/-components/preprint-status-banner/template.hbs b/app/preprints/-components/preprint-status-banner/template.hbs index f4596a4c2c0..f8d42529098 100644 --- a/app/preprints/-components/preprint-status-banner/template.hbs +++ b/app/preprints/-components/preprint-status-banner/template.hbs @@ -4,7 +4,6 @@ {{else}}
- {{!{{this.getClassName - after load}} {{#if this.isWithdrawn}}
+ {{this.reviewerComment}} + {{this.submission.provider.reviewsCommentsPrivate}} {{#if (and this.reviewerComment (not this.submission.provider.reviewsCommentsPrivate))}} - {{!comments}} -
- -
-
- {{t this.labelModeratorFeedback}} - - -
-
- {{t this.status}} -
{{this.feedbackBaseMessage}} {{t this.statusExplanation documentType=this.submission.provider.documentType}}
-
-
-

{{this.reviewerComment}}

- {{#unless this.submission.provider.reviewsCommentsAnonymous}} - {{!reviewer name}} -
{{this.reviewerName}}
- {{/unless}} - {{!#if this.theme.isProvider}} - {{!isProvider}} - {{!else}} - {{!not isProvider}} - {{!/if}} - {{if this.theme.isProvider this.theme.provider.name (t 'preprints.detail.status_banner.brand_name')}} {{t this.moderator}} -
-
-
+
{{/if}} {{/if}} diff --git a/lib/app-components/addon/components/branded-navbar/template.hbs b/lib/app-components/addon/components/branded-navbar/template.hbs index e6b1a93f2a5..db270f0b69a 100644 --- a/lib/app-components/addon/components/branded-navbar/template.hbs +++ b/lib/app-components/addon/components/branded-navbar/template.hbs @@ -11,6 +11,7 @@ - {{this.reviewerComment}} - {{this.submission.provider.reviewsCommentsPrivate}} {{#if (and this.reviewerComment (not this.submission.provider.reviewsCommentsPrivate))}}
{{#if (or this.showStatusBanner this.isWithdrawn)}} {{/if}} - {{! removed }}
{{#if this.model.preprint.isWithdrawn}}
+ {{! removed - tombstone }}

{{t 'preprints.detail.abstract'}}

@@ -57,29 +57,7 @@ data-analytics-scope='preprints detail page' {{/if}}

-
-

{{t 'preprints.detail.preprint_doi' documentType=this.model.provider.documentType.singular}}

- {{#if this.model.preprint.preprintDoiUrl}} - {{#if this.model.preprint.preprintDoiCreated}} - - {{this.preprintDoi}} - - {{else}} -

{{this.preprintDoi}}

-

{{t 'preprints.detail.preprint_pending_doi_minted'}}

- {{/if}} - {{else}} - {{#if (not this.model.preprint.public)}} - {{t 'preprints.detail.preprint_pending_doi' documentType=this.model.provider.documentType.singular }} - {{else if (and this.model.provider.reviewsWorkflow (not this.model.preprint.isPublished))}} - {{t 'preprints.detail.preprint_pending_doi_moderation'}} - {{/if}} - {{/if}} -
+ {{#if this.model.preprint.license.name}}

{{t 'preprints.detail.license'}}

@@ -243,29 +221,7 @@ data-analytics-scope='preprints detail page'
{{/if}} -
-

{{t 'preprints.detail.preprint_doi' documentType=this.model.provider.documentType.singular}}

- {{#if this.model.preprint.preprintDoiUrl}} - {{#if this.model.preprint.preprintDoiCreated}} - - {{this.preprintDoi}} - - {{else}} -

{{this.preprintDoi}}

-

{{t 'preprints.detail.preprint_pending_doi_minted'}}

- {{/if}} - {{else}} - {{#if (not this.model.preprint.public)}} - {{t 'preprints.detail.preprint_pending_doi' documentType=this.model.provider.documentType.singular }} - {{else if (and this.model.provider.reviewsWorkflow (not this.model.preprint.isPublished))}} - {{t 'preprints.detail.preprint_pending_doi_moderation'}} - {{/if}} - {{/if}} -
+ {{#if this.model.preprint.articleDoiUrl}}

{{t 'preprints.detail.article_doi'}}

diff --git a/mirage/factories/preprint.ts b/mirage/factories/preprint.ts index 9cde5c377ca..40b91a7f33e 100644 --- a/mirage/factories/preprint.ts +++ b/mirage/factories/preprint.ts @@ -15,6 +15,10 @@ function buildLicenseText(): string { return text; } +export interface PreprintMirageModel extends PreprintModel { + isPreprintDoi: boolean; +} + export interface PreprintTraits { pendingWithdrawal: Trait; isContributor: Trait; @@ -23,10 +27,12 @@ export interface PreprintTraits { rejectedWithdrawalNoComment: Trait; } -export default Factory.extend({ +export default Factory.extend({ id: guid('preprint'), title: faker.lorem.sentence(), + isPreprintDoi: true, + currentUserPermissions: [Permission.Admin], reviewsState: ReviewsState.REJECTED, diff --git a/mirage/scenarios/preprints.ts b/mirage/scenarios/preprints.ts index 148c5a07b5e..5a29a0aa7e8 100644 --- a/mirage/scenarios/preprints.ts +++ b/mirage/scenarios/preprints.ts @@ -94,14 +94,26 @@ function buildOSF( isPreprintOrphan: true, }, 'isContributor'); - const privatePreprint = server.create('preprint', { + const privatePreprint = server.create('preprint', Object({ provider: osf, id: 'osf-private', title: 'Preprint RWF: Pre-moderation, Non-Admin and Approved', currentUserPermissions: [], reviewsState: ReviewsState.ACCEPTED, public: false, - }, 'isContributor'); + isPreprintDoi: false, + }), 'isContributor'); + + const publicDoiPreprint = server.create('preprint', Object({ + provider: osf, + id: 'osf-public-doi', + title: 'Preprint RWF: Pre-moderation, Non-Admin and Approved', + currentUserPermissions: [], + reviewsState: ReviewsState.ACCEPTED, + public: true, + isPreprintDoi: false, + isPublished: false, + }), 'isContributor'); const notPublishedPreprint = server.create('preprint', { provider: osf, @@ -183,6 +195,7 @@ function buildOSF( rejectedWithdrawalPreprintComment, acceptedWithdrawalPreprintComment, notContributorPreprint, + publicDoiPreprint, ], description: 'This is the description for osf', }); @@ -213,14 +226,14 @@ function buildrXiv( isPublished: false, }, 'rejectedWithdrawalComment', 'isContributor'); - const pendingPreprint = server.create('preprint', { + const pendingPreprint = server.create('preprint', Object({ provider: preprintrxiv, id: 'preprintrxiv-pending', title: 'Preprint Non-Admin, Pending - Pre Moderation', currentUserPermissions: [], reviewsState: ReviewsState.PENDING, isPublished: false, - }, 'isContributor'); + }) , 'isContributor'); const subjects = server.createList('subject', 7); @@ -338,8 +351,21 @@ function buildBiohackrxiv(server: Server) { secondaryColor: '#ccc', heroBackgroundImage: 'https://singlecolorimage.com/get/ffffff/1000x1000', }); + + const publicDoiPreprint = server.create('preprint', Object({ + provider: biohackrxiv, + id: 'biohackrxiv-public-doi', + title: 'Preprint RWF: No ReviewStatus, Non-Admin, Accepted, No Preprint Doi, public ', + currentUserPermissions: [], + reviewsState: ReviewsState.ACCEPTED, + public: true, + isPreprintDoi: false, + isPublished: false, + }), 'isContributor'); + biohackrxiv.update({ brand: biohackrxivBrand, description: '

This is the description for biohackrxiv!

', + preprints: [publicDoiPreprint], }); } diff --git a/mirage/serializers/preprint.ts b/mirage/serializers/preprint.ts index ddaa3c39824..f17bade4d6f 100644 --- a/mirage/serializers/preprint.ts +++ b/mirage/serializers/preprint.ts @@ -1,21 +1,21 @@ import { ModelInstance } from 'ember-cli-mirage'; import config from 'ember-get-config'; -import PreprintModel from 'ember-osf-web/models/preprint'; +import { PreprintMirageModel } from 'ember-osf-web/mirage/factories/preprint'; import ApplicationSerializer, { SerializedRelationships } from './application'; const { OSF: { apiUrl } } = config; -export default class PreprintSerializer extends ApplicationSerializer { +export default class PreprintSerializer extends ApplicationSerializer { buildNormalLinks(model: ModelInstance) { return { self: `${apiUrl}/v2/${model.id}/`, doi: model.doi ? `https://doi.org/${model.doi}` : null, - preprint_doi: `https://doi.org/10.31219/osf.io/${model.id}`, + preprint_doi: model.isPreprintDoi ? `https://doi.org/10.31219/osf.io/${model.id}` : null, }; } - buildRelationships(model: ModelInstance) { - const relationships: SerializedRelationships = { + buildRelationships(model: ModelInstance) { + const relationships: SerializedRelationships = { provider: { links: { related: { From d878421dc281989ef461d3cbe4dd2595f8fa9ed8 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Thu, 5 Oct 2023 10:49:59 -0600 Subject: [PATCH 097/170] Renamed doi to be preprint-doi --- app/preprints/-components/{doi => preprint-doi}/component.ts | 2 +- app/preprints/-components/{doi => preprint-doi}/styles.scss | 0 app/preprints/-components/{doi => preprint-doi}/template.hbs | 0 app/preprints/detail/template.hbs | 4 ++-- 4 files changed, 3 insertions(+), 3 deletions(-) rename app/preprints/-components/{doi => preprint-doi}/component.ts (90%) rename app/preprints/-components/{doi => preprint-doi}/styles.scss (100%) rename app/preprints/-components/{doi => preprint-doi}/template.hbs (100%) diff --git a/app/preprints/-components/doi/component.ts b/app/preprints/-components/preprint-doi/component.ts similarity index 90% rename from app/preprints/-components/doi/component.ts rename to app/preprints/-components/preprint-doi/component.ts index 1f84a0bf6be..f7a5b26692b 100644 --- a/app/preprints/-components/doi/component.ts +++ b/app/preprints/-components/preprint-doi/component.ts @@ -8,7 +8,7 @@ interface InputArgs { provider: PreprintProviderModel; } -export default class DOI extends Component { +export default class PreprintDOI extends Component { preprint = this.args.preprint; provider = this.args.provider; diff --git a/app/preprints/-components/doi/styles.scss b/app/preprints/-components/preprint-doi/styles.scss similarity index 100% rename from app/preprints/-components/doi/styles.scss rename to app/preprints/-components/preprint-doi/styles.scss diff --git a/app/preprints/-components/doi/template.hbs b/app/preprints/-components/preprint-doi/template.hbs similarity index 100% rename from app/preprints/-components/doi/template.hbs rename to app/preprints/-components/preprint-doi/template.hbs diff --git a/app/preprints/detail/template.hbs b/app/preprints/detail/template.hbs index 74de6ddfb36..368fad36a47 100644 --- a/app/preprints/detail/template.hbs +++ b/app/preprints/detail/template.hbs @@ -57,7 +57,7 @@ data-analytics-scope='preprints detail page' {{/if}}
- + {{#if this.model.preprint.license.name}}

{{t 'preprints.detail.license'}}

@@ -221,7 +221,7 @@ data-analytics-scope='preprints detail page'
{{/if}} - + {{#if this.model.preprint.articleDoiUrl}}

{{t 'preprints.detail.article_doi'}}

From f5525c3d3fd68d9ec3857ba9ab16b0b86cbee28d Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Thu, 5 Oct 2023 11:53:58 -0600 Subject: [PATCH 098/170] Added the preprint-license --- .../-components/preprint-doi/component.ts | 4 -- .../-components/preprint-doi/styles.scss | 57 ------------------- .../-components/preprint-license/component.ts | 18 ++++++ .../-components/preprint-license/styles.scss | 25 ++++++++ .../-components/preprint-license/template.hbs | 14 +++++ app/preprints/detail/controller.ts | 6 -- app/preprints/detail/styles.scss | 24 -------- app/preprints/detail/template.hbs | 30 +--------- mirage/factories/preprint.ts | 44 +++++++------- mirage/scenarios/preprints.ts | 20 +++++-- 10 files changed, 98 insertions(+), 144 deletions(-) delete mode 100644 app/preprints/-components/preprint-doi/styles.scss create mode 100644 app/preprints/-components/preprint-license/component.ts create mode 100644 app/preprints/-components/preprint-license/styles.scss create mode 100644 app/preprints/-components/preprint-license/template.hbs diff --git a/app/preprints/-components/preprint-doi/component.ts b/app/preprints/-components/preprint-doi/component.ts index f7a5b26692b..cd47e4e2e30 100644 --- a/app/preprints/-components/preprint-doi/component.ts +++ b/app/preprints/-components/preprint-doi/component.ts @@ -14,10 +14,6 @@ export default class PreprintDOI extends Component { documentType = this.provider.documentType.singular; - constructor(owner: any, args: any) { - super(owner, args); - } - get preprintDoi(): string { return extractDoi(this.preprint.preprintDoiUrl) || ''; } diff --git a/app/preprints/-components/preprint-doi/styles.scss b/app/preprints/-components/preprint-doi/styles.scss deleted file mode 100644 index 4991ca1c5bf..00000000000 --- a/app/preprints/-components/preprint-doi/styles.scss +++ /dev/null @@ -1,57 +0,0 @@ -// stylelint-disable max-nesting-depth, selector-max-compound-selectors - -.subject-container { - width: 100%; - display: flex; - flex-direction: row; - justify-content: space-between; - align-items: flex-start; - margin-bottom: 10px; - - .subject-item { - width: calc(50% - 20px); - - .btn { - display: inline-block; - margin-bottom: 0; - font-weight: 400; - text-align: center; - white-space: nowrap; - touch-action: manipulation; - cursor: pointer; - background-image: none; - border: 1px solid transparent; - border-radius: 2px; - padding: 6px 12px; - font-size: 14px; - line-height: 1.42857; - user-select: none; - vertical-align: middle; - color: $color-text-white; - } - - .subject-button { - width: 100%; - font-size: 17px; - overflow: hidden; - text-overflow: ellipsis; - background-color: var(--primary-color); - color: var(--secondary-color); - border: 1px solid var(--secondary-color); - - &:hover { - color: var(--primary-color); - background-color: var(--secondary-color); - border: 1px solid var(--primary-color); - } - } - } - - &.mobile { - flex-direction: column; - - .subject-item { - width: 100%; - } - } -} diff --git a/app/preprints/-components/preprint-license/component.ts b/app/preprints/-components/preprint-license/component.ts new file mode 100644 index 00000000000..b29ae5e3e06 --- /dev/null +++ b/app/preprints/-components/preprint-license/component.ts @@ -0,0 +1,18 @@ +import { action } from '@ember/object'; +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import PreprintModel from 'ember-osf-web/models/preprint'; + +interface InputArgs { + preprint: PreprintModel; +} + +export default class PreprintLicense extends Component { + preprint = this.args.preprint; + @tracked showLicenseText = false; + + @action + toggleLicenseText(): void { + this.showLicenseText = !this.showLicenseText; + } +} diff --git a/app/preprints/-components/preprint-license/styles.scss b/app/preprints/-components/preprint-license/styles.scss new file mode 100644 index 00000000000..1623113a06e --- /dev/null +++ b/app/preprints/-components/preprint-license/styles.scss @@ -0,0 +1,25 @@ +// stylelint-disable max-nesting-depth, selector-max-compound-selectors + +.license-text { + pre { + white-space: pre-wrap; + font-size: 75%; + width: 100%; + text-align: justify; + max-height: 300px; + word-break: normal; + overflow: auto; + display: block; + padding: 9.5px; + margin: 0 0 10px; + line-height: 1.42857; + word-wrap: break-word; + background-color: $bg-light; + border: 1px solid $color-shadow-gray-light; + border-radius: 4px; + } + + span { + cursor: pointer; + } +} diff --git a/app/preprints/-components/preprint-license/template.hbs b/app/preprints/-components/preprint-license/template.hbs new file mode 100644 index 00000000000..4830862ec35 --- /dev/null +++ b/app/preprints/-components/preprint-license/template.hbs @@ -0,0 +1,14 @@ +{{#if this.preprint.license.name}} +
+

{{t 'preprints.detail.license'}}

+ {{this.preprint.license.name}} + + + + {{#if this.showLicenseText}} +
{{this.preprint.licenseText}}
+ {{/if}} +
+{{/if}} \ No newline at end of file diff --git a/app/preprints/detail/controller.ts b/app/preprints/detail/controller.ts index 1661e2f3741..ea8e098b82f 100644 --- a/app/preprints/detail/controller.ts +++ b/app/preprints/detail/controller.ts @@ -54,7 +54,6 @@ export default class PrePrintsDetailController extends Controller { }; @tracked fullScreenMFR = false; - @tracked showLicenseText = false; @tracked expandedAbstract = navigator.userAgent.includes('Prerender'); @@ -131,11 +130,6 @@ export default class PrePrintsDetailController extends Controller { return extractDoi(this.model.preprint.articleDoiUrl) || ''; } - @action - toggleLicenseText(): void { - this.showLicenseText = !this.showLicenseText; - } - get hasShortenedDescription(): String { return this.model.preprint.description && this.model.preprint.description.length > 350; } diff --git a/app/preprints/detail/styles.scss b/app/preprints/detail/styles.scss index f7ae3c066bd..1f29c9bc20a 100644 --- a/app/preprints/detail/styles.scss +++ b/app/preprints/detail/styles.scss @@ -181,30 +181,6 @@ padding: 10px; } - .license-text { - pre { - white-space: pre-wrap; - font-size: 75%; - width: 100%; - text-align: justify; - max-height: 300px; - word-break: normal; - overflow: auto; - display: block; - padding: 9.5px; - margin: 0 0 10px; - line-height: 1.42857; - word-wrap: break-word; - background-color: $bg-light; - border: 1px solid $color-shadow-gray-light; - border-radius: 4px; - } - - span { - cursor: pointer; - } - } - .badge, .subject-preview { display: inline-block; diff --git a/app/preprints/detail/template.hbs b/app/preprints/detail/template.hbs index 368fad36a47..90cb78d7d74 100644 --- a/app/preprints/detail/template.hbs +++ b/app/preprints/detail/template.hbs @@ -58,20 +58,7 @@ data-analytics-scope='preprints detail page' {{/if}}
- {{#if this.model.preprint.license.name}} -
-

{{t 'preprints.detail.license'}}

- {{this.model.preprint.license.name}} - - - - {{#if this.showLicenseText}} -
{{this.model.preprint.licenseText}}
- {{/if}} -
- {{/if}} +

{{t 'preprints.detail.disciplines'}}

{{#each this.disciplineReduced as |subject|}} @@ -234,20 +221,7 @@ data-analytics-scope='preprints detail page'
{{/if}} - {{#if this.model.preprint.license.name}} -
-

{{t 'preprints.detail.license'}}

- {{this.model.preprint.license.name}} - - - - {{#if this.showLicenseText}} -
{{this.model.preprint.licenseText}}
- {{/if}} -
- {{/if}} +

{{t 'preprints.detail.disciplines'}}

{{#each this.disciplineReduced as |subject|}} diff --git a/mirage/factories/preprint.ts b/mirage/factories/preprint.ts index 40b91a7f33e..535d137d5eb 100644 --- a/mirage/factories/preprint.ts +++ b/mirage/factories/preprint.ts @@ -17,6 +17,7 @@ function buildLicenseText(): string { export interface PreprintMirageModel extends PreprintModel { isPreprintDoi: boolean; + addLicenseName: boolean; } export interface PreprintTraits { @@ -33,6 +34,8 @@ export default Factory.extend({ isPreprintDoi: true, + addLicenseName: true, + currentUserPermissions: [Permission.Admin], reviewsState: ReviewsState.REJECTED, @@ -69,12 +72,12 @@ export default Factory.extend({ }, }, - afterCreate(newPreprint, server) { - guidAfterCreate(newPreprint, server); + afterCreate(preprint, server) { + guidAfterCreate(preprint, server); const file = server.create('file', { id: 'afile', - target: newPreprint, + target: preprint, links: { info: 'http://localhost:4200/assets/osf-assets/mfr-test.pdf', move: 'http://localhost:4200/assets/osf-assets/mfr-test.pdf', @@ -88,8 +91,7 @@ export default Factory.extend({ const node = server.create('node'); const license = server.create('license', { - id: 'asdksusslsh', - name: 'Mozilla Public License 2.0', + name: preprint.addLicenseName ? 'Mozilla Public License 3.0' : undefined, text: buildLicenseText(), url: 'https://creativecommons.org/licenses/by/4.0/legalcode', requiredFields: [], @@ -107,7 +109,7 @@ export default Factory.extend({ }); const contributor = server.create('contributor', { - preprint: newPreprint, + preprint, users: contributorUser, index: 0, }); @@ -120,7 +122,7 @@ export default Factory.extend({ const allContributors = [contributor, unregisteredContributor, secondContributor, thirdContributor]; - newPreprint.update({ + preprint.update({ contributors: allContributors, bibliographicContributors: allContributors, files: [file], @@ -135,48 +137,48 @@ export default Factory.extend({ }, pendingWithdrawal: trait({ - afterCreate(newPreprint, server) { + afterCreate(preprint, server) { const preprintRequest = server.create('preprintRequest', { - target: newPreprint, + target: preprint, }, 'pending'); - newPreprint.update({ requests: [preprintRequest ]}); + preprint.update({ requests: [preprintRequest ]}); }, }), isContributor: trait({ - afterCreate(newPreprint, server) { + afterCreate(preprint, server) { const { currentUserId } = server.schema.roots.first(); server.create('contributor', { - preprint: newPreprint, + preprint, id: currentUserId, }); }, }), rejectedWithdrawalComment: trait({ - afterCreate(newPreprint, server) { + afterCreate(preprint, server) { const preprintRequest = server.create('preprintRequest', { - target: newPreprint, + target: preprint, }, 'rejectComment'); - newPreprint.update({ requests: [preprintRequest ]}); + preprint.update({ requests: [preprintRequest ]}); }, }), acceptedWithdrawalComment: trait({ - afterCreate(newPreprint, server) { + afterCreate(preprint, server) { const preprintRequest = server.create('preprintRequest', { - target: newPreprint, + target: preprint, }, 'acceptComment'); - newPreprint.update({ requests: [preprintRequest ]}); + preprint.update({ requests: [preprintRequest ]}); }, }), rejectedWithdrawalNoComment: trait({ - afterCreate(newPreprint, server) { + afterCreate(preprint, server) { const preprintRequest = server.create('preprintRequest', { - target: newPreprint, + target: preprint, }, 'rejectNoComment'); - newPreprint.update({ requests: [preprintRequest ]}); + preprint.update({ requests: [preprintRequest ]}); }, }), diff --git a/mirage/scenarios/preprints.ts b/mirage/scenarios/preprints.ts index 5a29a0aa7e8..c738eccd5b0 100644 --- a/mirage/scenarios/preprints.ts +++ b/mirage/scenarios/preprints.ts @@ -124,15 +124,26 @@ function buildOSF( isPublished: false, }, 'isContributor'); - const withdrawnPreprint = server.create('preprint', { + const withdrawnPreprint = server.create('preprint', Object({ provider: osf, id: 'osf-withdrawn', - title: 'Preprint Non-Admin, Not Published and withdrawn', + title: 'Preprint Non-Admin, Not Published and withdrawn - no license', currentUserPermissions: [], reviewsState: ReviewsState.ACCEPTED, isPublished: false, dateWithdrawn: new Date(), - }, 'isContributor'); + addLicenseName: false, + }), 'isContributor'); + + const withdrawnLicensePreprint = server.create('preprint', Object({ + provider: osf, + id: 'osf-withdrawn-license', + title: 'Preprint Non-Admin, Not Published and withdrawn - license', + currentUserPermissions: [], + reviewsState: ReviewsState.ACCEPTED, + isPublished: false, + dateWithdrawn: new Date(), + }), 'isContributor'); const pendingWithdrawalPreprint = server.create('preprint', { provider: osf, @@ -190,6 +201,7 @@ function buildOSF( privatePreprint, notPublishedPreprint, withdrawnPreprint, + withdrawnLicensePreprint, pendingWithdrawalPreprint, rejectedWithdrawalPreprintNoComment, rejectedWithdrawalPreprintComment, @@ -361,7 +373,7 @@ function buildBiohackrxiv(server: Server) { public: true, isPreprintDoi: false, isPublished: false, - }), 'isContributor'); + })); biohackrxiv.update({ brand: biohackrxivBrand, From 1112a1b1a67e6725ba21b9b3e60652c52081bd75 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Fri, 6 Oct 2023 09:59:30 -0600 Subject: [PATCH 099/170] Added the tombstone page --- app/models/preprint.ts | 1 + .../-components/preprint-status-banner/component.ts | 3 ++- app/preprints/detail/template.hbs | 9 ++++++++- mirage/scenarios/preprints.ts | 5 +++-- translations/en-us.yml | 1 + 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/app/models/preprint.ts b/app/models/preprint.ts index 377e6770388..46f62ecb3d0 100644 --- a/app/models/preprint.ts +++ b/app/models/preprint.ts @@ -31,6 +31,7 @@ export default class PreprintModel extends OsfModel { @attr('date') preprintDoiCreated!: Date; @attr('array') currentUserPermissions!: string[]; @attr('fixstringarray') tags!: string[]; + @attr('fixstring') withdrawalJustification! : string; @belongsTo('node', { inverse: 'preprints' }) node!: AsyncBelongsTo & NodeModel; diff --git a/app/preprints/-components/preprint-status-banner/component.ts b/app/preprints/-components/preprint-status-banner/component.ts index 53e2fa8f8cd..6efa6872a54 100644 --- a/app/preprints/-components/preprint-status-banner/component.ts +++ b/app/preprints/-components/preprint-status-banner/component.ts @@ -175,10 +175,11 @@ export default class PreprintStatusBanner extends Component{ @task @waitFor async loadPreprintState() { + this.provider = await this.submission.provider; + if (this.isWithdrawn) { return; } - this.provider = await this.submission.provider; const submissionActions = await this.submission.reviewActions; const latestSubmissionAction = submissionActions.firstObject; const withdrawalRequests = await this.submission.requests; diff --git a/app/preprints/detail/template.hbs b/app/preprints/detail/template.hbs index 90cb78d7d74..cf133809c88 100644 --- a/app/preprints/detail/template.hbs +++ b/app/preprints/detail/template.hbs @@ -39,7 +39,14 @@ data-analytics-scope='preprints detail page'
{{#if this.model.preprint.isWithdrawn}}
- {{! removed - tombstone }} + {{#if this.model.preprint.withdrawalJustification}} +
+

{{t 'preprints.detail.reason_for_withdrawal'}}

+

+ {{this.model.preprint.withdrawalJustification}} +

+
+ {{/if}}

{{t 'preprints.detail.abstract'}}

diff --git a/mirage/scenarios/preprints.ts b/mirage/scenarios/preprints.ts index c738eccd5b0..bb3ef55fe1d 100644 --- a/mirage/scenarios/preprints.ts +++ b/mirage/scenarios/preprints.ts @@ -127,7 +127,7 @@ function buildOSF( const withdrawnPreprint = server.create('preprint', Object({ provider: osf, id: 'osf-withdrawn', - title: 'Preprint Non-Admin, Not Published and withdrawn - no license', + title: 'Preprint Non-Admin, Not Published and withdrawn - no license - no justification', currentUserPermissions: [], reviewsState: ReviewsState.ACCEPTED, isPublished: false, @@ -138,11 +138,12 @@ function buildOSF( const withdrawnLicensePreprint = server.create('preprint', Object({ provider: osf, id: 'osf-withdrawn-license', - title: 'Preprint Non-Admin, Not Published and withdrawn - license', + title: 'Preprint Non-Admin, Not Published and withdrawn - license - justification', currentUserPermissions: [], reviewsState: ReviewsState.ACCEPTED, isPublished: false, dateWithdrawn: new Date(), + withdrawalJustification: 'This is the justification', }), 'isContributor'); const pendingWithdrawalPreprint = server.create('preprint', { diff --git a/translations/en-us.yml b/translations/en-us.yml index 58dd1bfe720..125a64f376d 100644 --- a/translations/en-us.yml +++ b/translations/en-us.yml @@ -1157,6 +1157,7 @@ preprints: metrics_disclaimer: 'Metrics collected since:' supplemental_materials: 'Supplemental Materials' tags: 'Tags' + reason_for_withdrawal: 'Reason for withdrawal' status_banner: pre_moderation: 'pre-moderation' post_moderation: 'post-moderation' From 1ec3ca400a702e88abe65fe7a5178d6d9ea5f8ef Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Fri, 6 Oct 2023 10:11:51 -0600 Subject: [PATCH 100/170] Added the preprint disciplines component --- .../-components/preprint-discipline/component.ts | 15 +++++++++++++++ .../-components/preprint-discipline/styles.scss | 8 ++++++++ .../-components/preprint-discipline/template.hbs | 6 ++++++ app/preprints/detail/styles.scss | 3 +-- app/preprints/detail/template.hbs | 16 ++++------------ 5 files changed, 34 insertions(+), 14 deletions(-) create mode 100644 app/preprints/-components/preprint-discipline/component.ts create mode 100644 app/preprints/-components/preprint-discipline/styles.scss create mode 100644 app/preprints/-components/preprint-discipline/template.hbs diff --git a/app/preprints/-components/preprint-discipline/component.ts b/app/preprints/-components/preprint-discipline/component.ts new file mode 100644 index 00000000000..50866809b2d --- /dev/null +++ b/app/preprints/-components/preprint-discipline/component.ts @@ -0,0 +1,15 @@ +import Component from '@glimmer/component'; +import SubjectModel from 'ember-osf-web/models/subject'; + +interface InputArgs { + subjects: SubjectModel[]; +} + +export default class PreprintDiscipline extends Component { + subjects = this.args.subjects; + + get disciplineReduced(): SubjectModel[] { + // Preprint disciplines are displayed in collapsed form on content page + return this.subjects.reduce((acc: SubjectModel[], val: SubjectModel) => acc.concat(val), []).uniqBy('id'); + } +} diff --git a/app/preprints/-components/preprint-discipline/styles.scss b/app/preprints/-components/preprint-discipline/styles.scss new file mode 100644 index 00000000000..4f580fce232 --- /dev/null +++ b/app/preprints/-components/preprint-discipline/styles.scss @@ -0,0 +1,8 @@ +.subject-preview { + display: inline-block; + background-color: $bg-light; + border-radius: 3px; + border: 1px solid $color-light; + padding: 1px 7px; + margin-bottom: 4px; +} diff --git a/app/preprints/-components/preprint-discipline/template.hbs b/app/preprints/-components/preprint-discipline/template.hbs new file mode 100644 index 00000000000..7de2e4725c9 --- /dev/null +++ b/app/preprints/-components/preprint-discipline/template.hbs @@ -0,0 +1,6 @@ +

+

{{t 'preprints.detail.disciplines'}}

+ {{#each this.disciplineReduced as |subject|}} + {{subject.text}} + {{/each}} +
\ No newline at end of file diff --git a/app/preprints/detail/styles.scss b/app/preprints/detail/styles.scss index 1f29c9bc20a..7e0b85af575 100644 --- a/app/preprints/detail/styles.scss +++ b/app/preprints/detail/styles.scss @@ -181,8 +181,7 @@ padding: 10px; } - .badge, - .subject-preview { + .badge { display: inline-block; background-color: $bg-light; border-radius: 3px; diff --git a/app/preprints/detail/template.hbs b/app/preprints/detail/template.hbs index cf133809c88..023ebdcddf0 100644 --- a/app/preprints/detail/template.hbs +++ b/app/preprints/detail/template.hbs @@ -66,12 +66,8 @@ data-analytics-scope='preprints detail page'
-
-

{{t 'preprints.detail.disciplines'}}

- {{#each this.disciplineReduced as |subject|}} - {{subject.text}} - {{/each}} -
+ +

{{t 'preprints.detail.tags'}}

{{#if this.model.preprint.tags.length}} @@ -229,12 +225,8 @@ data-analytics-scope='preprints detail page'
{{/if}} -
-

{{t 'preprints.detail.disciplines'}}

- {{#each this.disciplineReduced as |subject|}} - {{subject.text}} - {{/each}} -
+ +

{{t 'preprints.detail.tags'}}

{{#if this.model.preprint.tags.length}} From fedd3edc6825b0a4df463d7f6d02f3e2c5cc47cc Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Fri, 6 Oct 2023 10:12:59 -0600 Subject: [PATCH 101/170] pruned some code --- app/preprints/detail/controller.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/app/preprints/detail/controller.ts b/app/preprints/detail/controller.ts index ea8e098b82f..6e981713cd9 100644 --- a/app/preprints/detail/controller.ts +++ b/app/preprints/detail/controller.ts @@ -6,7 +6,6 @@ import Theme from 'ember-osf-web/services/theme'; import CurrentUserService from 'ember-osf-web/services/current-user'; import Features from 'ember-feature-flags'; import ContributorModel from 'ember-osf-web/models/contributor'; -import SubjectModel from 'ember-osf-web/models/subject'; import Intl from 'ember-intl/services/intl'; import { Permission } from 'ember-osf-web/models/osf-model'; import { ReviewsState, ReviewsWorkFlow } from 'ember-osf-web/models/provider'; @@ -117,11 +116,6 @@ export default class PrePrintsDetailController extends Controller { ); } - get disciplineReduced(): [] { - // Preprint disciplines are displayed in collapsed form on content page - return this.model.subjects.reduce((acc: SubjectModel[], val: SubjectModel) => acc.concat(val), []).uniqBy('id'); - } - get authors(): ContributorModel[] { return this.model.contributors; } From d774635d96ddf5b8513090d6d2f5dd9b644b596f Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Fri, 6 Oct 2023 10:18:38 -0600 Subject: [PATCH 102/170] Converted the preprint-tag page --- app/preprints/-components/preprint-tag/component.ts | 10 ++++++++++ app/preprints/-components/preprint-tag/styles.scss | 8 ++++++++ app/preprints/-components/preprint-tag/template.hbs | 10 ++++++++++ app/preprints/detail/styles.scss | 9 --------- 4 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 app/preprints/-components/preprint-tag/component.ts create mode 100644 app/preprints/-components/preprint-tag/styles.scss create mode 100644 app/preprints/-components/preprint-tag/template.hbs diff --git a/app/preprints/-components/preprint-tag/component.ts b/app/preprints/-components/preprint-tag/component.ts new file mode 100644 index 00000000000..9d981c6e9de --- /dev/null +++ b/app/preprints/-components/preprint-tag/component.ts @@ -0,0 +1,10 @@ +import Component from '@glimmer/component'; +import PreprintModel from 'ember-osf-web/models/preprint'; + +interface InputArgs { + preprint: PreprintModel; +} + +export default class PreprintTag extends Component { + preprint = this.args.preprint; +} diff --git a/app/preprints/-components/preprint-tag/styles.scss b/app/preprints/-components/preprint-tag/styles.scss new file mode 100644 index 00000000000..c49c0eaaaa8 --- /dev/null +++ b/app/preprints/-components/preprint-tag/styles.scss @@ -0,0 +1,8 @@ +.badge { + display: inline-block; + background-color: $bg-light; + border-radius: 3px; + border: 1px solid $color-light; + padding: 1px 7px; + margin-bottom: 4px; +} diff --git a/app/preprints/-components/preprint-tag/template.hbs b/app/preprints/-components/preprint-tag/template.hbs new file mode 100644 index 00000000000..d08d2fa03a4 --- /dev/null +++ b/app/preprints/-components/preprint-tag/template.hbs @@ -0,0 +1,10 @@ +
+

{{t 'preprints.detail.tags'}}

+ {{#if this.preprint.tags.length}} + {{#each this.preprint.tags as |tag|}} + {{tag}} + {{/each}} + {{else}} + {{t 'preprints.detail.none'}} + {{/if}} +
\ No newline at end of file diff --git a/app/preprints/detail/styles.scss b/app/preprints/detail/styles.scss index 7e0b85af575..67fd00da800 100644 --- a/app/preprints/detail/styles.scss +++ b/app/preprints/detail/styles.scss @@ -180,15 +180,6 @@ width: 100%; padding: 10px; } - - .badge { - display: inline-block; - background-color: $bg-light; - border-radius: 3px; - border: 1px solid $color-light; - padding: 1px 7px; - margin-bottom: 4px; - } } } From 2b7b4d5b418e7d8f455de462ae567b1ac9fc5e53 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Fri, 6 Oct 2023 10:32:47 -0600 Subject: [PATCH 103/170] added the tombstone component --- .../preprint-tombstone/component.ts | 16 ++++++++ .../preprint-tombstone/styles.scss | 16 ++++++++ .../preprint-tombstone/template.hbs | 41 +++++++++++++++++++ app/preprints/detail/template.hbs | 24 ++--------- 4 files changed, 77 insertions(+), 20 deletions(-) create mode 100644 app/preprints/-components/preprint-tombstone/component.ts create mode 100644 app/preprints/-components/preprint-tombstone/styles.scss create mode 100644 app/preprints/-components/preprint-tombstone/template.hbs diff --git a/app/preprints/-components/preprint-tombstone/component.ts b/app/preprints/-components/preprint-tombstone/component.ts new file mode 100644 index 00000000000..e698bb29d1b --- /dev/null +++ b/app/preprints/-components/preprint-tombstone/component.ts @@ -0,0 +1,16 @@ +import Component from '@glimmer/component'; +import PreprintModel from 'ember-osf-web/models/preprint'; +import PreprintProviderModel from 'ember-osf-web/models/preprint-provider'; +import SubjectModel from 'ember-osf-web/models/subject'; + +interface InputArgs { + subjects: SubjectModel[]; + preprint: PreprintModel; + provider: PreprintProviderModel; +} + +export default class PreprintTombstone extends Component { + preprint = this.args.preprint; + provider = this.args.provider; + subjects = this.args.subjects; +} diff --git a/app/preprints/-components/preprint-tombstone/styles.scss b/app/preprints/-components/preprint-tombstone/styles.scss new file mode 100644 index 00000000000..b0e955fa4d4 --- /dev/null +++ b/app/preprints/-components/preprint-tombstone/styles.scss @@ -0,0 +1,16 @@ +.withdrawn-container { + padding: 0 15px; + width: 100%; + display: flex; + flex-direction: column; + justify-content: flex-start; + align-items: flex-start; + + h4 { + padding-bottom: 15px; + padding-top: 15px; + margin-top: 10px; + margin-bottom: 10px; + font-weight: bold; + } +} diff --git a/app/preprints/-components/preprint-tombstone/template.hbs b/app/preprints/-components/preprint-tombstone/template.hbs new file mode 100644 index 00000000000..5f1c419108e --- /dev/null +++ b/app/preprints/-components/preprint-tombstone/template.hbs @@ -0,0 +1,41 @@ +
+ {{#if this.preprint.withdrawalJustification}} +
+

{{t 'preprints.detail.reason_for_withdrawal'}}

+

+ {{this.preprint.withdrawalJustification}} +

+
+ {{/if}} +
+

{{t 'preprints.detail.abstract'}}

+

+ {{this.description}} +

+ {{#if this.hasShortenedDescription}} + + {{/if}} +
+ + + + +
+

{{t 'preprints.detail.tags'}}

+ {{#if this.preprint.tags.length}} + {{#each this.preprint.tags as |tag|}} + {{tag}} + {{/each}} + {{else}} + {{t 'preprints.detail.none'}} + {{/if}} +
+
\ No newline at end of file diff --git a/app/preprints/detail/template.hbs b/app/preprints/detail/template.hbs index 023ebdcddf0..a3cf9fd4b26 100644 --- a/app/preprints/detail/template.hbs +++ b/app/preprints/detail/template.hbs @@ -38,6 +38,10 @@ data-analytics-scope='preprints detail page' {{/if}}
{{#if this.model.preprint.isWithdrawn}} +
{{#if this.model.preprint.withdrawalJustification}}
@@ -68,16 +72,6 @@ data-analytics-scope='preprints detail page' -
-

{{t 'preprints.detail.tags'}}

- {{#if this.model.preprint.tags.length}} - {{#each this.model.preprint.tags as |tag|}} - {{tag}} - {{/each}} - {{else}} - {{t 'preprints.detail.none'}} - {{/if}} -
{{else}}
@@ -227,16 +221,6 @@ data-analytics-scope='preprints detail page' -
-

{{t 'preprints.detail.tags'}}

- {{#if this.model.preprint.tags.length}} - {{#each this.model.preprint.tags as |tag|}} - {{tag}} - {{/each}} - {{else}} - {{t 'preprints.detail.none'}} - {{/if}} -
{{#if this.model.preprint.originalPublicationDate}}

{{t 'preprints.detail.original_publication_date'}}

From 7987187365da50164816bb842a3982a792b4077a Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Fri, 6 Oct 2023 11:03:08 -0600 Subject: [PATCH 104/170] Added the abstract component and refactored the tombstone and detail page --- .../preprint-abstract/component.ts | 44 ++++++++++++++ .../-components/preprint-abstract/styles.scss | 3 + .../preprint-abstract/template.hbs | 17 ++++++ .../-components/preprint-doi/component.ts | 2 +- .../preprint-tombstone/template.hbs | 28 +-------- app/preprints/detail/controller.ts | 33 ----------- app/preprints/detail/styles.scss | 59 ------------------- app/preprints/detail/template.hbs | 49 +-------------- mirage/scenarios/preprints.ts | 1 + 9 files changed, 68 insertions(+), 168 deletions(-) create mode 100644 app/preprints/-components/preprint-abstract/component.ts create mode 100644 app/preprints/-components/preprint-abstract/styles.scss create mode 100644 app/preprints/-components/preprint-abstract/template.hbs diff --git a/app/preprints/-components/preprint-abstract/component.ts b/app/preprints/-components/preprint-abstract/component.ts new file mode 100644 index 00000000000..c94e98586ec --- /dev/null +++ b/app/preprints/-components/preprint-abstract/component.ts @@ -0,0 +1,44 @@ +import { action } from '@ember/object'; +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import PreprintModel from 'ember-osf-web/models/preprint'; + +interface InputArgs { + preprint: PreprintModel; +} + +export default class PreprintAbstract extends Component { + preprint = this.args.preprint; + + @tracked expandedAbstract = navigator.userAgent.includes('Prerender'); + + get hasShortenedDescription(): boolean { + return this.preprint.description !== undefined && this.preprint.description.length > 350; + } + + private get useShortenedDescription(): boolean { + return this.hasShortenedDescription && !this.expandedAbstract; + } + + /** + * description + * + * @description Get a shortened version of the abstract, but doesn't cut in the middle of word + * by going to the last space. + * @returns string + */ + public get description(): string { + if (this.useShortenedDescription) { + return this.preprint.description + .slice(0, 350) + .replace(/\s+\S*$/, ''); + } else { + return this.preprint.description; + } + } + + @action + public expandAbstract() { + this.expandedAbstract = !this.expandedAbstract; + } +} diff --git a/app/preprints/-components/preprint-abstract/styles.scss b/app/preprints/-components/preprint-abstract/styles.scss new file mode 100644 index 00000000000..0bdc85e54a1 --- /dev/null +++ b/app/preprints/-components/preprint-abstract/styles.scss @@ -0,0 +1,3 @@ +.abstract-truncated::after { + content: ' \2026'; +} diff --git a/app/preprints/-components/preprint-abstract/template.hbs b/app/preprints/-components/preprint-abstract/template.hbs new file mode 100644 index 00000000000..feed7cda1a5 --- /dev/null +++ b/app/preprints/-components/preprint-abstract/template.hbs @@ -0,0 +1,17 @@ +
+

{{t 'preprints.detail.abstract'}}

+

+ {{this.description}} +

+ {{#if this.hasShortenedDescription}} + + {{/if}} +
\ No newline at end of file diff --git a/app/preprints/-components/preprint-doi/component.ts b/app/preprints/-components/preprint-doi/component.ts index cd47e4e2e30..fcd0b6e2399 100644 --- a/app/preprints/-components/preprint-doi/component.ts +++ b/app/preprints/-components/preprint-doi/component.ts @@ -8,7 +8,7 @@ interface InputArgs { provider: PreprintProviderModel; } -export default class PreprintDOI extends Component { +export default class PreprintAbstract extends Component { preprint = this.args.preprint; provider = this.args.provider; diff --git a/app/preprints/-components/preprint-tombstone/template.hbs b/app/preprints/-components/preprint-tombstone/template.hbs index 5f1c419108e..a1bb67daa62 100644 --- a/app/preprints/-components/preprint-tombstone/template.hbs +++ b/app/preprints/-components/preprint-tombstone/template.hbs @@ -7,35 +7,9 @@

{{/if}} -
-

{{t 'preprints.detail.abstract'}}

-

- {{this.description}} -

- {{#if this.hasShortenedDescription}} - - {{/if}} -
+ -
-

{{t 'preprints.detail.tags'}}

- {{#if this.preprint.tags.length}} - {{#each this.preprint.tags as |tag|}} - {{tag}} - {{/each}} - {{else}} - {{t 'preprints.detail.none'}} - {{/if}} -
\ No newline at end of file diff --git a/app/preprints/detail/controller.ts b/app/preprints/detail/controller.ts index 6e981713cd9..8eaf6c7d130 100644 --- a/app/preprints/detail/controller.ts +++ b/app/preprints/detail/controller.ts @@ -53,8 +53,6 @@ export default class PrePrintsDetailController extends Controller { }; @tracked fullScreenMFR = false; - @tracked expandedAbstract = navigator.userAgent.includes('Prerender'); - get hyperlink(): string { return window.location.href; @@ -124,48 +122,17 @@ export default class PrePrintsDetailController extends Controller { return extractDoi(this.model.preprint.articleDoiUrl) || ''; } - get hasShortenedDescription(): String { - return this.model.preprint.description && this.model.preprint.description.length > 350; - } - - get useShortenedDescription(): boolean { - return this.hasShortenedDescription && !this.expandedAbstract; - } - - /** - * description - * - * @description Get a shortened version of the abstract, but doesn't cut in the middle of word - * by going to the last space. - * @returns string - */ - get description(): string { - if (this.useShortenedDescription) { - return this.model.preprint.description - .slice(0, 350) - .replace(/\s+\S*$/, ''); - } else { - return this.model.preprint.description; - } - } - emailHref(): string { const titleEncoded = encodeURIComponent(this.model.title); const hrefEncoded = encodeURIComponent(window.location.href); return `mailto:?subject=${titleEncoded}&body=${hrefEncoded}`; } - @action expandMFR() { this.fullScreenMFR = !this.fullScreenMFR; } - @action - expandAbstract() { - this.expandedAbstract = !this.expandedAbstract; - } - @action trackNonContributors(category: string, label: string, url: string): void { this.send('click', category, label, url); diff --git a/app/preprints/detail/styles.scss b/app/preprints/detail/styles.scss index 67fd00da800..1dc21d829ca 100644 --- a/app/preprints/detail/styles.scss +++ b/app/preprints/detail/styles.scss @@ -144,10 +144,6 @@ font-weight: bold; } - .abstract-truncated::after { - content: ' \2026'; - } - .plaudit-container { display: flex; flex-direction: row; @@ -261,59 +257,4 @@ } } } - -} - -.bottom-margin { - margin-bottom: 50px; -} - -.pointer { - cursor: pointer; -} - -.popover { - max-width: 100%; -} - -.popover-button { - margin-left: 7px; - height: 34px; -} - -.popover-content { - background: #000; - overflow: auto; - - .form-group { - margin-bottom: 0; - width: 150px; - } -} - -.flexbox { - justify-content: flex-end; - display: flex; - align-items: center; -} - -.social-icons { - padding: 15px; -} - -.plaudit-widget { - flex: auto; - padding-right: 33px; -} - - -@media (max-width: 768px) { - .preprint-title-container { - flex-direction: column; - align-items: center; - } - - .edit-preprint-button { - margin-top: 0; - } } diff --git a/app/preprints/detail/template.hbs b/app/preprints/detail/template.hbs index a3cf9fd4b26..62e6d05739f 100644 --- a/app/preprints/detail/template.hbs +++ b/app/preprints/detail/template.hbs @@ -42,37 +42,6 @@ data-analytics-scope='preprints detail page' @preprint={{this.model.preprint}} @provider={{this.model.provider}} @subjects={{this.model.subjects}} /> -
- {{#if this.model.preprint.withdrawalJustification}} -
-

{{t 'preprints.detail.reason_for_withdrawal'}}

-

- {{this.model.preprint.withdrawalJustification}} -

-
- {{/if}} -
-

{{t 'preprints.detail.abstract'}}

-

- {{this.description}} -

- {{#if this.hasShortenedDescription}} - - {{/if}} -
- - - - -
{{else}}
{{#if this.model.preprint.isPreprintOrphan}} @@ -175,23 +144,7 @@ data-analytics-scope='preprints detail page' {{!Plaudit }}
-
-

{{t 'preprints.detail.abstract'}}

-

- {{this.description}} -

- {{#if this.hasShortenedDescription}} - - {{/if}} -
+ {{#if this.model.node}}

{{t 'preprints.detail.supplemental_materials'}}

diff --git a/mirage/scenarios/preprints.ts b/mirage/scenarios/preprints.ts index bb3ef55fe1d..4c691b16ba9 100644 --- a/mirage/scenarios/preprints.ts +++ b/mirage/scenarios/preprints.ts @@ -144,6 +144,7 @@ function buildOSF( isPublished: false, dateWithdrawn: new Date(), withdrawalJustification: 'This is the justification', + description: `${faker.lorem.sentence(200)}\n${faker.lorem.sentence(100)}`, }), 'isContributor'); const pendingWithdrawalPreprint = server.create('preprint', { From 1ecf28edce89ba988728a7c788079ee6cccd3c16 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Tue, 10 Oct 2023 12:17:55 -0600 Subject: [PATCH 105/170] Added the initial author-assertions --- app/models/preprint.ts | 18 +++ .../preprint-author-assertions/component.ts | 53 ++++++++ .../preprint-author-assertions/styles.scss | 1 + .../preprint-author-assertions/template.hbs | 122 ++++++++++++++++++ app/preprints/detail/template.hbs | 6 +- mirage/scenarios/preprints.ts | 6 + translations/en-us.yml | 28 ++++ 7 files changed, 233 insertions(+), 1 deletion(-) create mode 100644 app/preprints/-components/preprint-author-assertions/component.ts create mode 100644 app/preprints/-components/preprint-author-assertions/styles.scss create mode 100644 app/preprints/-components/preprint-author-assertions/template.hbs diff --git a/app/models/preprint.ts b/app/models/preprint.ts index 46f62ecb3d0..e3e6d3a46d0 100644 --- a/app/models/preprint.ts +++ b/app/models/preprint.ts @@ -13,6 +13,20 @@ import OsfModel from './osf-model'; import PreprintProviderModel from './preprint-provider'; import SubjectModel from './subject'; +export enum PreprintDataLinksEnum { + AVAILABLE = 'available', + YES = 'yes', + NO = 'no', + NOT_APPLICABLE = 'pot applicable', +} + +export enum PreprintPreregLinksEnum { + AVAILABLE = 'available', + YES = 'yes', + NO = 'no', + NOT_APPLICABLE = 'pot applicable', +} + export default class PreprintModel extends OsfModel { @attr('fixstring') title!: string; @attr('date') dateCreated!: Date; @@ -32,6 +46,10 @@ export default class PreprintModel extends OsfModel { @attr('array') currentUserPermissions!: string[]; @attr('fixstringarray') tags!: string[]; @attr('fixstring') withdrawalJustification! : string; + @attr('boolean') hasCoi!: boolean; + @attr('string') hasDataLinks!: string; + @attr('string') hasPreregLinks!: string; + @attr('string') conflictOfInterestStatement!: string; @belongsTo('node', { inverse: 'preprints' }) node!: AsyncBelongsTo & NodeModel; diff --git a/app/preprints/-components/preprint-author-assertions/component.ts b/app/preprints/-components/preprint-author-assertions/component.ts new file mode 100644 index 00000000000..86ae86d37f5 --- /dev/null +++ b/app/preprints/-components/preprint-author-assertions/component.ts @@ -0,0 +1,53 @@ +import Component from '@glimmer/component'; +import { inject as service } from '@ember/service'; +import PreprintModel from 'ember-osf-web/models/preprint'; +import Features from 'ember-feature-flags'; +import ProviderModel from 'ember-osf-web/models/provider'; +import { tracked } from '@glimmer/tracking'; + +interface InputArgs { + preprint: PreprintModel; + provider: ProviderModel; + documentType: string; +} + +export default class PreprintAuthorAssertions extends Component { + @service features!: Features; + + @tracked displayCoi = false; + @tracked displayDataLinks = false; + + preprint = this.args.preprint; + provider = this.args.provider; + documentType = this.args.documentType; + + /* + shouldShowSloanIcons: alias('hasSloanData'), + shouldShowPreregLinks: alias('hasPreregLinks'), + */ + + public get shouldShowSloanIcons(): boolean { + return this.hasSloanData(); + } + + private hasSloanData(): boolean { + return this.hasCoi || this.hasDataLinks || this.hasPreregLinks(); + } + + public get hasCoi(): boolean { + return this.preprint.hasCoi; + } + + public get hasCoiStatement(): boolean { + return typeof this.preprint.conflictOfInterestStatement === 'string'; + } + + public get hasDataLinks(): boolean { + return typeof this.preprint.hasDataLinks === 'string'; + } + + private hasPreregLinks(): boolean { + return typeof this.preprint.hasPreregLinks === 'string'; + } +} + diff --git a/app/preprints/-components/preprint-author-assertions/styles.scss b/app/preprints/-components/preprint-author-assertions/styles.scss new file mode 100644 index 00000000000..8c972b5c2fd --- /dev/null +++ b/app/preprints/-components/preprint-author-assertions/styles.scss @@ -0,0 +1 @@ +// stylelint-disable max-nesting-depth, selector-max-compound-selectors diff --git a/app/preprints/-components/preprint-author-assertions/template.hbs b/app/preprints/-components/preprint-author-assertions/template.hbs new file mode 100644 index 00000000000..e1f18b6945d --- /dev/null +++ b/app/preprints/-components/preprint-author-assertions/template.hbs @@ -0,0 +1,122 @@ +{{#if this.shouldShowSloanIcons}} +
+ {{~t 'preprints.detail.author-assertions.header_label'~}} +
+
+ {{#if this.hasCoi}} +
+ + + +

{{t 'preprints.detail.author-assertions.conflict_of_interest.title'}}

+
+ +
+ {{#if this.hasCoiStatement}} + {{~this.preprint.conflictOfInterestStatement~}} + {{else}} + {{~t 'preprints.detail.author-assertions.conflict_of_interest.no'~}} + {{/if}} +
+
+
+
+ {{/if}} + + {{#if this.hasDataLinks}} + {{!-- if #3 --}} +
+ + + +

{{t 'preprints.detail.author-assertions.public_data.title'}}

+
+ +
+ {{#if (eq this.preprint.hasDataLinks 'available')}} + {{!-- if #3.1 --}} + {{assertions-links + links=this.preprint.dataLinks + analyticsName=(t 'preprints.detail.author-assertions.public_data.title') + }} + {{else if (eq this.preprint.hasDataLinks 'no')}} + {{!-- else if #3.2 --}} + {{#if this.preprint.whyNoData}} + {{!-- else if if #3.2.1 --}} + {{this.preprint.whyNoData}} + {{else}} + {{!-- else if if else #3.2.2 --}} + {{~t 'preprints.detail.author-assertions.public_data.no'~}} + {{/if}} + {{else}} + {{!-- else if else #3.3 --}} + {{~t 'preprints.detail.author-assertions.public_data.not-applicable' documentType=this.documentType~}} + {{/if}} +
+
+
+
+ {{/if}} + + {{#if this.shouldShowPreregLinks}} + {{!-- #if #4 --}} +
+ {{#assertions-dropdown + available=(t (concat 'preprints.detail.author-assertions.available.' this.preprint.hasPreregLinks)) + assertionName=(t 'preprints.detail.author-assertions.prereg.title') + as |dropdown| + }} + {{#dropdown.content}} + {{#if (eq this.preprint.hasPreregLinks 'available')}} + {{!-- #if #4.1 --}} + {{assertions-links + links=this.preprint.preregLinks + analyticsName=(t 'preprints.detail.author-assertions.prereg.title') + }} + {{else if (eq this.preprint.hasPreregLinks 'no')}} + {{!-- #if else #4.1.1 --}} + {{#if this.preprint.whyNoPrereg}} + {{!-- #if else if #4.1.2 --}} + {{this.preprint.whyNoPrereg}} + {{else}} + {{!-- #if else else #4.1.3 --}} + {{~t 'preprints.detail.author-assertions.prereg.no'~}} + {{/if}} + {{else}} + {{!-- #if #4.2 --}} + {{~t 'preprints.detail.author-assertions.prereg.not-applicable' documentType=this.documentType~}} + {{/if}} + {{/dropdown.content}} + {{/assertions-dropdown}} +
+ {{/if}} +
+{{/if}} \ No newline at end of file diff --git a/app/preprints/detail/template.hbs b/app/preprints/detail/template.hbs index 62e6d05739f..df866b07a9d 100644 --- a/app/preprints/detail/template.hbs +++ b/app/preprints/detail/template.hbs @@ -31,7 +31,11 @@ data-analytics-scope='preprints detail page'
- {{! removed - author-assertions }} +
{{#if (or this.showStatusBanner this.isWithdrawn)}} diff --git a/mirage/scenarios/preprints.ts b/mirage/scenarios/preprints.ts index 4c691b16ba9..f35013ba7ce 100644 --- a/mirage/scenarios/preprints.ts +++ b/mirage/scenarios/preprints.ts @@ -1,5 +1,6 @@ import { ModelInstance, Server } from 'ember-cli-mirage'; import { Permission } from 'ember-osf-web/models/osf-model'; +import { PreprintDataLinksEnum, PreprintPreregLinksEnum } from 'ember-osf-web/models/preprint'; import PreprintProvider from 'ember-osf-web/models/preprint-provider'; import { ReviewsState } from 'ember-osf-web/models/provider'; @@ -53,6 +54,7 @@ function buildOSF( doi: '10.30822/artk.v1i1.79', originalPublicationDate: new Date('2016-11-30T16:00:00.000000Z'), preprintDoiCreated: new Date('2016-11-30T16:00:00.000000Z'), + hasCoi: true, }); const notContributorPreprint = server.create('preprint', { @@ -83,6 +85,10 @@ function buildOSF( description: `${faker.lorem.sentence(200)}\n${faker.lorem.sentence(300)}`, originalPublicationDate: new Date('2016-11-30T16:00:00.000000Z'), preprintDoiCreated: new Date('2016-11-30T16:00:00.000000Z'), + hasCoi: true, + hasDataLinks: PreprintDataLinksEnum.AVAILABLE, + hasPreregLinks: PreprintPreregLinksEnum.available, + conflictOfInterestStatement: `${faker.lorem.sentence(200)}\n${faker.lorem.sentence(300)}`, }, 'isContributor'); const orphanedPreprint = server.create('preprint', { diff --git a/translations/en-us.yml b/translations/en-us.yml index 125a64f376d..d99e983d7d1 100644 --- a/translations/en-us.yml +++ b/translations/en-us.yml @@ -1158,6 +1158,34 @@ preprints: supplemental_materials: 'Supplemental Materials' tags: 'Tags' reason_for_withdrawal: 'Reason for withdrawal' + author-assertions: + header_label: 'Author Assertions' + describe: 'Describe' + available: + yes: 'Yes' + no: 'No' + available: 'Available' + not_applicable: 'Not applicable' + conflict_of_interest: + title: 'Conflict of Interest' + no: 'Author asserted no Conflict of Interest' + public_data: + linksToData: 'Links to data' + title: 'Public Data' + no: 'No additional information provided by author.' + 'not-applicable': 'Author asserted there is no data associated with this {documentType}.' + description: 'Data refers to raw and/or processed information (quantitative or qualitative) used for the analyses, case studies, and/or descriptive interpretation in the {documentType}. Public data could include data posted to open-access repositories, public archival library collection, or government archive. For data that is available under limited circumstances (e.g., after signing a data sharing agreement), choose the ‘No’ option and use the comment box to explain how others could access the data.' + prereg: + links: 'Links' + title: 'Preregistration' + type: 'Type' + chooseOne: 'Choose one' + no: 'No additional information provided by author.' + prereg_designs: 'Study Design' + prereg_analysis: 'Analysis Plan' + prereg_both: 'Both' + 'not-applicable': 'Author asserted that preregistration was not applicable because no data collection, extraction, or analysis is reported in this {documentType}.' + description: 'A preregistration is a description of the research design and/or analysis plan that is created and registered before researchers collected data or before they have seen/interacted with preexisting data. The description should appear in a public registry (e.g., clinicaltrials.gov, OSF, AEA registry).' status_banner: pre_moderation: 'pre-moderation' post_moderation: 'post-moderation' From 0952f2ce1e35c2e9a63acdebf00d5456c789dd1a Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Tue, 10 Oct 2023 12:40:43 -0600 Subject: [PATCH 106/170] Added the preprint assertion link --- app/models/preprint.ts | 1 + .../preprint-assertion-link/component.ts | 12 ++++++++++++ .../preprint-assertion-link/styles.scss | 19 +++++++++++++++++++ .../preprint-assertion-link/template.hbs | 14 ++++++++++++++ .../preprint-author-assertions/template.hbs | 10 ++++------ mirage/scenarios/preprints.ts | 3 ++- 6 files changed, 52 insertions(+), 7 deletions(-) create mode 100644 app/preprints/-components/preprint-assertion-link/component.ts create mode 100644 app/preprints/-components/preprint-assertion-link/styles.scss create mode 100644 app/preprints/-components/preprint-assertion-link/template.hbs diff --git a/app/models/preprint.ts b/app/models/preprint.ts index e3e6d3a46d0..00f3ec29b67 100644 --- a/app/models/preprint.ts +++ b/app/models/preprint.ts @@ -50,6 +50,7 @@ export default class PreprintModel extends OsfModel { @attr('string') hasDataLinks!: string; @attr('string') hasPreregLinks!: string; @attr('string') conflictOfInterestStatement!: string; + @attr('array') dataLinks!: string[]; @belongsTo('node', { inverse: 'preprints' }) node!: AsyncBelongsTo & NodeModel; diff --git a/app/preprints/-components/preprint-assertion-link/component.ts b/app/preprints/-components/preprint-assertion-link/component.ts new file mode 100644 index 00000000000..488c8833c6e --- /dev/null +++ b/app/preprints/-components/preprint-assertion-link/component.ts @@ -0,0 +1,12 @@ +import Component from '@glimmer/component'; + +interface InputArgs { + links: string[]; + analyticsName: string; +} + +export default class PreprintAssertionLink extends Component { + links = this.args.links; + analyticsName = this.args.analyticsName; +} + diff --git a/app/preprints/-components/preprint-assertion-link/styles.scss b/app/preprints/-components/preprint-assertion-link/styles.scss new file mode 100644 index 00000000000..599de3ae056 --- /dev/null +++ b/app/preprints/-components/preprint-assertion-link/styles.scss @@ -0,0 +1,19 @@ +// stylelint-disable max-nesting-depth, selector-max-compound-selectors + +.assertions-links { + list-style: none; + margin: 0; + padding: 0; + + li { + margin-bottom: 10px; + } + + & li > a { + color: $color-text-blue-dark; + + &:hover { + color: $color-text-blue-dark; + } + } +} diff --git a/app/preprints/-components/preprint-assertion-link/template.hbs b/app/preprints/-components/preprint-assertion-link/template.hbs new file mode 100644 index 00000000000..58125ffed33 --- /dev/null +++ b/app/preprints/-components/preprint-assertion-link/template.hbs @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/app/preprints/-components/preprint-author-assertions/template.hbs b/app/preprints/-components/preprint-author-assertions/template.hbs index e1f18b6945d..659493dece9 100644 --- a/app/preprints/-components/preprint-author-assertions/template.hbs +++ b/app/preprints/-components/preprint-author-assertions/template.hbs @@ -39,7 +39,6 @@ {{/if}} {{#if this.hasDataLinks}} - {{!-- if #3 --}}
- - -

{{t 'preprints.detail.author-assertions.conflict_of_interest.title'}}

-
- -
- {{#if this.hasCoiStatement}} - {{~this.preprint.conflictOfInterestStatement~}} - {{else}} - {{~t 'preprints.detail.author-assertions.conflict_of_interest.no'~}} - {{/if}} -
-
-
+
+
+
+ {{~t 'preprints.detail.author-assertions.header_label'~}}
- {{/if}} +
+ {{#if this.hasCoi}} +
+
+ {{~t 'preprints.detail.author-assertions.conflict_of_interest.title'~}} +
+ + + +

{{t 'preprints.detail.author-assertions.conflict_of_interest.title'}}

+
+ +
+ {{#if this.hasCoiStatement}} + {{~this.preprint.conflictOfInterestStatement~}} + {{else}} + {{~t 'preprints.detail.author-assertions.conflict_of_interest.no'~}} + {{/if}} +
+
+
+
+ {{/if}} - {{#if this.hasDataLinks}} -
- - - -

{{t 'preprints.detail.author-assertions.public_data.title'}}

-
- -
- {{#if (eq this.preprint.hasDataLinks 'available')}} - - {{else if (eq this.preprint.hasDataLinks 'no')}} - {{!-- else if #3.2 --}} - {{#if this.preprint.whyNoData}} - {{!-- else if if #3.2.1 --}} - {{this.preprint.whyNoData}} - {{else}} - {{!-- else if if else #3.2.2 --}} - {{~t 'preprints.detail.author-assertions.public_data.no'~}} - {{/if}} - {{else}} - {{!-- else if else #3.3 --}} - {{~t 'preprints.detail.author-assertions.public_data.not-applicable' documentType=this.documentType~}} - {{/if}} + {{#if this.hasDataLinks}} +
+
+ {{~t 'preprints.detail.author-assertions.public_data.title'~}}
- - -
- {{/if}} +
+ + + +

{{t 'preprints.detail.author-assertions.public_data.title'}}

+
+ +
+ {{#if (eq this.preprint.hasDataLinks 'available')}} + + {{else if (eq this.preprint.hasDataLinks 'no')}} + {{#if this.preprint.whyNoData}} + {{this.preprint.whyNoData}} + {{else}} + {{~t 'preprints.detail.author-assertions.public_data.no'~}} + {{/if}} + {{else}} + {{~t 'preprints.detail.author-assertions.public_data.not_applicable' documentType=this.documentType~}} + {{/if}} +
+
+
+
+
+ {{/if}} - {{#if this.shouldShowPreregLinks}} - {{!-- #if #4 --}} -
- {{#assertions-dropdown - available=(t (concat 'preprints.detail.author-assertions.available.' this.preprint.hasPreregLinks)) - assertionName=(t 'preprints.detail.author-assertions.prereg.title') - as |dropdown| - }} - {{#dropdown.content}} - {{#if (eq this.preprint.hasPreregLinks 'available')}} - {{!-- #if #4.1 --}} - {{assertions-links - links=this.preprint.preregLinks - analyticsName=(t 'preprints.detail.author-assertions.prereg.title') + {{#if this.shouldShowPreregLinks}} + {{!-- #if #4 --}} +
+
+ {{~t 'preprints.detail.author-assertions.public_data.title'~}} +
+
+ {{#assertions-dropdown + available=(t (concat 'preprints.detail.author-assertions.available.' this.preprint.hasPreregLinks)) + assertionName=(t 'preprints.detail.author-assertions.prereg.title') + as |dropdown| }} - {{else if (eq this.preprint.hasPreregLinks 'no')}} - {{!-- #if else #4.1.1 --}} - {{#if this.preprint.whyNoPrereg}} - {{!-- #if else if #4.1.2 --}} - {{this.preprint.whyNoPrereg}} - {{else}} - {{!-- #if else else #4.1.3 --}} - {{~t 'preprints.detail.author-assertions.prereg.no'~}} - {{/if}} - {{else}} - {{!-- #if #4.2 --}} - {{~t 'preprints.detail.author-assertions.prereg.not-applicable' documentType=this.documentType~}} - {{/if}} - {{/dropdown.content}} - {{/assertions-dropdown}} + {{#dropdown.content}} + {{#if (eq this.preprint.hasPreregLinks 'available')}} + {{!-- #if #4.1 --}} + {{assertions-links + links=this.preprint.preregLinks + analyticsName=(t 'preprints.detail.author-assertions.prereg.title') + }} + {{else if (eq this.preprint.hasPreregLinks 'no')}} + {{!-- #if else #4.1.1 --}} + {{#if this.preprint.whyNoPrereg}} + {{!-- #if else if #4.1.2 --}} + {{this.preprint.whyNoPrereg}} + {{else}} + {{!-- #if else else #4.1.3 --}} + {{~t 'preprints.detail.author-assertions.prereg.no'~}} + {{/if}} + {{else}} + {{!-- #if #4.2 --}} + {{~t 'preprints.detail.author-assertions.prereg.not-applicable' documentType=this.documentType~}} + {{/if}} + {{/dropdown.content}} + {{/assertions-dropdown}} +
+
+ {{/if}}
- {{/if}} +
{{/if}} \ No newline at end of file diff --git a/mirage/scenarios/preprints.ts b/mirage/scenarios/preprints.ts index 3f5caf13b64..57aaebc1447 100644 --- a/mirage/scenarios/preprints.ts +++ b/mirage/scenarios/preprints.ts @@ -55,6 +55,7 @@ function buildOSF( originalPublicationDate: new Date('2016-11-30T16:00:00.000000Z'), preprintDoiCreated: new Date('2016-11-30T16:00:00.000000Z'), hasCoi: true, + hasDataLinks: PreprintDataLinksEnum.NOT_APPLICABLE, }); const notContributorPreprint = server.create('preprint', { @@ -63,6 +64,8 @@ function buildOSF( title: 'Preprint RWF: Pre-moderation, Non-Admin and Rejected', currentUserPermissions: [], reviewsState: ReviewsState.REJECTED, + hasDataLinks: PreprintDataLinksEnum.NO, + whyNoData: `Why No Data\n${faker.lorem.sentence(200)}\n${faker.lorem.sentence(300)}`, tags: [], }); @@ -72,6 +75,7 @@ function buildOSF( title: 'Preprint RWF: Pre-moderation, Non-Admin and Rejected', currentUserPermissions: [], reviewsState: ReviewsState.REJECTED, + hasDataLinks: PreprintDataLinksEnum.NO, tags: [], }, 'isContributor'); diff --git a/translations/en-us.yml b/translations/en-us.yml index d99e983d7d1..b925cd9a634 100644 --- a/translations/en-us.yml +++ b/translations/en-us.yml @@ -1173,7 +1173,7 @@ preprints: linksToData: 'Links to data' title: 'Public Data' no: 'No additional information provided by author.' - 'not-applicable': 'Author asserted there is no data associated with this {documentType}.' + 'not_applicable': 'Author asserted there is no data associated with this {documentType}.' description: 'Data refers to raw and/or processed information (quantitative or qualitative) used for the analyses, case studies, and/or descriptive interpretation in the {documentType}. Public data could include data posted to open-access repositories, public archival library collection, or government archive. For data that is available under limited circumstances (e.g., after signing a data sharing agreement), choose the ‘No’ option and use the comment box to explain how others could access the data.' prereg: links: 'Links' From f341f7205fedd84cc36a6312997338b72498f3f1 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Wed, 11 Oct 2023 10:58:34 -0600 Subject: [PATCH 108/170] Finished author assertion for pre registration links --- app/models/preprint.ts | 2 + .../preprint-author-assertions/component.ts | 13 +++- .../preprint-author-assertions/styles.scss | 2 - .../preprint-author-assertions/template.hbs | 71 +++++++++++-------- mirage/scenarios/preprints.ts | 7 +- translations/en-us.yml | 4 +- 6 files changed, 60 insertions(+), 39 deletions(-) diff --git a/app/models/preprint.ts b/app/models/preprint.ts index 0fca267bb6d..9e4922d04c4 100644 --- a/app/models/preprint.ts +++ b/app/models/preprint.ts @@ -51,7 +51,9 @@ export default class PreprintModel extends OsfModel { @attr('string') hasPreregLinks!: string; @attr('string') conflictOfInterestStatement!: string; @attr('array') dataLinks!: string[]; + @attr('array') preregLinks!: string[]; @attr('string') whyNoData!: string; + @attr('string') whyNoPrereg!: string; @belongsTo('node', { inverse: 'preprints' }) node!: AsyncBelongsTo & NodeModel; diff --git a/app/preprints/-components/preprint-author-assertions/component.ts b/app/preprints/-components/preprint-author-assertions/component.ts index ba37cc263b3..ae7354da6a2 100644 --- a/app/preprints/-components/preprint-author-assertions/component.ts +++ b/app/preprints/-components/preprint-author-assertions/component.ts @@ -18,6 +18,7 @@ export default class PreprintAuthorAssertions extends Component { @tracked displayCoi = false; @tracked displayDataLinks = false; + @tracked displayPreregLinks = false; preprint = this.args.preprint; provider = this.args.provider; @@ -28,10 +29,16 @@ export default class PreprintAuthorAssertions extends Component { shouldShowPreregLinks: alias('hasPreregLinks'), */ - public get availableMessage(): string { + public get availableDataLinksMessage(): string { const prefix = 'preprints.detail.author-assertions.available.'; const suffix = this.preprint.hasDataLinks.replace(/\s/g, '_'); return this.intl.t(`${prefix}${suffix}`); + } + + public get availablePreregLinksMessage(): string { + const prefix = 'preprints.detail.author-assertions.available.'; + const suffix = this.preprint.hasPreregLinks.replace(/\s/g, '_'); + return this.intl.t(`${prefix}${suffix}`); } @@ -40,7 +47,7 @@ export default class PreprintAuthorAssertions extends Component { } private hasSloanData(): boolean { - return this.hasCoi || this.hasDataLinks || this.hasPreregLinks(); + return this.hasCoi || this.hasDataLinks || this.hasPreregLinks; } public get hasCoi(): boolean { @@ -55,7 +62,7 @@ export default class PreprintAuthorAssertions extends Component { return typeof this.preprint.hasDataLinks === 'string'; } - private hasPreregLinks(): boolean { + public get hasPreregLinks(): boolean { return typeof this.preprint.hasPreregLinks === 'string'; } } diff --git a/app/preprints/-components/preprint-author-assertions/styles.scss b/app/preprints/-components/preprint-author-assertions/styles.scss index 7cb88eb6042..1114790fb04 100644 --- a/app/preprints/-components/preprint-author-assertions/styles.scss +++ b/app/preprints/-components/preprint-author-assertions/styles.scss @@ -7,7 +7,6 @@ flex-direction: row; justify-content: center; align-items: center; - // border: 1px solid red; .author-assertions-container { width: calc(100% - 100px); @@ -15,7 +14,6 @@ flex-direction: column; justify-content: flex-start; align-items: flex-start; - // border: 1px solid white; .header-label { font-size: 11px; diff --git a/app/preprints/-components/preprint-author-assertions/template.hbs b/app/preprints/-components/preprint-author-assertions/template.hbs index 76e1289fa22..1f87b1e34d8 100644 --- a/app/preprints/-components/preprint-author-assertions/template.hbs +++ b/app/preprints/-components/preprint-author-assertions/template.hbs @@ -31,7 +31,7 @@

{{t 'preprints.detail.author-assertions.conflict_of_interest.title'}}

-
+
{{#if this.hasCoiStatement}} {{~this.preprint.conflictOfInterestStatement~}} {{else}} @@ -55,7 +55,7 @@ @type='default' {{on 'click' (action (mut this.displayDataLinks) (not this.displayDataLinks))}} > - {{this.availableMessage}} + {{this.availableDataLinksMessage}}
{{/unless}} {{/if}} - {{! removed - 1 }} - {{! removed - 2 }}
- {{!END DIV CONTAINER}}
From ba54c556a99c02793a2d9ffb61d8c5c696685e93 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Thu, 12 Oct 2023 13:48:17 -0600 Subject: [PATCH 110/170] Fixed a few issues recommended by Futa after the mega-merge --- app/adapters/index-property-search.ts | 13 ------------- app/models/index-property-search.ts | 21 --------------------- 2 files changed, 34 deletions(-) delete mode 100644 app/adapters/index-property-search.ts delete mode 100644 app/models/index-property-search.ts diff --git a/app/adapters/index-property-search.ts b/app/adapters/index-property-search.ts deleted file mode 100644 index 9a69df75bfc..00000000000 --- a/app/adapters/index-property-search.ts +++ /dev/null @@ -1,13 +0,0 @@ -import ShareAdapter from './share-adapter'; - -export default class IndexPropertySearchAdapter extends ShareAdapter { - pathForType() { - return 'index-property-search'; - } -} - -declare module 'ember-data/types/registries/adapter' { - export default interface AdapterRegistry { - 'index-property-search': IndexPropertySearchAdapter; - } // eslint-disable-line semi -} diff --git a/app/models/index-property-search.ts b/app/models/index-property-search.ts deleted file mode 100644 index c87fe60feb6..00000000000 --- a/app/models/index-property-search.ts +++ /dev/null @@ -1,21 +0,0 @@ -import Model, { AsyncHasMany, attr, hasMany } from '@ember-data/model'; - -import { SearchFilter } from './index-card-search'; -import SearchResultModel from './search-result'; - -export default class IndexPropertySearchModel extends Model { - @attr('string') propertySearchText!: string; - @attr('array') propertySearchFilter!: SearchFilter[]; - @attr('string') cardSearchText!: string; - @attr('array') cardSearchFilter!: SearchFilter[]; - @attr('number') totalResultCount!: number; - - @hasMany('search-result', { inverse: null }) - searchResultPage!: AsyncHasMany & SearchResultModel[]; -} - -declare module 'ember-data/types/registries/model' { - export default interface ModelRegistry { - 'index-property-search': IndexPropertySearchModel; - } // eslint-disable-line semi -} From d195c7e57a072cd9078f68dba97374e079f66abb Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Mon, 16 Oct 2023 11:10:08 -0600 Subject: [PATCH 111/170] Fixed pagination for branded preprint provider, added a provider without an image for a use case that eric is presenting --- mirage/config.ts | 5 ++++- mirage/fixtures/preprint-providers.ts | 17 +++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/mirage/config.ts b/mirage/config.ts index c822b842ace..8924247d4e0 100644 --- a/mirage/config.ts +++ b/mirage/config.ts @@ -297,7 +297,10 @@ export default function(this: Server) { only: ['index'], }); - osfResource(this, 'preprint-provider', { path: '/providers/preprints' }); + osfResource(this, 'preprint-provider', { + path: '/providers/preprints', + defaultPageSize: 1000, + }); osfNestedResource(this, 'preprint-provider', 'highlightedSubjects', { only: ['index'], path: '/providers/preprints/:parentID/subjects/highlighted/', diff --git a/mirage/fixtures/preprint-providers.ts b/mirage/fixtures/preprint-providers.ts index 7dda3f726f6..05e278f3109 100644 --- a/mirage/fixtures/preprint-providers.ts +++ b/mirage/fixtures/preprint-providers.ts @@ -4,10 +4,11 @@ import { ReviewsWorkFlow } from 'ember-osf-web/models/provider'; import { randomGravatar } from '../utils'; -function randomAssets(i: number) { +function randomAssets(i: number, includeImage = true) { + const image = includeImage ? placekitten(150, 75, i) : undefined; return { square_color_no_transparent: randomGravatar(100), - wide_white: placekitten(150, 75, i), + wide_white: image, }; } @@ -83,6 +84,18 @@ const preprintProviders: Array> = [ preprintWord: 'preprint', assets: randomAssets(10), }, + { + id: 'paleorxiv', + name: 'PaleoRrxiv', + preprintWord: 'preprint', + assets: randomAssets(10, false), + }, + { + id: 'sportrxiv', + name: 'Sport-Rxiv', + preprintWord: 'paper', + assets: randomAssets(10), + }, ]; export default preprintProviders; From 22d8c1492a85fa1386b667e32194397a5eacf061 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Tue, 17 Oct 2023 09:37:20 -0600 Subject: [PATCH 112/170] Removed all the `import config from ember-get-config` --- app/preprints/-components/plaudit-widget/component.ts | 2 +- app/preprints/detail/controller.ts | 2 +- mirage/serializers/preprint-request-action.ts | 2 +- mirage/serializers/preprint-request.ts | 2 +- mirage/serializers/preprint.ts | 2 +- vendor/highlight.pack.js | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/preprints/-components/plaudit-widget/component.ts b/app/preprints/-components/plaudit-widget/component.ts index 17424d53ba6..628cfab6468 100644 --- a/app/preprints/-components/plaudit-widget/component.ts +++ b/app/preprints/-components/plaudit-widget/component.ts @@ -1,5 +1,5 @@ import Component from '@glimmer/component'; -import config from 'ember-get-config'; +import config from 'ember-osf-web/config/environment'; export default class PlauditWidget extends Component { plauditWidgetUrl = config.PLAUDIT_WIDGET_URL; diff --git a/app/preprints/detail/controller.ts b/app/preprints/detail/controller.ts index 8eaf6c7d130..839a5941330 100644 --- a/app/preprints/detail/controller.ts +++ b/app/preprints/detail/controller.ts @@ -1,7 +1,7 @@ import Controller from '@ember/controller'; import { action } from '@ember/object'; import { inject as service } from '@ember/service'; -import config from 'ember-get-config'; +import config from 'ember-osf-web/config/environment'; import Theme from 'ember-osf-web/services/theme'; import CurrentUserService from 'ember-osf-web/services/current-user'; import Features from 'ember-feature-flags'; diff --git a/mirage/serializers/preprint-request-action.ts b/mirage/serializers/preprint-request-action.ts index 4e700d41ce0..b93db56e641 100644 --- a/mirage/serializers/preprint-request-action.ts +++ b/mirage/serializers/preprint-request-action.ts @@ -1,5 +1,5 @@ import { ModelInstance } from 'ember-cli-mirage'; -import config from 'ember-get-config'; +import config from 'ember-osf-web/config/environment'; import PreprintRequestActionModel from 'ember-osf-web/models/preprint-request-action'; import ApplicationSerializer, { SerializedRelationships } from './application'; diff --git a/mirage/serializers/preprint-request.ts b/mirage/serializers/preprint-request.ts index a292973bd9d..7ef1400186a 100644 --- a/mirage/serializers/preprint-request.ts +++ b/mirage/serializers/preprint-request.ts @@ -1,5 +1,5 @@ import { ModelInstance } from 'ember-cli-mirage'; -import config from 'ember-get-config'; +import config from 'ember-osf-web/config/environment'; import PreprintRequestModel from 'ember-osf-web/models/preprint-request'; import ApplicationSerializer, { SerializedRelationships } from './application'; diff --git a/mirage/serializers/preprint.ts b/mirage/serializers/preprint.ts index f17bade4d6f..9aadcd88c3c 100644 --- a/mirage/serializers/preprint.ts +++ b/mirage/serializers/preprint.ts @@ -1,5 +1,5 @@ import { ModelInstance } from 'ember-cli-mirage'; -import config from 'ember-get-config'; +import config from 'ember-osf-web/config/environment'; import { PreprintMirageModel } from 'ember-osf-web/mirage/factories/preprint'; import ApplicationSerializer, { SerializedRelationships } from './application'; diff --git a/vendor/highlight.pack.js b/vendor/highlight.pack.js index ebbdf0e9f05..385b990c9f1 100644 --- a/vendor/highlight.pack.js +++ b/vendor/highlight.pack.js @@ -1,2 +1,2 @@ /*! highlight.js v9.12.0 | BSD3 License | git.io/hljslicense */ -!function(e){var n="object"==typeof window&&window||"object"==typeof self&&self;"undefined"!=typeof exports?e(exports):n&&(n.hljs=e({}),"function"==typeof define&&define.amd&&define([],function(){return n.hljs}))}(function(e){function n(e){return e.replace(/&/g,"&").replace(//g,">")}function t(e){return e.nodeName.toLowerCase()}function r(e,n){var t=e&&e.exec(n);return t&&0===t.index}function a(e){return k.test(e)}function i(e){var n,t,r,i,o=e.className+" ";if(o+=e.parentNode?e.parentNode.className:"",t=B.exec(o))return w(t[1])?t[1]:"no-highlight";for(o=o.split(/\s+/),n=0,r=o.length;r>n;n++)if(i=o[n],a(i)||w(i))return i}function o(e){var n,t={},r=Array.prototype.slice.call(arguments,1);for(n in e)t[n]=e[n];return r.forEach(function(e){for(n in e)t[n]=e[n]}),t}function u(e){var n=[];return function r(e,a){for(var i=e.firstChild;i;i=i.nextSibling)3===i.nodeType?a+=i.nodeValue.length:1===i.nodeType&&(n.push({event:"start",offset:a,node:i}),a=r(i,a),t(i).match(/br|hr|img|input/)||n.push({event:"stop",offset:a,node:i}));return a}(e,0),n}function c(e,r,a){function i(){return e.length&&r.length?e[0].offset!==r[0].offset?e[0].offset"}function u(e){s+=""}function c(e){("start"===e.event?o:u)(e.node)}for(var l=0,s="",f=[];e.length||r.length;){var g=i();if(s+=n(a.substring(l,g[0].offset)),l=g[0].offset,g===e){f.reverse().forEach(u);do c(g.splice(0,1)[0]),g=i();while(g===e&&g.length&&g[0].offset===l);f.reverse().forEach(o)}else"start"===g[0].event?f.push(g[0].node):f.pop(),c(g.splice(0,1)[0])}return s+n(a.substr(l))}function l(e){return e.v&&!e.cached_variants&&(e.cached_variants=e.v.map(function(n){return o(e,{v:null},n)})),e.cached_variants||e.eW&&[o(e)]||[e]}function s(e){function n(e){return e&&e.source||e}function t(t,r){return new RegExp(n(t),"m"+(e.cI?"i":"")+(r?"g":""))}function r(a,i){if(!a.compiled){if(a.compiled=!0,a.k=a.k||a.bK,a.k){var o={},u=function(n,t){e.cI&&(t=t.toLowerCase()),t.split(" ").forEach(function(e){var t=e.split("|");o[t[0]]=[n,t[1]?Number(t[1]):1]})};"string"==typeof a.k?u("keyword",a.k):x(a.k).forEach(function(e){u(e,a.k[e])}),a.k=o}a.lR=t(a.l||/\w+/,!0),i&&(a.bK&&(a.b="\\b("+a.bK.split(" ").join("|")+")\\b"),a.b||(a.b=/\B|\b/),a.bR=t(a.b),a.e||a.eW||(a.e=/\B|\b/),a.e&&(a.eR=t(a.e)),a.tE=n(a.e)||"",a.eW&&i.tE&&(a.tE+=(a.e?"|":"")+i.tE)),a.i&&(a.iR=t(a.i)),null==a.r&&(a.r=1),a.c||(a.c=[]),a.c=Array.prototype.concat.apply([],a.c.map(function(e){return l("self"===e?a:e)})),a.c.forEach(function(e){r(e,a)}),a.starts&&r(a.starts,i);var c=a.c.map(function(e){return e.bK?"\\.?("+e.b+")\\.?":e.b}).concat([a.tE,a.i]).map(n).filter(Boolean);a.t=c.length?t(c.join("|"),!0):{exec:function(){return null}}}}r(e)}function f(e,t,a,i){function o(e,n){var t,a;for(t=0,a=n.c.length;a>t;t++)if(r(n.c[t].bR,e))return n.c[t]}function u(e,n){if(r(e.eR,n)){for(;e.endsParent&&e.parent;)e=e.parent;return e}return e.eW?u(e.parent,n):void 0}function c(e,n){return!a&&r(n.iR,e)}function l(e,n){var t=N.cI?n[0].toLowerCase():n[0];return e.k.hasOwnProperty(t)&&e.k[t]}function p(e,n,t,r){var a=r?"":I.classPrefix,i='',i+n+o}function h(){var e,t,r,a;if(!E.k)return n(k);for(a="",t=0,E.lR.lastIndex=0,r=E.lR.exec(k);r;)a+=n(k.substring(t,r.index)),e=l(E,r),e?(B+=e[1],a+=p(e[0],n(r[0]))):a+=n(r[0]),t=E.lR.lastIndex,r=E.lR.exec(k);return a+n(k.substr(t))}function d(){var e="string"==typeof E.sL;if(e&&!y[E.sL])return n(k);var t=e?f(E.sL,k,!0,x[E.sL]):g(k,E.sL.length?E.sL:void 0);return E.r>0&&(B+=t.r),e&&(x[E.sL]=t.top),p(t.language,t.value,!1,!0)}function b(){L+=null!=E.sL?d():h(),k=""}function v(e){L+=e.cN?p(e.cN,"",!0):"",E=Object.create(e,{parent:{value:E}})}function m(e,n){if(k+=e,null==n)return b(),0;var t=o(n,E);if(t)return t.skip?k+=n:(t.eB&&(k+=n),b(),t.rB||t.eB||(k=n)),v(t,n),t.rB?0:n.length;var r=u(E,n);if(r){var a=E;a.skip?k+=n:(a.rE||a.eE||(k+=n),b(),a.eE&&(k=n));do E.cN&&(L+=C),E.skip||(B+=E.r),E=E.parent;while(E!==r.parent);return r.starts&&v(r.starts,""),a.rE?0:n.length}if(c(n,E))throw new Error('Illegal lexeme "'+n+'" for mode "'+(E.cN||"")+'"');return k+=n,n.length||1}var N=w(e);if(!N)throw new Error('Unknown language: "'+e+'"');s(N);var R,E=i||N,x={},L="";for(R=E;R!==N;R=R.parent)R.cN&&(L=p(R.cN,"",!0)+L);var k="",B=0;try{for(var M,j,O=0;;){if(E.t.lastIndex=O,M=E.t.exec(t),!M)break;j=m(t.substring(O,M.index),M[0]),O=M.index+j}for(m(t.substr(O)),R=E;R.parent;R=R.parent)R.cN&&(L+=C);return{r:B,value:L,language:e,top:E}}catch(T){if(T.message&&-1!==T.message.indexOf("Illegal"))return{r:0,value:n(t)};throw T}}function g(e,t){t=t||I.languages||x(y);var r={r:0,value:n(e)},a=r;return t.filter(w).forEach(function(n){var t=f(n,e,!1);t.language=n,t.r>a.r&&(a=t),t.r>r.r&&(a=r,r=t)}),a.language&&(r.second_best=a),r}function p(e){return I.tabReplace||I.useBR?e.replace(M,function(e,n){return I.useBR&&"\n"===e?"
":I.tabReplace?n.replace(/\t/g,I.tabReplace):""}):e}function h(e,n,t){var r=n?L[n]:t,a=[e.trim()];return e.match(/\bhljs\b/)||a.push("hljs"),-1===e.indexOf(r)&&a.push(r),a.join(" ").trim()}function d(e){var n,t,r,o,l,s=i(e);a(s)||(I.useBR?(n=document.createElementNS("http://www.w3.org/1999/xhtml","div"),n.innerHTML=e.innerHTML.replace(/\n/g,"").replace(//g,"\n")):n=e,l=n.textContent,r=s?f(s,l,!0):g(l),t=u(n),t.length&&(o=document.createElementNS("http://www.w3.org/1999/xhtml","div"),o.innerHTML=r.value,r.value=c(t,u(o),l)),r.value=p(r.value),e.innerHTML=r.value,e.className=h(e.className,s,r.language),e.result={language:r.language,re:r.r},r.second_best&&(e.second_best={language:r.second_best.language,re:r.second_best.r}))}function b(e){I=o(I,e)}function v(){if(!v.called){v.called=!0;var e=document.querySelectorAll("pre code");E.forEach.call(e,d)}}function m(){addEventListener("DOMContentLoaded",v,!1),addEventListener("load",v,!1)}function N(n,t){var r=y[n]=t(e);r.aliases&&r.aliases.forEach(function(e){L[e]=n})}function R(){return x(y)}function w(e){return e=(e||"").toLowerCase(),y[e]||y[L[e]]}var E=[],x=Object.keys,y={},L={},k=/^(no-?highlight|plain|text)$/i,B=/\blang(?:uage)?-([\w-]+)\b/i,M=/((^(<[^>]+>|\t|)+|(?:\n)))/gm,C="
",I={classPrefix:"hljs-",tabReplace:null,useBR:!1,languages:void 0};return e.highlight=f,e.highlightAuto=g,e.fixMarkup=p,e.highlightBlock=d,e.configure=b,e.initHighlighting=v,e.initHighlightingOnLoad=m,e.registerLanguage=N,e.listLanguages=R,e.getLanguage=w,e.inherit=o,e.IR="[a-zA-Z]\\w*",e.UIR="[a-zA-Z_]\\w*",e.NR="\\b\\d+(\\.\\d+)?",e.CNR="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",e.BNR="\\b(0b[01]+)",e.RSR="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",e.BE={b:"\\\\[\\s\\S]",r:0},e.ASM={cN:"string",b:"'",e:"'",i:"\\n",c:[e.BE]},e.QSM={cN:"string",b:'"',e:'"',i:"\\n",c:[e.BE]},e.PWM={b:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},e.C=function(n,t,r){var a=e.inherit({cN:"comment",b:n,e:t,c:[]},r||{});return a.c.push(e.PWM),a.c.push({cN:"doctag",b:"(?:TODO|FIXME|NOTE|BUG|XXX):",r:0}),a},e.CLCM=e.C("//","$"),e.CBCM=e.C("/\\*","\\*/"),e.HCM=e.C("#","$"),e.NM={cN:"number",b:e.NR,r:0},e.CNM={cN:"number",b:e.CNR,r:0},e.BNM={cN:"number",b:e.BNR,r:0},e.CSSNM={cN:"number",b:e.NR+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",r:0},e.RM={cN:"regexp",b:/\//,e:/\/[gimuy]*/,i:/\n/,c:[e.BE,{b:/\[/,e:/\]/,r:0,c:[e.BE]}]},e.TM={cN:"title",b:e.IR,r:0},e.UTM={cN:"title",b:e.UIR,r:0},e.METHOD_GUARD={b:"\\.\\s*"+e.UIR,r:0},e});hljs.registerLanguage("scss",function(e){var t="[a-zA-Z-][a-zA-Z0-9_-]*",i={cN:"variable",b:"(\\$"+t+")\\b"},r={cN:"number",b:"#[0-9A-Fa-f]+"};({cN:"attribute",b:"[A-Z\\_\\.\\-]+",e:":",eE:!0,i:"[^\\s]",starts:{eW:!0,eE:!0,c:[r,e.CSSNM,e.QSM,e.ASM,e.CBCM,{cN:"meta",b:"!important"}]}});return{cI:!0,i:"[=/|']",c:[e.CLCM,e.CBCM,{cN:"selector-id",b:"\\#[A-Za-z0-9_-]+",r:0},{cN:"selector-class",b:"\\.[A-Za-z0-9_-]+",r:0},{cN:"selector-attr",b:"\\[",e:"\\]",i:"$"},{cN:"selector-tag",b:"\\b(a|abbr|acronym|address|area|article|aside|audio|b|base|big|blockquote|body|br|button|canvas|caption|cite|code|col|colgroup|command|datalist|dd|del|details|dfn|div|dl|dt|em|embed|fieldset|figcaption|figure|footer|form|frame|frameset|(h[1-6])|head|header|hgroup|hr|html|i|iframe|img|input|ins|kbd|keygen|label|legend|li|link|map|mark|meta|meter|nav|noframes|noscript|object|ol|optgroup|option|output|p|param|pre|progress|q|rp|rt|ruby|samp|script|section|select|small|span|strike|strong|style|sub|sup|table|tbody|td|textarea|tfoot|th|thead|time|title|tr|tt|ul|var|video)\\b",r:0},{b:":(visited|valid|root|right|required|read-write|read-only|out-range|optional|only-of-type|only-child|nth-of-type|nth-last-of-type|nth-last-child|nth-child|not|link|left|last-of-type|last-child|lang|invalid|indeterminate|in-range|hover|focus|first-of-type|first-line|first-letter|first-child|first|enabled|empty|disabled|default|checked|before|after|active)"},{b:"::(after|before|choices|first-letter|first-line|repeat-index|repeat-item|selection|value)"},i,{cN:"attribute",b:"\\b(z-index|word-wrap|word-spacing|word-break|width|widows|white-space|visibility|vertical-align|unicode-bidi|transition-timing-function|transition-property|transition-duration|transition-delay|transition|transform-style|transform-origin|transform|top|text-underline-position|text-transform|text-shadow|text-rendering|text-overflow|text-indent|text-decoration-style|text-decoration-line|text-decoration-color|text-decoration|text-align-last|text-align|tab-size|table-layout|right|resize|quotes|position|pointer-events|perspective-origin|perspective|page-break-inside|page-break-before|page-break-after|padding-top|padding-right|padding-left|padding-bottom|padding|overflow-y|overflow-x|overflow-wrap|overflow|outline-width|outline-style|outline-offset|outline-color|outline|orphans|order|opacity|object-position|object-fit|normal|none|nav-up|nav-right|nav-left|nav-index|nav-down|min-width|min-height|max-width|max-height|mask|marks|margin-top|margin-right|margin-left|margin-bottom|margin|list-style-type|list-style-position|list-style-image|list-style|line-height|letter-spacing|left|justify-content|initial|inherit|ime-mode|image-orientation|image-resolution|image-rendering|icon|hyphens|height|font-weight|font-variant-ligatures|font-variant|font-style|font-stretch|font-size-adjust|font-size|font-language-override|font-kerning|font-feature-settings|font-family|font|float|flex-wrap|flex-shrink|flex-grow|flex-flow|flex-direction|flex-basis|flex|filter|empty-cells|display|direction|cursor|counter-reset|counter-increment|content|column-width|column-span|column-rule-width|column-rule-style|column-rule-color|column-rule|column-gap|column-fill|column-count|columns|color|clip-path|clip|clear|caption-side|break-inside|break-before|break-after|box-sizing|box-shadow|box-decoration-break|bottom|border-width|border-top-width|border-top-style|border-top-right-radius|border-top-left-radius|border-top-color|border-top|border-style|border-spacing|border-right-width|border-right-style|border-right-color|border-right|border-radius|border-left-width|border-left-style|border-left-color|border-left|border-image-width|border-image-source|border-image-slice|border-image-repeat|border-image-outset|border-image|border-color|border-collapse|border-bottom-width|border-bottom-style|border-bottom-right-radius|border-bottom-left-radius|border-bottom-color|border-bottom|border|background-size|background-repeat|background-position|background-origin|background-image|background-color|background-clip|background-attachment|background-blend-mode|background|backface-visibility|auto|animation-timing-function|animation-play-state|animation-name|animation-iteration-count|animation-fill-mode|animation-duration|animation-direction|animation-delay|animation|align-self|align-items|align-content)\\b",i:"[^\\s]"},{b:"\\b(whitespace|wait|w-resize|visible|vertical-text|vertical-ideographic|uppercase|upper-roman|upper-alpha|underline|transparent|top|thin|thick|text|text-top|text-bottom|tb-rl|table-header-group|table-footer-group|sw-resize|super|strict|static|square|solid|small-caps|separate|se-resize|scroll|s-resize|rtl|row-resize|ridge|right|repeat|repeat-y|repeat-x|relative|progress|pointer|overline|outside|outset|oblique|nowrap|not-allowed|normal|none|nw-resize|no-repeat|no-drop|newspaper|ne-resize|n-resize|move|middle|medium|ltr|lr-tb|lowercase|lower-roman|lower-alpha|loose|list-item|line|line-through|line-edge|lighter|left|keep-all|justify|italic|inter-word|inter-ideograph|inside|inset|inline|inline-block|inherit|inactive|ideograph-space|ideograph-parenthesis|ideograph-numeric|ideograph-alpha|horizontal|hidden|help|hand|groove|fixed|ellipsis|e-resize|double|dotted|distribute|distribute-space|distribute-letter|distribute-all-lines|disc|disabled|default|decimal|dashed|crosshair|collapse|col-resize|circle|char|center|capitalize|break-word|break-all|bottom|both|bolder|bold|block|bidi-override|below|baseline|auto|always|all-scroll|absolute|table|table-cell)\\b"},{b:":",e:";",c:[i,r,e.CSSNM,e.QSM,e.ASM,{cN:"meta",b:"!important"}]},{b:"@",e:"[{;]",k:"mixin include extend for if else each while charset import debug media page content font-face namespace warn",c:[i,e.QSM,e.ASM,r,e.CSSNM,{b:"\\s[A-Za-z0-9_.-]+",r:0}]}]}});hljs.registerLanguage("xml",function(s){var e="[A-Za-z0-9\\._:-]+",t={eW:!0,i:/`]+/}]}]}]};return{aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist"],cI:!0,c:[{cN:"meta",b:"",r:10,c:[{b:"\\[",e:"\\]"}]},s.C("",{r:10}),{b:"<\\!\\[CDATA\\[",e:"\\]\\]>",r:10},{b:/<\?(php)?/,e:/\?>/,sL:"php",c:[{b:"/\\*",e:"\\*/",skip:!0}]},{cN:"tag",b:"|$)",e:">",k:{name:"style"},c:[t],starts:{e:"",rE:!0,sL:["css","xml"]}},{cN:"tag",b:"|$)",e:">",k:{name:"script"},c:[t],starts:{e:"",rE:!0,sL:["actionscript","javascript","handlebars","xml"]}},{cN:"meta",v:[{b:/<\?xml/,e:/\?>/,r:10},{b:/<\?\w+/,e:/\?>/}]},{cN:"tag",b:"",c:[{cN:"name",b:/[^\/><\s]+/,r:0},t]}]}});hljs.registerLanguage("handlebars",function(e){var a={"builtin-name":"each in with if else unless bindattr action collection debugger log outlet template unbound view yield"};return{aliases:["hbs","html.hbs","html.handlebars"],cI:!0,sL:"xml",c:[e.C("{{!(--)?","(--)?}}"),{cN:"template-tag",b:/\{\{[#\/]/,e:/\}\}/,c:[{cN:"name",b:/[a-zA-Z\.-]+/,k:a,starts:{eW:!0,r:0,c:[e.QSM]}}]},{cN:"template-variable",b:/\{\{/,e:/\}\}/,k:a}]}});hljs.registerLanguage("json",function(e){var i={literal:"true false null"},n=[e.QSM,e.CNM],r={e:",",eW:!0,eE:!0,c:n,k:i},t={b:"{",e:"}",c:[{cN:"attr",b:/"/,e:/"/,c:[e.BE],i:"\\n"},e.inherit(r,{b:/:/})],i:"\\S"},c={b:"\\[",e:"\\]",c:[e.inherit(r)],i:"\\S"};return n.splice(n.length,0,t,c),{c:n,k:i,i:"\\S"}});hljs.registerLanguage("htmlbars",function(e){var a="action collection component concat debugger each each-in else get hash if input link-to loc log mut outlet partial query-params render textarea unbound unless with yield view",t={i:/\}\}/,b:/[a-zA-Z0-9_]+=/,rB:!0,r:0,c:[{cN:"attr",b:/[a-zA-Z0-9_]+/}]},i=({i:/\}\}/,b:/\)/,e:/\)/,c:[{b:/[a-zA-Z\.\-]+/,k:{built_in:a},starts:{eW:!0,r:0,c:[e.QSM]}}]},{eW:!0,r:0,k:{keyword:"as",built_in:a},c:[e.QSM,t,e.NM]});return{cI:!0,sL:"xml",c:[e.C("{{!(--)?","(--)?}}"),{cN:"template-tag",b:/\{\{[#\/]/,e:/\}\}/,c:[{cN:"name",b:/[a-zA-Z\.\-]+/,k:{"builtin-name":a},starts:i}]},{cN:"template-variable",b:/\{\{[a-zA-Z][a-zA-Z\-]+/,e:/\}\}/,k:{keyword:"as",built_in:a},c:[e.QSM]}]}});hljs.registerLanguage("css",function(e){var c="[a-zA-Z-][a-zA-Z0-9_-]*",t={b:/[A-Z\_\.\-]+\s*:/,rB:!0,e:";",eW:!0,c:[{cN:"attribute",b:/\S/,e:":",eE:!0,starts:{eW:!0,eE:!0,c:[{b:/[\w-]+\(/,rB:!0,c:[{cN:"built_in",b:/[\w-]+/},{b:/\(/,e:/\)/,c:[e.ASM,e.QSM]}]},e.CSSNM,e.QSM,e.ASM,e.CBCM,{cN:"number",b:"#[0-9A-Fa-f]+"},{cN:"meta",b:"!important"}]}}]};return{cI:!0,i:/[=\/|'\$]/,c:[e.CBCM,{cN:"selector-id",b:/#[A-Za-z0-9_-]+/},{cN:"selector-class",b:/\.[A-Za-z0-9_-]+/},{cN:"selector-attr",b:/\[/,e:/\]/,i:"$"},{cN:"selector-pseudo",b:/:(:)?[a-zA-Z0-9\_\-\+\(\)"'.]+/},{b:"@(font-face|page)",l:"[a-z-]+",k:"font-face page"},{b:"@",e:"[{;]",i:/:/,c:[{cN:"keyword",b:/\w+/},{b:/\s/,eW:!0,eE:!0,r:0,c:[e.ASM,e.QSM,e.CSSNM]}]},{cN:"selector-tag",b:c,r:0},{b:"{",e:"}",i:/\S/,c:[e.CBCM,t]}]}});hljs.registerLanguage("typescript",function(e){var r={keyword:"in if for while finally var new function do return void else break catch instanceof with throw case default try this switch continue typeof delete let yield const class public private protected get set super static implements enum export import declare type namespace abstract as from extends async await",literal:"true false null undefined NaN Infinity",built_in:"eval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Error EvalError InternalError RangeError ReferenceError StopIteration SyntaxError TypeError URIError Number Math Date String RegExp Array Float32Array Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array Uint8Array Uint8ClampedArray ArrayBuffer DataView JSON Intl arguments require module console window document any number boolean string void Promise"};return{aliases:["ts"],k:r,c:[{cN:"meta",b:/^\s*['"]use strict['"]/},e.ASM,e.QSM,{cN:"string",b:"`",e:"`",c:[e.BE,{cN:"subst",b:"\\$\\{",e:"\\}"}]},e.CLCM,e.CBCM,{cN:"number",v:[{b:"\\b(0[bB][01]+)"},{b:"\\b(0[oO][0-7]+)"},{b:e.CNR}],r:0},{b:"("+e.RSR+"|\\b(case|return|throw)\\b)\\s*",k:"return throw case",c:[e.CLCM,e.CBCM,e.RM,{cN:"function",b:"(\\(.*?\\)|"+e.IR+")\\s*=>",rB:!0,e:"\\s*=>",c:[{cN:"params",v:[{b:e.IR},{b:/\(\s*\)/},{b:/\(/,e:/\)/,eB:!0,eE:!0,k:r,c:["self",e.CLCM,e.CBCM]}]}]}],r:0},{cN:"function",b:"function",e:/[\{;]/,eE:!0,k:r,c:["self",e.inherit(e.TM,{b:/[A-Za-z$_][0-9A-Za-z$_]*/}),{cN:"params",b:/\(/,e:/\)/,eB:!0,eE:!0,k:r,c:[e.CLCM,e.CBCM],i:/["'\(]/}],i:/%/,r:0},{bK:"constructor",e:/\{/,eE:!0,c:["self",{cN:"params",b:/\(/,e:/\)/,eB:!0,eE:!0,k:r,c:[e.CLCM,e.CBCM],i:/["'\(]/}]},{b:/module\./,k:{built_in:"module"},r:0},{bK:"module",e:/\{/,eE:!0},{bK:"interface",e:/\{/,eE:!0,k:"interface extends"},{b:/\$[(.]/},{b:"\\."+e.IR,r:0},{cN:"meta",b:"@[A-Za-z]+"}]}});hljs.registerLanguage("javascript",function(e){var r="[A-Za-z$_][0-9A-Za-z$_]*",t={keyword:"in of if for while finally var new function do return void else break catch instanceof with throw case default try this switch continue typeof delete let yield const export super debugger as async await static import from as",literal:"true false null undefined NaN Infinity",built_in:"eval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Error EvalError InternalError RangeError ReferenceError StopIteration SyntaxError TypeError URIError Number Math Date String RegExp Array Float32Array Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array Uint8Array Uint8ClampedArray ArrayBuffer DataView JSON Intl arguments require module console window document Symbol Set Map WeakSet WeakMap Proxy Reflect Promise"},a={cN:"number",v:[{b:"\\b(0[bB][01]+)"},{b:"\\b(0[oO][0-7]+)"},{b:e.CNR}],r:0},n={cN:"subst",b:"\\$\\{",e:"\\}",k:t,c:[]},c={cN:"string",b:"`",e:"`",c:[e.BE,n]};n.c=[e.ASM,e.QSM,c,a,e.RM];var s=n.c.concat([e.CBCM,e.CLCM]);return{aliases:["js","jsx"],k:t,c:[{cN:"meta",r:10,b:/^\s*['"]use (strict|asm)['"]/},{cN:"meta",b:/^#!/,e:/$/},e.ASM,e.QSM,c,e.CLCM,e.CBCM,a,{b:/[{,]\s*/,r:0,c:[{b:r+"\\s*:",rB:!0,r:0,c:[{cN:"attr",b:r,r:0}]}]},{b:"("+e.RSR+"|\\b(case|return|throw)\\b)\\s*",k:"return throw case",c:[e.CLCM,e.CBCM,e.RM,{cN:"function",b:"(\\(.*?\\)|"+r+")\\s*=>",rB:!0,e:"\\s*=>",c:[{cN:"params",v:[{b:r},{b:/\(\s*\)/},{b:/\(/,e:/\)/,eB:!0,eE:!0,k:t,c:s}]}]},{b://,sL:"xml",c:[{b:/<\w+\s*\/>/,skip:!0},{b:/<\w+/,e:/(\/\w+|\w+\/)>/,skip:!0,c:[{b:/<\w+\s*\/>/,skip:!0},"self"]}]}],r:0},{cN:"function",bK:"function",e:/\{/,eE:!0,c:[e.inherit(e.TM,{b:r}),{cN:"params",b:/\(/,e:/\)/,eB:!0,eE:!0,c:s}],i:/\[|%/},{b:/\$[(.]/},e.METHOD_GUARD,{cN:"class",bK:"class",e:/[{;=]/,eE:!0,i:/[:"\[\]]/,c:[{bK:"extends"},e.UTM]},{bK:"constructor",e:/\{/,eE:!0}],i:/#(?!!)/}});hljs.registerLanguage("markdown",function(e){return{aliases:["md","mkdown","mkd"],c:[{cN:"section",v:[{b:"^#{1,6}",e:"$"},{b:"^.+?\\n[=-]{2,}$"}]},{b:"<",e:">",sL:"xml",r:0},{cN:"bullet",b:"^([*+-]|(\\d+\\.))\\s+"},{cN:"strong",b:"[*_]{2}.+?[*_]{2}"},{cN:"emphasis",v:[{b:"\\*.+?\\*"},{b:"_.+?_",r:0}]},{cN:"quote",b:"^>\\s+",e:"$"},{cN:"code",v:[{b:"^```w*s*$",e:"^```s*$"},{b:"`.+?`"},{b:"^( {4}| )",e:"$",r:0}]},{b:"^[-\\*]{3,}",e:"$"},{b:"\\[.+?\\][\\(\\[].*?[\\)\\]]",rB:!0,c:[{cN:"string",b:"\\[",e:"\\]",eB:!0,rE:!0,r:0},{cN:"link",b:"\\]\\(",e:"\\)",eB:!0,eE:!0},{cN:"symbol",b:"\\]\\[",e:"\\]",eB:!0,eE:!0}],r:10},{b:/^\[[^\n]+\]:/,rB:!0,c:[{cN:"symbol",b:/\[/,e:/\]/,eB:!0,eE:!0},{cN:"link",b:/:\s*/,e:/$/,eB:!0}]}]}}); \ No newline at end of file +!function(e){var n="object"==typeof window&&window||"object"==typeof self&&self;"undefined"!=typeof exports?e(exports):n&&(n.hljs=e({}),"function"==typeof define&&define.amd&&define([],function(){return n.hljs}))}(function(e){function n(e){return e.replace(/&/g,"&").replace(//g,">")}function t(e){return e.nodeName.toLowerCase()}function r(e,n){var t=e&&e.exec(n);return t&&0===t.index}function a(e){return k.test(e)}function i(e){var n,t,r,i,o=e.className+" ";if(o+=e.parentNode?e.parentNode.className:"",t=B.exec(o))return w(t[1])?t[1]:"no-highlight";for(o=o.split(/\s+/),n=0,r=o.length;r>n;n++)if(i=o[n],a(i)||w(i))return i}function o(e){var n,t={},r=Array.prototype.slice.call(arguments,1);for(n in e)t[n]=e[n];return r.forEach(function(e){for(n in e)t[n]=e[n]}),t}function u(e){var n=[];return function r(e,a){for(var i=e.firstChild;i;i=i.nextSibling)3===i.nodeType?a+=i.nodeValue.length:1===i.nodeType&&(n.push({event:"start",offset:a,node:i}),a=r(i,a),t(i).match(/br|hr|img|input/)||n.push({event:"stop",offset:a,node:i}));return a}(e,0),n}function c(e,r,a){function i(){return e.length&&r.length?e[0].offset!==r[0].offset?e[0].offset"}function u(e){s+=""}function c(e){("start"===e.event?o:u)(e.node)}for(var l=0,s="",f=[];e.length||r.length;){var g=i();if(s+=n(a.substring(l,g[0].offset)),l=g[0].offset,g===e){f.reverse().forEach(u);do c(g.splice(0,1)[0]),g=i();while(g===e&&g.length&&g[0].offset===l);f.reverse().forEach(o)}else"start"===g[0].event?f.push(g[0].node):f.pop(),c(g.splice(0,1)[0])}return s+n(a.substr(l))}function l(e){return e.v&&!e.cached_variants&&(e.cached_variants=e.v.map(function(n){return o(e,{v:null},n)})),e.cached_variants||e.eW&&[o(e)]||[e]}function s(e){function n(e){return e&&e.source||e}function t(t,r){return new RegExp(n(t),"m"+(e.cI?"i":"")+(r?"g":""))}function r(a,i){if(!a.compiled){if(a.compiled=!0,a.k=a.k||a.bK,a.k){var o={},u=function(n,t){e.cI&&(t=t.toLowerCase()),t.split(" ").forEach(function(e){var t=e.split("|");o[t[0]]=[n,t[1]?Number(t[1]):1]})};"string"==typeof a.k?u("keyword",a.k):x(a.k).forEach(function(e){u(e,a.k[e])}),a.k=o}a.lR=t(a.l||/\w+/,!0),i&&(a.bK&&(a.b="\\b("+a.bK.split(" ").join("|")+")\\b"),a.b||(a.b=/\B|\b/),a.bR=t(a.b),a.e||a.eW||(a.e=/\B|\b/),a.e&&(a.eR=t(a.e)),a.tE=n(a.e)||"",a.eW&&i.tE&&(a.tE+=(a.e?"|":"")+i.tE)),a.i&&(a.iR=t(a.i)),null==a.r&&(a.r=1),a.c||(a.c=[]),a.c=Array.prototype.concat.apply([],a.c.map(function(e){return l("self"===e?a:e)})),a.c.forEach(function(e){r(e,a)}),a.starts&&r(a.starts,i);var c=a.c.map(function(e){return e.bK?"\\.?("+e.b+")\\.?":e.b}).concat([a.tE,a.i]).map(n).filter(Boolean);a.t=c.length?t(c.join("|"),!0):{exec:function(){return null}}}}r(e)}function f(e,t,a,i){function o(e,n){var t,a;for(t=0,a=n.c.length;a>t;t++)if(r(n.c[t].bR,e))return n.c[t]}function u(e,n){if(r(e.eR,n)){for(;e.endsParent&&e.parent;)e=e.parent;return e}return e.eW?u(e.parent,n):void 0}function c(e,n){return!a&&r(n.iR,e)}function l(e,n){var t=N.cI?n[0].toLowerCase():n[0];return e.k.hasOwnProperty(t)&&e.k[t]}function p(e,n,t,r){var a=r?"":I.classPrefix,i='',i+n+o}function h(){var e,t,r,a;if(!E.k)return n(k);for(a="",t=0,E.lR.lastIndex=0,r=E.lR.exec(k);r;)a+=n(k.substring(t,r.index)),e=l(E,r),e?(B+=e[1],a+=p(e[0],n(r[0]))):a+=n(r[0]),t=E.lR.lastIndex,r=E.lR.exec(k);return a+n(k.substr(t))}function d(){var e="string"==typeof E.sL;if(e&&!y[E.sL])return n(k);var t=e?f(E.sL,k,!0,x[E.sL]):g(k,E.sL.length?E.sL:void 0);return E.r>0&&(B+=t.r),e&&(x[E.sL]=t.top),p(t.language,t.value,!1,!0)}function b(){L+=null!=E.sL?d():h(),k=""}function v(e){L+=e.cN?p(e.cN,"",!0):"",E=Object.create(e,{parent:{value:E}})}function m(e,n){if(k+=e,null==n)return b(),0;var t=o(n,E);if(t)return t.skip?k+=n:(t.eB&&(k+=n),b(),t.rB||t.eB||(k=n)),v(t,n),t.rB?0:n.length;var r=u(E,n);if(r){var a=E;a.skip?k+=n:(a.rE||a.eE||(k+=n),b(),a.eE&&(k=n));do E.cN&&(L+=C),E.skip||(B+=E.r),E=E.parent;while(E!==r.parent);return r.starts&&v(r.starts,""),a.rE?0:n.length}if(c(n,E))throw new Error('Illegal lexeme "'+n+'" for mode "'+(E.cN||"")+'"');return k+=n,n.length||1}var N=w(e);if(!N)throw new Error('Unknown language: "'+e+'"');s(N);var R,E=i||N,x={},L="";for(R=E;R!==N;R=R.parent)R.cN&&(L=p(R.cN,"",!0)+L);var k="",B=0;try{for(var M,j,O=0;){if(E.t.lastIndex=O,M=E.t.exec(t),!M)break;j=m(t.substring(O,M.index),M[0]),O=M.index+j}for(m(t.substr(O)),R=E;R.parent;R=R.parent)R.cN&&(L+=C);return{r:B,value:L,language:e,top:E}}catch(T){if(T.message&&-1!==T.message.indexOf("Illegal"))return{r:0,value:n(t)};throw T}}function g(e,t){t=t||I.languages||x(y);var r={r:0,value:n(e)},a=r;return t.filter(w).forEach(function(n){var t=f(n,e,!1);t.language=n,t.r>a.r&&(a=t),t.r>r.r&&(a=r,r=t)}),a.language&&(r.second_best=a),r}function p(e){return I.tabReplace||I.useBR?e.replace(M,function(e,n){return I.useBR&&"\n"===e?"
":I.tabReplace?n.replace(/\t/g,I.tabReplace):""}):e}function h(e,n,t){var r=n?L[n]:t,a=[e.trim()];return e.match(/\bhljs\b/)||a.push("hljs"),-1===e.indexOf(r)&&a.push(r),a.join(" ").trim()}function d(e){var n,t,r,o,l,s=i(e);a(s)||(I.useBR?(n=document.createElementNS("http://www.w3.org/1999/xhtml","div"),n.innerHTML=e.innerHTML.replace(/\n/g,"").replace(//g,"\n")):n=e,l=n.textContent,r=s?f(s,l,!0):g(l),t=u(n),t.length&&(o=document.createElementNS("http://www.w3.org/1999/xhtml","div"),o.innerHTML=r.value,r.value=c(t,u(o),l)),r.value=p(r.value),e.innerHTML=r.value,e.className=h(e.className,s,r.language),e.result={language:r.language,re:r.r},r.second_best&&(e.second_best={language:r.second_best.language,re:r.second_best.r}))}function b(e){I=o(I,e)}function v(){if(!v.called){v.called=!0;var e=document.querySelectorAll("pre code");E.forEach.call(e,d)}}function m(){addEventListener("DOMContentLoaded",v,!1),addEventListener("load",v,!1)}function N(n,t){var r=y[n]=t(e);r.aliases&&r.aliases.forEach(function(e){L[e]=n})}function R(){return x(y)}function w(e){return e=(e||"").toLowerCase(),y[e]||y[L[e]]}var E=[],x=Object.keys,y={},L={},k=/^(no-?highlight|plain|text)$/i,B=/\blang(?:uage)?-([\w-]+)\b/i,M=/((^(<[^>]+>|\t|)+|(?:\n)))/gm,C="
",I={classPrefix:"hljs-",tabReplace:null,useBR:!1,languages:void 0};return e.highlight=f,e.highlightAuto=g,e.fixMarkup=p,e.highlightBlock=d,e.configure=b,e.initHighlighting=v,e.initHighlightingOnLoad=m,e.registerLanguage=N,e.listLanguages=R,e.getLanguage=w,e.inherit=o,e.IR="[a-zA-Z]\\w*",e.UIR="[a-zA-Z_]\\w*",e.NR="\\b\\d+(\\.\\d+)?",e.CNR="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",e.BNR="\\b(0b[01]+)",e.RSR="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",e.BE={b:"\\\\[\\s\\S]",r:0},e.ASM={cN:"string",b:"'",e:"'",i:"\\n",c:[e.BE]},e.QSM={cN:"string",b:'"',e:'"',i:"\\n",c:[e.BE]},e.PWM={b:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},e.C=function(n,t,r){var a=e.inherit({cN:"comment",b:n,e:t,c:[]},r||{});return a.c.push(e.PWM),a.c.push({cN:"doctag",b:"(?:TODO|FIXME|NOTE|BUG|XXX):",r:0}),a},e.CLCM=e.C("//","$"),e.CBCM=e.C("/\\*","\\*/"),e.HCM=e.C("#","$"),e.NM={cN:"number",b:e.NR,r:0},e.CNM={cN:"number",b:e.CNR,r:0},e.BNM={cN:"number",b:e.BNR,r:0},e.CSSNM={cN:"number",b:e.NR+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",r:0},e.RM={cN:"regexp",b:/\//,e:/\/[gimuy]*/,i:/\n/,c:[e.BE,{b:/\[/,e:/\]/,r:0,c:[e.BE]}]},e.TM={cN:"title",b:e.IR,r:0},e.UTM={cN:"title",b:e.UIR,r:0},e.METHOD_GUARD={b:"\\.\\s*"+e.UIR,r:0},e});hljs.registerLanguage("scss",function(e){var t="[a-zA-Z-][a-zA-Z0-9_-]*",i={cN:"variable",b:"(\\$"+t+")\\b"},r={cN:"number",b:"#[0-9A-Fa-f]+"};({cN:"attribute",b:"[A-Z\\_\\.\\-]+",e:":",eE:!0,i:"[^\\s]",starts:{eW:!0,eE:!0,c:[r,e.CSSNM,e.QSM,e.ASM,e.CBCM,{cN:"meta",b:"!important"}]}});return{cI:!0,i:"[=/|']",c:[e.CLCM,e.CBCM,{cN:"selector-id",b:"\\#[A-Za-z0-9_-]+",r:0},{cN:"selector-class",b:"\\.[A-Za-z0-9_-]+",r:0},{cN:"selector-attr",b:"\\[",e:"\\]",i:"$"},{cN:"selector-tag",b:"\\b(a|abbr|acronym|address|area|article|aside|audio|b|base|big|blockquote|body|br|button|canvas|caption|cite|code|col|colgroup|command|datalist|dd|del|details|dfn|div|dl|dt|em|embed|fieldset|figcaption|figure|footer|form|frame|frameset|(h[1-6])|head|header|hgroup|hr|html|i|iframe|img|input|ins|kbd|keygen|label|legend|li|link|map|mark|meta|meter|nav|noframes|noscript|object|ol|optgroup|option|output|p|param|pre|progress|q|rp|rt|ruby|samp|script|section|select|small|span|strike|strong|style|sub|sup|table|tbody|td|textarea|tfoot|th|thead|time|title|tr|tt|ul|var|video)\\b",r:0},{b:":(visited|valid|root|right|required|read-write|read-only|out-range|optional|only-of-type|only-child|nth-of-type|nth-last-of-type|nth-last-child|nth-child|not|link|left|last-of-type|last-child|lang|invalid|indeterminate|in-range|hover|focus|first-of-type|first-line|first-letter|first-child|first|enabled|empty|disabled|default|checked|before|after|active)"},{b:"::(after|before|choices|first-letter|first-line|repeat-index|repeat-item|selection|value)"},i,{cN:"attribute",b:"\\b(z-index|word-wrap|word-spacing|word-break|width|widows|white-space|visibility|vertical-align|unicode-bidi|transition-timing-function|transition-property|transition-duration|transition-delay|transition|transform-style|transform-origin|transform|top|text-underline-position|text-transform|text-shadow|text-rendering|text-overflow|text-indent|text-decoration-style|text-decoration-line|text-decoration-color|text-decoration|text-align-last|text-align|tab-size|table-layout|right|resize|quotes|position|pointer-events|perspective-origin|perspective|page-break-inside|page-break-before|page-break-after|padding-top|padding-right|padding-left|padding-bottom|padding|overflow-y|overflow-x|overflow-wrap|overflow|outline-width|outline-style|outline-offset|outline-color|outline|orphans|order|opacity|object-position|object-fit|normal|none|nav-up|nav-right|nav-left|nav-index|nav-down|min-width|min-height|max-width|max-height|mask|marks|margin-top|margin-right|margin-left|margin-bottom|margin|list-style-type|list-style-position|list-style-image|list-style|line-height|letter-spacing|left|justify-content|initial|inherit|ime-mode|image-orientation|image-resolution|image-rendering|icon|hyphens|height|font-weight|font-variant-ligatures|font-variant|font-style|font-stretch|font-size-adjust|font-size|font-language-override|font-kerning|font-feature-settings|font-family|font|float|flex-wrap|flex-shrink|flex-grow|flex-flow|flex-direction|flex-basis|flex|filter|empty-cells|display|direction|cursor|counter-reset|counter-increment|content|column-width|column-span|column-rule-width|column-rule-style|column-rule-color|column-rule|column-gap|column-fill|column-count|columns|color|clip-path|clip|clear|caption-side|break-inside|break-before|break-after|box-sizing|box-shadow|box-decoration-break|bottom|border-width|border-top-width|border-top-style|border-top-right-radius|border-top-left-radius|border-top-color|border-top|border-style|border-spacing|border-right-width|border-right-style|border-right-color|border-right|border-radius|border-left-width|border-left-style|border-left-color|border-left|border-image-width|border-image-source|border-image-slice|border-image-repeat|border-image-outset|border-image|border-color|border-collapse|border-bottom-width|border-bottom-style|border-bottom-right-radius|border-bottom-left-radius|border-bottom-color|border-bottom|border|background-size|background-repeat|background-position|background-origin|background-image|background-color|background-clip|background-attachment|background-blend-mode|background|backface-visibility|auto|animation-timing-function|animation-play-state|animation-name|animation-iteration-count|animation-fill-mode|animation-duration|animation-direction|animation-delay|animation|align-self|align-items|align-content)\\b",i:"[^\\s]"},{b:"\\b(whitespace|wait|w-resize|visible|vertical-text|vertical-ideographic|uppercase|upper-roman|upper-alpha|underline|transparent|top|thin|thick|text|text-top|text-bottom|tb-rl|table-header-group|table-footer-group|sw-resize|super|strict|static|square|solid|small-caps|separate|se-resize|scroll|s-resize|rtl|row-resize|ridge|right|repeat|repeat-y|repeat-x|relative|progress|pointer|overline|outside|outset|oblique|nowrap|not-allowed|normal|none|nw-resize|no-repeat|no-drop|newspaper|ne-resize|n-resize|move|middle|medium|ltr|lr-tb|lowercase|lower-roman|lower-alpha|loose|list-item|line|line-through|line-edge|lighter|left|keep-all|justify|italic|inter-word|inter-ideograph|inside|inset|inline|inline-block|inherit|inactive|ideograph-space|ideograph-parenthesis|ideograph-numeric|ideograph-alpha|horizontal|hidden|help|hand|groove|fixed|ellipsis|e-resize|double|dotted|distribute|distribute-space|distribute-letter|distribute-all-lines|disc|disabled|default|decimal|dashed|crosshair|collapse|col-resize|circle|char|center|capitalize|break-word|break-all|bottom|both|bolder|bold|block|bidi-override|below|baseline|auto|always|all-scroll|absolute|table|table-cell)\\b"},{b:":",e:";",c:[i,r,e.CSSNM,e.QSM,e.ASM,{cN:"meta",b:"!important"}]},{b:"@",e:"[{;]",k:"mixin include extend for if else each while charset import debug media page content font-face namespace warn",c:[i,e.QSM,e.ASM,r,e.CSSNM,{b:"\\s[A-Za-z0-9_.-]+",r:0}]}]}});hljs.registerLanguage("xml",function(s){var e="[A-Za-z0-9\\._:-]+",t={eW:!0,i:/`]+/}]}]}]};return{aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist"],cI:!0,c:[{cN:"meta",b:"",r:10,c:[{b:"\\[",e:"\\]"}]},s.C("",{r:10}),{b:"<\\!\\[CDATA\\[",e:"\\]\\]>",r:10},{b:/<\?(php)?/,e:/\?>/,sL:"php",c:[{b:"/\\*",e:"\\*/",skip:!0}]},{cN:"tag",b:"|$)",e:">",k:{name:"style"},c:[t],starts:{e:"",rE:!0,sL:["css","xml"]}},{cN:"tag",b:"|$)",e:">",k:{name:"script"},c:[t],starts:{e:"",rE:!0,sL:["actionscript","javascript","handlebars","xml"]}},{cN:"meta",v:[{b:/<\?xml/,e:/\?>/,r:10},{b:/<\?\w+/,e:/\?>/}]},{cN:"tag",b:"",c:[{cN:"name",b:/[^\/><\s]+/,r:0},t]}]}});hljs.registerLanguage("handlebars",function(e){var a={"builtin-name":"each in with if else unless bindattr action collection debugger log outlet template unbound view yield"};return{aliases:["hbs","html.hbs","html.handlebars"],cI:!0,sL:"xml",c:[e.C("{{!(--)?","(--)?}}"),{cN:"template-tag",b:/\{\{[#\/]/,e:/\}\}/,c:[{cN:"name",b:/[a-zA-Z\.-]+/,k:a,starts:{eW:!0,r:0,c:[e.QSM]}}]},{cN:"template-variable",b:/\{\{/,e:/\}\}/,k:a}]}});hljs.registerLanguage("json",function(e){var i={literal:"true false null"},n=[e.QSM,e.CNM],r={e:",",eW:!0,eE:!0,c:n,k:i},t={b:"{",e:"}",c:[{cN:"attr",b:/"/,e:/"/,c:[e.BE],i:"\\n"},e.inherit(r,{b:/:/})],i:"\\S"},c={b:"\\[",e:"\\]",c:[e.inherit(r)],i:"\\S"};return n.splice(n.length,0,t,c),{c:n,k:i,i:"\\S"}});hljs.registerLanguage("htmlbars",function(e){var a="action collection component concat debugger each each-in else get hash if input link-to loc log mut outlet partial query-params render textarea unbound unless with yield view",t={i:/\}\}/,b:/[a-zA-Z0-9_]+=/,rB:!0,r:0,c:[{cN:"attr",b:/[a-zA-Z0-9_]+/}]},i=({i:/\}\}/,b:/\)/,e:/\)/,c:[{b:/[a-zA-Z\.\-]+/,k:{built_in:a},starts:{eW:!0,r:0,c:[e.QSM]}}]},{eW:!0,r:0,k:{keyword:"as",built_in:a},c:[e.QSM,t,e.NM]});return{cI:!0,sL:"xml",c:[e.C("{{!(--)?","(--)?}}"),{cN:"template-tag",b:/\{\{[#\/]/,e:/\}\}/,c:[{cN:"name",b:/[a-zA-Z\.\-]+/,k:{"builtin-name":a},starts:i}]},{cN:"template-variable",b:/\{\{[a-zA-Z][a-zA-Z\-]+/,e:/\}\}/,k:{keyword:"as",built_in:a},c:[e.QSM]}]}});hljs.registerLanguage("css",function(e){var c="[a-zA-Z-][a-zA-Z0-9_-]*",t={b:/[A-Z\_\.\-]+\s*:/,rB:!0,e:";",eW:!0,c:[{cN:"attribute",b:/\S/,e:":",eE:!0,starts:{eW:!0,eE:!0,c:[{b:/[\w-]+\(/,rB:!0,c:[{cN:"built_in",b:/[\w-]+/},{b:/\(/,e:/\)/,c:[e.ASM,e.QSM]}]},e.CSSNM,e.QSM,e.ASM,e.CBCM,{cN:"number",b:"#[0-9A-Fa-f]+"},{cN:"meta",b:"!important"}]}}]};return{cI:!0,i:/[=\/|'\$]/,c:[e.CBCM,{cN:"selector-id",b:/#[A-Za-z0-9_-]+/},{cN:"selector-class",b:/\.[A-Za-z0-9_-]+/},{cN:"selector-attr",b:/\[/,e:/\]/,i:"$"},{cN:"selector-pseudo",b:/:(:)?[a-zA-Z0-9\_\-\+\(\)"'.]+/},{b:"@(font-face|page)",l:"[a-z-]+",k:"font-face page"},{b:"@",e:"[{;]",i:/:/,c:[{cN:"keyword",b:/\w+/},{b:/\s/,eW:!0,eE:!0,r:0,c:[e.ASM,e.QSM,e.CSSNM]}]},{cN:"selector-tag",b:c,r:0},{b:"{",e:"}",i:/\S/,c:[e.CBCM,t]}]}});hljs.registerLanguage("typescript",function(e){var r={keyword:"in if for while finally var new function do return void else break catch instanceof with throw case default try this switch continue typeof delete let yield const class public private protected get set super static implements enum export import declare type namespace abstract as from extends async await",literal:"true false null undefined NaN Infinity",built_in:"eval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Error EvalError InternalError RangeError ReferenceError StopIteration SyntaxError TypeError URIError Number Math Date String RegExp Array Float32Array Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array Uint8Array Uint8ClampedArray ArrayBuffer DataView JSON Intl arguments require module console window document any number boolean string void Promise"};return{aliases:["ts"],k:r,c:[{cN:"meta",b:/^\s*['"]use strict['"]/},e.ASM,e.QSM,{cN:"string",b:"`",e:"`",c:[e.BE,{cN:"subst",b:"\\$\\{",e:"\\}"}]},e.CLCM,e.CBCM,{cN:"number",v:[{b:"\\b(0[bB][01]+)"},{b:"\\b(0[oO][0-7]+)"},{b:e.CNR}],r:0},{b:"("+e.RSR+"|\\b(case|return|throw)\\b)\\s*",k:"return throw case",c:[e.CLCM,e.CBCM,e.RM,{cN:"function",b:"(\\(.*?\\)|"+e.IR+")\\s*=>",rB:!0,e:"\\s*=>",c:[{cN:"params",v:[{b:e.IR},{b:/\(\s*\)/},{b:/\(/,e:/\)/,eB:!0,eE:!0,k:r,c:["self",e.CLCM,e.CBCM]}]}]}],r:0},{cN:"function",b:"function",e:/[\{;]/,eE:!0,k:r,c:["self",e.inherit(e.TM,{b:/[A-Za-z$_][0-9A-Za-z$_]*/}),{cN:"params",b:/\(/,e:/\)/,eB:!0,eE:!0,k:r,c:[e.CLCM,e.CBCM],i:/["'\(]/}],i:/%/,r:0},{bK:"constructor",e:/\{/,eE:!0,c:["self",{cN:"params",b:/\(/,e:/\)/,eB:!0,eE:!0,k:r,c:[e.CLCM,e.CBCM],i:/["'\(]/}]},{b:/module\./,k:{built_in:"module"},r:0},{bK:"module",e:/\{/,eE:!0},{bK:"interface",e:/\{/,eE:!0,k:"interface extends"},{b:/\$[(.]/},{b:"\\."+e.IR,r:0},{cN:"meta",b:"@[A-Za-z]+"}]}});hljs.registerLanguage("javascript",function(e){var r="[A-Za-z$_][0-9A-Za-z$_]*",t={keyword:"in of if for while finally var new function do return void else break catch instanceof with throw case default try this switch continue typeof delete let yield const export super debugger as async await static import from as",literal:"true false null undefined NaN Infinity",built_in:"eval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Error EvalError InternalError RangeError ReferenceError StopIteration SyntaxError TypeError URIError Number Math Date String RegExp Array Float32Array Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array Uint8Array Uint8ClampedArray ArrayBuffer DataView JSON Intl arguments require module console window document Symbol Set Map WeakSet WeakMap Proxy Reflect Promise"},a={cN:"number",v:[{b:"\\b(0[bB][01]+)"},{b:"\\b(0[oO][0-7]+)"},{b:e.CNR}],r:0},n={cN:"subst",b:"\\$\\{",e:"\\}",k:t,c:[]},c={cN:"string",b:"`",e:"`",c:[e.BE,n]};n.c=[e.ASM,e.QSM,c,a,e.RM];var s=n.c.concat([e.CBCM,e.CLCM]);return{aliases:["js","jsx"],k:t,c:[{cN:"meta",r:10,b:/^\s*['"]use (strict|asm)['"]/},{cN:"meta",b:/^#!/,e:/$/},e.ASM,e.QSM,c,e.CLCM,e.CBCM,a,{b:/[{,]\s*/,r:0,c:[{b:r+"\\s*:",rB:!0,r:0,c:[{cN:"attr",b:r,r:0}]}]},{b:"("+e.RSR+"|\\b(case|return|throw)\\b)\\s*",k:"return throw case",c:[e.CLCM,e.CBCM,e.RM,{cN:"function",b:"(\\(.*?\\)|"+r+")\\s*=>",rB:!0,e:"\\s*=>",c:[{cN:"params",v:[{b:r},{b:/\(\s*\)/},{b:/\(/,e:/\)/,eB:!0,eE:!0,k:t,c:s}]}]},{b://,sL:"xml",c:[{b:/<\w+\s*\/>/,skip:!0},{b:/<\w+/,e:/(\/\w+|\w+\/)>/,skip:!0,c:[{b:/<\w+\s*\/>/,skip:!0},"self"]}]}],r:0},{cN:"function",bK:"function",e:/\{/,eE:!0,c:[e.inherit(e.TM,{b:r}),{cN:"params",b:/\(/,e:/\)/,eB:!0,eE:!0,c:s}],i:/\[|%/},{b:/\$[(.]/},e.METHOD_GUARD,{cN:"class",bK:"class",e:/[{;=]/,eE:!0,i:/[:"\[\]]/,c:[{bK:"extends"},e.UTM]},{bK:"constructor",e:/\{/,eE:!0}],i:/#(?!!)/}});hljs.registerLanguage("markdown",function(e){return{aliases:["md","mkdown","mkd"],c:[{cN:"section",v:[{b:"^#{1,6}",e:"$"},{b:"^.+?\\n[=-]{2,}$"}]},{b:"<",e:">",sL:"xml",r:0},{cN:"bullet",b:"^([*+-]|(\\d+\\.))\\s+"},{cN:"strong",b:"[*_]{2}.+?[*_]{2}"},{cN:"emphasis",v:[{b:"\\*.+?\\*"},{b:"_.+?_",r:0}]},{cN:"quote",b:"^>\\s+",e:"$"},{cN:"code",v:[{b:"^```w*s*$",e:"^```s*$"},{b:"`.+?`"},{b:"^( {4}| )",e:"$",r:0}]},{b:"^[-\\*]{3,}",e:"$"},{b:"\\[.+?\\][\\(\\[].*?[\\)\\]]",rB:!0,c:[{cN:"string",b:"\\[",e:"\\]",eB:!0,rE:!0,r:0},{cN:"link",b:"\\]\\(",e:"\\)",eB:!0,eE:!0},{cN:"symbol",b:"\\]\\[",e:"\\]",eB:!0,eE:!0}],r:10},{b:/^\[[^\n]+\]:/,rB:!0,c:[{cN:"symbol",b:/\[/,e:/\]/,eB:!0,eE:!0},{cN:"link",b:/:\s*/,e:/$/,eB:!0}]}]}}); \ No newline at end of file From 7e198577041318a3a81a981bd6d78079b7785844 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Tue, 17 Oct 2023 09:39:11 -0600 Subject: [PATCH 113/170] Removed some comments --- .../-components/preprint-author-assertions/component.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/app/preprints/-components/preprint-author-assertions/component.ts b/app/preprints/-components/preprint-author-assertions/component.ts index ae7354da6a2..1b1b65b0a66 100644 --- a/app/preprints/-components/preprint-author-assertions/component.ts +++ b/app/preprints/-components/preprint-author-assertions/component.ts @@ -24,11 +24,6 @@ export default class PreprintAuthorAssertions extends Component { provider = this.args.provider; documentType = this.args.documentType; - /* - shouldShowSloanIcons: alias('hasSloanData'), - shouldShowPreregLinks: alias('hasPreregLinks'), - */ - public get availableDataLinksMessage(): string { const prefix = 'preprints.detail.author-assertions.available.'; const suffix = this.preprint.hasDataLinks.replace(/\s/g, '_'); From 8f7b5a0e8a5347ab236d9acda02de7f97a41c390 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Tue, 17 Oct 2023 09:41:29 -0600 Subject: [PATCH 114/170] Removed some commentted out router code --- app/router.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/app/router.ts b/app/router.ts index dadcb7284df..d91dca36f09 100644 --- a/app/router.ts +++ b/app/router.ts @@ -30,7 +30,6 @@ Router.map(function() { this.route('index', { path: '/' }); this.route('index', { path: '/:provider_id' }); this.route('discover', { path: '/:provider_id/discover' }); - // this.route('detail', { path: '--preprint/:guid' }); this.route('detail', { path: '../:guid' }); }); From e41232bac5d98f5d425a506dd298c83c178e7b9b Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Tue, 17 Oct 2023 09:44:06 -0600 Subject: [PATCH 115/170] Defined the data-test --- app/preprints/index/template.hbs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/preprints/index/template.hbs b/app/preprints/index/template.hbs index 02e41c20efd..63e8a69b1dc 100644 --- a/app/preprints/index/template.hbs +++ b/app/preprints/index/template.hbs @@ -39,8 +39,8 @@
{{t 'preprints.header.example'}} @@ -64,8 +64,8 @@ {{#if this.theme.provider.hasHighlightedSubjects}} {{t 'preprints.subjects.links.seeAllSubjects'}} @@ -96,8 +96,8 @@ {{#each this.model.brandedProviders as |provider| }} {{#if (not-eq provider.id 'livedata') }} Date: Tue, 17 Oct 2023 09:48:24 -0600 Subject: [PATCH 116/170] Removed a bootstrap and eslint-ignore --- app/preprints/detail/route.ts | 1 - app/preprints/detail/template.hbs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/app/preprints/detail/route.ts b/app/preprints/detail/route.ts index d390000d4ba..644a7242c25 100644 --- a/app/preprints/detail/route.ts +++ b/app/preprints/detail/route.ts @@ -39,7 +39,6 @@ export default class PreprintsDetail extends Route { try { const guid = params.guid; - // eslint-disable-next-line max-len const preprint = await this.store.findRecord('preprint', guid, { include: ['bibliographicContributors'], adapterOptions: { diff --git a/app/preprints/detail/template.hbs b/app/preprints/detail/template.hbs index 03d5b080442..070ee0192a1 100644 --- a/app/preprints/detail/template.hbs +++ b/app/preprints/detail/template.hbs @@ -8,7 +8,7 @@ data-analytics-scope='preprints detail page'

{{this.model.preprint.title}}

{{#unless this.model.preprint.isWithdrawn}} -
+
{{#if (and this.userIsContrib (not this.isPendingWithdrawal))}} Date: Tue, 17 Oct 2023 09:48:56 -0600 Subject: [PATCH 117/170] Removed comments --- app/preprints/detail/route.ts | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/app/preprints/detail/route.ts b/app/preprints/detail/route.ts index 644a7242c25..a10d443e172 100644 --- a/app/preprints/detail/route.ts +++ b/app/preprints/detail/route.ts @@ -5,17 +5,6 @@ import { inject as service } from '@ember/service'; import Theme from 'ember-osf-web/services/theme'; import captureException from 'ember-osf-web/utils/capture-exception'; -// Error handling for API -/* -const handlers = new Map([ - // format: ['Message detail', 'page'] - ['Authentication credentials were not provided.', 'page-not-found'], // 401 - ['You do not have permission to perform this action.', 'page-not-found'], // 403 - ['Not found.', 'page-not-found'], // 404 - ['The requested node is no longer available.', 'resource-deleted'], // 410 -]); -*/ - /** * @module ember-preprints * @submodule routes From 46f707e2d6ca51addc030aadc223e412273bb5fa Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Tue, 17 Oct 2023 09:50:11 -0600 Subject: [PATCH 118/170] Removed an unnecessary max-len --- app/preprints/detail/controller.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/app/preprints/detail/controller.ts b/app/preprints/detail/controller.ts index 839a5941330..6a71806642e 100644 --- a/app/preprints/detail/controller.ts +++ b/app/preprints/detail/controller.ts @@ -77,7 +77,6 @@ export default class PrePrintsDetailController extends Controller { get editButtonLabel(): string { const editPreprint = 'preprints.detail.project_button.edit_preprint'; const editResubmitPreprint = 'preprints.detail.project_button.edit_resubmit_preprint'; - // eslint-disable-next-line max-len const translation = this.model.provider.reviewsWorkflow === ReviewsWorkFlow.PRE_MODERATION && this.model.preprint.reviewsState === ReviewsState.REJECTED && this.isAdmin() ? editResubmitPreprint : editPreprint; From 354df51dcb59ddf4cf6e9c59ee9c68be12ff4d48 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Tue, 17 Oct 2023 09:50:53 -0600 Subject: [PATCH 119/170] Removed comments --- app/preprints/detail/controller.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/preprints/detail/controller.ts b/app/preprints/detail/controller.ts index 6a71806642e..e299bdeb697 100644 --- a/app/preprints/detail/controller.ts +++ b/app/preprints/detail/controller.ts @@ -46,8 +46,6 @@ export default class PrePrintsDetailController extends Controller { @service intl!: Intl; @service media!: Media; - // metricsStartDate = config.OSF.metricsStartDate; - queryParams_Altered = { chosenFile: 'file', }; From efc6ea39e52d0dd319e136b24836d282b62020d7 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Tue, 17 Oct 2023 09:51:44 -0600 Subject: [PATCH 120/170] Removed comments --- app/preprints/-components/preprint-status-banner/styles.scss | 1 - 1 file changed, 1 deletion(-) diff --git a/app/preprints/-components/preprint-status-banner/styles.scss b/app/preprints/-components/preprint-status-banner/styles.scss index 3b4cd1ddda8..b073d71ed37 100644 --- a/app/preprints/-components/preprint-status-banner/styles.scss +++ b/app/preprints/-components/preprint-status-banner/styles.scss @@ -1,4 +1,3 @@ -/* Import variables before bootstrap so that boostrap variables can be overridden */ // stylelint-disable max-nesting-depth, selector-max-compound-selectors $color-alert-bg-warning: #fcf8e3; From 3a81346798cbf5a863916638cffa954a02e81649 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Tue, 17 Oct 2023 09:58:36 -0600 Subject: [PATCH 121/170] Fixed a length and added an enum --- app/models/provider.ts | 2 +- .../-components/preprint-status-banner/component.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/models/provider.ts b/app/models/provider.ts index 8f8958fb92e..617d876cfd1 100644 --- a/app/models/provider.ts +++ b/app/models/provider.ts @@ -68,7 +68,7 @@ export default abstract class ProviderModel extends OsfModel { @attr('boolean') allowCommenting!: boolean; @attr('boolean') allowUpdates!: boolean; @attr('array') permissions!: ReviewPermissions[]; - @attr('fixstring') reviewsWorkflow!: string | null; + @attr('fixstring') reviewsWorkflow!: ReviewsWorkFlow | null; @attr('boolean') reviewsCommentsAnonymous!: boolean | null; @attr() assets?: Partial; // TODO: camelize in transform diff --git a/app/preprints/-components/preprint-status-banner/component.ts b/app/preprints/-components/preprint-status-banner/component.ts index 6efa6872a54..e64bbe9af1b 100644 --- a/app/preprints/-components/preprint-status-banner/component.ts +++ b/app/preprints/-components/preprint-status-banner/component.ts @@ -128,8 +128,12 @@ export default class PreprintStatusBanner extends Component{ this.intl.t('preprints.detail.status_banner.brand_name'); const tWorkflow = this.intl.t(this.workflow); const tStatusExplanation = this.intl.t(this.statusExplanation); - // eslint-disable-next-line max-len - const base = (this.intl.t(this.baseMessage, { name: tName, reviewsWorkflow: tWorkflow, documentType: this.provider?.documentType.singular })); + const base = (this.intl.t(this.baseMessage, { + name: tName, + reviewsWorkflow: + tWorkflow, + documentType: this.provider?.documentType.singular, + })); return `${base} ${tStatusExplanation}`; } } From 93cc53d3d314f9a5c4675b34e9d32f3b96a86441 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Tue, 17 Oct 2023 09:59:32 -0600 Subject: [PATCH 122/170] Added enums to a model --- app/models/preprint.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/preprint.ts b/app/models/preprint.ts index 9e4922d04c4..fd219e95455 100644 --- a/app/models/preprint.ts +++ b/app/models/preprint.ts @@ -47,8 +47,8 @@ export default class PreprintModel extends OsfModel { @attr('fixstringarray') tags!: string[]; @attr('fixstring') withdrawalJustification! : string; @attr('boolean') hasCoi!: boolean; - @attr('string') hasDataLinks!: string; - @attr('string') hasPreregLinks!: string; + @attr('string') hasDataLinks!: PreprintDataLinksEnum; + @attr('string') hasPreregLinks!: PreprintPreregLinksEnum; @attr('string') conflictOfInterestStatement!: string; @attr('array') dataLinks!: string[]; @attr('array') preregLinks!: string[]; From 9b3d6dd520fb658e7fe119c7073e059489e0d65c Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Tue, 17 Oct 2023 10:01:25 -0600 Subject: [PATCH 123/170] Renamed a method --- app/models/preprint-provider.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/preprint-provider.ts b/app/models/preprint-provider.ts index 1d557ac221e..f7974aa2aee 100644 --- a/app/models/preprint-provider.ts +++ b/app/models/preprint-provider.ts @@ -60,16 +60,16 @@ export default class PreprintProviderModel extends ProviderModel { } @computed('id') - get preprintWordInTitle() { + get preprintWordNotInTitle() { return this.id === 'thesiscommons'; } // Is either OSF Preprints if provider is the default provider, // name+preprintWord.pluralCapitalized(e.g.AfricArXiv Preprints or MarXiv Papers), or "Thesis Commons" - @computed('documentType.pluralCapitalized', 'id', 'name', 'preprintWordInTitle') + @computed('documentType.pluralCapitalized', 'id', 'name', 'preprintWordNotInTitle') get providerTitle() { if (this.id !== defaultProvider) { - if (this.preprintWordInTitle) { + if (this.preprintWordNotInTitle) { return this.name; } return this.intl.t('preprints.provider-title', From 1bb431e399a26c3738ea60ca40029fc373536af9 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Tue, 17 Oct 2023 10:02:19 -0600 Subject: [PATCH 124/170] Removed a stale file --- app/serializers/index-property-search.ts | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 app/serializers/index-property-search.ts diff --git a/app/serializers/index-property-search.ts b/app/serializers/index-property-search.ts deleted file mode 100644 index 22707f3206d..00000000000 --- a/app/serializers/index-property-search.ts +++ /dev/null @@ -1,10 +0,0 @@ -import ShareSerializer from './share-serializer'; - -export default class IndexPropertySearchSerializer extends ShareSerializer { -} - -declare module 'ember-data/types/registries/serializer' { - export default interface SerializerRegistry { - 'index-property-search': IndexPropertySearchSerializer; - } // eslint-disable-line semi -} From 1a52ef3e3a04fb13516312237fa454f650b2ae0c Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Tue, 17 Oct 2023 10:05:33 -0600 Subject: [PATCH 125/170] Refactor the brandedProvider store call --- app/preprints/index/route.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/preprints/index/route.ts b/app/preprints/index/route.ts index efdaf9bb5a5..5d3b73376eb 100644 --- a/app/preprints/index/route.ts +++ b/app/preprints/index/route.ts @@ -30,10 +30,12 @@ export default class Preprints extends Route { }, }); - const brandedProviders = this.theme.id === 'osf' ? await this.store - .findAll('preprint-provider', { reload: true }) - .then(result => result - .filter(item => item.id !== 'osf')) : []; + let brandedProviders = []; + + if (this.theme.id === 'osf') { + const allProviders = await this.store.findAll('preprint-provider', { reload: true }); + brandedProviders = allProviders.filter(item => item.id !== 'osf'); + } return { provider, From fa096198e5b153c226f37f839539caa13ff2983d Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Tue, 17 Oct 2023 10:07:37 -0600 Subject: [PATCH 126/170] Refactored a template file --- app/preprints/detail/template.hbs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/preprints/detail/template.hbs b/app/preprints/detail/template.hbs index 070ee0192a1..2120431af1e 100644 --- a/app/preprints/detail/template.hbs +++ b/app/preprints/detail/template.hbs @@ -1,8 +1,10 @@ {{page-title this.model.preprint.title replace=false}} -
From 3e9572a9d42ae21e9d89a91443508cedf702d913 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Tue, 17 Oct 2023 10:08:46 -0600 Subject: [PATCH 127/170] Pruned translation strings --- translations/en-us.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/translations/en-us.yml b/translations/en-us.yml index a034d1da439..fbe03086d88 100644 --- a/translations/en-us.yml +++ b/translations/en-us.yml @@ -1231,13 +1231,10 @@ preprints: seeAllSubjects: 'See all subjects available' services: top: - # heading: '{documentType.singularCapitalized} Services' heading: '{documentType} Services' - # paragraph: 'Leading {documentType.singular} service providers use this open source infrastructure to support their communities.' paragraph: 'Leading {documentType} service providers use this open source infrastructure to support their communities.' bottom: contact: 'Contact us' - # p1: 'Create your own branded {documentType.singular} servers backed by the OSF.' p1: 'Create your own branded {documentType} servers backed by the OSF.' div: line1: 'Check out the' From 74c688835d628350466cb34f3f7edbf70bda5c48 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Tue, 17 Oct 2023 10:18:18 -0600 Subject: [PATCH 128/170] Removed a comment --- app/models/preprint.ts | 1 - app/preprints/-components/preprint-license/styles.scss | 2 -- 2 files changed, 3 deletions(-) diff --git a/app/models/preprint.ts b/app/models/preprint.ts index fd219e95455..7b55a138acd 100644 --- a/app/models/preprint.ts +++ b/app/models/preprint.ts @@ -91,7 +91,6 @@ export default class PreprintModel extends OsfModel { @alias('links.doi') articleDoiUrl!: string | null; @alias('links.preprint_doi') preprintDoiUrl!: string; - @computed('dateWithdrawn') get isWithdrawn(): boolean{ return this.dateWithdrawn !== null; } diff --git a/app/preprints/-components/preprint-license/styles.scss b/app/preprints/-components/preprint-license/styles.scss index 1623113a06e..ddf500d88e3 100644 --- a/app/preprints/-components/preprint-license/styles.scss +++ b/app/preprints/-components/preprint-license/styles.scss @@ -1,5 +1,3 @@ -// stylelint-disable max-nesting-depth, selector-max-compound-selectors - .license-text { pre { white-space: pre-wrap; From b8447f7c1cc206d25f69cc02f316980e95bde84d Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Tue, 17 Oct 2023 10:41:19 -0600 Subject: [PATCH 129/170] Enum name change --- app/models/preprint-provider.ts | 1 - app/models/provider.ts | 4 ++-- app/preprints/detail/controller.ts | 6 +++--- mirage/fixtures/preprint-providers.ts | 8 ++++---- mirage/scenarios/collections.ts | 3 ++- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/models/preprint-provider.ts b/app/models/preprint-provider.ts index f7974aa2aee..d631d9cc26d 100644 --- a/app/models/preprint-provider.ts +++ b/app/models/preprint-provider.ts @@ -53,7 +53,6 @@ export default class PreprintProviderModel extends ProviderModel { }; } - @computed('documentType.plural') get searchPlaceholder(): string { return this.intl.t('preprints.header.search_placeholder', { placeholder: this.documentType.plural}); diff --git a/app/models/provider.ts b/app/models/provider.ts index 617d876cfd1..c8da0d06a1c 100644 --- a/app/models/provider.ts +++ b/app/models/provider.ts @@ -20,7 +20,7 @@ export interface Assets { wide_white: string; } -export enum ReviewsWorkFlow{ +export enum PreprintProviderReviewsWorkFlow{ PRE_MODERATION = 'pre-moderation', POST_MODERATION = 'post-moderation' } @@ -68,7 +68,7 @@ export default abstract class ProviderModel extends OsfModel { @attr('boolean') allowCommenting!: boolean; @attr('boolean') allowUpdates!: boolean; @attr('array') permissions!: ReviewPermissions[]; - @attr('fixstring') reviewsWorkflow!: ReviewsWorkFlow | null; + @attr('fixstring') reviewsWorkflow!: PreprintProviderReviewsWorkFlow | null; @attr('boolean') reviewsCommentsAnonymous!: boolean | null; @attr() assets?: Partial; // TODO: camelize in transform diff --git a/app/preprints/detail/controller.ts b/app/preprints/detail/controller.ts index e299bdeb697..f7a4f086676 100644 --- a/app/preprints/detail/controller.ts +++ b/app/preprints/detail/controller.ts @@ -8,7 +8,7 @@ import Features from 'ember-feature-flags'; import ContributorModel from 'ember-osf-web/models/contributor'; import Intl from 'ember-intl/services/intl'; import { Permission } from 'ember-osf-web/models/osf-model'; -import { ReviewsState, ReviewsWorkFlow } from 'ember-osf-web/models/provider'; +import { ReviewsState, PreprintProviderReviewsWorkFlow } from 'ember-osf-web/models/provider'; import { tracked } from '@glimmer/tracking'; import { extractDoi } from 'ember-osf-web/utils/doi'; import Media from 'ember-responsive'; @@ -67,7 +67,7 @@ export default class PrePrintsDetailController extends Controller { } get dateLabel(): string { - return this.model.provider.reviewsWorkflow === ReviewsWorkFlow.PRE_MODERATION ? + return this.model.provider.reviewsWorkflow === PreprintProviderReviewsWorkFlow.PRE_MODERATION ? DATE_LABEL.submitted : DATE_LABEL.created; } @@ -75,7 +75,7 @@ export default class PrePrintsDetailController extends Controller { get editButtonLabel(): string { const editPreprint = 'preprints.detail.project_button.edit_preprint'; const editResubmitPreprint = 'preprints.detail.project_button.edit_resubmit_preprint'; - const translation = this.model.provider.reviewsWorkflow === ReviewsWorkFlow.PRE_MODERATION + const translation = this.model.provider.reviewsWorkflow === PreprintProviderReviewsWorkFlow.PRE_MODERATION && this.model.preprint.reviewsState === ReviewsState.REJECTED && this.isAdmin() ? editResubmitPreprint : editPreprint; return this.intl.t(translation, { diff --git a/mirage/fixtures/preprint-providers.ts b/mirage/fixtures/preprint-providers.ts index 05e278f3109..25f1870bd46 100644 --- a/mirage/fixtures/preprint-providers.ts +++ b/mirage/fixtures/preprint-providers.ts @@ -1,6 +1,6 @@ import PreprintProvider from 'ember-osf-web/models/preprint-provider'; import { placekitten } from 'ember-osf-web/mirage/utils'; -import { ReviewsWorkFlow } from 'ember-osf-web/models/provider'; +import { PreprintProviderReviewsWorkFlow } from 'ember-osf-web/models/provider'; import { randomGravatar } from '../utils'; @@ -19,7 +19,7 @@ const preprintProviders: Array> = [ preprintWord: 'preprint', assets: randomAssets(1), footerLinks: 'fake footer links', - reviewsWorkflow: ReviewsWorkFlow.PRE_MODERATION, + reviewsWorkflow: PreprintProviderReviewsWorkFlow.PRE_MODERATION, }, { id: 'thesiscommons', @@ -35,7 +35,7 @@ const preprintProviders: Array> = [ assets: randomAssets(3), footerLinks: 'fake footer links', reviewsCommentsPrivate: true, - reviewsWorkflow: ReviewsWorkFlow.PRE_MODERATION, + reviewsWorkflow: PreprintProviderReviewsWorkFlow.PRE_MODERATION, }, { id: 'paperxiv', @@ -70,7 +70,7 @@ const preprintProviders: Array> = [ name: 'AgriXiv', preprintWord: 'preprint', assets: randomAssets(8), - reviewsWorkflow: ReviewsWorkFlow.POST_MODERATION, + reviewsWorkflow: PreprintProviderReviewsWorkFlow.POST_MODERATION, }, { id: 'biohackrxiv', diff --git a/mirage/scenarios/collections.ts b/mirage/scenarios/collections.ts index 07f65338ce2..34a7c4c6188 100644 --- a/mirage/scenarios/collections.ts +++ b/mirage/scenarios/collections.ts @@ -8,6 +8,7 @@ import { Permission } from 'ember-osf-web/models/osf-model'; import User from 'ember-osf-web/models/user'; import { CollectionSubmissionActionTrigger } from 'ember-osf-web/models/collection-submission-action'; import { MirageSubmissionAction } from 'ember-osf-web/mirage/factories/collection-submission'; +import { PreprintProviderReviewsWorkFlow } from 'ember-osf-web/models/provider'; /** @@ -55,7 +56,7 @@ export function collectionScenario(server: Server, currentUser: ModelInstance Date: Tue, 17 Oct 2023 10:51:30 -0600 Subject: [PATCH 130/170] Updated the inverse to be target on preprint files --- app/models/preprint.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/preprint.ts b/app/models/preprint.ts index 7b55a138acd..884ac57a5cf 100644 --- a/app/models/preprint.ts +++ b/app/models/preprint.ts @@ -70,7 +70,7 @@ export default class PreprintModel extends OsfModel { @hasMany('review-action', { inverse: 'target' }) reviewActions!: AsyncHasMany; - @hasMany('files', { inverse: null}) + @hasMany('files', { inverse: 'target'}) files!: AsyncHasMany & FileModel; @hasMany('contributors', { inverse: 'preprint'}) From f4919fe3d8b28890468335789d606ee4b5ba4ea8 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Tue, 17 Oct 2023 11:01:09 -0600 Subject: [PATCH 131/170] removed the preprint-tag/component --- .../-components/preprint-abstract/template.hbs | 3 +++ app/preprints/-components/preprint-tag/component.ts | 10 ---------- app/preprints/-components/preprint-tag/template.hbs | 4 ++-- 3 files changed, 5 insertions(+), 12 deletions(-) delete mode 100644 app/preprints/-components/preprint-tag/component.ts diff --git a/app/preprints/-components/preprint-abstract/template.hbs b/app/preprints/-components/preprint-abstract/template.hbs index feed7cda1a5..21e1f164a13 100644 --- a/app/preprints/-components/preprint-abstract/template.hbs +++ b/app/preprints/-components/preprint-abstract/template.hbs @@ -4,6 +4,9 @@ {{this.description}}

{{#if this.hasShortenedDescription}} + {{!-- --}} + {{!-- {{manager.metadataRecord.description}} --}} + {{!-- --}}
+ {{!-- 1 {{this.reviewerComment}} --}} {{#if (and this.reviewerComment (not this.submission.provider.reviewsCommentsPrivate))}} + {{!-- 2 --}}
- {{!-- 1 {{this.reviewerComment}} --}} {{#if (and this.reviewerComment (not this.submission.provider.reviewsCommentsPrivate))}} - {{!-- 2 --}}
- {{/if}} + + {{@preprint.description}} +
\ No newline at end of file From 4acbbc9b959bc151f4794ad3ddf9552f70f904d9 Mon Sep 17 00:00:00 2001 From: Yuhuai Liu Date: Wed, 25 Oct 2023 10:41:51 -0400 Subject: [PATCH 161/170] set inverse to null --- app/models/file.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/file.ts b/app/models/file.ts index 9eceb34e00a..8cf55e6d3ba 100644 --- a/app/models/file.ts +++ b/app/models/file.ts @@ -57,7 +57,7 @@ export default class FileModel extends BaseFileItem { @hasMany('comment', { inverse: null }) comments!: AsyncHasMany; - @belongsTo('osf-model', { polymorphic: true }) + @belongsTo('osf-model', { inverse: null, polymorphic: true }) // eslint-disable-next-line max-len target!: (AsyncBelongsTo & AbstractNodeModel) | (AsyncBelongsTo & PreprintModel) | (AsyncBelongsTo & DraftNode); From a1438ea772a800153c3d89b4ecd695c1c210b89a Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Fri, 27 Oct 2023 11:14:29 -0600 Subject: [PATCH 162/170] Fixed build issues --- .../addon/components/search-page/component.ts | 11 ----------- mirage/config.ts | 1 - translations/en-us.yml | 1 - 3 files changed, 13 deletions(-) diff --git a/lib/osf-components/addon/components/search-page/component.ts b/lib/osf-components/addon/components/search-page/component.ts index 14596bf9069..80491840810 100644 --- a/lib/osf-components/addon/components/search-page/component.ts +++ b/lib/osf-components/addon/components/search-page/component.ts @@ -144,17 +144,6 @@ export default class SearchPage extends Component { return this.resourceTypeOptions.find(option => option.value === this.resourceType); } -<<<<<<< HEAD - get showResultCountMiddle() { - return this.totalResultCount && !this.args.showResourceTypeFilter && !this.showSidePanelToggle; - } - - get showResultCountLeft() { - return this.totalResultCount && (this.args.showResourceTypeFilter || this.showSidePanelToggle); - } - -======= ->>>>>>> 198df048d (Group CR feedback re: search-page component arguments) get showResultCountMiddle() { return this.totalResultCount && !this.args.showResourceTypeFilter && !this.showSidePanelToggle; } diff --git a/mirage/config.ts b/mirage/config.ts index fc915569572..63846dbe581 100644 --- a/mirage/config.ts +++ b/mirage/config.ts @@ -38,7 +38,6 @@ import { createSchemaResponseAction } from './views/schema-response-action'; import { rootDetail } from './views/root'; import { shareSearch } from './views/share-search'; import { cardSearch, valueSearch } from './views/search'; -import { cardSearch, valueSearch } from './views/search'; import { createToken } from './views/token'; import { createEmails, updateEmails } from './views/update-email'; import { diff --git a/translations/en-us.yml b/translations/en-us.yml index 91d8f1cda91..f3d2c7e701d 100644 --- a/translations/en-us.yml +++ b/translations/en-us.yml @@ -40,7 +40,6 @@ general: add: Add ok: OK apply: Apply - apply: Apply revisions: Revisions md5: MD5 date: Date From 53ef35f97383bc0bbc846cca1edd52e257c77c1e Mon Sep 17 00:00:00 2001 From: Yuhuai Liu Date: Wed, 18 Oct 2023 22:23:31 -0400 Subject: [PATCH 163/170] fix preprint routing --- app/resolve-guid/route.ts | 9 ++++++++- app/router.ts | 2 +- mirage/serializers/preprint.ts | 4 ++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/resolve-guid/route.ts b/app/resolve-guid/route.ts index 3ec11fd5a36..8d6571eb323 100644 --- a/app/resolve-guid/route.ts +++ b/app/resolve-guid/route.ts @@ -75,7 +75,14 @@ export default class ResolveGuid extends Route { throw new Error(`Unknown GUID referentType: ${guid.referentType}`); } - expanded = this.generateURL(this.routeMap[guid.referentType], params.guid); + if (guid.referentType === 'preprint') { + const preprint = await this.store.findRecord('preprint', params.guid); + const providerId = preprint.belongsTo('provider').id(); + expanded = this.generateURL(this.routeMap['preprint'], providerId, params.guid); + } else { + expanded = this.generateURL(this.routeMap[guid.referentType], params.guid); + } + } let url = expanded; diff --git a/app/router.ts b/app/router.ts index d91dca36f09..bed912efd32 100644 --- a/app/router.ts +++ b/app/router.ts @@ -30,7 +30,7 @@ Router.map(function() { this.route('index', { path: '/' }); this.route('index', { path: '/:provider_id' }); this.route('discover', { path: '/:provider_id/discover' }); - this.route('detail', { path: '../:guid' }); + this.route('detail', { path: '/:provider_id/:guid' }); }); diff --git a/mirage/serializers/preprint.ts b/mirage/serializers/preprint.ts index d6e2308c305..53f79a73dfb 100644 --- a/mirage/serializers/preprint.ts +++ b/mirage/serializers/preprint.ts @@ -17,6 +17,10 @@ export default class PreprintSerializer extends ApplicationSerializer) { const relationships: SerializedRelationships = { provider: { + data: { + id: model.provider.id, + type: 'preprint-providers', + }, links: { related: { href: `${apiUrl}/v2/providers/preprints/${model.provider.id}`, From 2bcf2474511e8b5553f0a4c2c6c5bbba57da7330 Mon Sep 17 00:00:00 2001 From: Yuhuai Liu Date: Mon, 30 Oct 2023 14:45:44 -0400 Subject: [PATCH 164/170] attempt --- app/models/file.ts | 2 +- app/preprints/-components/taxonomy-top-list/template.hbs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/file.ts b/app/models/file.ts index 8cf55e6d3ba..9eceb34e00a 100644 --- a/app/models/file.ts +++ b/app/models/file.ts @@ -57,7 +57,7 @@ export default class FileModel extends BaseFileItem { @hasMany('comment', { inverse: null }) comments!: AsyncHasMany; - @belongsTo('osf-model', { inverse: null, polymorphic: true }) + @belongsTo('osf-model', { polymorphic: true }) // eslint-disable-next-line max-len target!: (AsyncBelongsTo & AbstractNodeModel) | (AsyncBelongsTo & PreprintModel) | (AsyncBelongsTo & DraftNode); diff --git a/app/preprints/-components/taxonomy-top-list/template.hbs b/app/preprints/-components/taxonomy-top-list/template.hbs index 3c343bae627..897d2dc9630 100644 --- a/app/preprints/-components/taxonomy-top-list/template.hbs +++ b/app/preprints/-components/taxonomy-top-list/template.hbs @@ -7,7 +7,7 @@ data-analytics-name='Preprints taxonomy link' local-class='btn subject-button' @route='preprints.discover' - @models={{array this.provider.id}} + @models={{array this.provider}} @queryParams={{subject.queryParam}} > {{subject.text}} From 7cd90438a2c6d754b77422cc16239fc118fa5898 Mon Sep 17 00:00:00 2001 From: Yuhuai Liu Date: Mon, 30 Oct 2023 15:09:02 -0400 Subject: [PATCH 165/170] try this --- app/models/file-provider.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/file-provider.ts b/app/models/file-provider.ts index 4b931e33303..6e786a41dc5 100644 --- a/app/models/file-provider.ts +++ b/app/models/file-provider.ts @@ -19,7 +19,7 @@ export default class FileProviderModel extends BaseFileItem { @belongsTo('base-file-item', { polymorphic: true }) rootFolder!: AsyncBelongsTo & FileModel; - @hasMany('file', { polymorphic: true }) + @hasMany('file', { inverse:'parentFolder', polymorphic: true }) files!: AsyncHasMany; @belongsTo('abstract-node', { inverse: 'files', polymorphic: true }) From 4344e4112aaa09079d136aac6bd99ab83f30e3cb Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Wed, 1 Nov 2023 10:00:56 -0600 Subject: [PATCH 166/170] Removed the bibiliographic stuff and added feature switches for M1 chips --- app/adapters/osf-adapter.ts | 6 +++++- app/config/environment.d.ts | 1 + app/preprints/detail/route.ts | 1 - app/services/analytics.ts | 19 +++++++++++-------- config/environment.js | 2 ++ 5 files changed, 19 insertions(+), 10 deletions(-) diff --git a/app/adapters/osf-adapter.ts b/app/adapters/osf-adapter.ts index ca75c169050..c47cb453c80 100644 --- a/app/adapters/osf-adapter.ts +++ b/app/adapters/osf-adapter.ts @@ -11,6 +11,7 @@ import Session from 'ember-simple-auth/services/session'; import CurrentUser from 'ember-osf-web/services/current-user'; const { + ANALYTICS_ENABLED, OSF: { apiUrl: host, apiNamespace: namespace, @@ -74,7 +75,10 @@ export default class OsfAdapter extends JSONAPIAdapter { * @method buildQuery */ buildQuery(snapshot: DS.Snapshot): object { - const { query: adapterOptionsQuery = {} } = (snapshot.adapterOptions || {}) as AdapterOptions; + let adapterOptionsQuery = {} as AdapterOptions; + if (ANALYTICS_ENABLED) { + adapterOptionsQuery = (snapshot.adapterOptions || {}) as AdapterOptions; + } const { viewOnlyToken } = this.currentUser; diff --git a/app/config/environment.d.ts b/app/config/environment.d.ts index 51c702dcfe6..f5467fdb825 100644 --- a/app/config/environment.d.ts +++ b/app/config/environment.d.ts @@ -20,6 +20,7 @@ export interface KeenConfig { declare const config: { WATER_BUTLER_ENABLED: boolean; PLAUDIT_WIDGET_URL: string, + ANALYTICS_ENABLED: boolean, environment: any; lintOnBuild: boolean; testsEnabled: boolean; diff --git a/app/preprints/detail/route.ts b/app/preprints/detail/route.ts index a10d443e172..d137f76bee5 100644 --- a/app/preprints/detail/route.ts +++ b/app/preprints/detail/route.ts @@ -29,7 +29,6 @@ export default class PreprintsDetail extends Route { const guid = params.guid; const preprint = await this.store.findRecord('preprint', guid, { - include: ['bibliographicContributors'], adapterOptions: { query: { 'metrics[views]': 'total', diff --git a/app/services/analytics.ts b/app/services/analytics.ts index 4317443e49f..f8034d72f41 100644 --- a/app/services/analytics.ts +++ b/app/services/analytics.ts @@ -19,6 +19,7 @@ import Ready from 'ember-osf-web/services/ready'; const { metricsAdapters, + ANALYTICS_ENABLED, OSF: { analyticsAttrs, apiUrl, @@ -321,14 +322,16 @@ export default class Analytics extends Service { } async _sendCountedUsage(payload: object) { - await this.currentUser.authenticatedAJAX({ - method: 'POST', - url: `${apiUrl}/_/metrics/events/counted_usage/`, - data: JSON.stringify(payload), - headers: { - 'Content-Type': 'application/vnd.api+json', - }, - }); + if (ANALYTICS_ENABLED) { + await this.currentUser.authenticatedAJAX({ + method: 'POST', + url: `${apiUrl}/_/metrics/events/counted_usage/`, + data: JSON.stringify(payload), + headers: { + 'Content-Type': 'application/vnd.api+json', + }, + }); + } } _getPageviewPayload() { diff --git a/config/environment.js b/config/environment.js index c10b1dd4a89..807698a1abb 100644 --- a/config/environment.js +++ b/config/environment.js @@ -29,6 +29,7 @@ const { KEEN_CONFIG: keenConfig, LINT_ON_BUILD: lintOnBuild = false, WATER_BUTLER_ENABLED = true, + ANALYTICS_ENABLED = true, MIRAGE_ENABLED = false, MIRAGE_SCENARIOS = [ 'loggedIn', @@ -73,6 +74,7 @@ module.exports = function(environment) { const ENV = { modulePrefix: 'ember-osf-web', WATER_BUTLER_ENABLED, + ANALYTICS_ENABLED, plauditWidgetUrl, environment, lintOnBuild, From da03639cd9a659c8378fbd8b293391772909aede Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Wed, 1 Nov 2023 10:13:41 -0600 Subject: [PATCH 167/170] Better fix for adapters --- app/adapters/osf-adapter.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/adapters/osf-adapter.ts b/app/adapters/osf-adapter.ts index c47cb453c80..56acdb67fb6 100644 --- a/app/adapters/osf-adapter.ts +++ b/app/adapters/osf-adapter.ts @@ -75,10 +75,8 @@ export default class OsfAdapter extends JSONAPIAdapter { * @method buildQuery */ buildQuery(snapshot: DS.Snapshot): object { - let adapterOptionsQuery = {} as AdapterOptions; - if (ANALYTICS_ENABLED) { - adapterOptionsQuery = (snapshot.adapterOptions || {}) as AdapterOptions; - } + const { query: adapterOptionsQuery = {} } = ANALYTICS_ENABLED ? + (snapshot.adapterOptions || {}) as AdapterOptions : {} as AdapterOptions; const { viewOnlyToken } = this.currentUser; From c592410a998825c2ac370ec8a77ac321858854ab Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Wed, 1 Nov 2023 10:50:10 -0600 Subject: [PATCH 168/170] Revert "Better fix for adapters" This reverts commit da03639cd9a659c8378fbd8b293391772909aede. --- app/adapters/osf-adapter.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/adapters/osf-adapter.ts b/app/adapters/osf-adapter.ts index 56acdb67fb6..c47cb453c80 100644 --- a/app/adapters/osf-adapter.ts +++ b/app/adapters/osf-adapter.ts @@ -75,8 +75,10 @@ export default class OsfAdapter extends JSONAPIAdapter { * @method buildQuery */ buildQuery(snapshot: DS.Snapshot): object { - const { query: adapterOptionsQuery = {} } = ANALYTICS_ENABLED ? - (snapshot.adapterOptions || {}) as AdapterOptions : {} as AdapterOptions; + let adapterOptionsQuery = {} as AdapterOptions; + if (ANALYTICS_ENABLED) { + adapterOptionsQuery = (snapshot.adapterOptions || {}) as AdapterOptions; + } const { viewOnlyToken } = this.currentUser; From e4721e3e0595de9e7e300268bb229ef91b3827f9 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Wed, 1 Nov 2023 10:50:26 -0600 Subject: [PATCH 169/170] Revert "Removed the bibiliographic stuff and added feature switches for M1 chips" This reverts commit 4344e4112aaa09079d136aac6bd99ab83f30e3cb. --- app/adapters/osf-adapter.ts | 6 +----- app/config/environment.d.ts | 1 - app/preprints/detail/route.ts | 1 + app/services/analytics.ts | 19 ++++++++----------- config/environment.js | 2 -- 5 files changed, 10 insertions(+), 19 deletions(-) diff --git a/app/adapters/osf-adapter.ts b/app/adapters/osf-adapter.ts index c47cb453c80..ca75c169050 100644 --- a/app/adapters/osf-adapter.ts +++ b/app/adapters/osf-adapter.ts @@ -11,7 +11,6 @@ import Session from 'ember-simple-auth/services/session'; import CurrentUser from 'ember-osf-web/services/current-user'; const { - ANALYTICS_ENABLED, OSF: { apiUrl: host, apiNamespace: namespace, @@ -75,10 +74,7 @@ export default class OsfAdapter extends JSONAPIAdapter { * @method buildQuery */ buildQuery(snapshot: DS.Snapshot): object { - let adapterOptionsQuery = {} as AdapterOptions; - if (ANALYTICS_ENABLED) { - adapterOptionsQuery = (snapshot.adapterOptions || {}) as AdapterOptions; - } + const { query: adapterOptionsQuery = {} } = (snapshot.adapterOptions || {}) as AdapterOptions; const { viewOnlyToken } = this.currentUser; diff --git a/app/config/environment.d.ts b/app/config/environment.d.ts index f5467fdb825..51c702dcfe6 100644 --- a/app/config/environment.d.ts +++ b/app/config/environment.d.ts @@ -20,7 +20,6 @@ export interface KeenConfig { declare const config: { WATER_BUTLER_ENABLED: boolean; PLAUDIT_WIDGET_URL: string, - ANALYTICS_ENABLED: boolean, environment: any; lintOnBuild: boolean; testsEnabled: boolean; diff --git a/app/preprints/detail/route.ts b/app/preprints/detail/route.ts index d137f76bee5..a10d443e172 100644 --- a/app/preprints/detail/route.ts +++ b/app/preprints/detail/route.ts @@ -29,6 +29,7 @@ export default class PreprintsDetail extends Route { const guid = params.guid; const preprint = await this.store.findRecord('preprint', guid, { + include: ['bibliographicContributors'], adapterOptions: { query: { 'metrics[views]': 'total', diff --git a/app/services/analytics.ts b/app/services/analytics.ts index f8034d72f41..4317443e49f 100644 --- a/app/services/analytics.ts +++ b/app/services/analytics.ts @@ -19,7 +19,6 @@ import Ready from 'ember-osf-web/services/ready'; const { metricsAdapters, - ANALYTICS_ENABLED, OSF: { analyticsAttrs, apiUrl, @@ -322,16 +321,14 @@ export default class Analytics extends Service { } async _sendCountedUsage(payload: object) { - if (ANALYTICS_ENABLED) { - await this.currentUser.authenticatedAJAX({ - method: 'POST', - url: `${apiUrl}/_/metrics/events/counted_usage/`, - data: JSON.stringify(payload), - headers: { - 'Content-Type': 'application/vnd.api+json', - }, - }); - } + await this.currentUser.authenticatedAJAX({ + method: 'POST', + url: `${apiUrl}/_/metrics/events/counted_usage/`, + data: JSON.stringify(payload), + headers: { + 'Content-Type': 'application/vnd.api+json', + }, + }); } _getPageviewPayload() { diff --git a/config/environment.js b/config/environment.js index 807698a1abb..c10b1dd4a89 100644 --- a/config/environment.js +++ b/config/environment.js @@ -29,7 +29,6 @@ const { KEEN_CONFIG: keenConfig, LINT_ON_BUILD: lintOnBuild = false, WATER_BUTLER_ENABLED = true, - ANALYTICS_ENABLED = true, MIRAGE_ENABLED = false, MIRAGE_SCENARIOS = [ 'loggedIn', @@ -74,7 +73,6 @@ module.exports = function(environment) { const ENV = { modulePrefix: 'ember-osf-web', WATER_BUTLER_ENABLED, - ANALYTICS_ENABLED, plauditWidgetUrl, environment, lintOnBuild, From c844a69709f6fae22096e5f48e84633b42eafcf2 Mon Sep 17 00:00:00 2001 From: Brian Pilati Date: Wed, 1 Nov 2023 10:51:05 -0600 Subject: [PATCH 170/170] Remvoed bibliographicContributors --- app/preprints/detail/route.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/app/preprints/detail/route.ts b/app/preprints/detail/route.ts index a10d443e172..d137f76bee5 100644 --- a/app/preprints/detail/route.ts +++ b/app/preprints/detail/route.ts @@ -29,7 +29,6 @@ export default class PreprintsDetail extends Route { const guid = params.guid; const preprint = await this.store.findRecord('preprint', guid, { - include: ['bibliographicContributors'], adapterOptions: { query: { 'metrics[views]': 'total',