Skip to content

feat: add frontend for locked workspaces #8655

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 16 commits into from
Aug 4, 2023
Prev Previous commit
Next Next commit
make gen
  • Loading branch information
sreya committed Aug 2, 2023
commit e866e50f5e7ae3771cd9b84ef9cb357f6d5b1ed8
2 changes: 1 addition & 1 deletion coderd/database/queries.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/api/workspaces.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 1 addition & 5 deletions site/src/components/WorkspaceActions/WorkspaceActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ import Menu from "@mui/material/Menu"
import { makeStyles } from "@mui/styles"
import MoreVertOutlined from "@mui/icons-material/MoreVertOutlined"
import { FC, Fragment, ReactNode, useRef, useState } from "react"
import {
Workspace,
WorkspaceStatus,
WorkspaceBuildParameter,
} from "api/typesGenerated"
import { Workspace, WorkspaceBuildParameter } from "api/typesGenerated"
import {
ActionLoadingButton,
CancelButton,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const LockedWorkspaceBanner = ({
}

const alertText = (): string => {
if (workspaces.length == 1) {
if (workspaces.length === 1) {
if (
hasDeletionScheduledWorkspaces &&
hasDeletionScheduledWorkspaces.deleting_at &&
Expand Down
1 change: 0 additions & 1 deletion site/src/components/WorkspaceDeletion/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export const displayLockedWorkspace = (
allowAdvancedScheduling: boolean,
allowWorkspaceActions: boolean,
) => {
const today = new Date()
if (
!workspace.locked_at ||
!allowAdvancedScheduling ||
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useQuery } from "@tanstack/react-query"
import { getWorkspaces } from "api/api"
import { compareAsc, add, endOfToday } from "date-fns"
import { compareAsc } from "date-fns"
import { Workspace, Template } from "api/typesGenerated"
import { TemplateScheduleFormValues } from "./formHelpers"

Expand Down
6 changes: 3 additions & 3 deletions site/src/pages/WorkspacesPage/WorkspacesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { useUserFilterMenu } from "components/Filter/UserFilter"
import { getWorkspaces, updateWorkspaceVersion } from "api/api"

const WorkspacesPage: FC = () => {
const orgId = useOrganizationId()
const [lockedWorkspaces, setLockedWorkspaces] = useState<Workspace[]>([])
// If we use a useSearchParams for each hook, the values will not be in sync.
// So we have to use a single one, centralizing the values, and pass it to
Expand Down Expand Up @@ -49,10 +48,10 @@ const WorkspacesPage: FC = () => {
setLockedWorkspaces(resp.workspaces)
})
.catch((err) => {
console.log(err)
// TODO?
})
}
})
}, [includesLocked, data, lockedQuery])
} else {
// If the experiment isn't included then we'll pretend
// like locked workspaces don't exist.
Expand All @@ -69,6 +68,7 @@ const WorkspacesPage: FC = () => {

<WorkspacesPageView
workspaces={data?.workspaces}
lockedWorkspaces={lockedWorkspaces}
error={error}
count={data?.count}
page={pagination.page}
Expand Down
3 changes: 1 addition & 2 deletions site/src/pages/WorkspacesPage/WorkspacesPageView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { Stack } from "components/Stack/Stack"
import { WorkspaceHelpTooltip } from "components/Tooltips"
import { WorkspacesTable } from "pages/WorkspacesPage/WorkspacesTable"
import { useLocalStorage } from "hooks"
import difference from "lodash/difference"
import { LockedWorkspaceBanner, Count } from "components/WorkspaceDeletion"
import { ErrorAlert } from "components/Alert/ErrorAlert"
import { WorkspacesFilter } from "./filter/filter"
Expand Down Expand Up @@ -55,7 +54,7 @@ export const WorkspacesPageView: FC<
onUpdateWorkspace,
page,
}) => {
const { saveLocal, getLocal } = useLocalStorage()
const { saveLocal } = useLocalStorage()

const workspacesDeletionScheduled = lockedWorkspaces
?.filter((workspace) => workspace.deleting_at)
Expand Down