Skip to content
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
Next Next commit
feat: show last build initiator for workspaces
  • Loading branch information
AbhineetJain committed Jul 12, 2022
commit 2d87c2355fa7b3cccca8f612f734ef918416a4e0
15 changes: 13 additions & 2 deletions site/src/components/WorkspaceStats/WorkspaceStats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Link as RouterLink } from "react-router-dom"
import { Workspace } from "../../api/typesGenerated"
import { CardRadius, MONOSPACE_FONT_FAMILY } from "../../theme/constants"
import { combineClasses } from "../../util/combineClasses"
import { getDisplayStatus } from "../../util/workspace"
import { getDisplayStatus, getDisplayWorkspaceBuildInitiatedBy } from "../../util/workspace"
import { WorkspaceSection } from "../WorkspaceSection/WorkspaceSection"

const Language = {
Expand All @@ -17,6 +17,7 @@ const Language = {
lastBuiltLabel: "Last Built",
outdated: "Outdated",
upToDate: "Up to date",
byLabel: "Last Built by",
}

export interface WorkspaceStatsProps {
Expand All @@ -27,6 +28,7 @@ export const WorkspaceStats: FC<WorkspaceStatsProps> = ({ workspace }) => {
const styles = useStyles()
const theme = useTheme()
const status = getDisplayStatus(theme, workspace.latest_build)
const initiatedBy = getDisplayWorkspaceBuildInitiatedBy(theme, workspace.latest_build)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this function unit tested?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch. Adding them now!


return (
<WorkspaceSection title={Language.workspaceDetails} contentsProps={{ className: styles.stats }}>
Expand Down Expand Up @@ -59,6 +61,15 @@ export const WorkspaceStats: FC<WorkspaceStatsProps> = ({ workspace }) => {
</span>
</div>
<div className={styles.statsDivider} />
<div className={styles.statItem}>
<span className={styles.statsLabel}>{Language.byLabel}</span>
<span className={styles.statsValue}>
<span style={{ color: initiatedBy.color }}>
{initiatedBy.initiatedBy}
</span>
</span>
</div>
<div className={styles.statsDivider} />
<div className={styles.statItem}>
<span className={styles.statsLabel}>{Language.statusLabel}</span>
<span className={styles.statsValue}>
Expand Down Expand Up @@ -88,7 +99,7 @@ const useStyles = makeStyles((theme) => ({
},

statItem: {
minWidth: "20%",
minWidth: "16%",
padding: theme.spacing(2),
paddingTop: theme.spacing(1.75),
},
Expand Down
6 changes: 5 additions & 1 deletion site/src/components/WorkspacesTable/WorkspacesRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import dayjs from "dayjs"
import relativeTime from "dayjs/plugin/relativeTime"
import { FC } from "react"
import { useNavigate } from "react-router-dom"
import { getDisplayStatus } from "../../util/workspace"
import { getDisplayStatus, getDisplayWorkspaceBuildInitiatedBy } from "../../util/workspace"
import { WorkspaceItemMachineRef } from "../../xServices/workspaces/workspacesXService"
import { AvatarData } from "../AvatarData/AvatarData"
import { TableCellLink } from "../TableCellLink/TableCellLink"
Expand All @@ -27,6 +27,7 @@ export const WorkspacesRow: FC<{ workspaceRef: WorkspaceItemMachineRef }> = ({ w
const [workspaceState, send] = useActor(workspaceRef)
const { data: workspace } = workspaceState.context
const status = getDisplayStatus(theme, workspace.latest_build)
const initiatedBy = getDisplayWorkspaceBuildInitiatedBy(theme, workspace.latest_build)
const workspacePageLink = `/@${workspace.owner_name}/${workspace.name}`

return (
Expand Down Expand Up @@ -64,6 +65,9 @@ export const WorkspacesRow: FC<{ workspaceRef: WorkspaceItemMachineRef }> = ({ w
{dayjs().to(dayjs(workspace.latest_build.created_at))}
</span>
</TableCellLink>
<TableCellLink to={workspacePageLink}>
<span style={{ color: initiatedBy.color }}>{initiatedBy.initiatedBy}</span>
</TableCellLink>
<TableCellLink to={workspacePageLink}>
<span style={{ color: status.color }}>{status.status}</span>
</TableCellLink>
Expand Down
8 changes: 5 additions & 3 deletions site/src/components/WorkspacesTable/WorkspacesTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const Language = {
version: "Version",
lastBuilt: "Last Built",
status: "Status",
lastBuiltBy: "By",
}

export interface WorkspacesTableProps {
Expand All @@ -26,10 +27,11 @@ export const WorkspacesTable: FC<WorkspacesTableProps> = ({ isLoading, workspace
<Table>
<TableHead>
<TableRow>
<TableCell width="35%">{Language.name}</TableCell>
<TableCell width="30%">{Language.name}</TableCell>
<TableCell width="15%">{Language.template}</TableCell>
<TableCell width="15%">{Language.version}</TableCell>
<TableCell width="20%">{Language.lastBuilt}</TableCell>
<TableCell width="10%">{Language.version}</TableCell>
<TableCell width="15%">{Language.lastBuilt}</TableCell>
<TableCell width="15%">{Language.lastBuiltBy}</TableCell>
<TableCell width="15%">{Language.status}</TableCell>
<TableCell width="1%"></TableCell>
</TableRow>
Expand Down