Skip to content

Commit

Permalink
chore: Update workspace last active time tooltip (#20086)
Browse files Browse the repository at this point in the history
Refactor the tooltip for displaying the last active time of a workspace in the WorkspaceEntry component. The tooltip now shows the relative time (e.g. "2 days ago") as visible text and the exact date and time with GMT offset on hover. It uses the dayjs library for date formatting and relative time calculation. Additionally, it handles potential undefined dates with a fallback to the current date and removes the leading zero from single-digit GMT hour offsets.
  • Loading branch information
Siddhant-K-code authored Aug 5, 2024
1 parent 8487da8 commit 9037679
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions components/dashboard/src/workspaces/WorkspaceEntry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,22 @@ export const WorkspaceEntry: FunctionComponent<Props> = ({ info, shortVersion })
</div>
</div>
<div className="flex items-center">
{/*
* Tooltip for workspace last active time
* Displays relative time (e.g. "2 days ago") as visible text
* Shows exact date and time with GMT offset on hover
* Uses dayjs for date formatting and relative time calculation
* Handles potential undefined dates with fallback to current date
* Removes leading zero from single-digit GMT hour offsets
*/}
<Tooltip
content={`Last Activate ${dayjs(
info.status!.phase!.lastTransitionTime!.toDate(),
).fromNow()}`}
content={`Last active: ${dayjs(
info.status?.phase?.lastTransitionTime?.toDate() ?? new Date(),
).format("MMM D, YYYY, h:mm A")} GMT${dayjs(
info.status?.phase?.lastTransitionTime?.toDate() ?? new Date(),
)
.format("Z")
.replace(/^([+-])0/, "$1")}`}
className="w-full"
>
<div className="text-sm w-full text-gray-400 overflow-ellipsis truncate">
Expand Down

0 comments on commit 9037679

Please sign in to comment.