-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
feat(preprod): Use structured search #106961
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| import {OverlayTrigger} from '@sentry/scraps/overlayTrigger'; | ||
|
|
||
| import {CompactSelect, type SelectOption} from 'sentry/components/core/compactSelect'; | ||
| import {Container, Flex} from 'sentry/components/core/layout'; | ||
| import {PreprodBuildsDisplay} from 'sentry/components/preprod/preprodBuildsDisplay'; | ||
| import {PreprodSearchBar} from 'sentry/components/preprod/preprodSearchBar'; | ||
| import {t} from 'sentry/locale'; | ||
| import useOrganization from 'sentry/utils/useOrganization'; | ||
|
|
||
| const displaySelectOptions: Array<SelectOption<PreprodBuildsDisplay>> = [ | ||
| {value: PreprodBuildsDisplay.SIZE, label: t('Size')}, | ||
| {value: PreprodBuildsDisplay.DISTRIBUTION, label: t('Distribution')}, | ||
| ]; | ||
|
|
||
| interface PreprodBuildsSearchControlsProps { | ||
| /** | ||
| * Current display mode value from URL query | ||
| */ | ||
| display: PreprodBuildsDisplay; | ||
| /** | ||
| * Initial search query value | ||
| */ | ||
| initialQuery: string; | ||
| /** | ||
| * Called when display mode changes | ||
| */ | ||
| onDisplayChange: (display: PreprodBuildsDisplay) => void; | ||
| /** | ||
| * Project IDs to filter search attributes | ||
| */ | ||
| projects: number[]; | ||
| /** | ||
| * Called on every keystroke (for controlled input with debounce) | ||
| */ | ||
| onChange?: (query: string, state: {queryIsValid: boolean}) => void; | ||
| /** | ||
| * Called when search is submitted (e.g., on Enter) | ||
| */ | ||
| onSearch?: (query: string) => void; | ||
| } | ||
|
|
||
| /** | ||
| * Reusable search controls for preprod builds pages. | ||
| * Combines search bar with optional display mode toggle. | ||
| */ | ||
| export function PreprodBuildsSearchControls({ | ||
| initialQuery, | ||
| display, | ||
| projects, | ||
| onChange, | ||
| onSearch, | ||
| onDisplayChange, | ||
| }: PreprodBuildsSearchControlsProps) { | ||
| const organization = useOrganization(); | ||
| const hasDistributionFeature = organization.features.includes( | ||
| 'preprod-build-distribution' | ||
| ); | ||
|
|
||
| return ( | ||
| <Flex | ||
| align={{xs: 'stretch', sm: 'center'}} | ||
| direction={{xs: 'column', sm: 'row'}} | ||
| gap="md" | ||
| wrap="wrap" | ||
| > | ||
| <Container flex="1"> | ||
| <PreprodSearchBar | ||
| initialQuery={initialQuery} | ||
| onChange={onChange} | ||
| onSearch={onSearch} | ||
| projects={projects} | ||
| /> | ||
| </Container> | ||
| {hasDistributionFeature && ( | ||
| <Container maxWidth="200px"> | ||
| <CompactSelect | ||
| options={displaySelectOptions} | ||
| value={display} | ||
| onChange={option => onDisplayChange(option.value)} | ||
| trigger={triggerProps => ( | ||
| <OverlayTrigger.Button | ||
| {...triggerProps} | ||
| prefix={t('Display')} | ||
| style={{width: '100%', zIndex: 1}} | ||
| /> | ||
| )} | ||
| /> | ||
| </Container> | ||
| )} | ||
| </Flex> | ||
| ); | ||
| } |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,13 @@ | ||
| import {useCallback, useContext, useEffect, useMemo, useState} from 'react'; | ||
|
|
||
| import {Container, Flex} from 'sentry/components/core/layout'; | ||
| import {Container} from 'sentry/components/core/layout'; | ||
| import * as Layout from 'sentry/components/layouts/thirds'; | ||
| import LoadingError from 'sentry/components/loadingError'; | ||
| import { | ||
| getPreprodBuildsDisplay, | ||
| PreprodBuildsDisplay, | ||
| } from 'sentry/components/preprod/preprodBuildsDisplay'; | ||
| import {PreprodBuildsSearchControls} from 'sentry/components/preprod/preprodBuildsSearchControls'; | ||
| import {PreprodBuildsTable} from 'sentry/components/preprod/preprodBuildsTable'; | ||
| import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle'; | ||
| import {t} from 'sentry/locale'; | ||
|
|
@@ -22,10 +23,8 @@ import {useLocation} from 'sentry/utils/useLocation'; | |
| import useOrganization from 'sentry/utils/useOrganization'; | ||
| import {useParams} from 'sentry/utils/useParams'; | ||
| import {formatVersion} from 'sentry/utils/versions/formatVersion'; | ||
| import PreprodBuildsSearchBar from 'sentry/views/preprod/components/preprodBuildsSearchBar'; | ||
| import {usePreprodBuildsAnalytics} from 'sentry/views/preprod/hooks/usePreprodBuildsAnalytics'; | ||
| import type {BuildDetailsApiResponse} from 'sentry/views/preprod/types/buildDetailsTypes'; | ||
| import type {ListBuildsApiResponse} from 'sentry/views/preprod/types/listBuildsTypes'; | ||
| import {ReleaseContext} from 'sentry/views/releases/detail'; | ||
|
|
||
| import {PreprodOnboarding} from './preprodOnboarding'; | ||
|
|
@@ -96,12 +95,11 @@ export default function PreprodBuilds() { | |
| error: buildsError, | ||
| refetch, | ||
| getResponseHeader, | ||
| }: UseApiQueryResult< | ||
| ListBuildsApiResponse, | ||
| RequestError | ||
| > = useApiQuery<ListBuildsApiResponse>( | ||
| }: UseApiQueryResult<BuildDetailsApiResponse[], RequestError> = useApiQuery< | ||
| BuildDetailsApiResponse[] | ||
| >( | ||
| [ | ||
| getApiUrl(`/organizations/$organizationIdOrSlug/preprodartifacts/list-builds/`, { | ||
| getApiUrl(`/organizations/$organizationIdOrSlug/builds/`, { | ||
cursor[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| path: {organizationIdOrSlug: organization.slug}, | ||
| }), | ||
| {query: queryParams}, | ||
|
|
@@ -112,7 +110,7 @@ export default function PreprodBuilds() { | |
| } | ||
sentry[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ); | ||
|
|
||
| const handleSearch = (query: string) => { | ||
| const handleSearch = (query: string, _state?: {queryIsValid: boolean}) => { | ||
| setLocalSearchQuery(query); | ||
| }; | ||
|
|
||
|
|
@@ -130,7 +128,7 @@ export default function PreprodBuilds() { | |
| [location] | ||
| ); | ||
|
|
||
| const builds = buildsData?.builds || []; | ||
| const builds = buildsData ?? []; | ||
| const pageLinks = getResponseHeader?.('Link') || null; | ||
|
|
||
| const hasSearchQuery = !!urlSearchQuery?.trim(); | ||
|
|
@@ -171,23 +169,13 @@ export default function PreprodBuilds() { | |
| /> | ||
| {buildsError && <LoadingError onRetry={refetch} />} | ||
| <Container paddingBottom="md"> | ||
| <Flex | ||
| align={{xs: 'stretch', sm: 'center'}} | ||
| direction={{xs: 'column', sm: 'row'}} | ||
| gap="md" | ||
| wrap="wrap" | ||
| > | ||
| <PreprodBuildsSearchBar | ||
| onChange={handleSearch} | ||
| query={localSearchQuery} | ||
| disabled={isLoadingBuilds} | ||
| displayOptions={ | ||
| hasDistributionFeature | ||
| ? {selected: activeDisplay, onSelect: handleDisplayChange} | ||
| : undefined | ||
| } | ||
| /> | ||
| </Flex> | ||
| <PreprodBuildsSearchControls | ||
| initialQuery={localSearchQuery} | ||
| display={activeDisplay} | ||
| projects={[Number(projectId)]} | ||
| onChange={handleSearch} | ||
| onDisplayChange={handleDisplayChange} | ||
| /> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Search bar won't sync with external URL changesMedium Severity The migration from Additional Locations (1)
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| </Container> | ||
| {showOnboarding ? ( | ||
| <PreprodOnboarding projectPlatform={projectPlatform || null} /> | ||
|
|
||

Uh oh!
There was an error while loading. Please reload this page.