Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: Workspace StatusBar#1362

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

Merged
presleyp merged 52 commits intomainfromstatusbar/presleyp/1032
May 16, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
52 commits
Select commitHold shift + click to select a range
b1cc9d6
Move component and prep
presleypMay 5, 2022
0da5e7e
Make WorkspaceSection more reusable
presleypMay 5, 2022
580e801
Lay out elements
presleypMay 5, 2022
b995f4a
Layout tweaks
presleypMay 6, 2022
e7dc082
Add outdated to Workspace type
presleypMay 6, 2022
7f6bbda
Fill out status bar component
presleypMay 6, 2022
08b01c0
Merge branch 'main' into statusbar/presleyp/1032
presleypMay 6, 2022
1bc3e35
Format
presleypMay 6, 2022
ccbf527
Add transition to types
presleypMay 6, 2022
f6bcbaa
Add api handlers for build toggle
presleypMay 9, 2022
db348a6
Format
presleypMay 9, 2022
8d5fcfd
Parallelize machine
presleypMay 9, 2022
62c40f4
Lay out basics of build submachine
presleypMay 9, 2022
eaa353d
Pipe start and stop events through - needs status
presleypMay 9, 2022
399390e
Attempt at a machine
presleypMay 10, 2022
c100ec5
Update mock
presleypMay 10, 2022
903e8ee
Render status and buttons
presleypMay 10, 2022
e8e81ce
Fix type error on template page
presleypMay 10, 2022
2226fea
Move Settings
presleypMay 10, 2022
df0bc5b
Format
presleypMay 10, 2022
14bd598
Keep refreshed workspace
presleypMay 10, 2022
c93dde3
Merge branch 'main' into statusbar/presleyp/1032
presleypMay 10, 2022
1093103
Make it switch workspaces
presleypMay 10, 2022
478db51
Lint
presleypMay 10, 2022
40a62a8
Fix relative api path
presleypMay 10, 2022
bd3a026
Test
presleypMay 10, 2022
9786f6c
Fix polling
presleypMay 10, 2022
7727a1b
Add loading workspace state
presleypMay 10, 2022
4a57152
Format
presleypMay 10, 2022
e3ae1b8
Add stub settings page
presleypMay 11, 2022
2695a29
Format
presleypMay 11, 2022
44e4552
Merge branch 'main' into statusbar/presleyp/1032
presleypMay 11, 2022
d83e5ac
Lint
presleypMay 11, 2022
f909a86
Get rid of let
presleypMay 11, 2022
5dcec61
Merge branch 'main' into statusbar/presleyp/1032
presleypMay 11, 2022
be86750
Add update
presleypMay 12, 2022
992ee0c
Make start use version id
presleypMay 12, 2022
9903c96
Merge branch 'main' into statusbar/presleyp/1032
presleypMay 12, 2022
91d5811
Merge branch 'main' into statusbar/presleyp/1032
presleypMay 12, 2022
9cd386e
Fix imports
presleypMay 12, 2022
1a09166
Add polling for outdated
presleypMay 12, 2022
aee54a0
Merge branch 'main' into statusbar/presleyp/1032
presleypMay 12, 2022
e9758c7
Rely on context instead of finite state for status
presleypMay 12, 2022
87fee06
Handle canceling
presleypMay 13, 2022
b3f6b8c
Fix tests
presleypMay 13, 2022
39e84d9
Format
presleypMay 13, 2022
06abf62
Display errors so users know when button presses didn't work
presleypMay 13, 2022
8552ea2
Fix api typo, remove logging
presleypMay 13, 2022
72c856e
Lint
presleypMay 13, 2022
259d517
Merge branch 'main' into statusbar/presleyp/1032
presleypMay 13, 2022
24829be
Simplify type
presleypMay 16, 2022
542d865
Add type, extract helper
presleypMay 16, 2022
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
27 changes: 19 additions & 8 deletionssite/src/AppRouter.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,6 +18,7 @@ import { TemplatesPage } from "./pages/TemplatesPages/TemplatesPage"
import { CreateUserPage } from "./pages/UsersPage/CreateUserPage/CreateUserPage"
import { UsersPage } from "./pages/UsersPage/UsersPage"
import { WorkspacePage } from "./pages/WorkspacePage/WorkspacePage"
import { WorkspaceSettingsPage } from "./pages/WorkspaceSettingsPage/WorkspaceSettingsPage"

const TerminalPage = React.lazy(() => import("./pages/TerminalPage/TerminalPage"))

