Skip to content

Commit f1f43d0

Browse files
committed
Apply PR comments
1 parent c693ebf commit f1f43d0

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

site/src/pages/WorkspacesPage/WorkspacesTable.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import { type FC, type ReactNode, useMemo } from "react";
4141
import { useNavigate } from "react-router-dom";
4242
import { cn } from "utils/cn";
4343
import {
44-
type GetWorkspaceDisplayStatusType,
44+
type DisplayWorkspaceStatusType,
4545
getDisplayWorkspaceStatus,
4646
getDisplayWorkspaceTemplateName,
4747
lastUsedMessage,
@@ -338,7 +338,7 @@ const TableLoader: FC<TableLoaderProps> = ({ canCheckWorkspaces }) => {
338338
<AvatarDataSkeleton />
339339
</TableCell>
340340
<TableCell className="w-2/6">
341-
<Skeleton variant="text" width="75%" />
341+
<Skeleton variant="text" width="50%" />
342342
</TableCell>
343343
<TableCell className="w-0">
344344
<Skeleton variant="text" width="25%" />
@@ -357,14 +357,15 @@ type WorkspaceStatusCellProps = {
357357
};
358358

359359
const variantByStatusType: Record<
360-
GetWorkspaceDisplayStatusType,
360+
DisplayWorkspaceStatusType,
361361
StatusIndicatorProps["variant"]
362362
> = {
363363
active: "pending",
364364
inactive: "inactive",
365365
success: "success",
366366
error: "failed",
367367
danger: "warning",
368+
warning: "warning",
368369
};
369370

370371
const WorkspaceStatusCell: FC<WorkspaceStatusCellProps> = ({ workspace }) => {

site/src/utils/workspace.tsx

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,24 @@ export const getDisplayWorkspaceTemplateName = (
168168
: workspace.template_name;
169169
};
170170

171+
export type DisplayWorkspaceStatusType =
172+
| "success"
173+
| "active"
174+
| "inactive"
175+
| "error"
176+
| "warning"
177+
| "danger";
178+
179+
type DisplayWorkspaceStatus = {
180+
text: string;
181+
type: DisplayWorkspaceStatusType;
182+
icon: React.ReactNode;
183+
};
184+
171185
export const getDisplayWorkspaceStatus = (
172186
workspaceStatus: TypesGen.WorkspaceStatus,
173187
provisionerJob?: TypesGen.ProvisionerJob,
174-
) => {
188+
): DisplayWorkspaceStatus => {
175189
switch (workspaceStatus) {
176190
case undefined:
177191
return {
@@ -242,10 +256,6 @@ export const getDisplayWorkspaceStatus = (
242256
}
243257
};
244258

245-
export type GetWorkspaceDisplayStatusType = ReturnType<
246-
typeof getDisplayWorkspaceStatus
247-
>["type"];
248-
249259
export const hasJobError = (workspace: TypesGen.Workspace) => {
250260
return workspace.latest_build.job.error !== undefined;
251261
};
@@ -313,7 +323,7 @@ export const getResourceIconPath = (resourceType: string): string => {
313323
return BUILT_IN_ICON_PATHS[resourceType] ?? FALLBACK_ICON;
314324
};
315325

316-
export const lastUsedMessage = (lastUsedAt: string | Date) => {
326+
export const lastUsedMessage = (lastUsedAt: string | Date): string => {
317327
const t = dayjs(lastUsedAt);
318328
const now = dayjs();
319329
let message = t.fromNow();

0 commit comments

Comments
 (0)