Skip to content

Commit e7b6f89

Browse files
committed
added banner filter
1 parent dde782c commit e7b6f89

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

coderd/workspaces.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ func (api *API) workspaces(rw http.ResponseWriter, r *http.Request) {
186186
} else {
187187
for _, v := range wss {
188188
if v.DeletingAt == nil {
189-
break
189+
continue
190190
}
191191
// get the beginning of the day on which deletion is scheduled
192192
truncatedDeletionAt := v.DeletingAt.Truncate(24 * time.Hour)

site/src/components/WorkspaceDeletion/ImpendingDeletionBanner.tsx

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import { Workspace } from "api/typesGenerated"
22
import { displayImpendingDeletion } from "./utils"
33
import { useDashboard } from "components/Dashboard/DashboardProvider"
44
import { Alert } from "components/Alert/Alert"
5-
import { formatDistanceToNow, differenceInDays } from "date-fns"
5+
import { formatDistanceToNow, differenceInDays, add, format } from "date-fns"
6+
import Link from "@mui/material/Link"
7+
import { Link as RouterLink } from "react-router-dom"
68

79
export enum Count {
810
Singular,
@@ -46,17 +48,34 @@ export const ImpendingDeletionBanner = ({
4648
new Date(),
4749
)
4850

51+
const plusFourteen = add(new Date(), { days: 14 })
52+
4953
return (
5054
<Alert
5155
severity={daysUntilDelete <= 7 ? "warning" : "info"}
5256
onDismiss={onDismiss}
5357
dismissible
5458
>
55-
{count === Count.Singular
56-
? `This workspace has been unused for ${formatDistanceToNow(
57-
Date.parse(workspace.last_used_at),
58-
)} and is scheduled for deletion. To keep it, connect via SSH or the web terminal.`
59-
: "You have workspaces that will be deleted soon due to inactivity. To keep these workspaces, connect to them via SSH or the web terminal."}
59+
{count === Count.Singular ? (
60+
`This workspace has been unused for ${formatDistanceToNow(
61+
Date.parse(workspace.last_used_at),
62+
)} and is scheduled for deletion. To keep it, connect via SSH or the web terminal.`
63+
) : (
64+
<>
65+
<span>There are</span>{" "}
66+
<Link
67+
component={RouterLink}
68+
to={`/workspaces?filter=deleting_by:${format(
69+
plusFourteen,
70+
"y-MM-dd",
71+
)}`}
72+
>
73+
workspaces
74+
</Link>{" "}
75+
that will be deleted soon due to inactivity. To keep these workspaces,
76+
connect to them via SSH or the web terminal.
77+
</>
78+
)}
6079
</Alert>
6180
)
6281
}

0 commit comments

Comments
 (0)