8000 feat: Workspaces filtering by f0ssel · Pull Request #1972 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

feat: Workspaces filtering #1972

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 23 commits into from
Jun 3, 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
pr fixes
  • Loading branch information
f0ssel committed Jun 2, 2022
commit 568e3a61ec55d0e0d1cd8963074f36aec0573731
9 changes: 4 additions & 5 deletions site/src/pages/WorkspacesPage/WorkspacesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { makeStyles } from "@material-ui/core/styles"
import TextField from "@material-ui/core/TextField"
import AddCircleOutline from "@material-ui/icons/AddCircleOutline"
import { useMachine } from "@xstate/react"
import { FormikContextType, FormikErrors, useFormik } from "formik"
import { FormikErrors, useFormik } from "formik"
import { FC, useState } from "react"
import { Link as RouterLink } from "react-router-dom"
import { Margins } from "../../components/Margins/Margins"
Expand All @@ -25,7 +25,7 @@ const WorkspacesPage: FC = () => {
const styles = useStyles()
const [workspacesState, send] = useMachine(workspacesMachine)

const form = useFormik<FilterFormValues>({
const form = useFormik<FilterFormValues>({
initialValues: {
query: workspacesState.context.filter || "",
},
Expand All @@ -50,13 +50,13 @@ const form = useFormik<FilterFormValues>({
}

const setYourWorkspaces = () => {
form.setFieldValue("query", "owner:me")
void form.setFieldValue("query", "owner:me")
void form.submitForm()
handleClose()
}

const setAllWorkspaces = () => {
form.setFieldValue("query", "")
void form.setFieldValue("query", "")
void form.submitForm()
handleClose()
}
Expand Down Expand Up @@ -88,7 +88,6 @@ const form = useFormik<FilterFormValues>({
<WorkspacesPageView
loading={workspacesState.hasTag("loading")}
workspaces={workspacesState.context.workspaces}
error={workspacesState.context.getWorkspacesError}
/>
</Margins>
</>
Expand Down
1 change: 0 additions & 1 deletion site/src/pages/WorkspacesPage/WorkspacesPageView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export const Language = {
export interface WorkspacesPageViewProps {
loading?: boolean
workspaces?: TypesGen.Workspace[]
error?: unknown
}

export const WorkspacesPageView: FC<WorkspacesPageViewProps> = ({ loading, workspaces }) => {
Expand Down
1 change: 1 addition & 0 deletions site/src/util/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ export const isWorkspaceOn = (workspace: TypesGen.Workspace): boolean => {
return transition === "start" && status === "succeeded"
}


export const defaultWorkspaceExtension = (__startDate?: dayjs.Dayjs): TypesGen.PutExtendWorkspaceRequest => {
const now = __startDate ? dayjs(__startDate) : dayjs()
const NinetyMinutesFromNow = now.add(90, "minutes").utc()
Expand Down
3 changes: 2 additions & 1 deletion site/src/xServices/workspaces/workspacesXService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const workspacesMachine = createMachine(
},
onError: {
target: "ready",
actions: "assignGetWorkspacesError",
actions: ["assignGetWorkspacesError", "clearWorkspaces"],
},
},
tags: "loading",
Expand All @@ -70,6 +70,7 @@ export const workspacesMachine = createMachine(
getWorkspacesError: (_, event) => event.data,
}),
clearGetWorkspacesError: (context) => assign({ ...context, getWorkspacesError: undefined }),
clearWorkspaces: (context) => assign({ ...context, workspaces: undefined }),
},
services: {
getWorkspaces: (context) => API.getWorkspaces(workspaceQueryToFilter(context.filter)),
Expand Down
0