Skip to content

Commit 0a30b09

Browse files
committed
Merge branch 'release/23.12.0'
2 parents 84b11f3 + fab80b2 commit 0a30b09

File tree

86 files changed

+850
-2039
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+850
-2039
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## [23.12.0] - 2023-10-10
8+
### Added
9+
- Search improvement phase 2: preprints, institutions and registries discover pages
10+
711
## [23.11.0] - 2023-09-27
812
### Changed
913
- Upgrade to Ember 3.28
@@ -1945,6 +1949,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
19451949
### Added
19461950
- Quick Files
19471951

1952+
[23.12.0]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/23.12.0
1953+
[23.11.1]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/23.11.1
19481954
[23.11.0]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/23.11.0
19491955
[23.10.2]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/23.10.2
19501956
[23.10.1]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/23.10.1

app/adapters/share-adapter.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
import JSONAPIAdapter from '@ember-data/adapter/json-api';
2-
import config from 'ember-get-config';
2+
import config from 'ember-osf-web/config/environment';
3+
4+
const osfUrl = config.OSF.url;
35

46
export default class ShareAdapter extends JSONAPIAdapter {
57
host = config.OSF.shareBaseUrl.replace(/\/$/, ''); // Remove trailing slash to avoid // in URLs
68
namespace = 'api/v3';
9+
10+
queryRecord(store: any, type: any, query: any) {
11+
// check if we aren't serving locally, otherwise add accessService query param to card/value searches
12+
if (['index-card-search', 'index-value-search'].includes(type.modelName) && !osfUrl.includes('localhost')) {
13+
query.cardSearchFilter['accessService'] = osfUrl;
14+
}
15+
return super.queryRecord(store, type, query);
16+
}
717
}

app/institutions/discover/controller.ts

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,42 @@ import { inject as service } from '@ember/service';
33
import CurrentUser from 'ember-osf-web/services/current-user';
44
import { tracked } from '@glimmer/tracking';
55
import { action } from '@ember/object';
6-
import pathJoin from 'ember-osf-web/utils/path-join';
7-
import config from 'ember-get-config';
8-
import { OnSearchParams, ResourceTypeFilterValue } from 'osf-components/components/search-page/component';
6+
import { Filter, OnSearchParams, ResourceTypeFilterValue } from 'osf-components/components/search-page/component';
97

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

13-
@tracked cardSearchText?: string = '';
11+
@tracked q?: string = '';
1412
@tracked sort?: string = '-relevance';
15-
@tracked resourceType?: ResourceTypeFilterValue | null = null;
13+
@tracked resourceType: ResourceTypeFilterValue = ResourceTypeFilterValue.Projects;
14+
@tracked activeFilters?: Filter[] = [];
1615

17-
queryParams = ['cardSearchText', 'sort', 'resourceType'];
16+
queryParams = ['q', 'sort', 'resourceType', 'activeFilters'];
1817

1918
get defaultQueryOptions() {
19+
const identifiers = this.model.iris.join(',');
20+
let key = 'affiliation';
21+
const { resourceType } = this;
22+
switch (resourceType) {
23+
case ResourceTypeFilterValue.Preprints:
24+
key = 'creator.affiliation';
25+
break;
26+
case ResourceTypeFilterValue.Files:
27+
key = 'isContainedby.affiliation';
28+
break;
29+
default:
30+
break;
31+
}
2032
return {
21-
publisher: pathJoin(config.OSF.url, 'institutions', this.model.id),
33+
[key]: identifiers,
2234
};
2335
}
2436

2537
@action
2638
onSearch(queryOptions: OnSearchParams) {
27-
this.cardSearchText = queryOptions.cardSearchText;
39+
this.q = queryOptions.cardSearchText;
2840
this.sort = queryOptions.sort;
29-
this.resourceType = queryOptions.resourceType;
41+
this.resourceType = queryOptions.resourceType as ResourceTypeFilterValue;
42+
this.activeFilters = queryOptions.activeFilters;
3043
}
3144
}

app/institutions/discover/template.hbs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
{{page-title this.model.name}}
2+
13
<SearchPage
24
@route='search'
35
@query={{this.q}}
@@ -8,4 +10,5 @@
810
@institution={{this.model}}
911
@sort={{this.sort}}
1012
@showResourceTypeFilter={{true}}
13+
@activeFilters={{this.activeFilters}}
1114
/>

