Skip to content

Commit

Permalink
Merge branch 'release/23.12.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
adlius committed Oct 10, 2023
2 parents 84b11f3 + fab80b2 commit 0a30b09
Show file tree
Hide file tree
Showing 86 changed files with 850 additions and 2,039 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [23.12.0] - 2023-10-10
### Added
- Search improvement phase 2: preprints, institutions and registries discover pages

## [23.11.0] - 2023-09-27
### Changed
- Upgrade to Ember 3.28
Expand Down Expand Up @@ -1945,6 +1949,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added
- Quick Files

[23.12.0]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/23.12.0
[23.11.1]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/23.11.1
[23.11.0]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/23.11.0
[23.10.2]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/23.10.2
[23.10.1]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/23.10.1
Expand Down
12 changes: 11 additions & 1 deletion app/adapters/share-adapter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
import JSONAPIAdapter from '@ember-data/adapter/json-api';
import config from 'ember-get-config';
import config from 'ember-osf-web/config/environment';

const osfUrl = config.OSF.url;

export default class ShareAdapter extends JSONAPIAdapter {
host = config.OSF.shareBaseUrl.replace(/\/$/, ''); // Remove trailing slash to avoid // in URLs
namespace = 'api/v3';

queryRecord(store: any, type: any, query: any) {
// check if we aren't serving locally, otherwise add accessService query param to card/value searches
if (['index-card-search', 'index-value-search'].includes(type.modelName) && !osfUrl.includes('localhost')) {
query.cardSearchFilter['accessService'] = osfUrl;
}
return super.queryRecord(store, type, query);
}
}
31 changes: 22 additions & 9 deletions app/institutions/discover/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,42 @@ 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';
import { Filter, OnSearchParams, ResourceTypeFilterValue } from 'osf-components/components/search-page/component';

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

@tracked cardSearchText?: string = '';
@tracked q?: string = '';
@tracked sort?: string = '-relevance';
@tracked resourceType?: ResourceTypeFilterValue | null = null;
@tracked resourceType: ResourceTypeFilterValue = ResourceTypeFilterValue.Projects;
@tracked activeFilters?: Filter[] = [];

queryParams = ['cardSearchText', 'sort', 'resourceType'];
queryParams = ['q', 'sort', 'resourceType', 'activeFilters'];

get defaultQueryOptions() {
const identifiers = this.model.iris.join(',');
let key = 'affiliation';
const { resourceType } = this;
switch (resourceType) {
case ResourceTypeFilterValue.Preprints:
key = 'creator.affiliation';
break;
case ResourceTypeFilterValue.Files:
key = 'isContainedby.affiliation';
break;
default:
break;
}
return {
publisher: pathJoin(config.OSF.url, 'institutions', this.model.id),
[key]: identifiers,
};
}

@action
onSearch(queryOptions: OnSearchParams) {
this.cardSearchText = queryOptions.cardSearchText;
this.q = queryOptions.cardSearchText;
this.sort = queryOptions.sort;
this.resourceType = queryOptions.resourceType;
this.resourceType = queryOptions.resourceType as ResourceTypeFilterValue;
this.activeFilters = queryOptions.activeFilters;
}
}
3 changes: 3 additions & 0 deletions app/institutions/discover/template.hbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{{page-title this.model.name}}

