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;

app/preprints/discover/template.hbs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
<div data-analytics-scope='{{concat this.model.providerTitle ' Discover'}}'>
33
<SearchPage
44
@route='search'
5-
@query={{this.q}}
5+
@cardSearchText={{this.q}}
66
@defaultQueryOptions={{this.defaultQueryOptions}}
77
@resourceType={{'Preprint'}}
88
@showResourceTypeFilter={{false}}
99
@provider={{this.model}}
1010
@queryParams={{this.queryParams}}
1111
@onSearch={{action this.onSearch}}
1212
@sort={{this.sort}}
13+
@activeFilters={{this.activeFilters}}
1314
/>
1415
</div>

app/register/controller.ts

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,18 @@ import Controller from '@ember/controller';
33
import { computed } from '@ember/object';
44
import { inject as service } from '@ember/service';
55
import { waitFor } from '@ember/test-waiters';
6+
import { tracked } from '@glimmer/tracking';
67
import { task } from 'ember-concurrency';
78
import { taskFor } from 'ember-concurrency-ts';
89
import config from 'ember-osf-web/config/environment';
9-
import QueryParams from 'ember-parachute';
1010

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

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

17-
interface RegisterQueryParams {
18-
next: string;
19-
campaign: string;
20-
}
21-
22-
export const registerQueryParams = new QueryParams<RegisterQueryParams>({
23-
next: {
24-
defaultValue: '',
25-
},
26-
campaign: {
27-
defaultValue: '',
28-
},
29-
});
30-
31-
export default class Register extends Controller.extend(registerQueryParams.Mixin) {
17+
export default class Register extends Controller.extend() {
3218
@service analytics!: Analytics;
3319
@service store!: Store;
3420

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

43-
@computed('next')
29+
@tracked next?: string = '';
30+
@tracked campaign?: string = '';
31+
32+
queryParams = ['next', 'campaign'];
33+
4434
get orcidUrl() {
4535
return `${casUrl}/login?${param({
4636
redirectOrcid: 'true',
4737
service: `${baseUrl}/login/?next=${encodeURIComponent(this.next || baseUrl)}`,
4838
})}`;
4939
}
5040

51-
@computed('next')
5241
get institutionUrl() {
5342
return `${casUrl}/login?${param({
5443
campaign: 'institution',
@@ -77,10 +66,10 @@ export default class Register extends Controller.extend(registerQueryParams.Mixi
7766
}
7867
}
7968

80-
setup({ queryParams }: { queryParams: RegisterQueryParams }) {
81-
if (queryParams.campaign) {
82-
this.set('signUpCampaign', queryParams.campaign);
83-
const matches = queryParams.campaign.match(/^(.*)-(.*)$/);
69+
setup() {
70+
if (this.campaign) {
71+
this.set('signUpCampaign', this.campaign);
72+
const matches = this.campaign.match(/^(.*)-(.*)$/);
8473
if (matches) {
8574
const [, provider, type] = matches;
8675
if (provider === 'osf') {

app/register/route.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import Store from '@ember-data/store';
55

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

8+
import RegisterController from './controller';
89

910
export default class Register extends Route {
1011
@service session!: Session;
@@ -21,4 +22,9 @@ export default class Register extends Route {
2122
model() {
2223
return this.store.createRecord('user-registration');
2324
}
25+
26+
setupController(controller: RegisterController, model: any, transition: Transition) {
27+
super.setupController(controller, model, transition);
28+
controller.setup();
29+
}
2430
}

app/router.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@ Router.map(function() {
2222
this.route('goodbye');
2323
this.route('search');
2424
this.route('institutions', function() {
25-
// this.route('discover', { path: '/:institution_id' });
25+
this.route('discover', { path: '/:institution_id' });
2626
this.route('dashboard', { path: '/:institution_id/dashboard' });
2727
});
28-
// this.route('preprints', function() {
29-
// this.route('discover', { path: '/:provider_id/discover' });
30-
// });
28+
this.route('preprints', function() {
29+
this.route('discover');
30+
this.route('discover', { path: '/:provider_id/discover' });
31+
});
3132
this.route('register');
3233
this.route('settings', function() {
3334
this.route('profile', function() {

app/search/controller.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
import Controller from '@ember/controller';
22
import { action } from '@ember/object';
33
import { tracked } from '@glimmer/tracking';
4-
import { OnSearchParams, ResourceTypeFilterValue } from 'osf-components/components/search-page/component';
4+
import { Filter, OnSearchParams, ResourceTypeFilterValue } from 'osf-components/components/search-page/component';
55

66
export default class SearchController extends Controller {
77
@tracked q?: string = '';
88
@tracked sort?: string = '-relevance';
99
@tracked resourceType?: ResourceTypeFilterValue | null = null;
10+
@tracked activeFilters?: Filter[] = [];
1011

11-
queryParams = ['q', 'sort', 'resourceType'];
12+
queryParams = ['q', 'sort', 'resourceType', 'activeFilters'];
1213

1314
@action
1415
onSearch(queryOptions: OnSearchParams) {
1516
this.q = queryOptions.cardSearchText;
1617
this.sort = queryOptions.sort;
1718
this.resourceType = queryOptions.resourceType;
19+
this.activeFilters = queryOptions.activeFilters;
1820
}
1921
}

app/search/template.hbs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@
99
@sort={{this.sort}}
1010
@resourceType={{this.resourceType}}
1111
@page={{this.page}}
12+
@activeFilters={{this.activeFilters}}
1213
/>

0 commit comments

Comments
 (0)