forked from Sage-Bionetworks/synapse-web-monorepo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PORTALS-3373: in progress, portal does not currently start
- Loading branch information
1 parent
4431e59
commit 65cb3ca
Showing
7 changed files
with
189 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
apps/portals/cancercomplexity/src/pages/CCKPSearchPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { | ||
PortalSearchTabConfig, | ||
PortalSearchTabs, | ||
} from '@sage-bionetworks/synapse-portal-framework/components/PortalSearch/PortalSearchTabs' | ||
import { PortalFullTextSearchField } from '@sage-bionetworks/synapse-portal-framework/components/PortalSearch/PortalFullTextSearchField' | ||
|
||
import RedirectWithQuery from '@sage-bionetworks/synapse-portal-framework/components/RedirectWithQuery' | ||
import { useGetPortalComponentSearchParams } from '@sage-bionetworks/synapse-portal-framework/utils/UseGetPortalComponentSearchParams' | ||
import { Outlet, RouteObject } from 'react-router-dom' | ||
import { grantQueryWrapperPlotNavProps } from 'src/config/synapseConfigs/grants' | ||
import { QueryWrapperPlotNav } from 'synapse-react-client' | ||
export const searchPageTabs: PortalSearchTabConfig[] = [ | ||
{ | ||
title: 'Grants', | ||
path: 'Grants', | ||
tooltip: 'Search Grants', | ||
}, | ||
] | ||
|
||
export const searchPageChildRoutes: RouteObject[] = [ | ||
{ | ||
index: true, | ||
element: <RedirectWithQuery to={searchPageTabs[0].path} />, | ||
}, | ||
{ | ||
path: searchPageTabs[0].path, | ||
element: <QueryWrapperPlotNav {...grantQueryWrapperPlotNavProps} />, | ||
}, | ||
] | ||
|
||
export function CCKPSearchPage(props: React.PropsWithChildren) { | ||
const { children } = props | ||
const searchParams = useGetPortalComponentSearchParams() | ||
// on search field value update, update the special search parameter FTS_SEARCH_TERM, which the QueryWrapperPlotNav will load as the search term | ||
return ( | ||
<> | ||
<PortalFullTextSearchField /> | ||
<PortalSearchTabs tabConfig={searchPageTabs} /> | ||
{children} | ||
<Outlet /> | ||
</> | ||
) | ||
} |
42 changes: 42 additions & 0 deletions
42
apps/synapse-portal-framework/src/components/PortalSearch/PortalFullTextSearchField.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { useState } from 'react' | ||
import SearchIcon from '@mui/icons-material/Search' | ||
import { InputAdornment, TextField } from '@mui/material' | ||
import { useSearchParams } from 'react-router-dom' | ||
import { FTS_SEARCH_PARAM_KEY } from 'synapse-react-client/utils/functions/SqlFunctions' | ||
|
||
export function PortalFullTextSearchField() { | ||
const [searchParams, setSearchParams] = useSearchParams() | ||
const [searchInput, setSearchInput] = useState( | ||
searchParams.get(FTS_SEARCH_PARAM_KEY), | ||
) | ||
|
||
return ( | ||
<TextField | ||
size={'small'} | ||
placeholder="Search by keyword" | ||
value={searchInput} | ||
onChange={event => { | ||
setSearchInput(event.target.value) | ||
}} | ||
onKeyDown={(event: any) => { | ||
if (event.key === 'Enter') { | ||
const trimmedInput = event.target.value.trim() | ||
setSearchParams({ FTS_SEARCH_PARAM_KEY: trimmedInput }) | ||
} | ||
}} | ||
InputProps={{ | ||
startAdornment: ( | ||
<InputAdornment position="start"> | ||
<SearchIcon /> | ||
</InputAdornment> | ||
), | ||
}} | ||
sx={{ | ||
maxWidth: { xs: '100%', md: '350px' }, | ||
flex: '1 1 350px', | ||
}} | ||
/> | ||
) | ||
} | ||
|
||
export default PortalFullTextSearchField |
55 changes: 55 additions & 0 deletions
55
apps/synapse-portal-framework/src/components/PortalSearch/PortalSearchTabs.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { Tooltip, Chip } from '@mui/material' | ||
import { NavLink, useLocation } from 'react-router-dom' | ||
|
||
export type PortalSearchTabConfig = { | ||
path: string | ||
title: string | ||
tooltip?: string | ||
count?: number | ||
} | ||
|
||
export type PortalSearchTabUIProps = { | ||
tabConfig: PortalSearchTabConfig[] | ||
} | ||
|
||
function PortalSearchTab(props: PortalSearchTabConfig) { | ||
const { path, title, tooltip, count } = props | ||
const location = useLocation() | ||
|
||
return ( | ||
<Tooltip key={path} title={tooltip ?? ''} placement="top"> | ||
<NavLink | ||
to={{ | ||
pathname: path, | ||
search: location.search, | ||
}} | ||
className={'tab-item ignoreLink'} | ||
> | ||
{title} | ||
{count !== undefined && ( | ||
<Chip | ||
size={'small'} | ||
label={count} | ||
sx={{ | ||
backgroundColor: 'tertiary.500', | ||
color: 'grey.900', | ||
height: '21px', | ||
}} | ||
></Chip> | ||
)} | ||
</NavLink> | ||
</Tooltip> | ||
) | ||
} | ||
|
||
export function PortalSearchTabs(props: PortalSearchTabUIProps) { | ||
const { tabConfig } = props | ||
|
||
return ( | ||
<div className="tab-groups"> | ||
{tabConfig.map(config => ( | ||
<PortalSearchTab key={config.path} {...config} /> | ||
))} | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters