- Notifications
You must be signed in to change notification settings - Fork928
fix: hiding agent status on stopped workspaces#3512
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { screen } from "@testing-library/react" | ||
import { | ||
MockStoppedWorkspace, | ||
MockWorkspaceResource, | ||
MockWorkspaceResource2, | ||
} from "testHelpers/entities" | ||
import { render } from "testHelpers/renderHelpers" | ||
import { DisplayAgentStatusLanguage } from "util/workspace" | ||
import { Resources } from "./Resources" | ||
describe("ResourceTable", () => { | ||
it("hides status text when a workspace is stopped", async () => { | ||
// When | ||
const props = { | ||
resource: [{ ...MockWorkspaceResource }, { ...MockWorkspaceResource2 }], | ||
workspace: { ...MockStoppedWorkspace }, | ||
canUpdateWorkspace: false, | ||
} | ||
render(<Resources {...props} />) | ||
const statusText = screen.queryByText(DisplayAgentStatusLanguage.connecting) | ||
// Then | ||
expect(statusText).toBeNull() | ||
}) | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -8,8 +8,8 @@ import TableRow from "@material-ui/core/TableRow" | ||
import useTheme from "@material-ui/styles/useTheme" | ||
import { ErrorSummary } from "components/ErrorSummary/ErrorSummary" | ||
import { FC } from "react" | ||
import { getDisplayAgentStatus, getWorkspaceStatus, WorkspaceStateEnum } from "util/workspace" | ||
import { Workspace, WorkspaceResource } from "../../api/typesGenerated" | ||
import { AppLink } from "../AppLink/AppLink" | ||
import { SSHButton } from "../SSHButton/SSHButton" | ||
import { Stack } from "../Stack/Stack" | ||
@@ -42,6 +42,10 @@ export const Resources: FC<ResourcesProps> = ({ | ||
const styles = useStyles() | ||
const theme: Theme = useTheme() | ||
const workspaceStatus: keyof typeof WorkspaceStateEnum = getWorkspaceStatus( | ||
workspace.latest_build, | ||
) | ||
return ( | ||
<div aria-label={Language.resources} className={styles.wrapper}> | ||
{getResourcesError ? ( | ||
@@ -102,9 +106,12 @@ export const Resources: FC<ResourcesProps> = ({ | ||
{agent.name} | ||
<div className={styles.agentInfo}> | ||
<span className={styles.operatingSystem}>{agent.operating_system}</span> | ||
{WorkspaceStateEnum[workspaceStatus] !== | ||
WorkspaceStateEnum["stopped"] && ( | ||
<span style={{ color: agentStatus.color }} className={styles.status}> | ||
Kira-Pilot marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
{agentStatus.status} | ||
</span> | ||
)} | ||
</div> | ||
</TableCell> | ||
<TableCell> | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -6,6 +6,21 @@ import * as TypesGen from "../api/typesGenerated" | ||
dayjs.extend(utc) | ||
// all the possible states returned by the API | ||
export enum WorkspaceStateEnum { | ||
starting = "Starting", | ||
started = "Started", | ||
stopping = "Stopping", | ||
stopped = "Stopped", | ||
canceling = "Canceling", | ||
canceled = "Canceled", | ||
deleting = "Deleting", | ||
deleted = "Deleted", | ||
queued = "Queued", | ||
error = "Error", | ||
loading = "Loading", | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I moved this out of a component directory and into our util file so we can have properly typed statuses. | ||
export type WorkspaceStatus = | ||
| "queued" | ||
| "started" | ||