<SearchPage
@route='search'
@query={{this.q}}
Expand All @@ -8,4 +10,5 @@
@institution={{this.model}}
@sort={{this.sort}}
@showResourceTypeFilter={{true}}
@activeFilters={{this.activeFilters}}
/>
4 changes: 4 additions & 0 deletions app/models/institution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ export default class InstitutionModel extends OsfModel {
@attr('object') assets?: Assets;
@attr('boolean', { defaultValue: false }) currentUserIsAdmin!: boolean;
@attr('date') lastUpdated!: Date;
@attr('fixstring') rorIri!: string;
// identifier_domain in the admin app
@attr('fixstring') iri!: string;
@attr('fixstringarray') iris!: string[];

// TODO Might want to replace calls to `users` with `institutionUsers.user`?
@hasMany('user', { inverse: 'institutions' })
Expand Down
2 changes: 1 addition & 1 deletion app/models/preprint-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ 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 config from 'ember-osf-web/config/environment';
import Intl from 'ember-intl/services/intl';
import BrandModel from 'ember-osf-web/models/brand';

Expand Down
22 changes: 7 additions & 15 deletions app/models/related-property-path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,21 @@ interface PropertyPath {
shortFormLabel: LanguageText[];
}

export enum SuggestedFilterOperators {
AnyOf = 'any-of',
IsPresent = 'is-present',
AtDate = 'at-date'
}

export default class RelatedPropertyPathModel extends OsfModel {
@attr('string') propertyPathKey!: string;
@attr('number') cardSearchResultCount!: number;
@attr('array') osfmapPropertyPath!: string[];
@attr('array') propertyPath!: PropertyPath[];
@attr('string') suggestedFilterOperator!: SuggestedFilterOperators;

getLocalizedString = new GetLocalizedPropertyHelper(getOwner(this));

get shortFormLabel() {
const labelArray = [];
// propertyPath is likely an array of length 1,
// unless it is nested property(e.g. file's isContainedBy.funder, file's isContainedBy.license)
for (const property of this.propertyPath) {
const label = this.getLocalizedString.compute(
[property as unknown as Record<string, LanguageText[]>, 'shortFormLabel'],
);
if (label) {
labelArray.push(label);
}
}
return labelArray.join(',');
}

get displayLabel() {
// propertyPath is likely an array of length 1,
// unless it is nested property(e.g. file's isContainedBy.funder, file's isContainedBy.license)
Expand Down
1 change: 1 addition & 0 deletions app/models/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export default class UserModel extends OsfModel.extend(Validations) {
@attr('object') social!: {};
@attr('array') employment!: Employment[];
@attr('array') education!: Education[];
@attr('boolean', { allowNull: true }) allowIndexing?: boolean;

@belongsTo('region', { async: false })
defaultRegion!: RegionModel;
Expand Down
14 changes: 8 additions & 6 deletions app/preprints/discover/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,21 @@ import Controller from '@ember/controller';
import { action } from '@ember/object';
import { inject as service } from '@ember/service';
import { tracked } from '@glimmer/tracking';
import config from 'ember-get-config';
import config from 'ember-osf-web/config/environment';

import Theme from 'ember-osf-web/services/theme';
import pathJoin from 'ember-osf-web/utils/path-join';
import { OnSearchParams } from 'osf-components/components/search-page/component';
import { Filter, OnSearchParams } from 'osf-components/components/search-page/component';

export default class PreprintDiscoverController extends Controller {
@service store!: Store;
@service theme!: Theme;

@tracked cardSearchText?: string = '';
@tracked sort?: string = '-relevance';
@tracked q?: string = '';
@tracked sort?: string = '-relevance';
@tracked activeFilters?: Filter[] = [];

queryParams = ['cardSearchText', 'sort'];
queryParams = ['q', 'sort', 'activeFilters'];

get defaultQueryOptions() {
return {
Expand All @@ -28,7 +29,8 @@ export default class PreprintDiscoverController extends Controller {

@action
onSearch(queryOptions: OnSearchParams) {
this.cardSearchText = queryOptions.cardSearchText;
this.q = queryOptions.cardSearchText;
this.sort = queryOptions.sort;
this.activeFilters = queryOptions.activeFilters;
}
}
5 changes: 5 additions & 0 deletions app/preprints/discover/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ 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 config from 'ember-osf-web/config/environment';

import Theme from 'ember-osf-web/services/theme';

Expand All @@ -21,6 +22,10 @@ export default class PreprintDiscoverRoute extends Route {

async model(args: any) {
try {
if (!args.provider_id || args.provider_id === config.defaultProvider) {
this.router.transitionTo('search', { queryParams: { resourceType: 'Preprint' } });
return null;
}
const provider = await this.store.findRecord('preprint-provider', args.provider_id);
this.theme.providerType = 'preprint';
this.theme.id = args.provider_id;
Expand Down
3 changes: 2 additions & 1 deletion app/preprints/discover/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
<div data-analytics-scope='{{concat this.model.providerTitle ' Discover'}}'>
<SearchPage
@route='search'
@query={{this.q}}
@cardSearchText={{this.q}}
@defaultQueryOptions={{this.defaultQueryOptions}}
@resourceType={{'Preprint'}}
@showResourceTypeFilter={{false}}
@provider={{this.model}}
@queryParams={{this.queryParams}}
@onSearch={{action this.onSearch}}
@sort={{this.sort}}
@activeFilters={{this.activeFilters}}
/>
</div>
33 changes: 11 additions & 22 deletions app/register/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,18 @@ import Controller from '@ember/controller';
import { computed } from '@ember/object';
import { inject as service } from '@ember/service';
import { waitFor } from '@ember/test-waiters';
import { tracked } from '@glimmer/tracking';
import { task } from 'ember-concurrency';
import { taskFor } from 'ember-concurrency-ts';
import config from 'ember-osf-web/config/environment';
import QueryParams from 'ember-parachute';

import PreprintProvider from 'ember-osf-web/models/preprint-provider';
import Analytics from 'ember-osf-web/services/analytics';
import param from 'ember-osf-web/utils/param';

const { OSF: { casUrl, url: baseUrl } } = config;

interface RegisterQueryParams {
next: string;
campaign: string;
}

export const registerQueryParams = new QueryParams<RegisterQueryParams>({
next: {
defaultValue: '',
},
campaign: {
defaultValue: '',
},
});

export default class Register extends Controller.extend(registerQueryParams.Mixin) {
export default class Register extends Controller.extend() {
@service analytics!: Analytics;
@service store!: Store;

Expand All @@ -40,15 +26,18 @@ export default class Register extends Controller.extend(registerQueryParams.Mixi
isOsfPreprints = false;
isOsfRegistries = false;

@computed('next')
@tracked next?: string = '';
@tracked campaign?: string = '';

queryParams = ['next', 'campaign'];

get orcidUrl() {
return `${casUrl}/login?${param({
redirectOrcid: 'true',
service: `${baseUrl}/login/?next=${encodeURIComponent(this.next || baseUrl)}`,
})}`;
}

@computed('next')
get institutionUrl() {
return `${casUrl}/login?${param({
campaign: 'institution',
Expand Down Expand Up @@ -77,10 +66,10 @@ export default class Register extends Controller.extend(registerQueryParams.Mixi
}
}

setup({ queryParams }: { queryParams: RegisterQueryParams }) {
if (queryParams.campaign) {
this.set('signUpCampaign', queryParams.campaign);
const matches = queryParams.campaign.match(/^(.*)-(.*)$/);
setup() {
if (this.campaign) {
this.set('signUpCampaign', this.campaign);
const matches = this.campaign.match(/^(.*)-(.*)$/);
if (matches) {
const [, provider, type] = matches;
if (provider === 'osf') {
Expand Down
6 changes: 6 additions & 0 deletions app/register/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Store from '@ember-data/store';

import Session from 'ember-simple-auth/services/session';

import RegisterController from './controller';

export default class Register extends Route {
@service session!: Session;
Expand All @@ -21,4 +22,9 @@ export default class Register extends Route {
model() {
return this.store.createRecord('user-registration');
}

setupController(controller: RegisterController, model: any, transition: Transition) {
super.setupController(controller, model, transition);
controller.setup();
}
}
9 changes: 5 additions & 4 deletions app/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ Router.map(function() {
this.route('goodbye');
this.route('search');
this.route('institutions', function() {
// this.route('discover', { path: '/:institution_id' });
this.route('discover', { path: '/:institution_id' });
this.route('dashboard', { path: '/:institution_id/dashboard' });
});
// this.route('preprints', function() {
// this.route('discover', { path: '/:provider_id/discover' });
// });
this.route('preprints', function() {
this.route('discover');
this.route('discover', { path: '/:provider_id/discover' });
});
this.route('register');
this.route('settings', function() {
this.route('profile', function() {
Expand Down
6 changes: 4 additions & 2 deletions app/search/controller.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import Controller from '@ember/controller';
import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
import { OnSearchParams, ResourceTypeFilterValue } from 'osf-components/components/search-page/component';
import { Filter, OnSearchParams, ResourceTypeFilterValue } from 'osf-components/components/search-page/component';

export default class SearchController extends Controller {
@tracked q?: string = '';
@tracked sort?: string = '-relevance';
@tracked resourceType?: ResourceTypeFilterValue | null = null;
@tracked activeFilters?: Filter[] = [];

queryParams = ['q', 'sort', 'resourceType'];
queryParams = ['q', 'sort', 'resourceType', 'activeFilters'];

@action
onSearch(queryOptions: OnSearchParams) {
this.q = queryOptions.cardSearchText;
this.sort = queryOptions.sort;
this.resourceType = queryOptions.resourceType;
this.activeFilters = queryOptions.activeFilters;
}
}
1 change: 1 addition & 0 deletions app/search/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
@sort={{this.sort}}
@resourceType={{this.resourceType}}
@page={{this.page}}
@activeFilters={{this.activeFilters}}
/>
Loading

0 comments on commit 0a30b09

Please sign in to comment.