Skip to content

Commit

Permalink
Revert registry, preprint and institution discover pages. (#1935)
Browse files Browse the repository at this point in the history
* Revert "[ENG-4573] Registry discover (#1900)"

This reverts commit 2ab39e0.

* comment out institution discover and preprint routes

* skip tests
  • Loading branch information
adlius authored Aug 16, 2023
1 parent 78938b6 commit 61e9203
Show file tree
Hide file tree
Showing 49 changed files with 2,251 additions and 104 deletions.
8 changes: 4 additions & 4 deletions app/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ 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', { path: '/:provider_id/discover' });
// });
this.route('register');
this.route('settings', function() {
this.route('profile', function() {
Expand Down
40 changes: 0 additions & 40 deletions lib/osf-components/addon/helpers/get-localized-property.ts

This file was deleted.

1 change: 0 additions & 1 deletion lib/osf-components/app/helpers/get-localized-property.js

This file was deleted.

14 changes: 12 additions & 2 deletions lib/registries/addon/application/controller.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
import Controller from '@ember/controller';
import RouterService from '@ember/routing/router-service';
import { action } from '@ember/object';
import { inject as service } from '@ember/service';
import Features from 'ember-feature-flags/services/features';

import { OSFService } from 'osf-components/components/osf-navbar/component';

export default class Application extends Controller {
@service features!: Features;
@service router!: RouterService;

activeService = OSFService.REGISTRIES;

@action
search(query: string) {
this.transitionToRoute('discover', {
queryParams: { query },
});
}
}
42 changes: 12 additions & 30 deletions lib/registries/addon/branded/discover/controller.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,18 @@
import Store from '@ember-data/store';
// import EmberArray, { A } from '@ember/array';
import Controller from '@ember/controller';
import { action } from '@ember/object';
import { inject as service } from '@ember/service';
import Intl from 'ember-intl/services/intl';
import Media from 'ember-responsive';
import { tracked } from '@glimmer/tracking';
import { OnSearchParams } from 'osf-components/components/search-page/component';
import pathJoin from 'ember-osf-web/utils/path-join';
import config from 'ember-get-config';
import DiscoverController from 'registries/discover/controller';

export default class BrandedDiscover extends Controller.extend() {
@service media!: Media;
@service intl!: Intl;
@service store!: Store;
import { ShareTermsFilter } from 'registries/services/share-search';

@tracked cardSearchText? = '';
@tracked sort? = '-relevance';
@tracked page? = '';

queryParams = ['cardSearchText', 'page', 'sort'];

get defaultQueryOptions() {
return {
publisher: pathJoin(config.OSF.url, 'registrations', this.model.id),
};
export default class Discover extends DiscoverController {
// this route uses the registries.discover page template where the custom branding is handled
get providerModel() {
return this.model;
}

@action
onSearch(onSearchParams: OnSearchParams) {
this.cardSearchText = onSearchParams.cardSearchText;
this.page = onSearchParams.page;
this.sort = onSearchParams.sort;
get additionalFilters() {
const { shareSource, name } = this.model;

return [
new ShareTermsFilter('sources', shareSource, name),
];
}
}
13 changes: 4 additions & 9 deletions lib/registries/addon/branded/discover/route.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import Route from '@ember/routing/route';
import RouterService from '@ember/routing/router-service';
import { inject as service } from '@ember/service';

import RegistrationProviderModel from 'ember-osf-web/models/registration-provider';
import { notFoundURL } from 'ember-osf-web/utils/clean-url';

export default class BrandedRegistriesDiscoverRoute extends Route {
@service router!: RouterService;
// this route uses the registries.discover page template where the custom branding is handled
templateName = 'discover';

model() {
return this.modelFor('branded');
Expand All @@ -14,11 +14,7 @@ export default class BrandedRegistriesDiscoverRoute extends Route {
afterModel(provider: RegistrationProviderModel) {
if (!provider.brandedDiscoveryPage) {
if (provider.id === 'osf') {
this.router.transitionTo('search', {
queryParams: {
resourceType: 'osf:Registration',
},
});
this.transitionTo('discover');
} else {
this.transitionTo('page-not-found', notFoundURL(window.location.pathname));
}
Expand All @@ -29,7 +25,6 @@ export default class BrandedRegistriesDiscoverRoute extends Route {
return {
osfMetrics: {
isSearch: true,
providerId: this.controller.model.id,
},
};
}
Expand Down
11 changes: 11 additions & 0 deletions lib/registries/addon/branded/discover/styles.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.BrandedRegistriesSearchResult {
composes: RegistriesSearchResult from '../../discover/styles';

svg {
color: var(--primary-color);
}
}

.Pagination {
composes: Pagination from '../../discover/styles';
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@


.results-container {
composes: ResultsHeader from '../../discover/styles';

display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: flex-start;
width: 100%;

.header {
width: 50%;
}

.dropdown-container {
width: 50%;
display: flex;
flex-direction: row;
justify-content: flex-end;
align-items: flex-start;

}
}

/**
I have no idea why but these classes are needed just like they are spelled
even though they do not exist in the hbs file.
*/
.SortDropDown__List {
composes: SortDropDown__List from '../../discover/styles';
}

.SortDropDown__Option {
composes: SortDropDown__Option from '../../discover/styles';
}

.DropdownTrigger {
composes: Button from 'osf-components/components/button/styles';
composes: MediumButton from 'osf-components/components/button/styles';
composes: SecondaryButton from 'osf-components/components/button/styles';

color: $color-text-black;

// Recreate the browser focus state for buttons
&:focus {
outline: auto 2px Highlight;
outline: auto 5px -webkit-focus-ring-color;
}
}

.DropdownContent {
border: 1px solid $color-border-gray;
box-shadow: 0 1px 2px $primary-box-shadow;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<div local-class='results-container'>
<div local-class='header'>
<h2 data-test-results-count>
{{t 'registries.discover.registration_count' count=@totalResults}}
</h2>
</div>
<div local-class='dropdown-container'>
<ResponsiveDropdown as |dd|>
<dd.trigger
data-test-sort-dropdown
data-analytics-name='Sort Registries Button{{if @provider (concat ' ' @provider.name)}}'
local-class='DropdownTrigger'
>
{{t 'registries.discover.sort_by'}}: {{t @searchOptions.order.display}}
<span role='button' aria-label='{{t 'registries.discover.sort_by'}}'><FaIcon @icon='caret-down' /></span>
</dd.trigger>
<dd.content local-class='DropdownContent'>
{{#each @sortOptions as |option index|}}
<div>
<Button
data-test-sort-option-id='{{index}}'
local-class='SortDropDown__Option'
{{on 'click' (fn @setOrder option)}}
{{on 'click' dd.close}}
>
{{t option.display}}
</Button>
</div>
{{/each}}
</dd.content>
</ResponsiveDropdown>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { A } from '@ember/array';
import Component from '@ember/component';

import { layout, requiredAction } from 'ember-osf-web/decorators/component';
import { SearchOptions } from 'registries/services/search';
import template from './template';

@layout(template)
export default class Discover<T> extends Component {
results = A<T>([]);
searchOptions!: SearchOptions;
@requiredAction onSearchOptionsUpdated!: (options: SearchOptions) => void;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.Discover__Body {
background-color: #f5f5f5;
border-top: 1px solid $color-border-gray;
border-bottom: 1px solid #dedede;
padding-bottom: 50px;
padding-top: 50px;
}

.row {
margin-right: -15px;
margin-left: -15px;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<div local-class='Discover__Body'>
<div class='container'>
<div local-class='row'>
{{yield (hash
results=(component 'registries-discover-search/x-results' @results)
sidebar=(component 'registries-discover-search/x-sidebar'
searchOptions=@searchOptions
additionalFilters=@additionalFilters
provider=@provider
onSearchOptionsUpdated=(action @onSearchOptionsUpdated)
)
)}}
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Component from '@ember/component';
import { localClassNames } from 'ember-css-modules';

import { layout } from 'ember-osf-web/decorators/component';
import template from './template';

@layout(template)
@localClassNames('SearchResult')
export default class SearchResult<T> extends Component {
result!: T;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.SearchResult {
background: $color-bg-white;
margin-bottom: 30px;
word-wrap: break-word;
word-break: break-word;
overflow-wrap: break-word;
box-shadow: 0 1px 2px #ddd;
border-width: 0;
padding: 10px;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{yield @result}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import Component from '@ember/component';
import { action } from '@ember/object';
import { localClassNames } from 'ember-css-modules';

import { layout, requiredAction } from 'ember-osf-web/decorators/component';
import { SearchOptions } from 'registries/services/search';

import template from './template';

@layout(template)
@localClassNames('SearchResults')
export default class SearchResults<T> extends Component {
static positionalParams = ['results'];

searchOptions!: SearchOptions;
@requiredAction onSearchOptionsUpdated!: (options: SearchOptions) => void;

results!: T[];

@action
_onSearchOptionsUpdated(options: SearchOptions) {
this.onSearchOptionsUpdated(options);
}
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{{#each @results as |result|}}
{{#registries-discover-search/x-result result=result as |ctxResult|}}
{{yield ctxResult}}
{{/registries-discover-search/x-result}}
{{/each}}
Loading

0 comments on commit 61e9203

Please sign in to comment.