-
Notifications
You must be signed in to change notification settings - Fork 17
feat(gateways): add gateway stats widgets and new gateway pages #410
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
Draft
rickstaa
wants to merge
24
commits into
main
Choose a base branch
from
feat/add-gateway-dashboard
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
671d3c7
feat(gateways): add gateway stats widgets and new gateway pages
rickstaa 8d4699a
feat: add paid tickets to gateway history
rickstaa cbf8c87
fix: hide delegating tab when account is not delegator
rickstaa 50655d3
fix: correct gateway nav highlight when logged out
rickstaa 7f877ef
Merge branch 'main' into feat/add-gateway-dashboard
rickstaa 3adb176
fix: fix merge conflict
rickstaa 35c94c3
Merge branch 'main' into feat/add-gateway-dashboard
rickstaa b74acd7
chore: remove duplicate env variable from template
rickstaa cc3cffe
refactor: apply code improvements
rickstaa d0edde7
refactor: ensure correct tab highlight behavoir
rickstaa f622b78
refactor: improve gateway inclusion criteria and UI
rickstaa c5da583
refactor: improve profile tab order
rickstaa f1faa97
feat: add warning for self-redeeming gateways
rickstaa 478ba3f
refactor: improve account tabs mobile layout
rickstaa a15d1be
feat: add HorizontalScrollContainer component
rickstaa be56b20
refactor: add scrollBuffer constant
rickstaa 6ae32ab
refactor: add accessibility labels to horizontalScrollContainer
rickstaa 2bf8b2c
refactor: improve horizontalScrollContainer scroll behaviour
rickstaa 4db10d5
refactor: stabilize horizontalScrollContainer fade behavior
rickstaa 5f1c432
Merge branch 'main' into feat/add-gateway-dashboard
rickstaa bbc039e
refactor: small formatting fix introduce during merge
rickstaa d59f8ec
Merge branch 'main' into feat/add-gateway-dashboard
rickstaa 76c9886
fix: ensure gateway filtering is correct
rickstaa babb95a
chore: add gateway pagination comment
rickstaa 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
Large diffs are not rendered by default.
Oops, something went wrong.
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,131 @@ | ||
| import { ExplorerTooltip } from "@components/ExplorerTooltip"; | ||
| import Stat from "@components/Stat"; | ||
| import dayjs from "@lib/dayjs"; | ||
| import { Box, Grid } from "@livepeer/design-system"; | ||
| import { ExclamationTriangleIcon } from "@radix-ui/react-icons"; | ||
| import { GatewaysQuery } from "apollo"; | ||
| import { useGatewaySelfRedeemStatus } from "hooks"; | ||
| import numbro from "numbro"; | ||
| import { useMemo } from "react"; | ||
|
|
||
| // TODO: replace with common formatting util. | ||
| const formatEth = (value?: string | number | null) => { | ||
| const amount = Number(value ?? 0) || 0; | ||
| return `${numbro(amount).format( | ||
| amount > 0 && amount < 0.01 | ||
| ? { mantissa: 4, trimMantissa: true } | ||
| : { mantissa: 2, average: true, lowPrecision: false } | ||
| )} ETH`; | ||
| }; | ||
|
|
||
| const SelfRedeemIndicator = () => ( | ||
| <ExplorerTooltip | ||
| multiline | ||
| content={ | ||
| <Box>Self-redeemed winning tickets detected in the last 90 days.</Box> | ||
| } | ||
| > | ||
| <Box as={ExclamationTriangleIcon} css={{ color: "$amber11" }} /> | ||
| </ExplorerTooltip> | ||
| ); | ||
|
|
||
| const BroadcastingView = ({ | ||
| gateway, | ||
| }: { | ||
| gateway?: GatewaysQuery["gateways"] extends Array<infer G> ? G | null : null; | ||
| }) => { | ||
| const isSelfRedeeming = useGatewaySelfRedeemStatus(gateway?.id); | ||
|
|
||
| const activeSince = useMemo( | ||
| () => | ||
| gateway?.firstActiveDay | ||
| ? dayjs.unix(gateway.firstActiveDay).format("MMM D, YYYY") | ||
| : "Pending graph update", | ||
| [gateway] | ||
| ); | ||
| const statusText = useMemo(() => { | ||
| const active = Number(gateway?.ninetyDayVolumeETH ?? 0) > 0; | ||
| return active ? "Active" : "Inactive"; | ||
| }, [gateway]); | ||
| const statItems = useMemo( | ||
| () => [ | ||
| { | ||
| id: "total-fees-distributed", | ||
| label: "Total fees distributed", | ||
| value: ( | ||
| <Box | ||
| css={{ display: "inline-flex", alignItems: "center", gap: "$3" }} | ||
| > | ||
| <Box>{formatEth(gateway?.totalVolumeETH)}</Box> | ||
| {isSelfRedeeming && <SelfRedeemIndicator />} | ||
| </Box> | ||
| ), | ||
| tooltip: "Lifetime fees this gateway has distributed on-chain.", | ||
| }, | ||
| { | ||
| id: "status", | ||
| label: "Status", | ||
| value: statusText, | ||
| tooltip: "Active if this gateway distributed fees in the last 90 days.", | ||
| }, | ||
| { | ||
| id: "ninety-day-fees", | ||
| label: "90d fees distributed", | ||
| value: formatEth(gateway?.ninetyDayVolumeETH), | ||
| tooltip: | ||
| "Total fees distributed to orchestrators over the last 90 days.", | ||
| }, | ||
| { | ||
| id: "activation-date", | ||
| label: "Activation date", | ||
| value: activeSince, | ||
| tooltip: "First day this gateway funded deposit/reserve on-chain.", | ||
| }, | ||
| { | ||
| id: "deposit-balance", | ||
| label: "Deposit balance", | ||
| value: formatEth(gateway?.deposit), | ||
| tooltip: "Current deposit balance funded for gateway job payouts.", | ||
| }, | ||
| { | ||
| id: "reserve-balance", | ||
| label: "Reserve balance", | ||
| value: formatEth(gateway?.reserve), | ||
| tooltip: "Reserve funds available for winning ticket payouts.", | ||
| }, | ||
| ], | ||
| [gateway, activeSince, statusText, isSelfRedeeming] | ||
| ); | ||
|
|
||
| return ( | ||
| <Box | ||
| css={{ | ||
| paddingTop: "$4", | ||
| }} | ||
| > | ||
| <Grid | ||
| css={{ | ||
| display: "grid", | ||
| gridTemplateColumns: "1fr", | ||
| gap: "$3", | ||
| alignItems: "stretch", | ||
| "@media (min-width: 820px)": { | ||
| gridTemplateColumns: "repeat(2, minmax(0, 1fr))", | ||
| }, | ||
| }} | ||
| > | ||
| {statItems.map((stat) => ( | ||
| <Stat | ||
| key={stat.id} | ||
| label={stat.label} | ||
| value={stat.value} | ||
| tooltip={stat.tooltip} | ||
| css={{ height: "100%" }} | ||
| /> | ||
| ))} | ||
| </Grid> | ||
| </Box> | ||
| ); | ||
| }; | ||
|
|
||
| export default BroadcastingView; | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code duplication: The formatEth function is duplicated in both BroadcastingView and GatewayList components with identical implementation. The TODOs in both files acknowledge this should be replaced with a common formatting utility. Consider extracting this to a shared utility module to follow DRY principles and ensure consistent formatting across the application.