app/models/institution.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ export default class InstitutionModel extends OsfModel {
3030
@attr('object') assets?: Assets;
3131
@attr('boolean', { defaultValue: false }) currentUserIsAdmin!: boolean;
3232
@attr('date') lastUpdated!: Date;
33+
@attr('fixstring') rorIri!: string;
34+
// identifier_domain in the admin app
35+
@attr('fixstring') iri!: string;
36+
@attr('fixstringarray') iris!: string[];
3337

3438
// TODO Might want to replace calls to `users` with `institutionUsers.user`?
3539
@hasMany('user', { inverse: 'institutions' })

app/models/preprint-provider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { attr, hasMany, AsyncHasMany, belongsTo, AsyncBelongsTo } from '@ember-d
22
import { computed } from '@ember/object';
33
import { alias } from '@ember/object/computed';
44
import { inject as service } from '@ember/service';
5-
import config from 'ember-get-config';
5+
import config from 'ember-osf-web/config/environment';
66
import Intl from 'ember-intl/services/intl';
77
import BrandModel from 'ember-osf-web/models/brand';
88

app/models/related-property-path.ts

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,21 @@ interface PropertyPath {
1313
shortFormLabel: LanguageText[];
1414
}
1515

16+
export enum SuggestedFilterOperators {
17+
AnyOf = 'any-of',
18+
IsPresent = 'is-present',
19+
AtDate = 'at-date'
20+
}
21+
1622
export default class RelatedPropertyPathModel extends OsfModel {
1723
@attr('string') propertyPathKey!: string;
1824
@attr('number') cardSearchResultCount!: number;
1925
@attr('array') osfmapPropertyPath!: string[];
2026
@attr('array') propertyPath!: PropertyPath[];
27+
@attr('string') suggestedFilterOperator!: SuggestedFilterOperators;
2128

2229
getLocalizedString = new GetLocalizedPropertyHelper(getOwner(this));
2330

24-
get shortFormLabel() {
25-
const labelArray = [];
26-
// propertyPath is likely an array of length 1,
27-
// unless it is nested property(e.g. file's isContainedBy.funder, file's isContainedBy.license)
28-
for (const property of this.propertyPath) {
29-
const label = this.getLocalizedString.compute(
30-
[property as unknown as Record<string, LanguageText[]>, 'shortFormLabel'],
31-
);
32-
if (label) {
33-
labelArray.push(label);
34-
}
35-
}
36-
return labelArray.join(',');
37-
}
38-
3931
get displayLabel() {
4032
// propertyPath is likely an array of length 1,
4133
// unless it is nested property(e.g. file's isContainedBy.funder, file's isContainedBy.license)

app/models/user.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ export default class UserModel extends OsfModel.extend(Validations) {
9494
@attr('object') social!: {};
9595
@attr('array') employment!: Employment[];
9696
@attr('array') education!: Education[];
97+
@attr('boolean', { allowNull: true }) allowIndexing?: boolean;
9798

9899
@belongsTo('region', { async: false })
99100
defaultRegion!: RegionModel;

app/preprints/discover/controller.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,21 @@ import Controller from '@ember/controller';
44
import { action } from '@ember/object';
55
import { inject as service } from '@ember/service';
66
import { tracked } from '@glimmer/tracking';
7-
import config from 'ember-get-config';
7+
import config from 'ember-osf-web/config/environment';
88

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

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

17-
@tracked cardSearchText?: string = '';
18-
@tracked sort?: string = '-relevance';
17+
@tracked q?: string = '';
18+
@tracked sort?: string = '-relevance';
19+
@tracked activeFilters?: Filter[] = [];
1920

20-
queryParams = ['cardSearchText', 'sort'];
21+
queryParams = ['q', 'sort', 'activeFilters'];
2122

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

2930
@action
3031
onSearch(queryOptions: OnSearchParams) {
31-
this.cardSearchText = queryOptions.cardSearchText;
32+
this.q = queryOptions.cardSearchText;
3233
this.sort = queryOptions.sort;
34+
this.activeFilters = queryOptions.activeFilters;
3335
}
3436
}

app/preprints/discover/route.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import Store from '@ember-data/store';
22
import Route from '@ember/routing/route';
33
import RouterService from '@ember/routing/router-service';
44
import { inject as service } from '@ember/service';
5+
import config from 'ember-osf-web/config/environment';
56

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

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

2223
async model(args: any) {
2324
try {
25+
if (!args.provider_id || args.provider_id === config.defaultProvider) {
26+
this.router.transitionTo('search', { queryParams: { resourceType: 'Preprint' } });
27+
return null;
28+
}
2429
const provider = await this.store.findRecord('preprint-provider', args.provider_id);
2530
this.theme.providerType = 'preprint';
2631
this.theme.id = args.provider_id;

0 commit comments

Comments
 (0)