Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {IconClose, IconCommit, IconFocus, IconLock, IconTelescope} from 'sentry/
import {t} from 'sentry/locale';
import ProjectsStore from 'sentry/stores/projectsStore';
import {trackAnalytics} from 'sentry/utils/analytics';
import {getFormat, getFormattedDate} from 'sentry/utils/dates';
import useOrganization from 'sentry/utils/useOrganization';
import {useParams} from 'sentry/utils/useParams';
import type {BuildDetailsApiResponse} from 'sentry/views/preprod/types/buildDetailsTypes';
Expand All @@ -35,12 +36,34 @@ function BuildButton({
const sha = buildDetails.vcs_info?.head_sha?.substring(0, 7);
const branchName = buildDetails.vcs_info?.head_ref;
const buildId = buildDetails.id;
const version = buildDetails.app_info?.version;
const buildNumber = buildDetails.app_info?.build_number;
const dateBuilt = buildDetails.app_info?.date_built;
const dateAdded = buildDetails.app_info?.date_added;

const buildUrl = `/organizations/${organization.slug}/preprod/${projectId}/${buildId}/`;
const platform = buildDetails.app_info?.platform ?? null;

const dateToShow = dateBuilt || dateAdded;
const formattedDate = getFormattedDate(
dateToShow,
getFormat({timeZone: true, year: true}),
{
local: true,
}
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Missing date displays current date instead of fallback

When both dateBuilt and dateAdded are undefined or null, dateToShow becomes undefined. Passing undefined to getFormattedDate (which wraps moment.js) causes it to return the current date/time instead of handling the missing data case. This results in displaying today's date in the metadata line, which would mislead users about when the build was actually created.

Fix in Cursor Fix in Web

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we always have at least the date_added so this shouldn't happen.


// Build metadata parts for the second line
const metadataParts = [formattedDate];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the date isn't optional, everything else is.

Comment on lines +47 to +57

This comment was marked as outdated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we always have at least the date_added so this shouldn't happen.

if (version) {
metadataParts.unshift(`Version ${version}`);
}
if (buildNumber) {
metadataParts.unshift(`Build ${buildNumber}`);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Metadata order reversed from documented intent

The metadataParts array construction produces "Build number • Version • Date" but the PR description specifies "Version • Build number • Date". Using unshift adds each item to the beginning of the array, so adding version first then buildNumber results in buildNumber appearing first. To match the documented order, either reverse the order of the conditionals, or use push instead of unshift with the items already in the desired order.

Fix in Cursor Fix in Web


return (
<LinkButton
<StyledLinkButton
to={buildUrl}
onClick={() =>
trackAnalytics('preprod.builds.compare.go_to_build_details', {
Expand All @@ -53,15 +76,17 @@ function BuildButton({
})
}
>
<Flex align="center" gap="sm">
{icon}
<Text size="sm" variant="accent" bold>
{label}
</Text>
<Flex align="center" gap="md">
<Flex direction="column" gap="xs">
<Flex align="center" gap="sm">
{icon}
<Text size="sm" variant="accent" bold>
{`#${buildId}`}
{label}
</Text>
{!buildNumber && (
<Text size="sm" variant="accent" bold>
{`#${buildId}`}
</Text>
)}
{sha && (
<Flex align="center" gap="xs">
<IconCommit size="xs" />
Expand All @@ -70,33 +95,43 @@ function BuildButton({
</Text>
</Flex>
)}
{branchName && (
<BuildBranch>
<Text size="sm" variant="muted">
{branchName}
</Text>
</BuildBranch>
)}
{onRemove && (
<Button
onClick={e => {
e.preventDefault();
e.stopPropagation();
onRemove();
}}
size="zero"
priority="transparent"
borderless
aria-label={t('Clear base build')}
icon={<IconClose size="xs" color="purple400" />}
/>
)}
</Flex>
<Flex align="center" gap="sm">
<Text size="sm" variant="muted">
{metadataParts.join(' • ')}
</Text>
</Flex>
{branchName && (
<BuildBranch>
<Text size="sm" variant="muted">
{branchName}
</Text>
</BuildBranch>
)}
{onRemove && (
<Button
onClick={e => {
e.preventDefault();
e.stopPropagation();
onRemove();
}}
size="zero"
priority="transparent"
borderless
aria-label={t('Clear base build')}
icon={<IconClose size="xs" color="purple400" />}
/>
)}
</Flex>
</LinkButton>
</StyledLinkButton>
);
}

const StyledLinkButton = styled(LinkButton)`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to create this otherwise the LinkButton's height would be fixed and the elements would overflow.

height: auto;
min-height: auto;
`;

const ComparisonContainer = styled(Flex)`
flex-wrap: wrap;
align-items: center;
Expand Down
Loading