Skip to content

Commit

Permalink
Feature/search phase 2 (#2024)
Browse files Browse the repository at this point in the history
* Re add institution and preprints discover page; remove registries discover page. (#1985)

* Remove ember-parachute; Remove page QP (#1986)

* Reword object filter dropdown label (#1979)

* Fix branded page query-params (#1992)

* [ENG-4660] activeFilters query param (#1990)

* activeFilters query param

* add activeFilters to other pages

* Update app/institutions/discover/controller.ts

* [ENG-4656] Special-case is-present type filters (#1994)

* Special-case is-present type filters

* Remove unused style

* Update mirage endpoint

* Show provider hero-banner on search page (#1995)

* Show provider hero-banner on search page

* Allow html entities from institution description

* Update institution discover default query options (#1993)

* Update institution discover default query options

* Update link; Combine default qps

* Add accessService qp if appropriate

* No labels, just keys

* Remove accessService qp to SHARE (#1997)

* Use less restrictive filter to fetch non-boolean filters (#1999)

* Return sort dropdown for registries and preprints discover (#2000)

* Return sort dropdown for registries and preprints discover

* Address styling issue for tablet

* Address branded registries style issues (#2002)

* [ENG-4648] Opt out of SHARE indexing (#1998)

* Add allowIndexing attr to user model

* Add opt-out panel to user-settings

* Add test

* Update wording

* Use constructor; Match mirage default with BE default

* Reroute users to general discover page for preprints/discover and preprints/osf/discover (#2004)

* change query param name from cardSearchText to q (#2005)

* Institutions header (#2006)

* Add id back for search box

* Update institution page header

* Reroute for registry not found (#2007)

* Increase color contrast of link in help tour (#2010)

* Merge develop into feature/search phase 2 (#2009)

* [ENG-4012] Un-silence deprecation manager-capabilities.modifiers-3-13 (#1889)

## Purpose

Un-silence the deprecation `manager-capabilities.modifiers-3-13` and fix the resulting problems

## Summary of Changes

1. Unsilence deprecation
2. Upgrade ember-auto-import to v2
3. Upgrade ember-modifiers
4. Upgrade ember-moment and imports
5. Spread moment around all the engines
6. Refactor modifiers to work with new api for ember-modifiers
7. Remove unused modifier
8. Fix usage of side-effect from ember computed to give ember power select a placeholder in institutional dashboard

## Side Effects

If I didn't fix the modifiers right, something may have broken there silently.

* Fix the missing asset prefix for ember-auto-import (#1906)

## Purpose

Staging2 is broken because we can't find `chunk*.js` and it looks like that's because we need to add our `assetsPrefix` to ember-auto-import to make it work. This fix seems to work locally, but it works locally without the fix, so we'll see what actually happens on staging2.

## Summary of Changes

1. Fix the missing asset prefix

* [ENG-4591] Barium/upgrade ember 3.28 (#1899)

## Purpose

Upgrade ember to 3.28

## Summary of Changes

1. Match ember dependencies to `ember new` blueprint
2. Fix all the problems
3. Modify getApiErrorMessage to re-throw in the case of no API error message

(some problems fixed h/t @futa-ikeda)

* [ENG-4488] Remove ember-cli-clipboard (#1910)

## Purpose

Ember-cli-clipboard was doing deprecated things, and upgrading it was a nightmare. The actual functionality is trivial to implement, though, so we've made our own version of its copy button.

## Summary of Changes

1. Add copy button
2. Add tests

* Don't re-throw error in getApiErrorMessage (#1911)

## Purpose

See if a weird bug gets fixed on staging2 by removing a slightly risky re-throw of error messages.

## Summary of Changes

1. Don't re-throw error message

* [No ticket] Throw an error when registries overview page errors (#1912)

## Purpose

Help to be able to debug situations where the registries overview page goes to the not-found page inappropriately.

## Summary of Changes

1. Send the error to sentry after transitioning to page not found.

* Remove most non-dirty relationships (#1918)

## Purpose

When upgrading to ember 3.28, we lost the ability to distinguish between dirty relationships and clean ones when PATCHing a record, so we would send all the relationships. This was a problem because many of the clean relationships in the serializer had null information, which broke the API, because it doesn't like PATCHed relationships with null information. This fixes that by removing any relationship that is just null info in the serializer. We will still sometimes PATCH relationships we don't need to, but the info should be the same and thus not cause problems for the API. 

## Summary of Changes

1. Scan for null relationships in osf-serializer and remove them from the request payload.

* Fix infinite scrolling loader (#1919)

## Purpose

The infinite scroller stopped working because the component that manages if it's in the viewport was not compatible with the new modifiers until it was updated.

## Summary of Changes

1. Update ember-in-viewport

* [No ticket] Remove clean relationships from PATCH request (#1925)

## Purpose

Properly remove clean relationships from a PATCH request.

## Summary of Changes

1. Get the graph
2. Scan the graph for changes in each relationship in the serializer
3. Remove the relationship from the serializer if there are no changes
4. Types

* Make relationships polymorphic (#1928)

## Purpose

Make registrations load on basket/barium release

## Summary of Changes

1. Make relationships polymorphic

* [ENG-4025] Deprecation: has-block-and-has-block-params (#1909)

## Purpose
- Address deprecation: [has-block-and-has-block-params](https://deprecations.emberjs.com/v3.x#toc_has-block-and-has-block-params)

## Summary of Changes
- Remove `ember-cli-password-strength` and use `zxcvbn` directly
- Remove `ember-promise-helpers` as it doesn't seem to be used
- Update liquid-fire
- Update ember-radio-buttons
- Remove deprecation silencer

Co-authored-by: Brian J. Geiger <bgeiger@pobox.com>

* Remove test that accidentally merged in (#1977)

* [ENG-4013] Barium/deprecation this property fallback (#1970)

## Purpose

Eliminate this-property-fallback deprecation errors. Might want to review this commit-by-commit. The removal of ember-get-config added a bunch of noise.

## Summary of Changes

1. Upgrade ember-sortable
2. Fix tests that failed this deprecation
3. Upgrade:
    - ember-cli-showdown
    - tag-input
    - Ember-collapsible-panel
    - Ember-content-placeholders
    - Ember-radio-button
4. Remove ember-get-config
5. Move environment.d.ts
6. Fix tests

* remove 'argument-less-helper-paren-less-invocation' (#1978)

* Unsilence deprecation route-render-template (#1984)

## Purpose

Fix deprecation route-render-template

## Summary of Changes

1. Unsilence the deprecation

* Fix `ember.built-in-components.import` deprecation by upgrading ember-flatpickr (#1982)

* fix deprecation by upgrading ember-flatpickr

* use null as date param for ember-flatpickr

* Fix `deprecated-run-loop-and-computed-dot-access` by upgrading ember-responsive and ember-intl; fix `ember.built-in-components.legacy-arguments` (#1983)

* Fix `ember.built in components.legacy-attribute-arguments`; Fix `ember.built-in-components.reopen` (#1987)

* Try to fix selenium test (#1988)

## Purpose

Try to fix a selenium test that was broken when we re-wrote the clipboard button.

## Summary of Changes

1. Add data selector

* Update ember-composable-helpers (#1980)

## Purpose

There are two major parts to fixing the try-invoke deprecation. The first is updating ember-composable-helpers, and the second is removing ember parachute. This handles the first. The second will be part of Search Phase 2 once the branded registries discovery page, which is the page that uses ember-parachute, is removed.

## Summary of Changes

1. Update ember-composable-helpers

* Fix broken meetings searches (#1991)

## Purpose

A recent deprecation fix caused meetings searches to break. This should fix that.

## Summary of Changes

1. Add `target` string to `on` actions

* Fix some build-time deprecations (#1989)

## Purpose

Fix some build-time deprecations. Everything I know about except for https://deprecations.emberjs.com/v3.x/#toc_ember-global

## Summary of Changes

1. Upgrade ember power select
2. Upgrade Node
3. Remove node-sass
4. Remove ember-component-attributes
5. Fix usage of htmlSafe
6. Upgrade ember-cli-string-helpers
7. Remove unused osf-logo component
8. Update and remove various other dependencies

## Side effects
Builds may be a bit faster. I'm getting between 45 and 60ish second builds, although this may only be true for M1 and M2 chips. Could be slower on Intel. Also, we'll get a bunch of extraneous notices in the buld process like `unexpectedly found "<Pane" when slicing source, but expected "class"`. This is unfortunate but expected and isn't supposed to hurt anything.

* [ENG-4293] Fix node license validation (#1996)

* fix node license validation

* remove comments

* add test

* revert changes to copyMetadataChangesToDraft

* Restore placeholder text on sign-up page (#2003)

## Purpose

Placeholder text went away on the sign-up page. This restores the placeholders.

## Summary of Changes

1. Send the placeholders to the component properly.

* Bump version no. Add CHANGELOG

* hotfix password input

* fix test

---------

Co-authored-by: Brian J. Geiger <bgeiger@cos.io>
Co-authored-by: Brian J. Geiger <bgeiger@pobox.com>
Co-authored-by: futa-ikeda <51409893+futa-ikeda@users.noreply.github.com>

* fix query param (#2011)

* Search a11y (#2012)

* Add/update aria attributes

* Use darker color for object filter links

* Institutions updates (#2013)

* Remove All as option for instition discover page

* Use new iris field for institution identifiers

* Change institution default filters by object type

* Add back accessService to SHARE request (#2014)

* Add back accessService to SHARE request

* Move accessService logic to share-adapter

* Search: Mobile fixes (#2016)

* Add global-classes for use in admin app to modify provider descriptions

* Use institution banner image for all size screens

* Prevent covering help text on mobile

* Darken institution description links (#2015)

* Result counts (#2017)

* Show results counts for mobile preprint/registry discover page

* Grammar for result counts

* Search bug fixes (#2019)

* Update config import path

* Prevent defaultQPs from overwriting left panel filters

* Institution discover page-title

* Update search styles (#2021)

* well it's a fix, sort of (#2023)

* Add specificity to supposedly important rules (#2025)

---------

Co-authored-by: Yuhuai Liu <yuhuai@cos.io>
Co-authored-by: Brian J. Geiger <bgeiger@cos.io>
Co-authored-by: Brian J. Geiger <bgeiger@pobox.com>
  • Loading branch information
4 people authored Oct 10, 2023
1 parent 4fdf304 commit 98c850d
Show file tree
Hide file tree
Showing 85 changed files with 843 additions and 2,038 deletions.
12 changes: 11 additions & 1 deletion app/adapters/share-adapter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
import JSONAPIAdapter from '@ember-data/adapter/json-api';
import config from 'ember-get-config';
import config from 'ember-osf-web/config/environment';

const osfUrl = config.OSF.url;

export default class ShareAdapter extends JSONAPIAdapter {
host = config.OSF.shareBaseUrl.replace(/\/$/, ''); // Remove trailing slash to avoid // in URLs
namespace = 'api/v3';

queryRecord(store: any, type: any, query: any) {
// check if we aren't serving locally, otherwise add accessService query param to card/value searches
if (['index-card-search', 'index-value-search'].includes(type.modelName) && !osfUrl.includes('localhost')) {
query.cardSearchFilter['accessService'] = osfUrl;
}
return super.queryRecord(store, type, query);
}
}
31 changes: 22 additions & 9 deletions app/institutions/discover/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,42 @@ 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 pathJoin from 'ember-osf-web/utils/path-join';
import config from 'ember-get-config';
import { OnSearchParams, ResourceTypeFilterValue } from 'osf-components/components/search-page/component';
import { Filter, OnSearchParams, ResourceTypeFilterValue } from 'osf-components/components/search-page/component';

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

@tracked cardSearchText?: string = '';
@tracked q?: string = '';
@tracked sort?: string = '-relevance';
@tracked resourceType?: ResourceTypeFilterValue | null = null;
@tracked resourceType: ResourceTypeFilterValue = ResourceTypeFilterValue.Projects;
@tracked activeFilters?: Filter[] = [];

queryParams = ['cardSearchText', 'sort', 'resourceType'];
queryParams = ['q', 'sort', 'resourceType', 'activeFilters'];

get defaultQueryOptions() {
const identifiers = this.model.iris.join(',');
let key = 'affiliation';
const { resourceType } = this;
switch (resourceType) {
case ResourceTypeFilterValue.Preprints:
key = 'creator.affiliation';
break;
case ResourceTypeFilterValue.Files:
key = 'isContainedby.affiliation';
break;
default:
break;
}
return {
publisher: pathJoin(config.OSF.url, 'institutions', this.model.id),
[key]: identifiers,
};
}

@action
onSearch(queryOptions: OnSearchParams) {
this.cardSearchText = queryOptions.cardSearchText;
this.q = queryOptions.cardSearchText;
this.sort = queryOptions.sort;
this.resourceType = queryOptions.resourceType;
this.resourceType = queryOptions.resourceType as ResourceTypeFilterValue;
this.activeFilters = queryOptions.activeFilters;
}
}
3 changes: 3 additions & 0 deletions app/institutions/discover/template.hbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{{page-title this.model.name}}

<SearchPage
@route='search'
@query={{this.q}}
Expand All @@ -8,4 +10,5 @@
@institution={{this.model}}
@sort={{this.sort}}
@showResourceTypeFilter={{true}}
@activeFilters={{this.activeFilters}}
/>
4 changes: 4 additions & 0 deletions app/models/institution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ export default class InstitutionModel extends OsfModel {
@attr('object') assets?: Assets;
@attr('boolean', { defaultValue: false }) currentUserIsAdmin!: boolean;
@attr('date') lastUpdated!: Date;
@attr('fixstring') rorIri!: string;
// identifier_domain in the admin app
@attr('fixstring') iri!: string;
@attr('fixstringarray') iris!: string[];

// TODO Might want to replace calls to `users` with `institutionUsers.user`?
@hasMany('user', { inverse: 'institutions' })
Expand Down
2 changes: 1 addition & 1 deletion app/models/preprint-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { attr, hasMany, AsyncHasMany, belongsTo, AsyncBelongsTo } from '@ember-d
import { computed } from '@ember/object';
import { alias } from '@ember/object/computed';
import { inject as service } from '@ember/service';
import config from 'ember-get-config';
import config from 'ember-osf-web/config/environment';
import Intl from 'ember-intl/services/intl';
import BrandModel from 'ember-osf-web/models/brand';

Expand Down
22 changes: 7 additions & 15 deletions app/models/related-property-path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,21 @@ interface PropertyPath {
shortFormLabel: LanguageText[];
}

export enum SuggestedFilterOperators {
AnyOf = 'any-of',
IsPresent = 'is-present',
AtDate = 'at-date'
}

export default class RelatedPropertyPathModel extends OsfModel {
@attr('string') propertyPathKey!: string;
@attr('number') cardSearchResultCount!: number;
@attr('array') osfmapPropertyPath!: string[];
@attr('array') propertyPath!: PropertyPath[];
@attr('string') suggestedFilterOperator!: SuggestedFilterOperators;

getLocalizedString = new GetLocalizedPropertyHelper(getOwner(this));

get shortFormLabel() {
const labelArray = [];
// propertyPath is likely an array of length 1,
// unless it is nested property(e.g. file's isContainedBy.funder, file's isContainedBy.license)
for (const property of this.propertyPath) {
const label = this.getLocalizedString.compute(
[property as unknown as Record<string, LanguageText[]>, 'shortFormLabel'],
);
if (label) {
labelArray.push(label);
}
}
return labelArray.join(',');
}

get displayLabel() {
// propertyPath is likely an array of length 1,
// unless it is nested property(e.g. file's isContainedBy.funder, file's isContainedBy.license)
Expand Down
1 change: 1 addition & 0 deletions app/models/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export default class UserModel extends OsfModel.extend(Validations) {
@attr('object') social!: {};
@attr('array') employment!: Employment[];
@attr('array') education!: Education[];
@attr('boolean', { allowNull: true }) allowIndexing?: boolean;

@belongsTo('region', { async: false })
defaultRegion!: RegionModel;
Expand Down
14 changes: 8 additions & 6 deletions app/preprints/discover/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,21 @@ import Controller from '@ember/controller';
import { action } from '@ember/object';
import { inject as service } from '@ember/service';
import { tracked } from '@glimmer/tracking';
import config from 'ember-get-config';
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 { OnSearchParams } from 'osf-components/components/search-page/component';
import { Filter, OnSearchParams } from 'osf-components/components/search-page/component';

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

@tracked cardSearchText?: string = '';
@tracked sort?: string = '-relevance';
@tracked q?: string = '';
@tracked sort?: string = '-relevance';
@tracked activeFilters?: Filter[] = [];

queryParams = ['cardSearchText', 'sort'];
queryParams = ['q', 'sort', 'activeFilters'];

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

@action
onSearch(queryOptions: OnSearchParams) {
this.cardSearchText = queryOptions.cardSearchText;
this.q = queryOptions.cardSearchText;
this.sort = queryOptions.sort;
this.activeFilters = queryOptions.activeFilters;
}
}
5 changes: 5 additions & 0 deletions app/preprints/discover/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Store from '@ember-data/store';
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 Theme from 'ember-osf-web/services/theme';

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

async model(args: any) {
try {
if (!args.provider_id || args.provider_id === config.defaultProvider) {
this.router.transitionTo('search', { queryParams: { resourceType: 'Preprint' } });
return null;
}
const provider = await this.store.findRecord('preprint-provider', args.provider_id);
this.theme.providerType = 'preprint';
this.theme.id = args.provider_id;
Expand Down
3 changes: 2 additions & 1 deletion app/preprints/discover/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
<div data-analytics-scope='{{concat this.model.providerTitle ' Discover'}}'>
<SearchPage
@route='search'
@query={{this.q}}
@cardSearchText={{this.q}}
@defaultQueryOptions={{this.defaultQueryOptions}}
@resourceType={{'Preprint'}}
@showResourceTypeFilter={{false}}
@provider={{this.model}}
@queryParams={{this.queryParams}}
@onSearch={{action this.onSearch}}
@sort={{this.sort}}
@activeFilters={{this.activeFilters}}
/>
</div>
33 changes: 11 additions & 22 deletions app/register/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,18 @@ import Controller from '@ember/controller';
import { computed } from '@ember/object';
import { inject as service } from '@ember/service';
import { waitFor } from '@ember/test-waiters';
import { tracked } from '@glimmer/tracking';
import { task } from 'ember-concurrency';
import { taskFor } from 'ember-concurrency-ts';
import config from 'ember-osf-web/config/environment';
import QueryParams from 'ember-parachute';

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

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

interface RegisterQueryParams {
next: string;
campaign: string;
}

export const registerQueryParams = new QueryParams<RegisterQueryParams>({
next: {
defaultValue: '',
},
campaign: {
defaultValue: '',
},
});

export default class Register extends Controller.extend(registerQueryParams.Mixin) {
export default class Register extends Controller.extend() {
@service analytics!: Analytics;
@service store!: Store;

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

@computed('next')
@tracked next?: string = '';
@tracked campaign?: string = '';

queryParams = ['next', 'campaign'];

get orcidUrl() {
return `${casUrl}/login?${param({
redirectOrcid: 'true',
service: `${baseUrl}/login/?next=${encodeURIComponent(this.next || baseUrl)}`,
})}`;
}

@computed('next')
get institutionUrl() {
return `${casUrl}/login?${param({
campaign: 'institution',
Expand Down Expand Up @@ -77,10 +66,10 @@ export default class Register extends Controller.extend(registerQueryParams.Mixi
}
}

setup({ queryParams }: { queryParams: RegisterQueryParams }) {
if (queryParams.campaign) {
this.set('signUpCampaign', queryParams.campaign);
const matches = queryParams.campaign.match(/^(.*)-(.*)$/);
setup() {
if (this.campaign) {
this.set('signUpCampaign', this.campaign);
const matches = this.campaign.match(/^(.*)-(.*)$/);
if (matches) {
const [, provider, type] = matches;
if (provider === 'osf') {
Expand Down
6 changes: 6 additions & 0 deletions app/register/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Store from '@ember-data/store';

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

import RegisterController from './controller';

export default class Register extends Route {
@service session!: Session;
Expand All @@ -21,4 +22,9 @@ export default class Register extends Route {
model() {
return this.store.createRecord('user-registration');
}

setupController(controller: RegisterController, model: any, transition: Transition) {
super.setupController(controller, model, transition);
controller.setup();
}
}
9 changes: 5 additions & 4 deletions app/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ Router.map(function() {
this.route('goodbye');
this.route('search');
this.route('institutions', function() {
// this.route('discover', { path: '/:institution_id' });
this.route('discover', { path: '/:institution_id' });
this.route('dashboard', { path: '/:institution_id/dashboard' });
});
// this.route('preprints', function() {
// this.route('discover', { path: '/:provider_id/discover' });
// });
this.route('preprints', function() {
this.route('discover');
this.route('discover', { path: '/:provider_id/discover' });
});
this.route('register');
this.route('settings', function() {
this.route('profile', function() {
Expand Down
6 changes: 4 additions & 2 deletions app/search/controller.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import Controller from '@ember/controller';
import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
import { OnSearchParams, ResourceTypeFilterValue } from 'osf-components/components/search-page/component';
import { Filter, OnSearchParams, ResourceTypeFilterValue } from 'osf-components/components/search-page/component';

export default class SearchController extends Controller {
@tracked q?: string = '';
@tracked sort?: string = '-relevance';
@tracked resourceType?: ResourceTypeFilterValue | null = null;
@tracked activeFilters?: Filter[] = [];

queryParams = ['q', 'sort', 'resourceType'];
queryParams = ['q', 'sort', 'resourceType', 'activeFilters'];

@action
onSearch(queryOptions: OnSearchParams) {
this.q = queryOptions.cardSearchText;
this.sort = queryOptions.sort;
this.resourceType = queryOptions.resourceType;
this.activeFilters = queryOptions.activeFilters;
}
}
1 change: 1 addition & 0 deletions app/search/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
@sort={{this.sort}}
@resourceType={{this.resourceType}}
@page={{this.page}}
@activeFilters={{this.activeFilters}}
/>
Loading

0 comments on commit 98c850d

Please sign in to comment.