Skip to content

Commit 0c187ec

Browse files
authored
chore(preprod): make build details and build compare breadcrumb consistent (EME-657, EME-659) (#103994)
make behavior consistent for breadcrumb nav across compare and build details https://github.com/user-attachments/assets/2f89d873-3e80-49bd-8cec-d79078b63b16
1 parent 89d08af commit 0c187ec

File tree

3 files changed

+47
-37
lines changed

3 files changed

+47
-37
lines changed

static/app/views/preprod/buildComparison/header/buildCompareHeaderContent.tsx

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {Breadcrumbs, type Crumb} from 'sentry/components/breadcrumbs';
1212
import FeedbackButton from 'sentry/components/feedbackButton/feedbackButton';
1313
import {IconCode, IconDownload, IconJson, IconMobile} from 'sentry/icons';
1414
import {t} from 'sentry/locale';
15-
import useOrganization from 'sentry/utils/useOrganization';
15+
import ProjectsStore from 'sentry/stores/projectsStore';
1616
import {
1717
isSizeInfoCompleted,
1818
type BuildDetailsApiResponse,
@@ -24,6 +24,7 @@ import {
2424
getPlatformIconFromPlatform,
2525
getReadablePlatformLabel,
2626
} from 'sentry/views/preprod/utils/labelUtils';
27+
import {makeReleasesUrl} from 'sentry/views/preprod/utils/releasesUrl';
2728

2829
interface BuildCompareHeaderContentProps {
2930
buildDetails: BuildDetailsApiResponse;
@@ -32,23 +33,32 @@ interface BuildCompareHeaderContentProps {
3233

3334
export function BuildCompareHeaderContent(props: BuildCompareHeaderContentProps) {
3435
const {buildDetails, projectId} = props;
35-
const organization = useOrganization();
3636
const theme = useTheme();
37+
const project = ProjectsStore.getBySlug(projectId);
3738
const labels = getLabels(buildDetails.app_info?.platform ?? undefined);
3839
const breadcrumbs: Crumb[] = [
3940
{
40-
to: '#',
41+
to: makeReleasesUrl(project?.id, {
42+
appId: buildDetails.app_info.app_id ?? undefined,
43+
}),
4144
label: t('Releases'),
4245
},
43-
{
44-
to: `/organizations/${organization.slug}/preprod/${projectId}/${buildDetails.id}/`,
45-
label: buildDetails.app_info.version ?? t('Build Version'),
46-
},
47-
{
48-
label: t('Compare'),
49-
},
5046
];
5147

48+
if (buildDetails.app_info.version) {
49+
breadcrumbs.push({
50+
to: makeReleasesUrl(project?.id, {
51+
version: buildDetails.app_info.version,
52+
appId: buildDetails.app_info.app_id ?? undefined,
53+
}),
54+
label: buildDetails.app_info.version,
55+
});
56+
}
57+
58+
breadcrumbs.push({
59+
label: t('Compare'),
60+
});
61+
5262
return (
5363
<Flex justify="between" align="center" gap="lg">
5464
<Stack gap="lg" style={{padding: `0 0 ${theme.space.lg} 0`}}>

static/app/views/preprod/buildDetails/header/buildDetailsHeaderContent.tsx

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -29,35 +29,10 @@ import type RequestError from 'sentry/utils/requestError/requestError';
2929
import {useIsSentryEmployee} from 'sentry/utils/useIsSentryEmployee';
3030
import useOrganization from 'sentry/utils/useOrganization';
3131
import type {BuildDetailsApiResponse} from 'sentry/views/preprod/types/buildDetailsTypes';
32+
import {makeReleasesUrl} from 'sentry/views/preprod/utils/releasesUrl';
3233

3334
import {useBuildDetailsActions} from './useBuildDetailsActions';
3435

35-
function makeReleasesUrl(
36-
projectId: string | undefined,
37-
query: {appId?: string; version?: string}
38-
): string {
39-
const {appId, version} = query;
40-
41-
// Not knowing the projectId should be transient.
42-
if (projectId === undefined) {
43-
return '#';
44-
}
45-
46-
const params = new URLSearchParams();
47-
params.set('project', projectId);
48-
const parts = [];
49-
if (appId) {
50-
parts.push(`release.package:${appId}`);
51-
}
52-
if (version) {
53-
parts.push(`release.version:${version}`);
54-
}
55-
if (parts.length) {
56-
params.set('query', parts.join(' '));
57-
}
58-
return `/explore/releases/?${params}`;
59-
}
60-
6136
interface BuildDetailsHeaderContentProps {
6237
artifactId: string;
6338
buildDetailsQuery: UseApiQueryResult<BuildDetailsApiResponse, RequestError>;
@@ -108,7 +83,7 @@ export function BuildDetailsHeaderContent(props: BuildDetailsHeaderContentProps)
10883
const breadcrumbs: Crumb[] = [
10984
{
11085
to: makeReleasesUrl(project?.id, {
111-
version: buildDetailsData.app_info.version ?? undefined,
86+
appId: buildDetailsData.app_info.app_id ?? undefined,
11287
}),
11388
label: 'Releases',
11489
},
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
export function makeReleasesUrl(
2+
projectId: string | undefined,
3+
query: {appId?: string; version?: string}
4+
): string {
5+
const {appId, version} = query;
6+
7+
// Not knowing the projectId should be transient.
8+
if (projectId === undefined) {
9+
return '#';
10+
}
11+
12+
const params = new URLSearchParams();
13+
params.set('project', projectId);
14+
const parts = [];
15+
if (appId) {
16+
parts.push(`release.package:${appId}`);
17+
}
18+
if (version) {
19+
parts.push(`release.version:${version}`);
20+
}
21+
if (parts.length) {
22+
params.set('query', parts.join(' '));
23+
}
24+
return `/explore/releases/?${params}`;
25+
}

0 commit comments

Comments
 (0)