Skip to content

Commit 491977d

Browse files
refactor: remove activity column from workspaces table (coder#19555)
Fixes coder#19504
1 parent 6c01a77 commit 491977d

File tree

2 files changed

+3
-123
lines changed

2 files changed

+3
-123
lines changed

site/src/pages/WorkspacesPage/WorkspacesPageView.stories.tsx

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@ import {
22
MockBuildInfo,
33
MockOrganization,
44
MockPendingProvisionerJob,
5-
MockStoppedWorkspace,
65
MockTemplate,
76
MockUserOwner,
87
MockWorkspace,
98
MockWorkspaceAgent,
10-
MockWorkspaceAppStatus,
119
mockApiError,
1210
} from "testHelpers/entities";
1311
import {
@@ -383,68 +381,3 @@ export const ShowOrganizations: Story = {
383381
expect(accessibleTableCell).toBeDefined();
384382
},
385383
};
386-
387-
export const WithLatestAppStatus: Story = {
388-
args: {
389-
workspaces: [
390-
{
391-
...MockWorkspace,
392-
name: "long-app-status",
393-
latest_app_status: {
394-
...MockWorkspaceAppStatus,
395-
message:
396-
"This is a long message that will wrap around the component. It should wrap many times because this is very very very very very long.",
397-
},
398-
},
399-
{
400-
...MockWorkspace,
401-
name: "no-app-status",
402-
latest_app_status: null,
403-
},
404-
{
405-
...MockWorkspace,
406-
name: "app-status-working",
407-
latest_app_status: {
408-
...MockWorkspaceAppStatus,
409-
state: "working",
410-
message: "Fixing the competitors page...",
411-
},
412-
},
413-
{
414-
...MockWorkspace,
415-
name: "app-status-failure",
416-
latest_app_status: {
417-
...MockWorkspaceAppStatus,
418-
state: "failure",
419-
message: "I couldn't figure it out...",
420-
},
421-
},
422-
{
423-
...{
424-
...MockStoppedWorkspace,
425-
latest_build: {
426-
...MockStoppedWorkspace.latest_build,
427-
resources: [],
428-
},
429-
},
430-
name: "stopped-app-status-failure",
431-
latest_app_status: {
432-
...MockWorkspaceAppStatus,
433-
state: "failure",
434-
message: "I couldn't figure it out...",
435-
uri: "",
436-
},
437-
},
438-
{
439-
...MockWorkspace,
440-
name: "app-status-working-with-uri",
441-
latest_app_status: {
442-
...MockWorkspaceAppStatus,
443-
state: "working",
444-
message: "Updating the README...",
445-
uri: "file:///home/coder/projects/coder/coder/README.md",
446-
},
447-
},
448-
],
449-
},
450-
};

site/src/pages/WorkspacesPage/WorkspacesTable.tsx

Lines changed: 3 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ import {
6464
import { useAppLink } from "modules/apps/useAppLink";
6565
import { useDashboard } from "modules/dashboard/useDashboard";
6666
import { abilitiesByWorkspaceStatus } from "modules/workspaces/actions";
67-
import { WorkspaceAppStatus } from "modules/workspaces/WorkspaceAppStatus/WorkspaceAppStatus";
6867
import { WorkspaceBuildCancelDialog } from "modules/workspaces/WorkspaceBuildCancelDialog/WorkspaceBuildCancelDialog";
6968
import { WorkspaceDormantBadge } from "modules/workspaces/WorkspaceDormantBadge/WorkspaceDormantBadge";
7069
import { WorkspaceMoreActions } from "modules/workspaces/WorkspaceMoreActions/WorkspaceMoreActions";
@@ -79,7 +78,6 @@ import {
7978
type FC,
8079
type PropsWithChildren,
8180
type ReactNode,
82-
useMemo,
8381
useState,
8482
} from "react";
8583
import { useMutation, useQuery, useQueryClient } from "react-query";
@@ -116,51 +114,12 @@ export const WorkspacesTable: FC<WorkspacesTableProps> = ({
116114
onActionError,
117115
}) => {
118116
const dashboard = useDashboard();
119-
const workspaceIDToAppByStatus = useMemo(() => {
120-
return (
121-
workspaces?.reduce(
122-
(acc, workspace) => {
123-
if (!workspace.latest_app_status) {
124-
return acc;
125-
}
126-
for (const resource of workspace.latest_build.resources) {
127-
for (const agent of resource.agents ?? []) {
128-
for (const app of agent.apps ?? []) {
129-
if (app.id === workspace.latest_app_status.app_id) {
130-
acc[workspace.id] = { app, agent };
131-
break;
132-
}
133-
}
134-
}
135-
}
136-
return acc;
137-
},
138-
{} as Record<
139-
string,
140-
{
141-
app: WorkspaceApp;
142-
agent: WorkspaceAgent;
143-
}
144-
>,
145-
) || {}
146-
);
147-
}, [workspaces]);
148-
const hasActivity = useMemo(
149-
() => Object.keys(workspaceIDToAppByStatus).length > 0,
150-
[workspaceIDToAppByStatus],
151-
);
152-
const tableColumnSize = {
153-
name: "w-2/6",
154-
template: hasActivity ? "w-1/6" : "w-2/6",
155-
status: hasActivity ? "w-1/6" : "w-2/6",
156-
activity: "w-2/6",
157-
};
158117

159118
return (
160119
<Table>
161120
<TableHeader>
162121
<TableRow>
163-
<TableHead className={tableColumnSize.name}>
122+
<TableHead className="w-1/3">
164123
<div className="flex items-center gap-2">
165124
{canCheckWorkspaces && (
166125
<Checkbox
@@ -184,11 +143,8 @@ export const WorkspacesTable: FC<WorkspacesTableProps> = ({
184143
Name
185144
</div>
186145
</TableHead>
187-
<TableHead className={tableColumnSize.template}>Template</TableHead>
188-
<TableHead className={tableColumnSize.status}>Status</TableHead>
189-
{hasActivity && (
190-
<TableHead className={tableColumnSize.activity}>Activity</TableHead>
191-
)}
146+
<TableHead className="w-1/3">Template</TableHead>
147+
<TableHead className="w-1/3">Status</TableHead>
192148
<TableHead className="w-0">
193149
<span className="sr-only">Actions</span>
194150
</TableHead>
@@ -302,15 +258,6 @@ export const WorkspacesTable: FC<WorkspacesTableProps> = ({
302258

303259
<WorkspaceStatusCell workspace={workspace} />
304260

305-
{hasActivity && (
306-
<TableCell>
307-
<WorkspaceAppStatus
308-
status={workspace.latest_app_status}
309-
disabled={workspace.latest_build.status !== "running"}
310-
/>
311-
</TableCell>
312-
)}
313-
314261
<WorkspaceActionsCell
315262
workspace={workspace}
316263
onActionSuccess={onActionSuccess}

0 commit comments

Comments
 (0)