8000 feat: Make workspace timeline rows obviously clickable by AbhineetJain · Pull Request #2047 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

feat: Make workspace timeline rows obviously clickable #2047

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
23 changes: 21 additions & 2 deletions site/src/components/BuildsTable/BuildsTable.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import Box from "@material-ui/core/Box"
import { makeStyles, Theme } from "@material-ui/core/styles"
import { fade, makeStyles, Theme } from "@material-ui/core/styles"
import Table from "@material-ui/core/Table"
import TableBody from "@material-ui/core/TableBody"
import TableCell from "@material-ui/core/TableCell"
import TableHead from "@material-ui/core/TableHead"
import TableRow from "@material-ui/core/TableRow"
import KeyboardArrowRight from "@material-ui/icons/KeyboardArrowRight"
import useTheme from "@material-ui/styles/useTheme"
import { FC } from "react"
import { useNavigate } from "react-router-dom"
Expand Down Expand Up @@ -41,6 +42,7 @@ export const BuildsTable: FC<BuildsTableProps> = ({ builds, className }) => {
<TableCell width="20%">{Language.durationLabel}</TableCell>
<TableCell width="40%">{Language.startedAtLabel}</TableCell>
<TableCell width="20%">{Language.statusLabel}</TableCell>
<TableCell></TableCell>
</TableRow>
</TableHead>
<TableBody>
Expand Down Expand Up @@ -79,6 +81,11 @@ export const BuildsTable: FC<BuildsTableProps> = ({ builds, className }) => {
<TableCell>
<span style={{ color: status.color }}>{status.status}</span>
</TableCell>
<TableCell>
<div className={styles.arrowCell}>
<KeyboardArrowRight className={styles.arrowRight} />
</div>
</TableCell>
</TableRow>
)
})}
Expand All @@ -102,11 +109,23 @@ const useStyles = makeStyles((theme) => ({
cursor: "pointer",

"&:hover td": {
backgroundColor: theme.palette.background.default,
backgroundColor: fade(theme.palette.primary.light, 0.1),
},

"&:focus": {
outline: `1px solid ${theme.palette.secondary.dark}`,
},

"& .MuiTableCell-root:last-child": {
paddingRight: theme.spacing(2),
},
},
arrowRight: {
color: fade(theme.palette.primary.contrastText, 0.7),
width: 20,
height: 20,
},
arrowCell: {
display: "flex",
},
}))
74 changes: 60 additions & 14 deletions site/src/pages/TemplatesPage/TemplatesPageView.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import Link from "@material-ui/core/Link"
import { makeStyles } from "@material-ui/core/styles"
import { fade, makeStyles } from "@material-ui/core/styles"
import Table from "@material-ui/core/Table"
import TableBody from "@material-ui/core/TableBody"
import TableCell from "@material-ui/core/TableCell"
import TableHead from "@material-ui/core/TableHead"
import TableRow from "@material-ui/core/TableRow"
import KeyboardArrowRight from "@material-ui/icons/KeyboardArrowRight"
import dayjs from "dayjs"
import relativeTime from "dayjs/plugin/relativeTime"
import { FC } from "react"
import { useNavigate } from "react-router-dom"
import * as TypesGen from "../../api/typesGenerated"
import { AvatarData } from "../../components/AvatarData/AvatarData"
import { CodeExample } from "../../components/CodeExample/CodeExample"
Expand Down Expand Up @@ -71,6 +73,8 @@ export interface TemplatesPageViewProps {

export const TemplatesPageView: FC<TemplatesPageViewProps> = (props) => {
const styles = useStyles()
const navigate = useNavigate()

return (
<Margins>
<PageHeader>
Expand All @@ -88,6 +92,7 @@ export const TemplatesPageView: FC<TemplatesPageViewProps> = (props) => {
<TableCell>{Language.nameLabel}</TableCell>
<TableCell>{Language.usedByLabel}</TableCell>
<TableCell>{Language.lastUpdatedLabel}</TableCell>
<TableCell width="1%"></TableCell>
</TableRow>
</TableHead>
<TableBody>
Expand All @@ -104,21 +109,39 @@ export const TemplatesPageView: FC<TemplatesPageViewProps> = (props) => {
</TableCell>
</TableRow>
)}
{props.templates?.map((template) => (
<TableRow key={template.id}>
<TableCell>
<AvatarData
title={template.name}
subtitle={template.description}
link={`/templates/${template.name}`}
/>
</TableCell>
{props.templates?.map((template) => {
const navigateToTemplatePage = () => {
navigate(`/templates/${template.name}`)
}
return (
<TableRow
key={template.id}
hover
data-testid={`template-${template.id}`}
tabIndex={0}
onClick={navigateToTemplatePage}
onKeyDown={(event) => {
if (event.key === "Enter") {
navigateToTemplatePage()
}
}}
className={styles.clickableTableRow}
>
<TableCell>
<AvatarData title={template.name} subtitle={template.description} />
</TableCell>

<TableCell>{Language.developerCount(template.workspace_owner_count)}</TableCell>
<TableCell>{Language.developerCount(template.workspace_owner_count)}</TableCell>

<TableCell data-chromatic="ignore">{dayjs().to(dayjs(template.updated_at))}</TableCell>
</TableRow>
))}
<TableCell data-chromatic="ignore">{dayjs().to(dayjs(template.updated_at))}</TableCell>
<TableCell>
<div className={styles.arrowCell}>
<KeyboardArrowRight className={styles.arrowRight} />
</div>
</TableCell>
</TableRow>
)
})}
</TableBody>
</Table>
</Margins>
Expand All @@ -129,4 +152,27 @@ const useStyles = makeStyles((theme) => ({
emptyDescription: {
maxWidth: theme.spacing(62),
},
clickableTableRow: {
cursor: "pointer",

"&:hover td": {
backgroundColor: fade(theme.palette.primary.light, 0.1),
},

"&:focus": {
outline: `1px solid ${theme.palette.secondary.dark}`,
},

"& .MuiTableCell-root:last-child": {
paddingRight: theme.spacing(2),
},
},
arrowRight: {
color: fade(theme.palette.primary.contrastText, 0.7),
width: 20,
height: 20,
},
arrowCell: {
display: "flex",
},
}))
58 changes: 50 additions & 8 deletions site/src/pages/WorkspacesPage/WorkspacesPageView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,22 @@ import InputAdornment from "@material-ui/core/InputAdornment"
import Link from "@material-ui/core/Link"
import Menu from "@material-ui/core/Menu"
import MenuItem from "@material-ui/core/MenuItem"
import { makeStyles, Theme } from "@material-ui/core/styles"
import { fade, makeStyles, Theme } from "@material-ui/core/styles"
import Table from "@material-ui/core/Table"
import TableBody from "@material-ui/core/TableBody"
import TableCell from "@material-ui/core/TableCell"
import TableHead from "@material-ui/core/TableHead"
import TableRow from "@material-ui/core/TableRow"
import TextField from "@material-ui/core/TextField"
import AddCircleOutline from "@material-ui/icons/AddCircleOutline"
import KeyboardArrowRight from "@material-ui/icons/KeyboardArrowRight"
import SearchIcon from "@material-ui/icons/Search"
import useTheme from "@material-ui/styles/useTheme"
import dayjs from "dayjs"
import relativeTime from "dayjs/plugin/relativeTime"
import { FormikErrors, useFormik } from "formik"
import { FC, useState } from "react"
import { Link as RouterLink } from "react-router-dom"
import { Link as RouterLink, useNavigate } from "react-router-dom"
import * as TypesGen from "../../api/typesGenerated"
import { AvatarData } from "../../components/AvatarData/AvatarData"
import { CloseDropdown, OpenDropdown } from "../../components/DropdownArrows/DropdownArrows"
Expand Down Expand Up @@ -90,6 +91,7 @@ export interface WorkspacesPageViewProps {

export const WorkspacesPageView: FC<WorkspacesPageViewProps> = ({ loading, workspaces, filter, onFilter }) => {
const styles = useStyles()
const navigate = useNavigate()
const theme: Theme = useTheme()

const form = useFormik<FilterFormValues>({
Expand Down Expand Up @@ -195,6 +197,7 @@ export const WorkspacesPageView: FC<WorkspacesPageViewProps> = ({ loading, works
<TableCell>Version</TableCell>
<TableCell>Last Built</TableCell>
<TableCell>Status</TableCell>
<TableCell width="1%"></TableCell>
</TableRow>
</TableHead>
<TableBody>
Expand All @@ -217,14 +220,25 @@ export const WorkspacesPageView: FC<WorkspacesPageViewProps> = ({ loading, works
{workspaces &&
workspaces.map((workspace) => {
const status = getDisplayStatus(theme, workspace.latest_build)
const navigateToWorkspacePage = () => {
navigate(`/@${workspace.owner_name}/${workspace.name}`)
}
return (
<TableRow key={workspace.id}>
<TableRow
key={workspace.id}
hover
data-testid={`workspace-${workspace.id}`}
tabIndex={0}
onClick={navigateToWorkspacePage}
onKeyDown={(event) => {
if (event.key === "Enter") {
navigateToWorkspacePage()
}
}}
className={styles.clickableTableRow}
>
<TableCell>
<AvatarData
title={workspace.name}
subtitle={workspace.owner_name}
link={`/@${workspace.owner_name}/${workspace.name}`}
/>
<AvatarData title={workspace.name} subtitle={workspace.owner_name} />
</TableCell>
<TableCell>{workspace.template_name}</TableCell>
<TableCell>
Expand All @@ -242,6 +256,11 @@ export const WorkspacesPageView: FC<WorkspacesPageViewProps> = ({ loading, works
<TableCell>
<span style={{ color: status.color }}>{status.status}</span>
</TableCell>
<TableCell>
<div className={styles.arrowCell}>
<KeyboardArrowRight className={styles.arrowRight} />
</div>
</TableCell>
</TableRow>
)
})}
Expand Down Expand Up @@ -286,4 +305,27 @@ const useStyles = makeStyles((theme) => ({
border: "none",
},
},
clickableTableRow: {
cursor: "pointer",

"&:hover td": {
backgroundColor: fade(theme.palette.primary.light, 0.1),
},

"&:focus": {
outline: `1px solid ${theme.palette.secondary.dark}`,
},

"& .MuiTableCell-root:last-child": {
paddingRight: theme.spacing(2),
},
},
arrowRight: {
color: fade(theme.palette.primary.contrastText, 0.7),
width: 20,
height: 20,
},
arrowCell: {
display: "flex",
},
}))
0