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 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
Add clickable rows to template and workspace list
  • Loading branch information
AbhineetJain committed Jun 7, 2022
commit 9f3bd50a90d1772a922db5e58b527c4446a33838
10 changes: 6 additions & 4 deletions site/src/components/BuildsTable/BuildsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,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 @@ -78,8 +79,10 @@ export const BuildsTable: FC<BuildsTableProps> = ({ builds, className }) => {
</span>
</TableCell>
<TableCell>
<div className={styles.statusCell}>
<span style={{ color: status.color }}>{status.status}</span>
<span style={{ color: status.color }}>{status.status}</span>
</TableCell>
<TableCell>
<div className={styles.arrowCell}>
<KeyboardArrowRight className={styles.arrowRight} />
</div>
</TableCell>
Expand Down Expand Up @@ -122,8 +125,7 @@ const useStyles = makeStyles((theme) => ({
width: 20,
height: 20,
},
statusCell: {
arrowCell: {
display: "flex",
justifyContent: "space-between",
},
}))
80 changes: 63 additions & 17 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 @@ -85,9 +89,10 @@ export const TemplatesPageView: FC<TemplatesPageViewProps> = (props) => {
<Table>
<TableHead>
<TableRow>
<TableCell>{Language.nameLabel}</TableCell>
<TableCell>{Language.usedByLabel}</TableCell>
<TableCell>{Language.lastUpdatedLabel}</TableCell>
<TableCell width="33%">{Language.nameLabel}</TableCell>
<TableCell width="33%">{Language.usedByLabel}</TableCell>
<TableCell width="33%">{Language.lastUpdatedLabel}</TableCell>
<TableCell></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",
},
}))
68 changes: 55 additions & 13 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 @@ -190,11 +192,12 @@ export const WorkspacesPageView: FC<WorkspacesPageViewProps> = ({ loading, works
<Table>
<TableHead>
<TableRow>
<TableCell>Name</TableCell>
<TableCell>Template</TableCell>
<TableCell>Version</TableCell>
<TableCell>Last Built</TableCell>
<TableCell>Status</TableCell>
<TableCell width="20%">Name</TableCell>
<TableCell width="20%">Template</TableCell>
<TableCell width="20%">Version</TableCell>
<TableCell width="20%">Last Built</TableCell>
<TableCell width="20%">Status</TableCell>
<TableCell></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",
},
}))