diff --git a/site/src/components/Checkbox/Checkbox.tsx b/site/src/components/Checkbox/Checkbox.tsx index ac757952f6..0f8dee083b 100644 --- a/site/src/components/Checkbox/Checkbox.tsx +++ b/site/src/components/Checkbox/Checkbox.tsx @@ -17,7 +17,7 @@ export const Checkbox = React.forwardRef< = ({ -
+
{canCheckTasks && ( 0 && checkedTaskIds.size === tasks.length } - size="xsmall" - onChange={(_, checked) => { + onCheckedChange={(checked) => { if (!tasks || !onCheckChange) { return; } @@ -209,17 +207,16 @@ const TaskRow: FC = ({ {...clickableRowProps} > -
+
{canCheck && ( { e.stopPropagation(); }} - onChange={(e) => { - onCheckChange(task.id, e.currentTarget.checked); + onCheckedChange={(checked) => { + onCheckChange(task.id, Boolean(checked)); }} aria-label={`Select task ${task.initial_prompt}`} /> @@ -320,8 +317,8 @@ const TasksSkeleton: FC = ({ canCheckTasks }) => { -
- {canCheckTasks && } +
+ {canCheckTasks && }
diff --git a/site/src/pages/WorkspacesPage/WorkspacesPage.test.tsx b/site/src/pages/WorkspacesPage/WorkspacesPage.test.tsx index df7587fe85..a415d86e8c 100644 --- a/site/src/pages/WorkspacesPage/WorkspacesPage.test.tsx +++ b/site/src/pages/WorkspacesPage/WorkspacesPage.test.tsx @@ -360,9 +360,7 @@ describe("WorkspacesPage", () => { }); const getWorkspaceCheckbox = (workspace: Workspace) => { - return within(screen.getByTestId(`checkbox-${workspace.id}`)).getByRole( - "checkbox", - ); + return screen.getByTestId(`checkbox-${workspace.id}`); }; describe("WorkspaceApps filtering", () => { diff --git a/site/src/pages/WorkspacesPage/WorkspacesPageView.stories.tsx b/site/src/pages/WorkspacesPage/WorkspacesPageView.stories.tsx index 13f075efb6..ddab6b94ab 100644 --- a/site/src/pages/WorkspacesPage/WorkspacesPageView.stories.tsx +++ b/site/src/pages/WorkspacesPage/WorkspacesPageView.stories.tsx @@ -397,3 +397,12 @@ export const ShowWorkspaceTasks: Story = { ], }, }; + +export const WithCheckedWorkspaces: Story = { + args: { + workspaces: allWorkspaces.slice(0, 5), + checkedWorkspaces: allWorkspaces.slice(0, 2), + canCheckWorkspaces: true, + count: 5, + }, +}; diff --git a/site/src/pages/WorkspacesPage/WorkspacesTable.tsx b/site/src/pages/WorkspacesPage/WorkspacesTable.tsx index 991b259329..50dcc8d01d 100644 --- a/site/src/pages/WorkspacesPage/WorkspacesTable.tsx +++ b/site/src/pages/WorkspacesPage/WorkspacesTable.tsx @@ -1,4 +1,3 @@ -import Checkbox from "@mui/material/Checkbox"; import Skeleton from "@mui/material/Skeleton"; import { templateVersion } from "api/queries/templates"; import { apiKey } from "api/queries/users"; @@ -19,6 +18,7 @@ import { AvatarData } from "components/Avatar/AvatarData"; import { AvatarDataSkeleton } from "components/Avatar/AvatarDataSkeleton"; import { Badge } from "components/Badge/Badge"; import { Button } from "components/Button/Button"; +import { Checkbox } from "components/Checkbox/Checkbox"; import { ConfirmDialog } from "components/Dialogs/ConfirmDialog/ConfirmDialog"; import { ExternalImage } from "components/ExternalImage/ExternalImage"; import { VSCodeIcon } from "components/Icons/VSCodeIcon"; @@ -117,14 +117,16 @@ export const WorkspacesTable: FC = ({ -
+
{canCheckWorkspaces && ( { + checked={ + workspaces && + workspaces.length > 0 && + checkedWorkspaces.length === workspaces.length + } + onCheckedChange={(checked) => { if (!workspaces) { return; } @@ -135,6 +137,7 @@ export const WorkspacesTable: FC = ({ onCheckChange(workspaces); } }} + aria-label="Select all workspaces" /> )} Name @@ -173,18 +176,17 @@ export const WorkspacesTable: FC = ({ checked={checked} > -
+
{canCheckWorkspaces && ( { e.stopPropagation(); }} - onChange={(e) => { - if (e.currentTarget.checked) { + onCheckedChange={(checked) => { + if (checked) { onCheckChange([...checkedWorkspaces, workspace]); } else { onCheckChange( @@ -194,6 +196,7 @@ export const WorkspacesTable: FC = ({ ); } }} + aria-label={`Select workspace ${workspace.name}`} /> )} = ({ canCheckWorkspaces }) => { -
- {canCheckWorkspaces && } +
+ {canCheckWorkspaces && }