Skip to content

Commit 9037679

Browse files
chore: Update workspace last active time tooltip (#20086)
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.
1 parent 8487da8 commit 9037679

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

components/dashboard/src/workspaces/WorkspaceEntry.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,22 @@ export const WorkspaceEntry: FunctionComponent<Props> = ({ info, shortVersion })
105105
</div>
106106
</div>
107107
<div className="flex items-center">
108+
{/*
109+
* Tooltip for workspace last active time
110+
* Displays relative time (e.g. "2 days ago") as visible text
111+
* Shows exact date and time with GMT offset on hover
112+
* Uses dayjs for date formatting and relative time calculation
113+
* Handles potential undefined dates with fallback to current date
114+
* Removes leading zero from single-digit GMT hour offsets
115+
*/}
108116
<Tooltip
109-
content={`Last Activate ${dayjs(
110-
info.status!.phase!.lastTransitionTime!.toDate(),
111-
).fromNow()}`}
117+
content={`Last active: ${dayjs(
118+
info.status?.phase?.lastTransitionTime?.toDate() ?? new Date(),
119+
).format("MMM D, YYYY, h:mm A")} GMT${dayjs(
120+
info.status?.phase?.lastTransitionTime?.toDate() ?? new Date(),
121+
)
122+
.format("Z")
123+
.replace(/^([+-])0/, "$1")}`}
112124
className="w-full"
113125
>
114126
<div className="text-sm w-full text-gray-400 overflow-ellipsis truncate">

0 commit comments

Comments
 (0)