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.

app/search/controller.ts

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

68
export default class SearchController extends Controller {
79
@tracked q?: string = '';
@@ -12,7 +14,7 @@ export default class SearchController extends Controller {
1214
queryParams = ['q', 'sort', 'resourceType', 'activeFilters'];
1315

1416
@action
15-
onSearch(queryOptions: OnSearchParams) {
17+
onQueryParamChange(queryOptions: OnQueryParamChangeParams) {
1618
this.q = queryOptions.cardSearchText;
1719
this.sort = queryOptions.sort;
1820
this.resourceType = queryOptions.resourceType;

app/search/template.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
@route='search'
55
@cardSearchText={{this.q}}
66
@queryParams={{this.queryParams}}
7-
@onSearch={{action this.onSearch}}
7+
@onQueryParamChange={{action this.onQueryParamChange}}
88
@showResourceTypeFilter={{true}}
99
@sort={{this.sort}}
1010
@resourceType={{this.resourceType}}

app/settings/tokens/-components/edit-form/component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ export default class TokenForm extends Component {
6767
@action
6868
async deleteToken() {
6969
try {
70-
await this.token!.destroyRecord();
70+
this.token!.deleteRecord();
71+
await this.token.save();
7172
this.toast.success(this.intl.t('settings.tokens.deleted'));
7273
this.router.transitionTo('settings.tokens');
7374
} catch {

app/settings/tokens/edit/controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default class SettingsTokensEditController extends Controller {
2121
token?: Token;
2222

2323
@action
24-
refresh() {
24+
refreshToken() {
2525
this.clearTokenValue();
2626

2727
// Send action to route

app/settings/tokens/edit/template.hbs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,21 @@
3232
{{t 'settings.tokens.createSuccess.instructions'}}
3333
</p>
3434
<Button
35-
{{on 'click' (action this.refresh)}}
35+
{{on 'click' (action this.refreshToken)}}
3636
>
3737
{{t 'settings.tokens.createSuccess.editScopes'}}
3838
</Button>
3939
{{else}}
4040
<h4>{{t 'settings.tokens.editToken'}}</h4>
4141

42-
{{#if this.model.taskInstance.isError}}
43-
{{this.model.taskInstance.error}}
44-
{{else}}
42+
{{#if this.model.taskInstance.isRunning}}
43+
<LoadingIndicator @dark={{true}} />
44+
{{else if this.model.taskInstance.isSuccessful}}
4545
<Settings::Tokens::-Components::EditForm
4646
@token={{this.token}}
4747
/>
48+
{{else}}
49+
{{this.model.taskInstance.error}}
4850
{{/if}}
4951
{{/if}}
5052
</div>

app/styles/_global.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ fieldset[disabled] .form-control {
337337
position: fixed;
338338
right: 0;
339339
left: 0;
340-
z-index: 1030;
340+
z-index: 998;
341341
}
342342

343343
.navbar-inverse .navbar-collapse,

lib/app-components/addon/components/branded-navbar/styles.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
.branded-nav-wrapper {
44
.branded-nav {
5-
z-index: 999;
5+
z-index: 998;
66
}
77

88
:global(.navbar) {

lib/osf-components/addon/components/osf-dialog/styles.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
left: 0;
66
right: 0;
77

8-
padding-bottom: 10vh;
8+
padding: 2rem 0 10vh;
99

1010
display: flex;
1111
align-items: center;
1212
justify-content: center;
1313

14-
z-index: 900;
14+
z-index: 999;
1515
background-color: rgba(0, 0, 0, 0.5);
1616
}
1717

0 commit comments

Comments
 (0)