8000 feat: resources card by presleyp · Pull Request #1627 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

feat: resources card #1627

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 17 commits into from
May 20, 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
Next Next commit
Set up table
  • Loading branch information
presleyp committed May 18, 2022
commit 448070bcc25252edf53acb8d67efe95be72e469a
60 changes: 60 additions & 0 deletions site/src/components/Resources/Resources.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
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 React from "react"
import { WorkspaceResource } from "../../api/typesGenerated"
import { TableHeaderRow } from "../TableHeaders/TableHeaders"
import { WorkspaceSection } from "../WorkspaceSection/WorkspaceSection"

const Language = {
resources: "Resources",
resourceLabel: "Resource",
agentsLabel: "Agents",
agentLabel: "Agent",
statusLabel: "Status",
}

interface ResourcesProps {
resources?: WorkspaceResource[]
}

export const Resources: React.FC<ResourcesProps> = ({ resources }) => {
return <WorkspaceSection title={Language.resources}>
<Table>
<TableHead>
<TableHeaderRow>
<TableCell size="small">{Language.resourceLabel}</TableCell>
<TableCell size="small">{Language.agentsLabel}</TableCell>
</TableHeaderRow>
</TableHead>
<TableBody>
{resources?.map((resource) => (
<TableRow key={resource.id}>
<TableCell size="small">{resource.name}</TableCell>
<TableCell>
<Table>
<TableHead>
<TableHeaderRow>
<TableCell size="small">{Language.agentLabel}</TableCell>
<TableCell size="small">{Language.statusLabel}</TableCell>
</TableHeaderRow>
</TableHead>
<TableBody>
{resource.agents?.map((agent) => (
<TableRow key={agent.id}>
<TableCell size="small">{agent.name}</TableCell>
<TableCell size="small">{agent.status}</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</TableCell>
</TableRow>
))}
</TableBody>

</Table>
</WorkspaceSection>
}
3 changes: 2 additions & 1 deletion site/src/components/Workspace/Workspace.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { action } from "@storybook/addon-actions"
import { Story } from "@storybook/react"
import React from "react"
import { MockOrganization, MockOutdatedWorkspace, MockTemplate, MockWorkspace } from "../../testHelpers/renderHelpers"
import { MockOrganization, MockOutdatedWorkspace, MockTemplate, MockWorkspace, MockWorkspaceResource } from "../../testHelpers/renderHelpers"
import { Workspace, WorkspaceProps } from "./Workspace"

export default {
Expand All @@ -21,6 +21,7 @@ Started.args = {
handleStop: action("stop"),
handleRetry: action("retry"),
workspaceStatus: "started",
resources: [MockWorkspaceResource, MockWorkspaceResource]
}

export const Starting = Template.bind({})
Expand Down
7 changes: 4 additions & 3 deletions site/src/components/Workspace/Workspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Typography from "@material-ui/core/Typography"
import React from "react"
import * as TypesGen from "../../api/typesGenerated"
import { WorkspaceStatus } from "../../pages/WorkspacePage/WorkspacePage"
import { Resources } from "../Resources/Resources"
import { WorkspaceSchedule } from "../WorkspaceSchedule/WorkspaceSchedule"
import { WorkspaceSection } from "../WorkspaceSection/WorkspaceSection"
import { WorkspaceStatusBar } from "../WorkspaceStatusBar/WorkspaceStatusBar"
Expand All @@ -16,6 +17,7 @@ export interface WorkspaceProps {
handleRetry: () => void
handleUpdate: () => void
workspaceStatus: WorkspaceStatus
resources?: TypesGen.WorkspaceResource[]
}

/**
Expand All @@ -30,6 +32,7 @@ export const Workspace: React.FC<WorkspaceProps> = ({
handleRetry,
handleUpdate,
workspaceStatus,
resources
}) => {
const styles = useStyles()

Expand All @@ -46,6 +49,7 @@ export const Workspace: React.FC<WorkspaceProps> = ({
handleUpdate={handleUpdate}
workspaceStatus={workspaceStatus}
/>
<Resources resources={resources} />
<div className={styles.horizontal}>
<div className={styles.sidebarContainer}>
<WorkspaceSection title="Applications">
Expand All @@ -55,9 +59,6 @@ export const Workspace: React.FC<WorkspaceProps> = ({
<WorkspaceSection title="Dev URLs">
<Placeholder />
</WorkspaceSection>
<WorkspaceSection title="Resources">
<Placeholder />
</WorkspaceSection>
</div>
<div className={styles.timelineContainer}>
<WorkspaceSection title="Timeline">
Expand Down
2 changes: 1 addition & 1 deletion site/src/testHelpers/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export const MockWorkspaceAgent: TypesGen.WorkspaceAgent = {
}

export const MockWorkspaceResource: TypesGen.WorkspaceResource = {
agents: [MockWorkspaceAgent],
agents: [MockWorkspaceAgent, MockWorkspaceAgent],
created_at: "",
id: "test-workspace-resource",
job_id: "",
Expand Down
0