Expand DownExpand Up@@ -75,14 +76,24 @@ export const AppRouter: React.FC = () => (
</Route>

<Route path="workspaces">
<Route
path=":workspace"
element={
<AuthAndFrame>
<WorkspacePage />
</AuthAndFrame>
}
/>
<Route path=":workspace">
<Route
index
element={
<AuthAndFrame>
<WorkspacePage />
</AuthAndFrame>
}
/>
<Route
path="edit"
element={
<AuthAndFrame>
<WorkspaceSettingsPage />
</AuthAndFrame>
}
/>
</Route>
</Route>

<Route path="users">
Expand Down
16 changes: 16 additions & 0 deletionssite/src/api/api.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
import axios, { AxiosRequestHeaders } from "axios"
import { mutate } from "swr"
import { WorkspaceBuildTransition } from "./types"
import * as TypesGen from "./typesGenerated"

const CONTENT_TYPE_JSON: AxiosRequestHeaders = {
Expand DownExpand Up@@ -132,6 +133,21 @@ export const getWorkspaceResources = async (workspaceBuildID: string): Promise<T
return response.data
}

const postWorkspaceBuild =
(transition: WorkspaceBuildTransition) =>
async (workspaceId: string, template_version_id?: string): Promise<TypesGen.WorkspaceBuild> => {
const payload = {
transition,
template_version_id,
}
const response = await axios.post(`/api/v2/workspaces/${workspaceId}/builds`, payload)
return response.data
}

export const startWorkspace = postWorkspaceBuild("start")
export const stopWorkspace = postWorkspaceBuild("stop")
export const deleteWorkspace = postWorkspaceBuild("delete")

export const createUser = async (user: TypesGen.CreateUserRequest): Promise<TypesGen.User> => {
const response = await axios.post<TypesGen.User>("/api/v2/users", user)
return response.data
Expand Down
2 changes: 2 additions & 0 deletionssite/src/api/types.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,3 +10,5 @@ export interface ReconnectingPTYRequest {
readonly height?: number
readonly width?: number
}

export type WorkspaceBuildTransition = "start" | "stop" | "delete"
41 changes: 38 additions & 3 deletionssite/src/components/Workspace/Workspace.stories.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
import { action } from "@storybook/addon-actions"
import { Story } from "@storybook/react"
import React from "react"
import { MockOrganization, MockTemplate, MockWorkspace } from "../../testHelpers/renderHelpers"
import { MockOrganization,MockOutdatedWorkspace,MockTemplate, MockWorkspace } from "../../testHelpers/renderHelpers"
import { Workspace, WorkspaceProps } from "./Workspace"

export default {
Expand All@@ -11,9 +12,43 @@ export default {

const Template: Story<WorkspaceProps> = (args) => <Workspace {...args} />

export constExample = Template.bind({})
Example.args = {
export constStarted = Template.bind({})
Started.args = {
organization: MockOrganization,
template: MockTemplate,
workspace: MockWorkspace,
handleStart: action("start"),
handleStop: action("stop"),
handleRetry: action("retry"),
workspaceStatus: "started",
}

export const Starting = Template.bind({})
Starting.args = { ...Started.args, workspaceStatus: "starting" }

export const Stopped = Template.bind({})
Stopped.args = { ...Started.args, workspaceStatus: "stopped" }

export const Stopping = Template.bind({})
Stopping.args = { ...Started.args, workspaceStatus: "stopping" }

export const Error = Template.bind({})
Error.args = { ...Started.args, workspaceStatus: "error" }

export const BuildLoading = Template.bind({})
BuildLoading.args = { ...Started.args, workspaceStatus: "loading" }

export const Deleting = Template.bind({})
Deleting.args = { ...Started.args, workspaceStatus: "deleting" }

export const Deleted = Template.bind({})
Deleted.args = { ...Started.args, workspaceStatus: "deleted" }

export const Canceling = Template.bind({})
Canceling.args = { ...Started.args, workspaceStatus: "canceling" }

export const NoBreadcrumb = Template.bind({})
NoBreadcrumb.args = { ...Started.args, template: undefined }

export const Outdated = Template.bind({})
Outdated.args = { ...Started.args, workspace: MockOutdatedWorkspace }
15 changes: 0 additions & 15 deletionssite/src/components/Workspace/Workspace.test.tsx
View file
Open in desktop

This file was deleted.

84 changes: 30 additions & 54 deletionssite/src/components/Workspace/Workspace.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,51 @@
import Box from "@material-ui/core/Box"
import Paper from "@material-ui/core/Paper"
import { makeStyles } from "@material-ui/core/styles"
import Typography from "@material-ui/core/Typography"
import CloudCircleIcon from "@material-ui/icons/CloudCircle"
import React from "react"
import { Link } from "react-router-dom"
import * as TypesGen from "../../api/typesGenerated"
import { WorkspaceStatus } from "../../pages/WorkspacePage/WorkspacePage"
import { WorkspaceSchedule } from "../WorkspaceSchedule/WorkspaceSchedule"
import { WorkspaceSection } from "../WorkspaceSection/WorkspaceSection"
import* as Constants from "./constants"
import{ WorkspaceStatusBar } from "../WorkspaceStatusBar/WorkspaceStatusBar"

export interface WorkspaceProps {
organization: TypesGen.Organization
organization?: TypesGen.Organization
workspace: TypesGen.Workspace
template: TypesGen.Template
template?: TypesGen.Template
handleStart: () => void
handleStop: () => void
handleRetry: () => void
handleUpdate: () => void
workspaceStatus: WorkspaceStatus
}

/**
* Workspace is the top-level component for viewing an individual workspace
*/
export const Workspace: React.FC<WorkspaceProps> = ({ organization, template, workspace }) => {
export const Workspace: React.FC<WorkspaceProps> = ({
organization,
template,
workspace,
handleStart,
handleStop,
handleRetry,
handleUpdate,
workspaceStatus,
}) => {
const styles = useStyles()

return (
<div className={styles.root}>
<div className={styles.vertical}>
<WorkspaceHeader organization={organization} template={template} workspace={workspace} />
<WorkspaceStatusBar
organization={organization}
template={template}
workspace={workspace}
handleStart={handleStart}
handleStop={handleStop}
handleRetry={handleRetry}
handleUpdate={handleUpdate}
workspaceStatus={workspaceStatus}
/>
<div className={styles.horizontal}>
<div className={styles.sidebarContainer}>
<WorkspaceSection title="Applications">
Expand DownExpand Up@@ -55,40 +75,6 @@ export const Workspace: React.FC<WorkspaceProps> = ({ organization, template, wo
)
}

/**
* Component for the header at the top of the workspace page
*/
export const WorkspaceHeader: React.FC<WorkspaceProps> = ({ organization, template, workspace }) => {
const styles = useStyles()

const templateLink = `/templates/${organization.name}/${template.name}`

return (
<Paper elevation={0} className={styles.section}>
<div className={styles.horizontal}>
<WorkspaceHeroIcon />
<div className={styles.vertical}>
<Typography variant="h4">{workspace.name}</Typography>
<Typography variant="body2" color="textSecondary">
<Link to={templateLink}>{template.name}</Link>
</Typography>
</div>
</div>
</Paper>
)
}

/**
* Component to render the 'Hero Icon' in the header of a workspace
*/
export const WorkspaceHeroIcon: React.FC = () => {
return (
<Box mr="1em">
<CloudCircleIcon width={Constants.TitleIconSize} height={Constants.TitleIconSize} />
</Box>
)
}

/**
* Temporary placeholder component until we have the sections implemented
* Can be removed once the Workspace page has all the necessary sections
Expand All@@ -101,7 +87,7 @@ const Placeholder: React.FC = () => {
)
}

export const useStyles = makeStyles((theme) => {
export const useStyles = makeStyles(() => {
return {
root: {
display: "flex",
Expand All@@ -115,12 +101,6 @@ export const useStyles = makeStyles((theme) => {
display: "flex",
flexDirection: "column",
},
section: {
border: `1px solid ${theme.palette.divider}`,
borderRadius: Constants.CardRadius,
padding: Constants.CardPadding,
margin: theme.spacing(1),
},
sidebarContainer: {
display: "flex",
flexDirection: "column",
Expand All@@ -129,9 +109,5 @@ export const useStyles = makeStyles((theme) => {
timelineContainer: {
flex: 1,
},
icon: {
width: Constants.TitleIconSize,
height: Constants.TitleIconSize,
},
}
})
3 changes: 0 additions & 3 deletionssite/src/components/Workspace/constants.ts
View file
Open in desktop

This file was deleted.

14 changes: 8 additions & 6 deletionssite/src/components/WorkspaceSection/WorkspaceSection.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,22 +2,24 @@ import Paper from "@material-ui/core/Paper"
import { makeStyles } from "@material-ui/core/styles"
import Typography from "@material-ui/core/Typography"
import React from "react"
import { CardPadding, CardRadius } from "../Workspace/constants"
import { CardPadding, CardRadius } from "../../theme/constants"

export interface WorkspaceSectionProps {
title: string
title?: string
}

export const WorkspaceSection: React.FC<WorkspaceSectionProps> = ({ title, children }) => {
const styles = useStyles()

return (
<Paper elevation={0} className={styles.root}>
<div className={styles.headerContainer}>
<div className={styles.header}>
<Typography variant="h6">{title}</Typography>
{title && (
<div className={styles.headerContainer}>
<div className={styles.header}>
<Typography variant="h6">{title}</Typography>
</div>
</div>
</div>
)}

<div className={styles.contents}>{children}</div>
</Paper>
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp