Skip to content

Commit 6814ce3

Browse files
committed
Merge branch 'release/23.13.0'
2 parents 8e32667 + d7462a1 commit 6814ce3

File tree

42 files changed

+349
-79
lines changed

Some content is hidden

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

42 files changed

+349
-79
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ 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.13.0] - 2023-10-25
8+
### Added
9+
- Search improvement post release fixes
10+
- Misc bug fixes
11+
712
## [23.12.0] - 2023-10-10
813
### Added
914
- Search improvement phase 2: preprints, institutions and registries discover pages
@@ -1949,6 +1954,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
19491954
### Added
19501955
- Quick Files
19511956

1957+
[23.13.0]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/23.13.0
1958+
[23.12.1]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/23.12.1
19521959
[23.12.0]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/23.12.0
19531960
[23.11.1]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/23.11.1
19541961
[23.11.0]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/23.11.0

app/institutions/discover/controller.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ 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 { Filter, OnSearchParams, ResourceTypeFilterValue } from 'osf-components/components/search-page/component';
6+
import {
7+
Filter, OnQueryParamChangeParams, ResourceTypeFilterValue,
8+
} from 'osf-components/components/search-page/component';
79

810
export default class InstitutionDiscoverController extends Controller {
911
@service currentUser!: CurrentUser;
@@ -35,7 +37,7 @@ export default class InstitutionDiscoverController extends Controller {
3537
}
3638

3739
@action
38-
onSearch(queryOptions: OnSearchParams) {
40+
onQueryParamChange(queryOptions: OnQueryParamChangeParams) {
3941
this.q = queryOptions.cardSearchText;
4042
this.sort = queryOptions.sort;
4143
this.resourceType = queryOptions.resourceType as ResourceTypeFilterValue;

app/institutions/discover/template.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
@query={{this.q}}
66
@defaultQueryOptions={{this.defaultQueryOptions}}
77
@queryParams={{this.queryParams}}
8-
@onSearch={{action this.onSearch}}
8+
@onQueryParamChange={{action this.onQueryParamChange}}
99
@resourceType={{this.resourceType}}
1010
@institution={{this.model}}
1111
@sort={{this.sort}}

app/models/index-card.ts

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1+
import { getOwner } from '@ember/application';
12
import { inject as service } from '@ember/service';
3+
import { waitFor } from '@ember/test-waiters';
24
import Model, { AsyncHasMany, attr, hasMany } from '@ember-data/model';
5+
import { dropTask } from 'ember-concurrency';
36
import IntlService from 'ember-intl/services/intl';
47

58
import GetLocalizedPropertyHelper from 'ember-osf-web/helpers/get-localized-property';
6-
import { getOwner } from '@ember/application';
9+
import config from 'ember-osf-web/config/environment';
10+
import OsfModel from 'ember-osf-web/models/osf-model';
11+
import { tracked } from 'tracked-built-ins';
12+
const osfUrl = config.OSF.url;
713

814
export interface LanguageText {
915
'@language': string;
@@ -23,10 +29,28 @@ export default class IndexCardModel extends Model {
2329

2430
getLocalizedString = new GetLocalizedPropertyHelper(getOwner(this));
2531

32+
@tracked osfModel?: OsfModel;
33+
2634
get resourceId() {
2735
return this.resourceIdentifier[0];
2836
}
2937

38+
get osfModelType() {
39+
const types = this.resourceMetadata.resourceType.map( (item: any) => item['@id']);
40+
if (types.includes('Project') || types.includes('ProjectComponent')) {
41+
return 'node';
42+
} else if (types.includes('Registration') || types.includes('RegistrationComponent')) {
43+
return 'registration';
44+
} else if (types.includes('Preprint')) {
45+
return 'preprint';
46+
} else if (types.includes('Person') || types.includes('Agent')) {
47+
return 'user';
48+
} else if(types.includes('File')) {
49+
return 'file';
50+
}
51+
return null;
52+
}
53+
3054
get label() {
3155
const possibleLabelKeys = ['displayLabel', 'name', 'title'];
3256
for (const key of possibleLabelKeys) {
@@ -44,6 +68,31 @@ export default class IndexCardModel extends Model {
4468
}
4569
return '';
4670
}
71+
72+
@dropTask
73+
@waitFor
74+
async getOsfModel(options?: object) {
75+
const identifier = this.resourceIdentifier;
76+
if (identifier && this.osfModelType) {
77+
const guid = this.guidFromIdentifierList(identifier);
78+
if (guid) {
79+
const osfModel = await this.store.findRecord(this.osfModelType, guid, options);
80+
this.osfModel = osfModel;
81+
}
82+
}
83+
}
84+
85+
guidFromIdentifierList() {
86+
for (const iri of this.resourceIdentifier) {
87+
if (iri && iri.startsWith(osfUrl)) {
88+
const pathSegments = iri.slice(osfUrl.length).split('/').filter(Boolean);
89+
if (pathSegments.length === 1) {
90+
return pathSegments[0]; // one path segment; looks like osf-id
91+
}
92+
}
93+
}
94+
return null;
95+
}
4796
}
4897

4998
declare module 'ember-data/types/registries/model' {

app/models/search-result.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,15 @@ export default class SearchResultModel extends Model {
7373
return this.resourceMetadata['@id'];
7474
}
7575

76+
// returns list of affilated institutions for users
7677
// returns list of contributors for osf objects
7778
// returns list of affiliated institutions for osf users
7879
get affiliatedEntities() {
7980
if (this.resourceType === 'user') {
80-
// return something
81+
if (this.resourceMetadata.affiliation) {
82+
return this.resourceMetadata.affiliation.map((item: any) =>
83+
({ name: item.name[0]['@value'], absoluteUrl: item['@id'] }));
84+
}
8185
} else if (this.resourceMetadata.creator) {
8286
return this.resourceMetadata.creator?.map((item: any) =>
8387
({ name: item.name[0]['@value'], absoluteUrl: item['@id'] }));
@@ -241,7 +245,7 @@ export default class SearchResultModel extends Model {
241245
get orcids() {
242246
if (this.resourceMetadata.identifier) {
243247
const orcids = this.resourceMetadata.identifier.filter(
244-
(item: any) => item['@value'].includes('http://orcid.org/'),
248+
(item: any) => new URL(item['@value']).host === 'orcid.org',
245249
);
246250
return orcids.map( (item: any) => item['@value']);
247251
}

app/models/user.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { buildValidations, validator } from 'ember-cp-validations';
44
import config from 'ember-osf-web/config/environment';
55
import { Link } from 'jsonapi-typescript';
66

7+
import PreprintModel from 'ember-osf-web/models/preprint';
78
import SparseNodeModel from 'ember-osf-web/models/sparse-node';
89
import ContributorModel from './contributor';
910
import DraftRegistrationModel from './draft-registration';
@@ -114,6 +115,9 @@ export default class UserModel extends OsfModel.extend(Validations) {
114115
@hasMany('draft-registration')
115116
draftRegistrations!: AsyncHasMany<DraftRegistrationModel>;
116117

118+
@hasMany('preprint')
119+
preprints!: AsyncHasMany<PreprintModel>;
120+
117121
@hasMany('institution', { inverse: 'users' })
118122
institutions!: AsyncHasMany<InstitutionModel>;
119123

app/preprints/discover/controller.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,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 { Filter, OnSearchParams } from 'osf-components/components/search-page/component';
11+
import { Filter, OnQueryParamChangeParams } from 'osf-components/components/search-page/component';
1212

1313
export default class PreprintDiscoverController extends Controller {
1414
@service store!: Store;
@@ -28,7 +28,7 @@ export default class PreprintDiscoverController extends Controller {
2828
}
2929

3030
@action
31-
onSearch(queryOptions: OnSearchParams) {
31+
onQueryParamChange(queryOptions: OnQueryParamChangeParams) {
3232
this.q = queryOptions.cardSearchText;
3333
this.sort = queryOptions.sort;
3434
this.activeFilters = queryOptions.activeFilters;

app/preprints/discover/route.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@ import Route from '@ember/routing/route';
33
import RouterService from '@ember/routing/router-service';
44
import { inject as service } from '@ember/service';
55
import config from 'ember-osf-web/config/environment';
6+
import PreprintProviderModel from 'ember-osf-web/models/preprint-provider';
67

8+
import MetaTags, { HeadTagDef } from 'ember-osf-web/services/meta-tags';
79
import Theme from 'ember-osf-web/services/theme';
810

911
export default class PreprintDiscoverRoute extends Route {
1012
@service store!: Store;
1113
@service theme!: Theme;
1214
@service router!: RouterService;
15+
@service metaTags!: MetaTags;
16+
headTags?: HeadTagDef[];
1317

1418
buildRouteInfoMetadata() {
1519
return {
@@ -36,6 +40,20 @@ export default class PreprintDiscoverRoute extends Route {
3640
}
3741
}
3842

43+
// TODO: Move this to app/preprints/index/route.ts when landing page PR is merged
44+
afterModel(model: PreprintProviderModel) {
45+
if (model && model.assets && model.assets.favicon) {
46+
const headTags = [{
47+
type: 'link',
48+
attrs: {
49+
rel: 'icon',
50+
href: model.assets.favicon,
51+
},
52+
}];
53+
this.set('headTags', headTags);
54+
}
55+
}
56+
3957
deactivate() {
4058
this.theme.reset();
4159
}

app/preprints/discover/template.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
@showResourceTypeFilter={{false}}
99
@provider={{this.model}}
1010
@queryParams={{this.queryParams}}
11-
@onSearch={{action this.onSearch}}
11+
@onQueryParamChange={{action this.onQueryParamChange}}
1212
@sort={{this.sort}}
1313
@activeFilters={{this.activeFilters}}
1414
/>

app/resolve-guid/guid-route.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export default abstract class GuidRoute extends Route {
3030
model = await this.store.findRecord(this.modelName(), guid, {
3131
include: this.include(),
3232
adapterOptions: this.adapterOptions(),
33+
reload: true,
3334
});
3435
} catch (e) {
3536
// To do custom error handling, add an error() action to the route that subclasses GuidRoute.

0 commit comments

Comments
 (0)