Skip to content

Commit e241b91

Browse files
feat(aci): grid cell components for monitors (#84281)
# `TitleCell` refactored + renamed `AutomationTitleCell` so that it can be used for monitors and automations <img width="502" alt="Screenshot 2025-01-29 at 3 33 04 PM" src="https://github.com/user-attachments/assets/42dd80c5-6047-45cd-abe3-c1b48bd1856a" /> # `ConnectionCell` refactored + renamed `MonitorsCell` so that it can be used for connected monitors and automations <img width="278" alt="Screenshot 2025-01-29 at 3 32 49 PM" src="https://github.com/user-attachments/assets/e2146d8c-283f-4398-a944-fd06fb70aa37" /> # `IssueCell` https://github.com/user-attachments/assets/a17dabb0-e60f-4fe7-992e-c36bd16fb5b7 # `NumberCell` <img width="170" alt="Screenshot 2025-01-29 at 3 15 00 PM" src="https://github.com/user-attachments/assets/4fa44018-f2e6-402b-99af-aff4613138b5" /> --------- Co-authored-by: Nate Moore <[email protected]>
1 parent fc0e079 commit e241b91

File tree

8 files changed

+335
-144
lines changed

8 files changed

+335
-144
lines changed

static/app/components/group/inboxBadges/shortId.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function ShortId({shortId, avatar}: Props) {
2121

2222
export default ShortId;
2323

24-
const Wrapper = styled('div')`
24+
export const Wrapper = styled('div')`
2525
display: flex;
2626
align-items: center;
2727
white-space: nowrap;

static/app/components/workflowEngine/gridCell/automationTitleCell.tsx

Lines changed: 0 additions & 52 deletions
This file was deleted.

static/app/components/workflowEngine/gridCell/monitorsCell.tsx renamed to static/app/components/workflowEngine/gridCell/connectionCell.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,32 @@ import {Hovercard} from 'sentry/components/hovercard';
66
import ProjectBadge from 'sentry/components/idBadge/projectBadge';
77
import Link from 'sentry/components/links/link';
88
import {EmptyCell} from 'sentry/components/workflowEngine/gridCell/emptyCell';
9-
import {tn} from 'sentry/locale';
109
import {space} from 'sentry/styles/space';
1110
import type {AvatarProject} from 'sentry/types/project';
1211

13-
export type Monitor = {
14-
id: string;
12+
export type Item = {
13+
link: string;
1514
name: string;
1615
project: AvatarProject;
1716
description?: string;
1817
};
1918

20-
type MonitorsCellProps = {
21-
monitors: Monitor[];
19+
export type ConnectionCellProps = {
20+
items: Item[];
21+
renderText: (count: number) => string;
2222
};
2323

24-
export function MonitorsCell({monitors}: MonitorsCellProps) {
25-
if (monitors.length === 0) {
24+
export function ConnectionCell({items, renderText}: ConnectionCellProps) {
25+
if (items.length === 0) {
2626
return <EmptyCell />;
2727
}
2828
return (
2929
<div>
3030
<Hovercard
31-
body={monitors.map(({name, id, project, description}, index) => (
32-
<Fragment key={id}>
31+
body={items.map(({name, project, description, link}, index) => (
32+
<Fragment key={link}>
3333
{index > 0 && <Divider />}
34-
<HovercardRow to={`/monitors/${id}/`}>
34+
<HovercardRow to={link}>
3535
<strong>{name}</strong>
3636
<MonitorDetails>
3737
<ProjectBadge
@@ -55,7 +55,7 @@ export function MonitorsCell({monitors}: MonitorsCellProps) {
5555
</Fragment>
5656
))}
5757
>
58-
<MonitorCount>{tn('%s monitor', '%s monitors', monitors.length)}</MonitorCount>
58+
<MonitorCount>{renderText(items.length)}</MonitorCount>
5959
</Hovercard>
6060
</div>
6161
);

static/app/components/workflowEngine/gridCell/index.spec.tsx

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
33
import {TooltipContext} from 'sentry/components/tooltip';
44

55
import {ActionCell} from './actionCell';
6-
import {MonitorsCell} from './monitorsCell';
6+
import {ConnectionCell} from './connectionCell';
7+
import {NumberCell} from './numberCell';
78
import {TimeAgoCell} from './timeAgoCell';
89

910
describe('Action Cell Component', function () {
@@ -38,31 +39,38 @@ describe('Time Ago Cell Component', function () {
3839
});
3940
});
4041

41-
const renderMonitorCell = () => {
42+
const renderConnectionCell = (renderText: (count: number) => string) => {
4243
render(
43-
<MonitorsCell
44-
monitors={[
44+
<ConnectionCell
45+
items={[
4546
{
4647
name: '/endpoint',
47-
id: 'def456',
48+
link: 'link/def456',
4849
project: {slug: 'javascript', platform: 'javascript'},
4950
description: 'transaction.duration',
5051
},
5152
]}
53+
renderText={renderText}
5254
/>
5355
);
5456
};
5557

56-
describe('Monitors Cell Component', function () {
57-
it('renders children and context values', function () {
58-
renderMonitorCell();
58+
describe('Connection Cell Component', function () {
59+
it('renders monitors', function () {
60+
renderConnectionCell(count => count + ' monitor');
5961

6062
const text = screen.getByText('1 monitor');
6163
expect(text).toBeInTheDocument();
6264
});
6365

66+
it('renders automations', function () {
67+
renderConnectionCell(count => count + ' automation');
68+
const text = screen.getByText('1 automation');
69+
expect(text).toBeInTheDocument();
70+
});
71+
6472
it('renders hovercard', async function () {
65-
renderMonitorCell();
73+
renderConnectionCell(count => count + ' monitor');
6674

6775
const span = screen.getByText('1 monitor');
6876
expect(span).toBeInTheDocument();
@@ -72,3 +80,12 @@ describe('Monitors Cell Component', function () {
7280
expect(await screen.findByText('transaction.duration')).toBeInTheDocument();
7381
});
7482
});
83+
84+
describe('Number Cell Component', function () {
85+
it('renders', () => {
86+
render(<NumberCell number={3} />);
87+
88+
const text = screen.getByText('3');
89+
expect(text).toBeInTheDocument();
90+
});
91+
});

0 commit comments

Comments
 (0)