Skip to content

Commit aa4971a

Browse files
committed
feat(ui): Show units in check-in timeline
1 parent a4a0791 commit aa4971a

File tree

5 files changed

+35
-4
lines changed

5 files changed

+35
-4
lines changed

static/app/components/checkInTimeline/checkInTimeline.tsx

+9
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import styled from '@emotion/styled';
33

44
import {DateTime} from 'sentry/components/dateTime';
55
import {Tooltip} from 'sentry/components/tooltip';
6+
import {tn} from 'sentry/locale';
67

78
import {getAggregateStatus} from './utils/getAggregateStatus';
89
import {getTickStyle} from './utils/getTickStyle';
@@ -35,6 +36,12 @@ export interface CheckInTimelineProps<Status extends string>
3536
* Represents each check-in tick as bucketed check-in data.
3637
*/
3738
bucketedData: Array<CheckInBucket<Status>>;
39+
/**
40+
* Status unit. Displayed on the check-in tooltip.
41+
*
42+
* Defaults to 'check-ins'
43+
*/
44+
makeUnit?: (count: number) => React.ReactNode;
3845
}
3946

4047
function getBucketedCheckInsPosition(
@@ -54,6 +61,7 @@ export function CheckInTimeline<Status extends string>({
5461
statusPrecedent,
5562
className,
5663
style,
64+
makeUnit = count => tn('check-in', 'check-ins', count),
5765
}: CheckInTimelineProps<Status>) {
5866
const jobTicks = mergeBuckets(
5967
statusPrecedent,
@@ -76,6 +84,7 @@ export function CheckInTimeline<Status extends string>({
7684
timeWindowConfig={timeWindowConfig}
7785
skipWrapper
7886
key={startTs}
87+
makeUnit={makeUnit}
7988
>
8089
<JobTick
8190
style={{left, width}}

static/app/components/checkInTimeline/checkInTooltip.spec.tsx

+6
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ describe('CheckInTooltip', function () {
5151
statusLabel={testStatusLabel}
5252
statusStyle={testStatusStyle}
5353
forceVisible
54+
makeUnit={() => 'some unit'}
5455
/>
5556
);
5657

@@ -82,23 +83,28 @@ describe('CheckInTooltip', function () {
8283
statusLabel={testStatusLabel}
8384
statusStyle={testStatusStyle}
8485
forceVisible
86+
makeUnit={() => 'some unit'}
8587
/>
8688
);
8789

8890
const okayRow = (await screen.findAllByRole('row'))[1]!;
8991
expect(within(okayRow).getByText('Okay')).toBeInTheDocument();
9092
expect(within(okayRow).getByText('1')).toBeInTheDocument();
93+
expect(within(okayRow).getByText('some unit')).toBeInTheDocument();
9194

9295
const missedRow = screen.getAllByRole('row')[2]!;
9396
expect(within(missedRow).getByText('Missed')).toBeInTheDocument();
9497
expect(within(missedRow).getByText('1')).toBeInTheDocument();
98+
expect(within(missedRow).getByText('some unit')).toBeInTheDocument();
9599

96100
const timeoutRow = screen.getAllByRole('row')[3]!;
97101
expect(within(timeoutRow).getByText('Timed Out')).toBeInTheDocument();
98102
expect(within(timeoutRow).getByText('1')).toBeInTheDocument();
103+
expect(within(timeoutRow).getByText('some unit')).toBeInTheDocument();
99104

100105
const errorRow = screen.getAllByRole('row')[4]!;
101106
expect(within(errorRow).getByText('Failed')).toBeInTheDocument();
102107
expect(within(errorRow).getByText('1')).toBeInTheDocument();
108+
expect(within(errorRow).getByText('some unit')).toBeInTheDocument();
103109
});
104110
});

static/app/components/checkInTimeline/checkInTooltip.tsx

+16-3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ interface CheckInTooltipProps<Status extends string> extends Omit<TooltipProps,
1616
* The tick that the tooltip is rendered for
1717
*/
1818
jobTick: JobTickData<Status>;
19+
/**
20+
* A function which returns the unit for the row given the count of check-ins.
21+
*/
22+
makeUnit: (count: number) => React.ReactNode;
1923
/**
2024
* Maps the job tick status to a human readable label
2125
*/
@@ -33,6 +37,7 @@ export function CheckInTooltip<Status extends string>({
3337
statusStyle,
3438
statusLabel,
3539
children,
40+
makeUnit,
3641
...props
3742
}: CheckInTooltipProps<Status>) {
3843
const {startTs, endTs, stats} = jobTick;
@@ -56,6 +61,7 @@ export function CheckInTooltip<Status extends string>({
5661
<tr>
5762
<td>{t('Status')}</td>
5863
<td>{t('Count')}</td>
64+
<td>{t('Unit')}</td>
5965
</tr>
6066
</thead>
6167
<tbody>
@@ -67,6 +73,7 @@ export function CheckInTooltip<Status extends string>({
6773
{statusLabel[status]}
6874
</StatusLabel>
6975
<StatusCount>{count}</StatusCount>
76+
<StatusUnit>{makeUnit(count)}</StatusUnit>
7077
</tr>
7178
)
7279
)}
@@ -86,7 +93,7 @@ const StatusCountContainer = styled('table')`
8693
width: 100%;
8794
margin: 0;
8895
display: grid;
89-
grid-template-columns: max-content max-content;
96+
grid-template-columns: max-content max-content max-content;
9097
gap: ${space(1)};
9198
9299
/* Visually hide the tooltip headers but keep them for accessability */
@@ -106,6 +113,10 @@ const StatusCountContainer = styled('table')`
106113
grid-column: 1 / -1;
107114
grid-template-columns: subgrid;
108115
}
116+
117+
td {
118+
text-align: left;
119+
}
109120
`;
110121

111122
const TooltipTimeLabel = styled('div')`
@@ -115,10 +126,12 @@ const TooltipTimeLabel = styled('div')`
115126

116127
const StatusLabel = styled('td')<{labelColor: ColorOrAlias}>`
117128
color: ${p => p.theme[p.labelColor]};
118-
text-align: left;
119129
`;
120130

121131
const StatusCount = styled('td')`
122132
font-variant-numeric: tabular-nums;
123-
text-align: left;
133+
`;
134+
135+
const StatusUnit = styled('td')`
136+
color: ${p => p.theme.subText};
124137
`;

static/app/views/insights/uptime/components/overviewTimeline/overviewRow.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import ActorBadge from 'sentry/components/idBadge/actorBadge';
1010
import ProjectBadge from 'sentry/components/idBadge/projectBadge';
1111
import Link from 'sentry/components/links/link';
1212
import {IconTimer, IconUser} from 'sentry/icons';
13-
import {t} from 'sentry/locale';
13+
import {t, tn} from 'sentry/locale';
1414
import {space} from 'sentry/styles/space';
1515
import getDuration from 'sentry/utils/duration/getDuration';
1616
import {useLocation} from 'sentry/utils/useLocation';
@@ -103,6 +103,7 @@ export function OverviewRow({uptimeRule, timeWindowConfig, singleRuleView}: Prop
103103
statusStyle={tickStyle}
104104
statusPrecedent={checkStatusPrecedent}
105105
timeWindowConfig={timeWindowConfig}
106+
makeUnit={count => tn('check', 'checks', count)}
106107
/>
107108
)}
108109
</TimelineContainer>

static/app/views/issueDetails/streamline/issueUptimeCheckTimeline.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
GridLineOverlay,
99
} from 'sentry/components/checkInTimeline/gridLines';
1010
import {Flex} from 'sentry/components/container/flex';
11+
import {tn} from 'sentry/locale';
1112
import {space} from 'sentry/styles/space';
1213
import type {Event} from 'sentry/types/event';
1314
import type {Group} from 'sentry/types/group';
@@ -120,6 +121,7 @@ export function IssueUptimeCheckTimeline({group}: {group: Group}) {
120121
statusStyle={tickStyle}
121122
statusPrecedent={checkStatusPrecedent}
122123
timeWindowConfig={timeWindowConfig}
124+
makeUnit={count => tn('check', 'checks', count)}
123125
/>
124126
)}
125127
</TimelineContainer>

0 commit comments

Comments
 (0)