Skip to content

Commit

Permalink
Merge branch 'release/23.13.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
adlius committed Oct 25, 2023
2 parents 8e32667 + d7462a1 commit 6814ce3
Show file tree
Hide file tree
Showing 42 changed files with 349 additions and 79 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ 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.13.0] - 2023-10-25
### Added
- Search improvement post release fixes
- Misc bug fixes

## [23.12.0] - 2023-10-10
### Added
- Search improvement phase 2: preprints, institutions and registries discover pages
Expand Down Expand Up @@ -1949,6 +1954,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added
- Quick Files

[23.13.0]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/23.13.0
[23.12.1]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/23.12.1
[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
Expand Down
6 changes: 4 additions & 2 deletions app/institutions/discover/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ 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 { Filter, OnSearchParams, ResourceTypeFilterValue } from 'osf-components/components/search-page/component';
import {
Filter, OnQueryParamChangeParams, ResourceTypeFilterValue,
} from 'osf-components/components/search-page/component';

export default class InstitutionDiscoverController extends Controller {
@service currentUser!: CurrentUser;
Expand Down Expand Up @@ -35,7 +37,7 @@ export default class InstitutionDiscoverController extends Controller {
}

@action
onSearch(queryOptions: OnSearchParams) {
onQueryParamChange(queryOptions: OnQueryParamChangeParams) {
this.q = queryOptions.cardSearchText;
this.sort = queryOptions.sort;
this.resourceType = queryOptions.resourceType as ResourceTypeFilterValue;
Expand Down
2 changes: 1 addition & 1 deletion app/institutions/discover/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
@query={{this.q}}
@defaultQueryOptions={{this.defaultQueryOptions}}
@queryParams={{this.queryParams}}
@onSearch={{action this.onSearch}}
@onQueryParamChange={{action this.onQueryParamChange}}
@resourceType={{this.resourceType}}
@institution={{this.model}}
@sort={{this.sort}}
Expand Down
51 changes: 50 additions & 1 deletion app/models/index-card.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { getOwner } from '@ember/application';
import { inject as service } from '@ember/service';
import { waitFor } from '@ember/test-waiters';
import Model, { AsyncHasMany, attr, hasMany } from '@ember-data/model';
import { dropTask } from 'ember-concurrency';
import IntlService from 'ember-intl/services/intl';

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

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

getLocalizedString = new GetLocalizedPropertyHelper(getOwner(this));

@tracked osfModel?: OsfModel;

get resourceId() {
return this.resourceIdentifier[0];
}

get osfModelType() {
const types = this.resourceMetadata.resourceType.map( (item: any) => item['@id']);
if (types.includes('Project') || types.includes('ProjectComponent')) {
return 'node';
} else if (types.includes('Registration') || types.includes('RegistrationComponent')) {
return 'registration';
} else if (types.includes('Preprint')) {
return 'preprint';
} else if (types.includes('Person') || types.includes('Agent')) {
return 'user';
} else if(types.includes('File')) {
return 'file';
}
return null;
}

get label() {
const possibleLabelKeys = ['displayLabel', 'name', 'title'];
for (const key of possibleLabelKeys) {
Expand All @@ -44,6 +68,31 @@ export default class IndexCardModel extends Model {
}
return '';
}

@dropTask
@waitFor
async getOsfModel(options?: object) {
const identifier = this.resourceIdentifier;
if (identifier && this.osfModelType) {
const guid = this.guidFromIdentifierList(identifier);
if (guid) {
const osfModel = await this.store.findRecord(this.osfModelType, guid, options);
this.osfModel = osfModel;
}
}
}

guidFromIdentifierList() {
for (const iri of this.resourceIdentifier) {
if (iri && iri.startsWith(osfUrl)) {
const pathSegments = iri.slice(osfUrl.length).split('/').filter(Boolean);
if (pathSegments.length === 1) {
return pathSegments[0]; // one path segment; looks like osf-id
}
}
}
return null;
}
}

declare module 'ember-data/types/registries/model' {
Expand Down
8 changes: 6 additions & 2 deletions app/models/search-result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,15 @@ export default class SearchResultModel extends Model {
return this.resourceMetadata['@id'];
}

// returns list of affilated institutions for users
// returns list of contributors for osf objects
// returns list of affiliated institutions for osf users
get affiliatedEntities() {
if (this.resourceType === 'user') {
// return something
if (this.resourceMetadata.affiliation) {
return this.resourceMetadata.affiliation.map((item: any) =>
({ name: item.name[0]['@value'], absoluteUrl: item['@id'] }));
}
} else if (this.resourceMetadata.creator) {
return this.resourceMetadata.creator?.map((item: any) =>
({ name: item.name[0]['@value'], absoluteUrl: item['@id'] }));
Expand Down Expand Up @@ -241,7 +245,7 @@ export default class SearchResultModel extends Model {
get orcids() {
if (this.resourceMetadata.identifier) {
const orcids = this.resourceMetadata.identifier.filter(
(item: any) => item['@value'].includes('http://orcid.org/'),
(item: any) => new URL(item['@value']).host === 'orcid.org',
);
return orcids.map( (item: any) => item['@value']);
}
Expand Down
4 changes: 4 additions & 0 deletions app/models/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { buildValidations, validator } from 'ember-cp-validations';
import config from 'ember-osf-web/config/environment';
import { Link } from 'jsonapi-typescript';

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

@hasMany('preprint')
preprints!: AsyncHasMany<PreprintModel>;

@hasMany('institution', { inverse: 'users' })
institutions!: AsyncHasMany<InstitutionModel>;

Expand Down
4 changes: 2 additions & 2 deletions app/preprints/discover/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ 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 { Filter, OnSearchParams } from 'osf-components/components/search-page/component';
import { Filter, OnQueryParamChangeParams } from 'osf-components/components/search-page/component';

export default class PreprintDiscoverController extends Controller {
@service store!: Store;
Expand All @@ -28,7 +28,7 @@ export default class PreprintDiscoverController extends Controller {
}

@action
onSearch(queryOptions: OnSearchParams) {
onQueryParamChange(queryOptions: OnQueryParamChangeParams) {
this.q = queryOptions.cardSearchText;
this.sort = queryOptions.sort;
this.activeFilters = queryOptions.activeFilters;
Expand Down
18 changes: 18 additions & 0 deletions app/preprints/discover/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ 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 PreprintProviderModel from 'ember-osf-web/models/preprint-provider';

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

export default class PreprintDiscoverRoute extends Route {
@service store!: Store;
@service theme!: Theme;
@service router!: RouterService;
@service metaTags!: MetaTags;
headTags?: HeadTagDef[];

buildRouteInfoMetadata() {
return {
Expand All @@ -36,6 +40,20 @@ export default class PreprintDiscoverRoute extends Route {
}
}

// TODO: Move this to app/preprints/index/route.ts when landing page PR is merged
afterModel(model: PreprintProviderModel) {
if (model && model.assets && model.assets.favicon) {
const headTags = [{
type: 'link',
attrs: {
rel: 'icon',
href: model.assets.favicon,
},
}];
this.set('headTags', headTags);
}
}

deactivate() {
this.theme.reset();
}
Expand Down
2 changes: 1 addition & 1 deletion app/preprints/discover/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
@showResourceTypeFilter={{false}}
@provider={{this.model}}
@queryParams={{this.queryParams}}
@onSearch={{action this.onSearch}}
@onQueryParamChange={{action this.onQueryParamChange}}
@sort={{this.sort}}
@activeFilters={{this.activeFilters}}
/>
Expand Down
1 change: 1 addition & 0 deletions app/resolve-guid/guid-route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default abstract class GuidRoute extends Route {
model = await this.store.findRecord(this.modelName(), guid, {
include: this.include(),
adapterOptions: this.adapterOptions(),
reload: true,
});
} catch (e) {
// To do custom error handling, add an error() action to the route that subclasses GuidRoute.
Expand Down
6 changes: 4 additions & 2 deletions app/search/controller.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import Controller from '@ember/controller';
import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
import { Filter, OnSearchParams, ResourceTypeFilterValue } from 'osf-components/components/search-page/component';
import {
Filter, OnQueryParamChangeParams, ResourceTypeFilterValue,
} from 'osf-components/components/search-page/component';

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

@action
onSearch(queryOptions: OnSearchParams) {
onQueryParamChange(queryOptions: OnQueryParamChangeParams) {
this.q = queryOptions.cardSearchText;
this.sort = queryOptions.sort;
this.resourceType = queryOptions.resourceType;
Expand Down
2 changes: 1 addition & 1 deletion app/search/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
@route='search'
@cardSearchText={{this.q}}
@queryParams={{this.queryParams}}
@onSearch={{action this.onSearch}}
@onQueryParamChange={{action this.onQueryParamChange}}
@showResourceTypeFilter={{true}}
@sort={{this.sort}}
@resourceType={{this.resourceType}}
Expand Down
3 changes: 2 additions & 1 deletion app/settings/tokens/-components/edit-form/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ export default class TokenForm extends Component {
@action
async deleteToken() {
try {
await this.token!.destroyRecord();
this.token!.deleteRecord();
await this.token.save();
this.toast.success(this.intl.t('settings.tokens.deleted'));
this.router.transitionTo('settings.tokens');
} catch {
Expand Down
2 changes: 1 addition & 1 deletion app/settings/tokens/edit/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default class SettingsTokensEditController extends Controller {
token?: Token;

@action
refresh() {
refreshToken() {
this.clearTokenValue();

// Send action to route
Expand Down
10 changes: 6 additions & 4 deletions app/settings/tokens/edit/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,21 @@
{{t 'settings.tokens.createSuccess.instructions'}}
</p>
<Button
{{on 'click' (action this.refresh)}}
{{on 'click' (action this.refreshToken)}}
>
{{t 'settings.tokens.createSuccess.editScopes'}}
</Button>
{{else}}
<h4>{{t 'settings.tokens.editToken'}}</h4>

{{#if this.model.taskInstance.isError}}
{{this.model.taskInstance.error}}
{{else}}
{{#if this.model.taskInstance.isRunning}}
<LoadingIndicator @dark={{true}} />
{{else if this.model.taskInstance.isSuccessful}}
<Settings::Tokens::-Components::EditForm
@token={{this.token}}
/>
{{else}}
{{this.model.taskInstance.error}}
{{/if}}
{{/if}}
</div>
2 changes: 1 addition & 1 deletion app/styles/_global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ fieldset[disabled] .form-control {
position: fixed;
right: 0;
left: 0;
z-index: 1030;
z-index: 998;
}

.navbar-inverse .navbar-collapse,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

.branded-nav-wrapper {
.branded-nav {
z-index: 999;
z-index: 998;
}

:global(.navbar) {
Expand Down
4 changes: 2 additions & 2 deletions lib/osf-components/addon/components/osf-dialog/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
left: 0;
right: 0;

padding-bottom: 10vh;
padding: 2rem 0 10vh;

display: flex;
align-items: center;
justify-content: center;

z-index: 900;
z-index: 999;
background-color: rgba(0, 0, 0, 0.5);
}

Expand Down
Loading

0 comments on commit 6814ce3

Please sign in to comment.