Skip to content

feat: add impending deletion banner to workspace page #7634

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 5 commits into from
May 25, 2023
Merged
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
color-code banner
  • Loading branch information
Kira-Pilot committed May 24, 2023
commit 467efae7bca00b9853d0b13247ef896029da8e5c
14 changes: 12 additions & 2 deletions site/src/components/WorkspaceDeletion/ImpendingDeletionBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Workspace } from "api/typesGenerated"
import { displayImpendingDeletion } from "./utils"
import { useDashboard } from "components/Dashboard/DashboardProvider"
import { Alert } from "components/Alert/Alert"
import { formatDistanceToNow } from "date-fns"
import { formatDistanceToNow, differenceInDays } from "date-fns"

export enum Count {
Singular,
Expand Down Expand Up @@ -39,8 +39,18 @@ export const ImpendingDeletionBanner = ({
return null
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found it hard to read/understand this "display or not" logic here. I think the names displayImpendingDeletion and displayImpendingDeletionBanner are very similar and I took some time to understand they are different but not sure how to improve this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, let me improve that


// if deleting_at is 7 days away or less, display an 'error' banner to convey urgency to user
const daysUntilDelete = differenceInDays(
Date.parse(workspace.last_used_at),
new Date(),
)

return (
<Alert severity="info" onDismiss={onDismiss} dismissible>
<Alert
severity={daysUntilDelete <= 7 ? "error" : "info"}
onDismiss={onDismiss}
dismissible
>
{count === Count.Singular
? `This workspace has been unused for ${formatDistanceToNow(
Date.parse(workspace.last_used_at),
Expand Down