Skip to content

Commit 62e113f

Browse files
Merge branch 'main' into warren/HDX-5837-webhook-tags-variable
2 parents 650ec0a + 00768bb commit 62e113f

7 files changed

Lines changed: 130 additions & 19 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@hyperdx/app': patch
3+
---
4+
5+
Fix the alert preview chart highlighting the region below the threshold for "above" alerts. Recharts v3 flipped the default edge for open-ended reference areas, so "above" and "not between" alerts shaded the wrong side of the threshold line.

‎.changeset/nav-sentence-case.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@hyperdx/app': patch
3+
---
4+
5+
fix: Use sentence case for sidebar nav labels, menus, and tooltips

‎packages/app/src/components/Alerts.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,15 +194,15 @@ export const getAlertReferenceLines = ({
194194
return [
195195
<ReferenceArea
196196
key="not-between-lower"
197-
y2={threshold}
197+
y1={threshold}
198198
ifOverflow="extendDomain"
199199
fill="red"
200200
strokeWidth={0}
201201
fillOpacity={0.05}
202202
/>,
203203
<ReferenceArea
204204
key="not-between-upper"
205-
y1={thresholdMax}
205+
y2={thresholdMax}
206206
ifOverflow="extendDomain"
207207
fill="red"
208208
strokeWidth={0}
@@ -231,7 +231,7 @@ export const getAlertReferenceLines = ({
231231
) {
232232
return (
233233
<ReferenceArea
234-
y1={threshold}
234+
y2={threshold}
235235
ifOverflow="extendDomain"
236236
fill="red"
237237
strokeWidth={0}

‎packages/app/src/components/AppNav/AppNav.components.tsx‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export const AppNavCloudBanner = () => {
6060
target="_blank"
6161
rel="noopener noreferrer"
6262
>
63-
Get Started for Free
63+
Get started for free
6464
</Button>
6565
</div>
6666
</div>
@@ -155,15 +155,15 @@ export const AppNavUserMenu = ({
155155
component={Link}
156156
leftSection={<IconSettings size={16} />}
157157
>
158-
Team Settings
158+
Team settings
159159
</Menu.Item>
160160
)}
161161
<Menu.Item
162162
data-testid="user-preferences-menu-item"
163163
leftSection={<IconUserCog size={16} />}
164164
onClick={onClickUserPreferences}
165165
>
166-
User Preferences
166+
User preferences
167167
</Menu.Item>
168168
{logoutUrl && (
169169
<>
@@ -287,7 +287,7 @@ export const AppNavHelpMenu = ({
287287
target="_blank"
288288
rel="noopener noreferrer"
289289
>
290-
Setup Instructions
290+
Setup instructions
291291
</Menu.Item>
292292
<Menu.Item
293293
data-testid="keyboard-shortcuts-menu-item"
@@ -304,7 +304,7 @@ export const AppNavHelpMenu = ({
304304
target="_blank"
305305
rel="noopener noreferrer"
306306
>
307-
Discord Community
307+
Discord community
308308
</Menu.Item>
309309

310310
<Menu.Divider />
@@ -396,7 +396,7 @@ export const AppNavLink = ({
396396
)}
397397
{!isCollapsed && onToggle && (
398398
<Tooltip
399-
label={isExpanded ? 'Hide Favorites' : 'Show Favorites'}
399+
label={isExpanded ? 'Hide favorites' : 'Show favorites'}
400400
position="right"
401401
>
402402
<button

‎packages/app/src/components/AppNav/AppNav.tsx‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ type NavLinkConfig = {
8383
const NAV_LINKS: NavLinkConfig[] = [
8484
{
8585
id: 'chart',
86-
label: 'Chart Explorer',
86+
label: 'Chart explorer',
8787
href: '/chart',
8888
icon: <IconChartDots size={16} />,
8989
},
@@ -96,13 +96,13 @@ const NAV_LINKS: NavLinkConfig[] = [
9696
},
9797
{
9898
id: 'sessions',
99-
label: 'Client Sessions',
99+
label: 'Client sessions',
100100
href: '/sessions',
101101
icon: <IconDeviceLaptop size={16} />,
102102
},
103103
{
104104
id: 'service-map',
105-
label: 'Service Map',
105+
label: 'Service map',
106106
href: '/service-map',
107107
icon: <IconSitemap size={16} />,
108108
isBeta: true,
@@ -392,7 +392,7 @@ export default function AppNav({ fixed = false }: { fixed?: boolean }) {
392392
className={cx(styles.collapseButton, {
393393
[styles.collapseButtonCollapsed]: isCollapsed,
394394
})}
395-
title="Collapse/Expand Navigation"
395+
title="Collapse/expand navigation"
396396
onClick={() => setIsPreferCollapsed((v: boolean) => !v)}
397397
>
398398
<IconArrowBarToLeft size={16} />
@@ -417,7 +417,7 @@ export default function AppNav({ fixed = false }: { fixed?: boolean }) {
417417

418418
{/* Saved Searches */}
419419
<AppNavLink
420-
label="Saved Searches"
420+
label="Saved searches"
421421
href="/search/list"
422422
icon={<IconDeviceFloppy size={16} />}
423423
isActive={isSavedSearchActive}
@@ -434,7 +434,7 @@ export default function AppNav({ fixed = false }: { fixed?: boolean }) {
434434
<Text size="xs" c="dimmed" pl="lg" pr="xs" py={4} lh={1.4}>
435435
No favorites. Star on{' '}
436436
<Anchor component={Link} href="/search/list" size="xs">
437-
Saved Searches
437+
Saved searches
438438
</Anchor>
439439
.
440440
</Text>
@@ -499,7 +499,7 @@ export default function AppNav({ fixed = false }: { fixed?: boolean }) {
499499
{/* Team Settings (Cloud only) */}
500500
{!IS_LOCAL_MODE && (
501501
<AppNavLink
502-
label="Team Settings"
502+
label="Team settings"
503503
href="/team"
504504
icon={<IconSettings size={16} />}
505505
/>
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import React from 'react';
2+
import { Line, LineChart, ReferenceLine, XAxis, YAxis } from 'recharts';
3+
import { AlertThresholdType } from '@hyperdx/common-utils/dist/types';
4+
import { render } from '@testing-library/react';
5+
6+
import { getAlertReferenceLines } from '@/components/Alerts';
7+
8+
type Rect = { top: number; bottom: number };
9+
10+
function renderAreas(
11+
thresholdType: AlertThresholdType,
12+
threshold: number,
13+
thresholdMax?: number,
14+
): { rects: Rect[]; thresholdY: number; thresholdMaxY?: number } {
15+
const { container } = render(
16+
<LineChart
17+
width={400}
18+
height={300}
19+
data={[
20+
{ t: 0, v: 10 },
21+
{ t: 1, v: 80 },
22+
]}
23+
>
24+
<XAxis dataKey="t" />
25+
<YAxis domain={[0, 100]} />
26+
<Line dataKey="v" isAnimationActive={false} />
27+
{getAlertReferenceLines({ threshold, thresholdMax, thresholdType })}
28+
<ReferenceLine y={threshold} />
29+
{thresholdMax != null ? <ReferenceLine y={thresholdMax} /> : null}
30+
</LineChart>,
31+
);
32+
33+
const rects = Array.from(
34+
container.querySelectorAll('.recharts-reference-area-rect'),
35+
).map(r => {
36+
const top = Number(r.getAttribute('y'));
37+
return { top, bottom: top + Number(r.getAttribute('height')) };
38+
});
39+
const lineYs = Array.from(
40+
container.querySelectorAll('.recharts-reference-line-line'),
41+
).map(l => Number(l.getAttribute('y1')));
42+
43+
return {
44+
rects,
45+
thresholdY: lineYs[0],
46+
thresholdMaxY: lineYs[1],
47+
};
48+
}
49+
50+
const EPS = 1;
51+
52+
describe('getAlertReferenceLines shading', () => {
53+
it.each([AlertThresholdType.ABOVE, AlertThresholdType.ABOVE_EXCLUSIVE])(
54+
'shades above the threshold line for %s',
55+
thresholdType => {
56+
const { rects, thresholdY } = renderAreas(thresholdType, 50);
57+
expect(rects).toHaveLength(1);
58+
expect(rects[0].top).toBeLessThan(thresholdY);
59+
expect(rects[0].bottom).toBeLessThanOrEqual(thresholdY + EPS);
60+
},
61+
);
62+
63+
it.each([AlertThresholdType.BELOW, AlertThresholdType.BELOW_OR_EQUAL])(
64+
'shades below the threshold line for %s',
65+
thresholdType => {
66+
const { rects, thresholdY } = renderAreas(thresholdType, 50);
67+
expect(rects).toHaveLength(1);
68+
expect(rects[0].top).toBeGreaterThanOrEqual(thresholdY - EPS);
69+
expect(rects[0].bottom).toBeGreaterThan(thresholdY);
70+
},
71+
);
72+
73+
it('shades the band between the two thresholds for BETWEEN', () => {
74+
const { rects, thresholdY, thresholdMaxY } = renderAreas(
75+
AlertThresholdType.BETWEEN,
76+
30,
77+
70,
78+
);
79+
expect(rects).toHaveLength(1);
80+
expect(thresholdMaxY).toBeDefined();
81+
expect(rects[0].top).toBeCloseTo(thresholdMaxY!, 0);
82+
expect(rects[0].bottom).toBeCloseTo(thresholdY, 0);
83+
});
84+
85+
it('shades below the lower bound and above the upper bound for NOT_BETWEEN', () => {
86+
const { rects, thresholdY, thresholdMaxY } = renderAreas(
87+
AlertThresholdType.NOT_BETWEEN,
88+
30,
89+
70,
90+
);
91+
expect(rects).toHaveLength(2);
92+
expect(thresholdMaxY).toBeDefined();
93+
94+
const lower = rects.find(r => r.bottom > thresholdY)!;
95+
const upper = rects.find(r => r.top < thresholdMaxY!)!;
96+
// Lower firing region: from the lower threshold line downward.
97+
expect(lower.top).toBeCloseTo(thresholdY, 0);
98+
// Upper firing region: from the upper threshold line upward.
99+
expect(upper.bottom).toBeCloseTo(thresholdMaxY!, 0);
100+
});
101+
});

‎yarn.lock‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18454,9 +18454,9 @@ __metadata:
1845418454
linkType: hard
1845518455

1845618456
"fast-uri@npm:^3.0.1":
18457-
version: 3.1.8
18458-
resolution: "fast-uri@npm:3.1.8"
18459-
checksum: 10c0/c9c47860a7f9110176d94bb30a02942182f0bfc8d6780e9702f320336dc2dadb83b1d9879cceaf8d4b439642d1ec6d78c317cb808ab155455551bd5d9d7c22d8
18457+
version: 3.1.9
18458+
resolution: "fast-uri@npm:3.1.9"
18459+
checksum: 10c0/052757540d8c0bbc16bb124a45b8f5cb5d0932f9b89f019221ee41cdb3cafc1db44b2e809d6b888b87922af3e5560a863124454e9d9193e1fc955887357b5add
1846018460
languageName: node
1846118461
linkType: hard
1846218462

0 commit comments

Comments
 (0)