Skip to content

Commit

Permalink
PORTALS-2908: add Announcements section to the NF Browse Tools page, …
Browse files Browse the repository at this point in the history
…and clean up PopularSearches
  • Loading branch information
jay-hodgson committed Feb 2, 2024
1 parent 4c2f768 commit ff23ac4
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 49 deletions.
21 changes: 20 additions & 1 deletion apps/portals/src/portal-components/nf/BrowseToolsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { ReactComponent as PlasmidsReagents } from './assets/plasmids-reagents.s
import PopularSearches from './PopularSearches'
import { Form } from 'react-bootstrap'
import pluralize from 'pluralize'
import PortalComponents from '../../portal-components'

export const gotoExploreToolsWithFullTextSearch = (
fullTextSearchString: string,
Expand Down Expand Up @@ -218,6 +219,25 @@ const BrowseToolsPage = () => {
</SynapseComponents.WideButton>
</div>
</Layout>
<Layout outsideContainerClassName="home-container-description home-bg-dark home-spacer">
<Typography variant="sectionTitle" className="sectionTitle">
Announcements
</Typography>
<PortalComponents.Ecosystem
config={[
{
title: 'Free Cell Lines',
ownerId: 'syn26451327',
wikiId: '614272',
},
{
title: 'Acquire Tissue',
ownerId: 'syn26451327',
wikiId: '625915',
},
]}
/>
</Layout>
<Layout outsideContainerClassName="home-spacer highlightSubmitToolContainer">
<Typography variant="sectionTitle" className="sectionTitle">
Submit a Tool to NF Research Tools Central
Expand Down Expand Up @@ -249,5 +269,4 @@ const BrowseToolsPage = () => {
</div>
)
}

export default BrowseToolsPage
66 changes: 18 additions & 48 deletions apps/portals/src/portal-components/nf/PopularSearches.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import React, { useEffect, useState } from 'react'
import {
SynapseClient,
SynapseConstants,
SynapseContextUtils,
SynapseUtilityFunctions,
} from 'synapse-react-client'
import { QueryBundleRequest, RowSet } from '@sage-bionetworks/synapse-types'
import React from 'react'
import { SynapseConstants, SynapseUtilityFunctions } from 'synapse-react-client'
import { QueryBundleRequest } from '@sage-bionetworks/synapse-types'
import { gotoExploreToolsWithFullTextSearch } from './BrowseToolsPage'
import { Link } from '@mui/material'
import { SynapseQueries } from 'synapse-react-client'

export type PopularSearchesProps = {
sql: string
Expand All @@ -19,47 +15,21 @@ export type PopularSearchesProps = {
const PopularSearches: React.FunctionComponent<PopularSearchesProps> = ({
sql,
}) => {
const { accessToken } = SynapseContextUtils.useSynapseContext()
const [rowSet, setRowSet] = useState<RowSet>()
const [isLoading, setIsLoading] = useState<boolean>()
let mounted = true
useEffect(() => {
const fetchData = async function () {
setIsLoading(true)
const entityId =
SynapseUtilityFunctions.parseEntityIdFromSqlStatement(sql)
const partMask = SynapseConstants.BUNDLE_MASK_QUERY_RESULTS
const request: QueryBundleRequest = {
partMask,
concreteType: 'org.sagebionetworks.repo.model.table.QueryBundleRequest',
entityId,
query: {
sql,
limit: 4,
},
}
const partMask = SynapseConstants.BUNDLE_MASK_QUERY_RESULTS
const entityId = SynapseUtilityFunctions.parseEntityIdFromSqlStatement(sql)
const request: QueryBundleRequest = {
partMask,
concreteType: 'org.sagebionetworks.repo.model.table.QueryBundleRequest',
entityId,
query: {
sql,
limit: 4,
},
}
const { data: queryResultResponse, isLoading } =
SynapseQueries.useGetQueryResultBundleWithAsyncStatus(request)

const queryResultBundle = await SynapseClient.getQueryTableResults(
request,
accessToken,
)
setIsLoading(false)
const { queryResult } = queryResultBundle
const queryResults = queryResult?.queryResults
if (queryResults) {
if (mounted) {
setRowSet(queryResults)
}
} else {
console.log('PopularSearches: Error getting data')
}
}
fetchData()

return () => {
mounted = false
}
}, [sql, accessToken])
const rowSet = queryResultResponse?.responseBody?.queryResult?.queryResults

return (
<div className="PopularSearches">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,7 @@
background-color: #dc6525;
}
}
.Ecosystem {
padding-bottom: 0px;
}
}

0 comments on commit ff23ac4

Please sign in to comment.