Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: add middle-click and cmd-click support for rows
  • Loading branch information
Parkreiner committed Sep 22, 2023
commit 65355457e4fd5c62801fc278cb0ada3b1394a4e2
24 changes: 21 additions & 3 deletions site/src/pages/WorkspacesPage/WorkspacesTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -250,15 +250,33 @@ const WorkspacesRow: FC<{
checked: boolean;
}> = ({ workspace, children, checked }) => {
const navigate = useNavigate();

const workspacePageLink = `/@${workspace.owner_name}/${workspace.name}`;
const clickable = useClickableTableRow(() => {
navigate(workspacePageLink);
const openLinkInNewTab = () => window.open(workspacePageLink, "_blank");

const clickableProps = useClickableTableRow({
onAuxClick: (event) => {
const userClickedMiddleButton = event.button === 1;
if (userClickedMiddleButton) {
openLinkInNewTab();
}
},
onClick: (event) => {
const shouldOpenInNewTab =
event.ctrlKey || event.shiftKey || event.metaKey;

if (shouldOpenInNewTab) {
openLinkInNewTab();
} else {
navigate(workspacePageLink);
}
},
});

return (
<TableRow
{...clickableProps}
data-testid={`workspace-${workspace.id}`}
{...clickable}
sx={{
backgroundColor: (theme) =>
checked ? theme.palette.action.hover : undefined,
Expand Down