Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Hold until after Search Improvements release]Preprint landing page #1933

Closed
wants to merge 61 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
9507347
Add new route for search (#1830)
futa-ikeda Mar 24, 2023
2aa4c9c
[ENG-4450] Add new share-search models (#1835)
futa-ikeda Apr 19, 2023
8ac0470
Add basic search page layout (#1850)
futa-ikeda Apr 24, 2023
f0166c6
[ENG-4465] Left panel facets manager (#1858)
futa-ikeda May 15, 2023
b503bdd
Add route analytics metadata (#1865)
futa-ikeda May 16, 2023
2631945
[ENG-4469] Add object filter and sort dropdown to search (#1864)
futa-ikeda May 23, 2023
dda39df
[ENG-4470] Reroute to new search (#1870)
futa-ikeda Jun 13, 2023
998642b
[No ticket] Update SHARE endpoints (#1879)
futa-ikeda Jun 21, 2023
35694bb
[ENG-4568] Componentize search page (#1886)
futa-ikeda Jun 27, 2023
0a68c2a
[ENG-4570] Add institution search placeholder route (#1888)
adlius Jun 28, 2023
5917ee3
add route for preprint discover page (#1890)
adlius Jun 28, 2023
3e7e779
[ENG-4574] Preprint discover rewrite (#1896)
futa-ikeda Jul 11, 2023
2ab39e0
[ENG-4573] Registry discover (#1900)
adlius Jul 13, 2023
bb2a0aa
[ENG-4574] Preprint discover fixes (#1905)
futa-ikeda Jul 13, 2023
d258e21
Track theme service properties (#1908)
futa-ikeda Jul 18, 2023
691326b
[ENG-4575] Institution dashboard page re-write (#1902)
chth0n1x Aug 1, 2023
95fc41b
[ENG-4535] Search help feature (#1907)
futa-ikeda Aug 1, 2023
7e2a4c7
Merge branch 'develop' into feature/search-improvements
futa-ikeda Aug 1, 2023
e964c01
[No Ticket] Change queryparam passed to SHARE when filtering by resou…
adlius Aug 8, 2023
7f1c167
[No ticket] Preprint branding rework (#1913)
futa-ikeda Aug 8, 2023
b0c5f89
[WIP][ENG-4467]Search result card (#1914)
adlius Aug 9, 2023
2946e3c
Explicitly ask for resource-types when selecting All (#1920)
futa-ikeda Aug 9, 2023
f467e27
add registration template info to search result card (#1923)
adlius Aug 10, 2023
7ebe4fe
Preprints branding update (#1922)
futa-ikeda Aug 10, 2023
2d63e22
Show loading indicators and no-results message (#1927)
futa-ikeda Aug 14, 2023
d228961
Add file-secondary-metadata (#1926)
adlius Aug 14, 2023
bf24f81
[ENG-4583] Add analytics to new search interface (#1893)
chth0n1x Aug 14, 2023
4b2be94
Test prerpint discover page
futa-ikeda Jul 7, 2023
c186cd3
Added new preprints index to the new branch
bp-cos Jul 5, 2023
ba0a4f5
Added translation strings
bp-cos Jul 5, 2023
6a7c42b
Fixed a rebase
bp-cos Aug 1, 2023
61c77c0
Rebase fix
bp-cos Aug 1, 2023
e79deea
Removed the add-ons and moved search-help-modal to osf-components
bp-cos Jul 7, 2023
0205f35
Fixed a merge conflict
bp-cos Aug 8, 2023
2691f10
Fixed a few git merge conflicts
bp-cos Jul 12, 2023
35f12c3
Added more logic to get the page to render
bp-cos Jul 13, 2023
14fbc25
Added the taxonomy top list component and integrated it into the inde…
bp-cos Jul 14, 2023
bd6035d
Updates to the preprints template file to remove bootstrap
bp-cos Jul 17, 2023
c02ec1f
Fixed the css for the taxonomy-top-list
bp-cos Jul 17, 2023
9dab76a
Removed an unnecessary import for analytics
bp-cos Jul 17, 2023
655663a
Added more information for the providers
bp-cos Jul 18, 2023
727c7cf
Added the advisory board attribute
bp-cos Jul 18, 2023
a183efb
Finished the html transformation for preprints
bp-cos Jul 25, 2023
6cdc16e
Fixed the routing to use a single template
bp-cos Jul 25, 2023
5106c8f
Updates to remove unused variables and added branding
bp-cos Jul 26, 2023
d67ea11
Fixed the css for the steering committee
bp-cos Jul 27, 2023
32077bc
Updates for comments from PR
bp-cos Jul 28, 2023
661b4c0
Fixed some css and updated the mirage for global classes
bp-cos Aug 3, 2023
0b1fa2a
Updates for branding
bp-cos Aug 4, 2023
60d67d0
Added more styling for mobile
bp-cos Aug 7, 2023
9699281
Added more information for preprints
bp-cos Aug 8, 2023
c429580
Added more information for the taxomony
bp-cos Aug 8, 2023
6f5b153
Added a branded footer for preprints
bp-cos Aug 8, 2023
f6eb655
Fixed the preprint provider logic ... again
bp-cos Aug 8, 2023
667f42f
Fixed the branded header search
bp-cos Aug 8, 2023
cb95fe9
Fixed the page title logic
bp-cos Aug 8, 2023
3e005d2
Removed useless test
bp-cos Aug 10, 2023
fadce7a
Move preprint specific components to the app/preprints/-components
bp-cos Aug 11, 2023
bcabd0d
Added taxonomy tests
bp-cos Aug 11, 2023
036d88d
Added another test
bp-cos Aug 11, 2023
daa8383
Added another test
bp-cos Aug 14, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions app/adapters/index-card-search.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import ShareAdapter from './share-adapter';
export default class IndexCardSearchAdapter extends ShareAdapter {
pathForType() {
return 'index-card-search';
}
}

declare module 'ember-data/types/registries/adapter' {
export default interface AdapterRegistry {
'index-card-search': IndexCardSearchAdapter;
} // eslint-disable-line semi
}
13 changes: 13 additions & 0 deletions app/adapters/index-card.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import ShareAdapter from './share-adapter';

export default class IndexCardAdapter extends ShareAdapter {
pathForType() {
return 'index-card';
}
}

declare module 'ember-data/types/registries/adapter' {
export default interface AdapterRegistry {
'index-card': IndexCardAdapter;
} // eslint-disable-line semi
}
13 changes: 13 additions & 0 deletions app/adapters/index-property-search.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
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
}
13 changes: 13 additions & 0 deletions app/adapters/index-value-search.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import ShareAdapter from './share-adapter';

export default class IndexValueSearchAdapter extends ShareAdapter {
pathForType() {
return 'index-value-search';
}
}

declare module 'ember-data/types/registries/adapter' {
export default interface AdapterRegistry {
'index-value-search': IndexValueSearchAdapter;
} // eslint-disable-line semi
}
10 changes: 10 additions & 0 deletions app/adapters/search-result.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import ShareAdapter from './share-adapter';

export default class SearchResultAdapter extends ShareAdapter {
}

declare module 'ember-data/types/registries/adapter' {
export default interface AdapterRegistry {
'search-result': SearchResultAdapter;
} // eslint-disable-line semi
}
7 changes: 7 additions & 0 deletions app/adapters/share-adapter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import JSONAPIAdapter from '@ember-data/adapter/json-api';
import config from 'ember-get-config';

export default class ShareAdapter extends JSONAPIAdapter {
host = config.OSF.shareBaseUrl.replace(/\/$/, ''); // Remove trailing slash to avoid // in URLs
namespace = 'api/v3';
}
40 changes: 40 additions & 0 deletions app/helpers/get-localized-property.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import Helper from '@ember/component/helper';
import { inject as service } from '@ember/service';
import IntlService from 'ember-intl/services/intl';

import { LanguageText } from 'ember-osf-web/models/index-card';

/**
* This helper is used to get a locale-appropriate string for a property from a metadata hash.
* It is used to fetch metadata fields from a index-card's resourceMetadata attribute, but can be used for any
* hash that contains an array of LangaugeText objects.
* If the property is not found, the first value in the array is returned, or if the property is found,
* but there is no locale-appropriate value, the first value in the array is returned.
*
* @example
* ```handlebars
* {{get-localized-property indexCard.resourceMetadata 'title'}}
* ```
* where `indexCard` is an index-card model instance.
* @class get-localized-property
* @param {Object} metadataHash The metadata hash to search for the property
* @param {String} propertyName The name of the property to search for
* @return {String} The locale-appropriate string or the first value in the array or 'Not provided' message
*/
export default class GetLocalizedPropertyHelper extends Helper {
@service intl!: IntlService;

compute([metadataHash, propertyName]: [Record<string, LanguageText[]>, string]): string {
const locale = this.intl.locale;
const valueOptions = metadataHash?.[propertyName];
if (!metadataHash || !valueOptions || valueOptions.length === 0) {
return this.intl.t('helpers.get-localized-property.not-provided');
}

const index = valueOptions.findIndex((valueOption: LanguageText) => valueOption['@language'] === locale);
if (index === -1) {
return valueOptions[0]['@value'];
}
return valueOptions[index]['@value'];
}
}
2 changes: 1 addition & 1 deletion app/institutions/dashboard/controller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { alias } from '@ember/object/computed';
import Controller from '@ember/controller';
import { computed } from '@ember/object';
import { alias } from '@ember/object/computed';
import { inject as service } from '@ember/service';

import { InstitutionsDashboardModel } from 'ember-osf-web/institutions/dashboard/route';
Expand Down
31 changes: 31 additions & 0 deletions app/institutions/discover/controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import Controller from '@ember/controller';
import { inject as service } from '@ember/service';
import CurrentUser from 'ember-osf-web/services/current-user';
import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';
import pathJoin from 'ember-osf-web/utils/path-join';
import config from 'ember-get-config';
import { OnSearchParams, ResourceTypeFilterValue } from 'osf-components/components/search-page/component';

export default class InstitutionDiscoverController extends Controller {
@service currentUser!: CurrentUser;

@tracked cardSearchText?: string = '';
@tracked sort?: string = '-relevance';
@tracked resourceType?: ResourceTypeFilterValue | null = null;

queryParams = ['cardSearchText', 'page', 'sort', 'resourceType'];

get defaultQueryOptions() {
return {
publisher: pathJoin(config.OSF.url, 'institutions', this.model.id),
};
}

@action
onSearch(queryOptions: OnSearchParams) {
this.cardSearchText = queryOptions.cardSearchText;
this.sort = queryOptions.sort;
this.resourceType = queryOptions.resourceType;
}
}
8 changes: 8 additions & 0 deletions app/institutions/discover/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Route from '@ember/routing/route';
import RouterService from '@ember/routing/router-service';
import { inject as service } from '@ember/service';


export default class InstitutionDiscoverRoute extends Route {
@service router!: RouterService;
}
11 changes: 11 additions & 0 deletions app/institutions/discover/template.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<SearchPage
@route='search'
@query={{this.q}}
@defaultQueryOptions={{this.defaultQueryOptions}}
@queryParams={{this.queryParams}}
@onSearch={{action this.onSearch}}
@resourceType={{this.resourceType}}
@institution={{this.model}}
@sort={{this.sort}}
@showResourceTypeFilter={{true}}
/>
28 changes: 28 additions & 0 deletions app/models/index-card-search.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import Model, { AsyncBelongsTo, AsyncHasMany, attr, belongsTo, hasMany } from '@ember-data/model';

import IndexPropertySearchModel from './index-property-search';
import SearchResultModel from './search-result';

export interface SearchFilter {
propertyPath: string;
filterValue: string[];
filterType?: string;
}

export default class IndexCardSearchModel extends Model {
@attr('string') cardSearchText!: string;
@attr('array') cardSearchFilters!: SearchFilter[];
@attr('number') totalResultCount!: number;

@hasMany('search-result', { inverse: null })
searchResultPage!: AsyncHasMany<SearchResultModel> & SearchResultModel[];

@belongsTo('index-property-search', { inverse: null })
relatedPropertySearch!: AsyncBelongsTo<IndexPropertySearchModel> & IndexPropertySearchModel;
}

declare module 'ember-data/types/registries/model' {
export default interface ModelRegistry {
'index-card-search': IndexCardSearchModel;
} // eslint-disable-line semi
}
26 changes: 26 additions & 0 deletions app/models/index-card.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
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 IndexCardModel extends Model {
@service intl!: IntlService;

@attr('array') resourceType!: string[];
@attr('array') resourceIdentifier!: string[];
// TODO: can we add a type for resourceMetadata?
@attr('object') resourceMetadata!: any;

@hasMany('index-card', { inverse: null })
relatedRecordSet!: AsyncHasMany<IndexCardModel> & IndexCardModel[];
}

declare module 'ember-data/types/registries/model' {
export default interface ModelRegistry {
'index-card': IndexCardModel;
} // eslint-disable-line semi
}
21 changes: 21 additions & 0 deletions app/models/index-property-search.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
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> & SearchResultModel[];
}

declare module 'ember-data/types/registries/model' {
export default interface ModelRegistry {
'index-property-search': IndexPropertySearchModel;
} // eslint-disable-line semi
}
25 changes: 25 additions & 0 deletions app/models/index-value-search.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import Model, { AsyncHasMany, AsyncBelongsTo, attr, belongsTo, hasMany } from '@ember-data/model';

import IndexPropertySearchModel from './index-property-search';
import { SearchFilter } from './index-card-search';
import SearchResultModel from './search-result';

export default class IndexValueSearchModel extends Model {
@attr('string') valueSearchText!: string;
@attr('array') valueSearchFilter!: SearchFilter[];
@attr('string') cardSearchText!: string;
@attr('array') cardSearchFilter!: SearchFilter[];
@attr('number') totalResultCount!: number;

@hasMany('search-result', { inverse: null })
searchResultPage!: AsyncHasMany<SearchResultModel> & SearchResultModel[];

@belongsTo('index-property-search', { inverse: null })
relatedPropertySearch!: AsyncBelongsTo<IndexPropertySearchModel> & IndexPropertySearchModel;
}

declare module 'ember-data/types/registries/model' {
export default interface ModelRegistry {
'index-value-search': IndexValueSearchModel;
} // eslint-disable-line semi
}
33 changes: 31 additions & 2 deletions app/models/preprint-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,30 @@ import { attr, hasMany, AsyncHasMany, belongsTo, AsyncBelongsTo } from '@ember-d
import { computed } from '@ember/object';
import { alias } from '@ember/object/computed';
import { inject as service } from '@ember/service';
import config from 'ember-get-config';
import Intl from 'ember-intl/services/intl';
import BrandModel from 'ember-osf-web/models/brand';

import { RelatedLinkMeta } from 'osf-api';

import PreprintModel from './preprint';
import ProviderModel from './provider';
import ProviderModel, { ReviewPermissions } from './provider';

export type PreprintWord = 'default' | 'work' | 'paper' | 'preprint' | 'thesis';
export type PreprintWordGrammar = 'plural' | 'pluralCapitalized' | 'singular' | 'singularCapitalized';

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;
@attr('string') preprintWord!: PreprintWord;

// Reviews settings
@attr('array') permissions!: string[];
@attr('array') permissions!: ReviewPermissions[];
@attr('boolean', { allowNull: true }) reviewsCommentsPrivate!: boolean | null;

// Relationships
Expand All @@ -49,6 +52,32 @@ export default class PreprintProviderModel extends ProviderModel {
singularCapitalized: this.intl.t(`${documentType}.singularCapitalized`),
};
}

@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';
}

// 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')
get providerTitle() {
if (this.id !== defaultProvider) {
if (this.preprintWordInTitle) {
return this.name;
}
return this.intl.t('preprints.provider-title',
{ name: this.name, pluralizedPreprintWord: this.documentType.pluralCapitalized });
} else {
return this.intl.t('preprints.header.osf_registrations');
}
}
}

declare module 'ember-data/types/registries/model' {
Expand Down
Loading