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

Search from registry #2242

Merged
merged 5 commits into from
Jun 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 10 additions & 7 deletions catalog/app/containers/Bucket/Overview.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import Skeleton from 'components/Skeleton'
import StackedAreaChart from 'components/StackedAreaChart'
import Thumbnail from 'components/Thumbnail'
import * as authSelectors from 'containers/Auth/selectors'
import * as APIConnector from 'utils/APIConnector'
import * as AWS from 'utils/AWS'
import AsyncResult from 'utils/AsyncResult'
import * as Config from 'utils/Config'
Expand Down Expand Up @@ -763,8 +764,9 @@ const useHeadStyles = M.makeStyles((t) => ({
},
}))

function Head({ req, s3, overviewUrl, bucket, description }) {
function Head({ s3, overviewUrl, bucket, description }) {
const classes = useHeadStyles()
const req = APIConnector.use()
const isRODA = !!overviewUrl && overviewUrl.includes(`/${RODA_BUCKET}/`)
const colorPool = useConst(() => mkKeyedPool(COLOR_MAP))
const statsData = useData(requests.bucketStats, { req, s3, bucket, overviewUrl })
Expand Down Expand Up @@ -1138,7 +1140,8 @@ function Readmes({ s3, overviewUrl, bucket }) {
)
}

function Imgs({ req, s3, overviewUrl, inStack, bucket }) {
function Imgs({ s3, overviewUrl, inStack, bucket }) {
const req = APIConnector.use()
return (
<Data fetch={requests.bucketImgs} params={{ req, s3, overviewUrl, inStack, bucket }}>
{AsyncResult.case({
Expand All @@ -1163,7 +1166,8 @@ function Imgs({ req, s3, overviewUrl, inStack, bucket }) {

const SUMMARY_ENTRIES = 7

function Summary({ req, s3, bucket, inStack, overviewUrl }) {
function Summary({ s3, bucket, inStack, overviewUrl }) {
const req = APIConnector.use()
const data = useData(requests.bucketSummary, { req, s3, bucket, inStack, overviewUrl })
const [shown, setShown] = React.useState(SUMMARY_ENTRIES)
const showMore = React.useCallback(() => {
Expand Down Expand Up @@ -1200,7 +1204,6 @@ export default function Overview({
},
}) {
const s3 = AWS.S3.use()
const req = AWS.APIGateway.use()
const { noOverviewImages } = Config.use()
const [{ data }] = urql.useQuery({
query: BUCKET_CONFIG_QUERY,
Expand All @@ -1218,7 +1221,7 @@ export default function Overview({
</React.Suspense>
)}
{cfg ? (
<Head {...{ req, s3, bucket, overviewUrl, description }} />
<Head {...{ s3, bucket, overviewUrl, description }} />
) : (
<M.Box
pt={2}
Expand All @@ -1230,8 +1233,8 @@ export default function Overview({
</M.Box>
)}
<Readmes {...{ s3, bucket, overviewUrl }} />
{!noOverviewImages && <Imgs {...{ req, s3, bucket, inStack, overviewUrl }} />}
<Summary {...{ req, s3, bucket, inStack, overviewUrl }} />
{!noOverviewImages && <Imgs {...{ s3, bucket, inStack, overviewUrl }} />}
<Summary {...{ s3, bucket, inStack, overviewUrl }} />
</M.Box>
)
}
3 changes: 2 additions & 1 deletion catalog/app/containers/Bucket/PackageList.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { fade } from '@material-ui/core/styles'
import Skeleton from 'components/Skeleton'
import Sparkline from 'components/Sparkline'
import * as AWS from 'utils/AWS'
import * as APIConnector from 'utils/APIConnector'
// import AsyncResult from 'utils/AsyncResult'
// import * as BucketConfig from 'utils/BucketConfig'
import * as Config from 'utils/Config'
Expand Down Expand Up @@ -319,7 +320,7 @@ export default function PackageList({
}) {
const history = useHistory()
const s3 = AWS.S3.use()
const req = AWS.APIGateway.use()
const req = APIConnector.use()
// const sign = AWS.Signer.useS3Signer()
// const { analyticsBucket, apiGatewayEndpoint: endpoint } = Config.useConfig()
const { analyticsBucket } = Config.useConfig()
Expand Down
5 changes: 3 additions & 2 deletions catalog/app/containers/Bucket/PackageRevisions.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Skeleton from 'components/Skeleton'
import Sparkline from 'components/Sparkline'
import AsyncResult from 'utils/AsyncResult'
import * as AWS from 'utils/AWS'
import * as APIConnector from 'utils/APIConnector'
// import * as BucketConfig from 'utils/BucketConfig'
import * as Config from 'utils/Config'
import * as Data from 'utils/Data'
Expand Down Expand Up @@ -370,12 +371,12 @@ function Revision({ bucket, name, hash, stats, message, modified, metadata, coun
}

function useRevisionCountData({ bucket, name, key }) {
const req = AWS.APIGateway.use()
const req = APIConnector.use()
return Data.use(requests.countPackageRevisions, { req, bucket, name, key })
}

function useRevisionsData({ bucket, name, page, perPage, key }) {
const req = AWS.APIGateway.use()
const req = APIConnector.use()
return Data.use(requests.getPackageRevisions, { req, bucket, name, page, perPage, key })
}

Expand Down
8 changes: 5 additions & 3 deletions catalog/app/containers/Bucket/Queries/requests/search.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as errors from 'containers/Bucket/errors'
import * as AWS from 'utils/AWS'
import * as APIConnector from 'utils/APIConnector'
import { useData } from 'utils/Data'
import mkSearch from 'utils/mkSearch'

import { ElasticSearchQuery } from './query'
import { AsyncData } from './requests'
Expand Down Expand Up @@ -32,7 +33,8 @@ async function search({ req, query }: SearchArgs): Promise<ElasticSearchResults>
}
if (query.size) requestOptions.size = query.size
if (query.from) requestOptions.from = query.size
return req('/search', requestOptions)
const qs = mkSearch(requestOptions)
return req(`/search${qs}`)
} catch (e) {
if (e instanceof errors.FileNotFound || e instanceof errors.VersionNotFound)
return null
Expand All @@ -48,6 +50,6 @@ async function search({ req, query }: SearchArgs): Promise<ElasticSearchResults>
export function useSearch(
query: ElasticSearchQuery | string,
): AsyncData<ElasticSearchResults> {
const req = AWS.APIGateway.use()
const req = APIConnector.use()
return useData(search, { req, query }, { noAutoFetch: !query })
}
4 changes: 2 additions & 2 deletions catalog/app/containers/Bucket/RevisionInfo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Link as RRLink } from 'react-router-dom'
import * as M from '@material-ui/core'

import * as Notifications from 'containers/Notifications'
import * as AWS from 'utils/AWS'
import * as APIConnector from 'utils/APIConnector'
import AsyncResult from 'utils/AsyncResult'
import { useData } from 'utils/Data'
import * as NamedRoutes from 'utils/NamedRoutes'
Expand All @@ -16,7 +16,7 @@ import copyToClipboard from 'utils/clipboard'
import * as requests from './requests'

function useRevisionsData({ bucket, name }) {
const req = AWS.APIGateway.use()
const req = APIConnector.use()
return useData(requests.getPackageRevisions, { req, bucket, name, perPage: 5 })
}

Expand Down
8 changes: 3 additions & 5 deletions catalog/app/containers/Bucket/Search.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ import { useHistory, Link } from 'react-router-dom'
import * as M from '@material-ui/core'

import * as SearchResults from 'components/SearchResults'
import * as AWS from 'utils/AWS'
import * as BucketConfig from 'utils/BucketConfig'
import * as Data from 'utils/Data'
import MetaTitle from 'utils/MetaTitle'
import * as NamedRoutes from 'utils/NamedRoutes'
import parseSearch from 'utils/parseSearch'
import search from 'utils/search'
import useSearch from 'utils/search'
import useEditableValue from 'utils/useEditableValue'

function Browse({ bucket }) {
Expand Down Expand Up @@ -298,10 +297,9 @@ function Search({ bucket, query, page, mode, retry }) {

const retryUrl = urls.bucketSearch(bucket, { q: query, mode, retry: (retry || 0) + 1 })

const req = AWS.APIGateway.use()
const data = Data.use(
search,
{ req, buckets: [bucket], mode, query, retry },
useSearch(),
{ buckets: [bucket], mode, query, retry },
{ noAutoFetch: !query },
)

Expand Down
Loading