Skip to content

Commit e182feb

Browse files
committed
Balance deployment table columns and truncate long errors
1 parent 3d2898e commit e182feb

3 files changed

Lines changed: 222 additions & 74 deletions

File tree

‎platform/packages/api/src/admin/react/styles.css‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -790,8 +790,25 @@ body {
790790
.void-admin-top-projects-table {
791791
min-width: 54rem;
792792
}
793-
.void-admin-deployments-table {
794-
min-width: 52rem;
793+
.void-admin-deployment-link {
794+
display: block;
795+
overflow: hidden;
796+
text-overflow: ellipsis;
797+
white-space: nowrap;
798+
}
799+
.void-admin-deployment-error {
800+
display: flex;
801+
align-items: center;
802+
gap: var(--spacing-2);
803+
min-width: 0;
804+
}
805+
.void-admin-deployment-error-message {
806+
flex: 1;
807+
min-width: 0;
808+
color: var(--color-text-red);
809+
}
810+
.void-admin-deployment-error .astryx-button {
811+
flex-shrink: 0;
795812
}
796813
.void-admin-top-projects-table th:nth-child(1) {
797814
width: 4%;
Lines changed: 97 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
/** @jsxImportSource @voidcloud/api/admin-jsx */
2-
import {
3-
Table,
4-
TableBody,
5-
TableCell,
6-
TableHeader,
7-
TableHeaderCell,
8-
TableRow,
9-
} from '@astryxdesign/core/Table';
2+
import { Table, pixel, proportional, type TableColumn } from '@astryxdesign/core/Table';
3+
import { Text } from '@astryxdesign/core/Text';
104
import type { Deployment } from '../../../types.ts';
115
import { CopyButton } from './CopyButton.tsx';
126
import { formatDateTime } from './format.ts';
137

8+
type DeploymentRow = Deployment & {
9+
project_slug?: string | null;
10+
active_deployment_id?: string | null;
11+
};
12+
1413
export function displayStatus(
1514
d: Deployment,
1615
activeDeploymentId: string | null | undefined,
@@ -54,12 +53,7 @@ export function DeploymentTable({
5453
showProject,
5554
tz,
5655
}: {
57-
deployments: ReadonlyArray<
58-
Deployment & {
59-
project_slug?: string | null;
60-
active_deployment_id?: string | null;
61-
}
62-
>;
56+
deployments: ReadonlyArray<DeploymentRow>;
6357
activeDeploymentId?: string | null;
6458
showProject?: boolean;
6559
tz?: string;
@@ -71,64 +65,95 @@ export function DeploymentTable({
7165
</p>
7266
);
7367
}
68+
const columns: Array<TableColumn<DeploymentRow>> = [
69+
{
70+
key: 'id',
71+
header: 'ID',
72+
width: proportional(1, { minWidth: 115 }),
73+
renderCell: (d: DeploymentRow) => (
74+
<a className="void-admin-deployment-link" href={`/admin/deployments/${d.id}`} title={d.id}>
75+
{d.id}
76+
</a>
77+
),
78+
},
79+
];
80+
if (showProject) {
81+
columns.push({
82+
key: 'project_slug',
83+
header: 'Project',
84+
width: proportional(1, { minWidth: 115 }),
85+
renderCell: (d: DeploymentRow) =>
86+
d.project_slug ? (
87+
<a
88+
className="void-admin-deployment-link"
89+
href={`/admin/projects/${d.project_id}`}
90+
title={d.project_slug}
91+
>
92+
{d.project_slug}
93+
</a>
94+
) : (
95+
'-'
96+
),
97+
});
98+
}
99+
columns.push(
100+
{
101+
key: 'status',
102+
header: 'Status',
103+
width: pixel(88),
104+
renderCell: (d: DeploymentRow) => {
105+
const status = displayStatus(d, activeDeploymentId ?? d.active_deployment_id);
106+
return <span style={statusColor(status)}>{status}</span>;
107+
},
108+
},
109+
{
110+
key: 'source',
111+
header: 'Source',
112+
width: pixel(84),
113+
renderCell: (d: DeploymentRow) => d.source ?? '-',
114+
},
115+
{
116+
key: 'cli_version',
117+
header: 'CLI',
118+
width: pixel(64),
119+
renderCell: (d: DeploymentRow) => d.cli_version ?? '-',
120+
},
121+
{
122+
key: 'commit',
123+
header: 'Commit',
124+
width: pixel(90),
125+
renderCell: (d: DeploymentRow) => d.commit?.slice(0, 7) ?? '-',
126+
},
127+
{
128+
key: 'error_message',
129+
header: 'Error',
130+
width: proportional(1.8, { minWidth: 180 }),
131+
renderCell: (d: DeploymentRow) =>
132+
d.error_message ? (
133+
<div className="void-admin-deployment-error">
134+
<Text className="void-admin-deployment-error-message" maxLines={1}>
135+
{d.error_message}
136+
</Text>
137+
<CopyButton text={d.error_message} />
138+
</div>
139+
) : (
140+
'-'
141+
),
142+
},
143+
{
144+
key: 'created_at',
145+
header: 'Created',
146+
width: pixel(200),
147+
renderCell: (d: DeploymentRow) => formatDateTime(d.created_at, tz),
148+
},
149+
);
74150
return (
75-
<Table className="void-admin-deployments-table" hasHover>
76-
<TableHeader>
77-
<TableRow>
78-
<TableHeaderCell>ID</TableHeaderCell>
79-
{showProject && <TableHeaderCell>Project</TableHeaderCell>}
80-
<TableHeaderCell>Status</TableHeaderCell>
81-
<TableHeaderCell>Source</TableHeaderCell>
82-
<TableHeaderCell>CLI</TableHeaderCell>
83-
<TableHeaderCell>Commit</TableHeaderCell>
84-
<TableHeaderCell>Error</TableHeaderCell>
85-
<TableHeaderCell>Created</TableHeaderCell>
86-
</TableRow>
87-
</TableHeader>
88-
<TableBody>
89-
{deployments.map((d) => {
90-
const activeId = activeDeploymentId ?? d.active_deployment_id;
91-
const status = displayStatus(d, activeId);
92-
return (
93-
<TableRow key={d.id}>
94-
<TableCell>
95-
<a href={`/admin/deployments/${d.id}`}>{d.id}</a>
96-
</TableCell>
97-
{showProject && (
98-
<TableCell>
99-
{d.project_slug ? (
100-
<a href={`/admin/projects/${d.project_id}`}>{d.project_slug}</a>
101-
) : (
102-
'-'
103-
)}
104-
</TableCell>
105-
)}
106-
<TableCell>
107-
<span style={statusColor(status)}>{status}</span>
108-
</TableCell>
109-
<TableCell>{d.source ?? '-'}</TableCell>
110-
<TableCell>{d.cli_version ?? '-'}</TableCell>
111-
<TableCell>{d.commit ? d.commit.slice(0, 7) : '-'}</TableCell>
112-
<TableCell>
113-
{d.error_message ? (
114-
<>
115-
<span style="color: red; max-width: 400px; display: inline-block; word-break: break-word">
116-
{d.error_message}
117-
</span>
118-
<br />
119-
<span style="float: right; margin-top: 5px">
120-
<CopyButton text={d.error_message} />
121-
</span>
122-
</>
123-
) : (
124-
'-'
125-
)}
126-
</TableCell>
127-
<TableCell>{formatDateTime(d.created_at, tz)}</TableCell>
128-
</TableRow>
129-
);
130-
})}
131-
</TableBody>
132-
</Table>
151+
<Table
152+
className="void-admin-deployments-table"
153+
data={[...deployments]}
154+
columns={columns}
155+
textOverflow="truncate"
156+
hasHover
157+
/>
133158
);
134159
}

‎platform/packages/api/test/integration/admin-dashboard.test.ts‎

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,6 +1086,112 @@ describe('GET /admin/ (dashboard)', () => {
10861086
vi.restoreAllMocks();
10871087
});
10881088

1089+
test('keeps deployment columns readable and long errors compact across list views', async () => {
1090+
const admin = await createTestUser(
1091+
env.db,
1092+
'deployment-layout-admin',
1093+
'github',
1094+
undefined,
1095+
'free',
1096+
'admin',
1097+
);
1098+
const project = await createTestProject(
1099+
env.db,
1100+
admin.id,
1101+
'a-project-with-a-long-name-for-truncation',
1102+
);
1103+
const error = 'Worker upload failed: upstream rejected the deployment.\n'.repeat(20);
1104+
const failed = await createTestDeployment(env.db, project.id, 'failed', 'cli', error);
1105+
const client = await readFile(
1106+
new URL('../../dist/admin-assets/admin/client.js', import.meta.url),
1107+
);
1108+
const css = await readFile(new URL('../../dist/admin-assets/admin/style.css', import.meta.url));
1109+
const browser = await chromium.launch();
1110+
try {
1111+
for (const width of [1280, 390]) {
1112+
const context = await browser.newContext({ viewport: { width, height: 844 } });
1113+
await context.addCookies([
1114+
{ name: 'admin_token', value: admin.adminJwt, url: 'http://localhost' },
1115+
]);
1116+
await context.addInitScript(() => {
1117+
Object.defineProperty(navigator, 'clipboard', {
1118+
value: {
1119+
writeText: async (text: string) => {
1120+
(window as unknown as { copiedError: string }).copiedError = text;
1121+
},
1122+
},
1123+
});
1124+
});
1125+
const page = await context.newPage();
1126+
const errors: Array<string> = [];
1127+
page.on('pageerror', (error) => errors.push(error.message));
1128+
await page.route('**/*', async (route) => {
1129+
const incoming = route.request();
1130+
const url = new URL(incoming.url());
1131+
if (url.origin !== 'http://localhost') {
1132+
return route.abort();
1133+
}
1134+
if (url.pathname === '/admin/client.js' || url.pathname === '/admin/style.css') {
1135+
return route.fulfill({
1136+
contentType: url.pathname.endsWith('.js') ? 'text/javascript' : 'text/css',
1137+
body: url.pathname.endsWith('.js') ? client : css,
1138+
});
1139+
}
1140+
const response = await app.fetch(
1141+
new Request(incoming.url(), {
1142+
method: incoming.method(),
1143+
headers: await incoming.allHeaders(),
1144+
...(incoming.method() === 'POST' ? { body: incoming.postData() ?? '' } : {}),
1145+
}),
1146+
{ ...env, DEV_AUTH_BYPASS: 'true' },
1147+
);
1148+
await route.fulfill({
1149+
status: response.status,
1150+
headers: Object.fromEntries(response.headers),
1151+
body: Buffer.from(await response.arrayBuffer()),
1152+
});
1153+
});
1154+
for (const path of ['/admin/', '/admin/deployments', `/admin/projects/${project.id}`]) {
1155+
await page.goto(`http://localhost${path}`);
1156+
await page.locator('[data-hydrated="true"]').waitFor();
1157+
const table = page.locator('.void-admin-deployments-table');
1158+
const row = table
1159+
.getByRole('row')
1160+
.filter({ has: page.getByRole('link', { name: failed.id, exact: true }) });
1161+
expect((await row.boundingBox())!.height).toBeLessThan(55);
1162+
const columns = await table.locator('th').evaluateAll((headers) =>
1163+
headers.map((header) => ({
1164+
title: header.textContent,
1165+
width: header.getBoundingClientRect().width,
1166+
})),
1167+
);
1168+
expect(columns.find((column) => column.title === 'Created')!.width).toBeLessThan(
1169+
(await table.boundingBox())!.width / 3,
1170+
);
1171+
expect(columns.every((column) => column.width >= 64)).toBe(true);
1172+
const message = row.locator('.void-admin-deployment-error-message');
1173+
expect(await message.textContent()).toBe(error);
1174+
expect((await message.boundingBox())!.height).toBeLessThan(30);
1175+
await message.hover();
1176+
await page.getByRole('tooltip').filter({ hasText: 'Worker upload failed' }).waitFor();
1177+
await row.getByRole('button', { name: 'Copy', exact: true }).click();
1178+
await expect
1179+
.poll(() =>
1180+
page.evaluate(() => (window as unknown as { copiedError?: string }).copiedError),
1181+
)
1182+
.toBe(error);
1183+
expect(
1184+
await page.evaluate(() => document.documentElement.scrollWidth <= window.innerWidth),
1185+
).toBe(true);
1186+
}
1187+
expect(errors).toEqual([]);
1188+
await context.close();
1189+
}
1190+
} finally {
1191+
await browser.close();
1192+
}
1193+
}, 30_000);
1194+
10891195
test('does not query Analytics Engine during the initial dashboard render', async () => {
10901196
const admin = await createTestUser(
10911197
env.db,

0 commit comments

Comments
 (0)