-
Notifications
You must be signed in to change notification settings - Fork 15
feat(ensadmin): include projection info on status page #1332
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
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b9c5eb6
feat(ensadmin): include projection info on status page
tk-o ecab5ef
Apply AI agents feedback
tk-o a12735c
Apply AI agents feedback
tk-o 45849d1
docs(changeset): Includes `ProjectionInfo` component on Indexing Stat…
tk-o ec183a8
docs(changeset): Updates `useIndexingStatusWithSwr` to always return …
tk-o f00f0a7
Merge branch 'main' into feat/ensadmin-projection-info
tk-o a032afd
Address PR feedback
tk-o File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "ensadmin": minor | ||
| --- | ||
|
|
||
| Updates `useIndexingStatusWithSwr` to always return current realtime indexing status projection. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "ensadmin": minor | ||
| --- | ||
|
|
||
| Includes `ProjectionInfo` component on Indexing Status page. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
apps/ensadmin/src/components/indexing-status/projection-info.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| "use client"; | ||
|
|
||
| import { formatRelativeTime, RelativeTime, useNow } from "@namehash/namehash-ui"; | ||
| import { InfoIcon } from "lucide-react"; | ||
|
|
||
| import type { Duration, UnixTimestamp } from "@ensnode/ensnode-sdk"; | ||
|
|
||
| import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip"; | ||
|
|
||
| /** | ||
| * Formats the worst-case distance for display in the projection info tooltip. | ||
| * | ||
| * If the worst-case distance is 1 minute or less, we present it as | ||
| * an absolute number of seconds (e.g. "45 seconds"). | ||
| * | ||
| * Otherwise, we present it as a relative time (e.g. "2 hours ago") instead of | ||
| * an absolute number of seconds. Also, we drop the "ago" suffix from | ||
| * the relative time string to focus on the distance aspect | ||
| * (e.g. "2 hours" instead of "2 hours ago"). | ||
| */ | ||
| const formatWorstCaseDistance = ( | ||
| worstCaseDistance: Duration, | ||
| omnichainIndexingCursor: UnixTimestamp, | ||
| ) => { | ||
| const presentWorstCaseDistanceAsRelativeTime = worstCaseDistance > 60; | ||
|
|
||
| if (presentWorstCaseDistanceAsRelativeTime) { | ||
| return formatRelativeTime(omnichainIndexingCursor, true, true, true).replace(" ago", ""); | ||
| } | ||
|
|
||
| return `${worstCaseDistance} seconds`; | ||
| }; | ||
|
|
||
| interface ProjectionInfoProps { | ||
| omnichainIndexingCursor: UnixTimestamp; | ||
| snapshotTime: UnixTimestamp; | ||
| worstCaseDistance: Duration; | ||
| } | ||
|
|
||
| /** | ||
| * Displays metadata about the current indexing status projection in a tooltip. | ||
| * Shows when the projection was generated, when the snapshot was taken, and worst-case distance. | ||
| */ | ||
| export function ProjectionInfo({ | ||
| omnichainIndexingCursor, | ||
| snapshotTime, | ||
| worstCaseDistance, | ||
| }: ProjectionInfoProps) { | ||
| const now = useNow(); | ||
| return ( | ||
| <Tooltip delayDuration={300}> | ||
| <TooltipTrigger asChild> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please optimize the hover state. The way there's a rectangular light-grey panel appearing in the background on hover doesn't feel good. |
||
| <InfoIcon className="shrink-0 text-[#9CA3AF] w-4 h-4" /> | ||
| </TooltipTrigger> | ||
| <TooltipContent | ||
| side="right" | ||
| className="bg-gray-50 text-sm text-black shadow-md outline-none w-80 p-4" | ||
| > | ||
| <div className="flex flex-col gap-3"> | ||
| <div className="flex flex-col gap-1"> | ||
| <div className="font-semibold text-xs text-gray-500 uppercase"> | ||
| Worst-Case Distance* | ||
| </div> | ||
| <div className="text-sm"> | ||
| {formatWorstCaseDistance(worstCaseDistance, omnichainIndexingCursor)} | ||
| </div> | ||
tk-o marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </div> | ||
|
|
||
| <div className="text-xs text-gray-600 leading-relaxed"> | ||
| * as of the real-time projection generated just now from indexing status snapshot | ||
| captured{" "} | ||
| <RelativeTime | ||
| timestamp={snapshotTime} | ||
| relativeTo={now} | ||
| includeSeconds | ||
| conciseFormatting | ||
| /> | ||
| . | ||
| </div> | ||
| </div> | ||
| </TooltipContent> | ||
| </Tooltip> | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.