Skip to content

feat: add impending deletion filter to workspaces page #7860

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 18 commits into from
Jun 12, 2023
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
added banner filter
  • Loading branch information
Kira-Pilot committed Jun 5, 2023
commit e7b6f899ab715a86b25f71fbbd3d033dde657aab
2 changes: 1 addition & 1 deletion coderd/workspaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func (api *API) workspaces(rw http.ResponseWriter, r *http.Request) {
} else {
for _, v := range wss {
if v.DeletingAt == nil {
break
continue
}
// get the beginning of the day on which deletion is scheduled
truncatedDeletionAt := v.DeletingAt.Truncate(24 * time.Hour)
Expand Down
31 changes: 25 additions & 6 deletions site/src/components/WorkspaceDeletion/ImpendingDeletionBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import { Workspace } from "api/typesGenerated"
import { displayImpendingDeletion } from "./utils"
import { useDashboard } from "components/Dashboard/DashboardProvider"
import { Alert } from "components/Alert/Alert"
import { formatDistanceToNow, differenceInDays } from "date-fns"
import { formatDistanceToNow, differenceInDays, add, format } from "date-fns"
import Link from "@mui/material/Link"
import { Link as RouterLink } from "react-router-dom"

export enum Count {
Singular,
Expand Down Expand Up @@ -46,17 +48,34 @@ export const ImpendingDeletionBanner = ({
new Date(),
)

const plusFourteen = add(new Date(), { days: 14 })

return (
<Alert
severity={daysUntilDelete <= 7 ? "warning" : "info"}
onDismiss={onDismiss}
dismissible
>
{count === Count.Singular
? `This workspace has been unused for ${formatDistanceToNow(
Date.parse(workspace.last_used_at),
)} and is scheduled for deletion. To keep it, connect via SSH or the web terminal.`
: "You have workspaces that will be deleted soon due to inactivity. To keep these workspaces, connect to them via SSH or the web terminal."}
{count === Count.Singular ? (
`This workspace has been unused for ${formatDistanceToNow(
Date.parse(workspace.last_used_at),
)} and is scheduled for deletion. To keep it, connect via SSH or the web terminal.`
) : (
<>
<span>There are</span>{" "}
<Link
component={RouterLink}
to={`/workspaces?filter=deleting_by:${format(
plusFourteen,
"y-MM-dd",
)}`}
>
workspaces
</Link>{" "}
that will be deleted soon due to inactivity. To keep these workspaces,
connect to them via SSH or the web terminal.
</>
)}
</Alert>
)
}