Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
Block Explorer UI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hive
Block Explorer UI
Commits
7af9d9c3
Commit
7af9d9c3
authored
4 months ago
by
Dima Rifai
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#382
- Add rank, URL, and show if witness is deactivated
parent
c2fbe8b0
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
components/account/AccountMainCard.tsx
+93
-22
93 additions, 22 deletions
components/account/AccountMainCard.tsx
with
93 additions
and
22 deletions
components/account/AccountMainCard.tsx
+
93
−
22
View file @
7af9d9c3
import
{
Loader2
}
from
"
lucide-react
"
;
import
{
Loader2
}
from
"
lucide-react
"
;
import
Image
from
"
next/image
"
;
import
Image
from
"
next/image
"
;
import
{
FontAwesomeIcon
}
from
"
@fortawesome/react-fontawesome
"
;
import
{
faLink
,
faStar
}
from
"
@fortawesome/free-solid-svg-icons
"
;
import
Explorer
from
"
@/types/Explorer
"
;
import
Explorer
from
"
@/types/Explorer
"
;
import
{
formatAndDelocalizeTime
}
from
"
@/utils/TimeUtils
"
;
import
{
formatAndDelocalizeTime
}
from
"
@/utils/TimeUtils
"
;
import
{
getHiveAvatarUrl
}
from
"
@/utils/HiveBlogUtils
"
;
import
{
getHiveAvatarUrl
}
from
"
@/utils/HiveBlogUtils
"
;
...
@@ -8,6 +9,15 @@ import useManabars from "@/hooks/api/accountPage/useManabars";
...
@@ -8,6 +9,15 @@ import useManabars from "@/hooks/api/accountPage/useManabars";
import
{
Card
,
CardContent
,
CardFooter
,
CardHeader
}
from
"
../ui/card
"
;
import
{
Card
,
CardContent
,
CardFooter
,
CardHeader
}
from
"
../ui/card
"
;
import
{
Toggle
}
from
"
../ui/toggle
"
;
import
{
Toggle
}
from
"
../ui/toggle
"
;
import
{
Progress
}
from
"
@/components/ui/progress
"
;
import
{
Progress
}
from
"
@/components/ui/progress
"
;
import
useWitnessDetails
from
"
@/hooks/api/common/useWitnessDetails
"
;
import
{
config
}
from
"
@/Config
"
;
import
{
cn
}
from
"
@/lib/utils
"
;
import
{
TooltipProvider
,
Tooltip
,
TooltipTrigger
,
TooltipContent
,
}
from
"
../ui/tooltip
"
;
interface
AccountMainCardProps
{
interface
AccountMainCardProps
{
accountDetails
:
Explorer
.
FormattedAccountDetails
;
accountDetails
:
Explorer
.
FormattedAccountDetails
;
...
@@ -31,35 +41,96 @@ const AccountMainCard: React.FC<AccountMainCardProps> = ({
...
@@ -31,35 +41,96 @@ const AccountMainCard: React.FC<AccountMainCardProps> = ({
changeLiveRefresh
,
changeLiveRefresh
,
})
=>
{
})
=>
{
const
{
manabarsData
}
=
useManabars
(
accountName
,
liveDataEnabled
);
const
{
manabarsData
}
=
useManabars
(
accountName
,
liveDataEnabled
);
const
{
witnessDetails
}
=
useWitnessDetails
(
accountName
,
accountDetails
.
is_witness
);
const
isWitnessActive
=
witnessDetails
?.
witness
.
signing_key
!==
config
.
inactiveWitnessKey
;
return
(
return
(
<
Card
data-testid
=
"account-details"
>
<
Card
data-testid
=
"account-details"
>
<
CardHeader
>
<
CardHeader
>
<
div
className
=
"flex justify-between bg-theme dark:bg-theme text-explorer-orange text-2xl my-4"
>
<
div
className
=
"flex flex-wrap items-center justify-between gap-4 bg-theme dark:bg-theme"
>
{
accountDetails
.
is_witness
?
(
{
/* Avatar and Name */
}
<
div
data-testid
=
"account-name"
>
<
div
className
=
"flex items-center gap-4"
>
{
accountDetails
.
name
}
<
span
className
=
"text-sm"
>
(witness)
</
span
>
</
div
>
)
:
(
<
div
>
{
accountDetails
.
name
}
</
div
>
)
}
<
span
>
<
Image
<
Image
className
=
"rounded-full border-2 border-explorer-orange"
className
=
"rounded-full border-2 border-explorer-orange"
src
=
{
getHiveAvatarUrl
(
accountName
)
}
src
=
{
getHiveAvatarUrl
(
accountName
)
}
alt
=
"avatar"
alt
=
"avatar"
width
=
{
5
0
}
width
=
{
6
0
}
height
=
{
5
0
}
height
=
{
6
0
}
data-testid
=
"user-avatar"
data-testid
=
"user-avatar"
/>
/>
</
span
>
<
div
>
<
h2
className
=
"text-lg font-semibold text-gray-800 dark:text-white"
>
{
accountDetails
.
name
}
</
h2
>
{
accountDetails
.
is_witness
&&
(
<
div
className
=
"flex items-center gap-2 text-sm text-gray-500 dark:text-gray-400"
>
<
span
className
=
{
cn
({
"
line-through text-red-500
"
:
!
isWitnessActive
,
})
}
>
Witness
</
span
>
{
witnessDetails
?.
witness
.
rank
&&
isWitnessActive
&&
(
<
TooltipProvider
>
<
Tooltip
>
<
TooltipTrigger
asChild
>
<
span
className
=
"flex items-center gap-1"
>
<
FontAwesomeIcon
icon
=
{
faStar
}
data-testid
=
"witness-rank-icon"
/>
<
span
>
{
witnessDetails
.
witness
.
rank
}
</
span
>
</
span
>
</
TooltipTrigger
>
<
TooltipContent
>
<
span
className
=
"text-xs"
>
Witness Rank:
{
witnessDetails
.
witness
.
rank
}
</
span
>
</
TooltipContent
>
</
Tooltip
>
</
TooltipProvider
>
)
}
{
witnessDetails
?.
witness
.
url
&&
isWitnessActive
&&
(
<
TooltipProvider
>
<
Tooltip
>
<
TooltipTrigger
asChild
>
<
a
href
=
{
witnessDetails
.
witness
.
url
}
target
=
"_blank"
rel
=
"noopener noreferrer"
>
<
FontAwesomeIcon
icon
=
{
faLink
}
data-testid
=
"witness-url-icon"
/>
</
a
>
</
TooltipTrigger
>
<
TooltipContent
>
<
span
className
=
"text-xs"
>
Witness Link
</
span
>
</
TooltipContent
>
</
Tooltip
>
</
TooltipProvider
>
)
}
</
div
>
)
}
</
div
>
</
div
>
{
/* Live Data Toggle */
}
<
div
className
=
"w-full sm:w-auto mt-4 sm:mt-0 top-0"
>
<
Toggle
checked
=
{
liveDataEnabled
}
onClick
=
{
changeLiveRefresh
}
className
=
"text-base"
leftLabel
=
"Live Data"
/>
</
div
>
</
div
>
</
div
>
<
Toggle
checked
=
{
liveDataEnabled
}
onClick
=
{
changeLiveRefresh
}
className
=
"text-base"
leftLabel
=
"Live Data"
/>
</
CardHeader
>
</
CardHeader
>
<
CardContent
>
<
CardContent
>
{
!!
manabarsData
?
(
{
!!
manabarsData
?
(
...
@@ -114,14 +185,14 @@ const AccountMainCard: React.FC<AccountMainCardProps> = ({
...
@@ -114,14 +185,14 @@ const AccountMainCard: React.FC<AccountMainCardProps> = ({
</>
</>
)
:
(
)
:
(
<
div
className
=
"flex justify-center text-center items-center"
>
<
div
className
=
"flex justify-center text-center items-center"
>
<
Loader2
className
=
"animate-spin mt-1h-12 w-12 ml-3 ..."
/>
<
Loader2
className
=
"animate-spin mt-1
h-12 w-12 ml-3 ..."
/>
</
div
>
</
div
>
)
}
)
}
<
div
className
=
"flex justify-between p-4"
>
<
div
className
=
"flex justify-between p-4"
>
<
div
className
=
"text-center flex flex-col justify-space-between w-full gap-2"
>
<
div
className
=
"text-center flex flex-col justify-space-between w-full gap-2"
>
<
span
className
=
"text"
>
Creation Date:
</
span
>
<
span
className
=
"text"
>
Creation Date:
</
span
>
<
span
<
span
className
=
"text"
className
=
"text"
data-testid
=
"creation-date"
data-testid
=
"creation-date"
>
>
{
formatAndDelocalizeTime
(
accountDetails
.
created
)
}
{
formatAndDelocalizeTime
(
accountDetails
.
created
)
}
...
@@ -130,7 +201,7 @@ const AccountMainCard: React.FC<AccountMainCardProps> = ({
...
@@ -130,7 +201,7 @@ const AccountMainCard: React.FC<AccountMainCardProps> = ({
<
div
className
=
"text-center flex flex-col justify-space-between w-full gap-2"
>
<
div
className
=
"text-center flex flex-col justify-space-between w-full gap-2"
>
<
span
className
=
"text"
>
Reputation:
</
span
>
<
span
className
=
"text"
>
Reputation:
</
span
>
<
span
<
span
className
=
"text"
className
=
"text"
data-testid
=
"creation-date"
data-testid
=
"creation-date"
>
>
{
accountDetails
.
reputation
}
{
accountDetails
.
reputation
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment