Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

John conroy/replace searchkit #3441

Open
wants to merge 77 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 71 commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
e46c1be
Add changelog
john-conroy May 26, 2024
08a8643
Install elastic-builder
john-conroy May 30, 2024
4c6b90a
Type for es endpoint in context
john-conroy May 30, 2024
8ef242b
Add basic search implementation
john-conroy May 30, 2024
53cd566
Display results
john-conroy May 30, 2024
c7eefaf
Fix util path
john-conroy Jun 4, 2024
e2364ed
Add sorting
john-conroy Jun 4, 2024
cf5b7e8
Get esfield from mapping
john-conroy Jun 6, 2024
898b776
Refactor sort cell
john-conroy Jun 6, 2024
6cf6194
Add term facet
john-conroy Jun 7, 2024
05457df
Add hierarchical facet
john-conroy Jun 10, 2024
a20a996
Fix hierarchical facet
john-conroy Jun 10, 2024
9e24f03
Add free text search
john-conroy Jun 10, 2024
cfd23bb
Add search scrolling
john-conroy Jun 10, 2024
793d3e0
Fix alignment of results count
john-conroy Jun 10, 2024
a792014
Add indeterminate state to term facet
john-conroy Jun 10, 2024
63d38c1
Add highlighting
john-conroy Jun 10, 2024
9008444
Add no results and fix spacing
john-conroy Jun 10, 2024
017282d
Add builder to simplify config
john-conroy Jun 10, 2024
d66c613
Pull labels out of state
john-conroy Jun 11, 2024
bda4c63
Simplify config
john-conroy Jun 11, 2024
893df18
Switch out placeholder variable name
john-conroy Jun 11, 2024
3d21a09
Add range facet
john-conroy Jun 11, 2024
736c7ee
Update range facet when commited
john-conroy Jun 11, 2024
e6bc6f6
Set filters at once
john-conroy Jun 23, 2024
57ef9f2
Filter aggs
john-conroy Jun 24, 2024
cf03521
Refactor aggs
john-conroy Jun 24, 2024
573db7e
Allow for facet groups in config
john-conroy Jun 25, 2024
2716314
Add filter chips
john-conroy Jun 26, 2024
69742ac
Fix spacing
john-conroy Jun 26, 2024
c584da0
Temp update routes
john-conroy Jun 26, 2024
e45bca7
Merge branch 'main' into john-conroy/replace-searchkit
john-conroy Jun 26, 2024
ef11e8a
Add tile view
john-conroy Jun 27, 2024
243eca1
Add tiles sort
john-conroy Jun 27, 2024
44db61c
Merge branch 'main' into john-conroy/replace-searchkit
john-conroy Jun 27, 2024
00d1594
Add selection and dropdown menus
john-conroy Jun 27, 2024
573697a
Add header
john-conroy Jun 27, 2024
763f9a0
Delete cells search
john-conroy Jun 27, 2024
5a24e17
Add configs for each entity
john-conroy Jun 27, 2024
97d44ac
Fix missing organs
john-conroy Jun 27, 2024
2689f7e
Add support for default queries
john-conroy Jun 27, 2024
eedfada
Sync url state
john-conroy Jun 30, 2024
37df38b
Add redirect for old routes
john-conroy Jul 1, 2024
00f8e7f
Add tracking
john-conroy Jul 1, 2024
698f340
Increase agg size
john-conroy Jul 1, 2024
b31397a
Track view more results
john-conroy Jul 1, 2024
d8576d0
Handle last modied table cells
john-conroy Jul 1, 2024
561303a
Refactor filter state
john-conroy Jul 1, 2024
88fc038
Fix hierarchical toggle
john-conroy Jul 1, 2024
04febf0
Don't show view more button if hits reached
john-conroy Jul 1, 2024
95f986b
Add expand for term facets
john-conroy Jul 1, 2024
c71a4cf
Merge branch 'main' into john-conroy/replace-searchkit
john-conroy Oct 8, 2024
31965cb
Update facets
john-conroy Oct 8, 2024
ab8ce31
Update labels, handle bools
john-conroy Oct 8, 2024
9d97076
Style
john-conroy Oct 8, 2024
36671af
Refactor field configurations
john-conroy Oct 8, 2024
3cdf555
Add agg sorting options
john-conroy Oct 8, 2024
9bd5ada
Use history
john-conroy Oct 15, 2024
6bc0af0
Update variable name
john-conroy Oct 15, 2024
8886795
Add loading state
john-conroy Oct 15, 2024
323c889
Fix width
john-conroy Oct 15, 2024
e287f3a
Add json validation
john-conroy Oct 17, 2024
47a371d
Add function to build link
john-conroy Oct 17, 2024
c6a140f
Add search note
john-conroy Oct 17, 2024
4138e0b
Update links
john-conroy Oct 17, 2024
f40f0b9
Fix links
john-conroy Oct 17, 2024
492f783
Refactor
john-conroy Oct 17, 2024
652db67
Add index
john-conroy Oct 17, 2024
6a33a4a
Add comment
john-conroy Oct 17, 2024
a71f028
Uninstall qs
john-conroy Oct 17, 2024
97372ef
Move query build into fetch
john-conroy Oct 17, 2024
f105649
Merge branch 'main' into john-conroy/replace-searchkit
john-conroy Oct 18, 2024
c8e3784
Update store selectors
john-conroy Oct 21, 2024
3da9471
add memoization
NickAkhmetov Oct 21, 2024
1a1157a
suppress proptypes warning
NickAkhmetov Oct 21, 2024
ffea00a
suppress console warnings for invalid prop and tooltip on disabled b…
NickAkhmetov Oct 21, 2024
87fede2
decrease scope of facet state subscriptions
NickAkhmetov Oct 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG-replace-searchkit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Replace searchkit.
52 changes: 22 additions & 30 deletions context/app/routes_main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from flask import (render_template, current_app, abort,
session, request)
session, request, redirect, url_for)

from .utils import get_default_flask_data, make_blueprint, get_organs

Expand Down Expand Up @@ -42,28 +42,13 @@ def ccf_eui():
)


@blueprint.route('/search')
@blueprint.route('/cells-search')
def search():
entity_type = request.args.get('entity_type[0]')
title = f'{entity_type}s' if entity_type else 'Search'
flask_data = {
**get_default_flask_data(),
'title': title,
}
return render_template(
'base-pages/react-content.html',
title=title,
flask_data=flask_data,
)


@blueprint.route('/test-search/<type>')
def test_search(type):
@blueprint.route('/search/<type>')
def search(type):
if type not in ['donors', 'samples', 'datasets']:
abort(404)
title = f'{type.capitalize()} Test Search'
title = f'{type.capitalize()} Search'
flask_data = {
'type': type,
**get_default_flask_data(),
'title': title,
}
Expand All @@ -74,7 +59,14 @@ def test_search(type):
)


@blueprint.route('/dev-search')
@blueprint.route('/search')
def search_redirect():
entity_type = request.args.get('entity_type[0]')
return redirect(
url_for('routes_main.search', type=f'{entity_type}s'.lower()))


@ blueprint.route('/dev-search')
def dev_search():
title = 'Dev Search'
flask_data = {
Expand All @@ -88,7 +80,7 @@ def dev_search():
)


@blueprint.route('/diversity')
@ blueprint.route('/diversity')
def vis():
title = 'Donor Diversity'
flask_data = {
Expand All @@ -102,7 +94,7 @@ def vis():
)


@blueprint.route('/collections')
@ blueprint.route('/collections')
def collections():
flask_data = {**get_default_flask_data()}
return render_template(
Expand All @@ -112,7 +104,7 @@ def collections():
)


@blueprint.route('/publications')
@ blueprint.route('/publications')
def publications():
flask_data = {**get_default_flask_data()}
return render_template(
Expand All @@ -122,7 +114,7 @@ def publications():
)


@blueprint.route('/my-lists')
@ blueprint.route('/my-lists')
def my_lists():
flask_data = {**get_default_flask_data()}
return render_template(
Expand All @@ -132,7 +124,7 @@ def my_lists():
)


@blueprint.route('/my-lists/<saved_list_uuid>')
@ blueprint.route('/my-lists/<saved_list_uuid>')
def list_page(saved_list_uuid):
flask_data = {
**get_default_flask_data(),
Expand All @@ -145,7 +137,7 @@ def list_page(saved_list_uuid):
)


@blueprint.route('/iframe/<path:path>')
@ blueprint.route('/iframe/<path:path>')
def iframe_page(path):
flask_data = {
**get_default_flask_data(),
Expand All @@ -158,7 +150,7 @@ def iframe_page(path):
)


@blueprint.route('/tutorials')
@ blueprint.route('/tutorials')
def tutorials():
flask_data = {
**get_default_flask_data(),
Expand All @@ -170,7 +162,7 @@ def tutorials():
)


@blueprint.route('/tutorials/<tutorial_name>')
@ blueprint.route('/tutorials/<tutorial_name>')
def tutorial_detail(tutorial_name):
flask_data = {
**get_default_flask_data(),
Expand All @@ -183,7 +175,7 @@ def tutorial_detail(tutorial_name):
)


@blueprint.route('/profile')
@ blueprint.route('/profile')
def profile():
flask_data = {**get_default_flask_data()}
return render_template(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import ExternalImageIcon from 'js/shared-styles/icons/ExternalImageIcon';
import { entityIconMap } from 'js/shared-styles/icons/entityIconMap';
import { contactUsUrl } from 'js/shared-styles/Links/ContactUsLink';
import { DrawerTitle } from 'js/shared-styles/Drawer/styles';
import { buildSearchLink } from 'js/components/search/store';
import AuthButton from '../AuthButton';

export const resourceLinks: DrawerSection[] = [
Expand Down Expand Up @@ -99,7 +100,9 @@ export const dataLinks: DrawerSection[] = [
{
label: 'Datasets',
description: 'Find datasets by dataset type, organs, pipelines and other metadata.',
href: '/search?entity_type[0]=Dataset',
href: buildSearchLink({
entity_type: 'Dataset',
}),
icon: <entityIconMap.Dataset color="primary" />,
},
{
Expand Down Expand Up @@ -158,13 +161,17 @@ export const dataLinks: DrawerSection[] = [
{
label: 'Samples',
description: 'Find samples by organ and other metadata, and discover derived datasets.',
href: '/search?entity_type[0]=Sample',
href: buildSearchLink({
entity_type: 'Sample',
}),
icon: <entityIconMap.Sample color="primary" />,
},
{
label: 'Donors',
description: 'Find donors by age, race and other metadata, and discover derived samples and datasets.',
href: '/search?entity_type[0]=Donor',
href: buildSearchLink({
entity_type: 'Donor',
}),
icon: <entityIconMap.Donor color="primary" />,
},
],
Expand Down
14 changes: 3 additions & 11 deletions context/app/static/js/components/Routes/Routes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ const Dataset = lazy(() => import('js/pages/Dataset'));
const Sample = lazy(() => import('js/pages/Sample'));
const Collection = lazy(() => import('js/pages/Collection'));
const Home = lazy(() => import('js/pages/Home/Home'));
const Search = lazy(() => import('js/pages/search/Search'));
const CellsSearch = lazy(() => import('js/pages/search/CellsSearch'));
const DevSearch = lazy(() => import('js/pages/search/DevSearch'));
const Search = lazy(() => import('js/pages/search/S'));
const Diversity = lazy(() => import('js/pages/Diversity'));
const Preview = lazy(() => import('js/pages/Preview'));
const Publications = lazy(() => import('js/pages/Publications'));
Expand Down Expand Up @@ -55,6 +54,7 @@ function Routes({ flaskData }) {
geneSymbol,
cell_type: cellId,
tutorialName,
type,
} = flaskData;
const urlPath = window.location.pathname;
const url = window.location.href;
Expand Down Expand Up @@ -118,15 +118,7 @@ function Routes({ flaskData }) {
if (urlPath.startsWith('/search')) {
return (
<Route>
<Search title={title} />
</Route>
);
}

if (urlPath.startsWith('/cells-search')) {
return (
<Route>
<CellsSearch title={title} />
<Search type={type} />
</Route>
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
import React from 'react';
import { render, screen } from 'test-utils/functions';
import { buildSearchLink } from 'js/components/search/store';
import SupportAlert from './SupportAlert';

test('The alert links to parent dataset on search page', () => {
const fakeUUID = 'abc123';
const hrefToTest = `/search?descendant_ids[0]=${fakeUUID}&entity_type[0]=Dataset`;
const hrefToTest = buildSearchLink({
entity_type: 'Dataset',
filters: {
descendant_ids: {
values: [fakeUUID],
type: 'TERM',
},
},
});
render(<SupportAlert uuid={fakeUUID} isSupport />);

expect(screen.getByText('the parent dataset')).toHaveAttribute('href', hrefToTest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { InternalLink } from 'js/shared-styles/Links';
import Typography from '@mui/material/Typography';

import { DetailPageAlert } from 'js/components/detailPage/style';
import { buildSearchLink } from 'js/components/search/store';

interface SupportAlertProps {
uuid: string;
Expand All @@ -19,7 +20,17 @@ function SupportAlert({ uuid, isSupport }: SupportAlertProps) {
<DetailPageAlert severity="warning">
<Typography variant="body2">
“Support” entities provide derived, low-level data for visualizations. Navigate to{' '}
<InternalLink href={`/search?descendant_ids[0]=${uuid}&entity_type[0]=Dataset`}>
<InternalLink
href={buildSearchLink({
entity_type: 'Dataset',
filters: {
descendant_ids: {
values: [uuid],
type: 'TERM',
},
},
})}
>
the parent dataset
</InternalLink>{' '}
for a view of this information in context.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import DerivedEntitiesSectionWrapper from 'js/components/detailPage/related-enti
import RelatedEntitiesTabs from 'js/components/detailPage/related-entities/RelatedEntitiesTabs';
import RelatedEntitiesSectionActions from 'js/components/detailPage/related-entities/RelatedEntitiesSectionActions';
import { AllEntityTypes } from 'js/shared-styles/icons/entityIconMap';
import { buildSearchLink } from 'js/components/search/store';
import { useDerivedDatasetsSection } from './hooks';

interface DerivedDatasetsSectionProps {
Expand All @@ -21,7 +22,17 @@ function DerivedDatasetsSection({ uuid, entityType }: DerivedDatasetsSectionProp
id="derived-data"
title="Derived Data"
action={
<RelatedEntitiesSectionActions searchPageHref={`/search?ancestor_ids[0]=${uuid}&entity_type[0]=Dataset`} />
<RelatedEntitiesSectionActions
searchPageHref={buildSearchLink({
entity_type: 'Dataset',
filters: {
ancestor_ids: {
values: [uuid],
type: 'TERM',
},
},
})}
/>
}
>
<RelatedEntitiesTabs
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import React, { useState } from 'react';

import { useFlaskDataContext } from 'js/components/Contexts';
import RelatedEntitiesSectionWrapper from 'js/components/detailPage/related-entities/RelatedEntitiesSectionWrapper';
import RelatedEntitiesTabs from 'js/components/detailPage/related-entities/RelatedEntitiesTabs';
import RelatedEntitiesSectionActions from 'js/components/detailPage/related-entities/RelatedEntitiesSectionActions';
import { AllEntityTypes } from 'js/shared-styles/icons/entityIconMap';
import { buildSearchLink } from 'js/components/search/store';
import { useDerivedEntitiesSection } from './hooks';

const tooltipTexts = {
Expand All @@ -27,7 +29,15 @@ function DerivedEntitiesSection() {
title="Derived Data"
action={
<RelatedEntitiesSectionActions
searchPageHref={`/search?ancestor_ids[0]=${uuid}&entity_type[0]=${entities[openIndex].entityType}`}
searchPageHref={buildSearchLink({
entity_type: entities[openIndex].entityType,
filters: {
ancestor_ids: {
values: [uuid],
type: 'TERM',
},
},
})}
/>
}
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,37 @@
import React from 'react';

import { useTrackEntityPageEvent } from 'js/components/detailPage/useTrackEntityPageEvent';
import { buildSearchLink } from 'js/components/search/store';
import { ESEntityType } from 'js/components/types';
import { LinkButton } from './style';

interface ProvTableDerivedLinkProps {
uuid: string;
type: string;
type: ESEntityType;
}

function ProvTableDerivedLink({ uuid, type }: ProvTableDerivedLinkProps) {
const trackEntityPageEvent = useTrackEntityPageEvent();
return (
<LinkButton
href={`/search?ancestor_ids[0]=${uuid}&entity_type[0]=${type}`}
onClick={() => trackEntityPageEvent({ action: `Provenance / Table / View Derived ${type}s`, label: uuid })}
>
View Derived {type}s
</LinkButton>
);

if (type === 'Sample' || type === 'Dataset') {
return (
<LinkButton
href={buildSearchLink({
entity_type: type,
filters: {
ancestor_ids: {
values: [uuid],
type: 'TERM',
},
},
})}
onClick={() => trackEntityPageEvent({ action: `Provenance / Table / View Derived ${type}s`, label: uuid })}
>
View Derived {type}s
</LinkButton>
);
}
return null;
}

export default ProvTableDerivedLink;
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ import React from 'react';

import EntityCount from 'js/components/home/EntityCount';
import { DatasetIcon, SampleIcon, DonorIcon, CollectionIcon, OrganIcon } from 'js/shared-styles/icons';
import { buildSearchLink } from 'js/components/search/store';
import { useEntityCounts } from './hooks';
import { Background, FlexContainer, StyledSvgIcon } from './style';

const entities = [
const entities: {
icon: typeof DonorIcon;
entity_type: 'Donor' | 'Sample' | 'Dataset';
}[] = [
{
icon: DonorIcon,
entity_type: 'Donor',
Expand Down Expand Up @@ -37,7 +41,9 @@ function EntityCounts({ organsCount }: EntityCountsProps) {
}
count={entityCounts?.[entity_type]}
label={`${entity_type}s`}
href={`/search?entity_type[0]=${entity_type}`}
href={buildSearchLink({
entity_type,
})}
/>
))}
<EntityCount
Expand Down
Loading
Loading