Skip to content
GitLab
Explore
Sign in
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
Merge requests
!482
Delrifai/
#382
add witness details on main card
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Delrifai/
#382
add witness details on main card
delrifai/#382_add_witness_details_on_main_card
into
develop
Overview
0
Commits
3
Pipelines
2
Changes
1
Merged
Dima Rifai
requested to merge
delrifai/#382_add_witness_details_on_main_card
into
develop
4 months ago
Overview
0
Commits
3
Pipelines
2
Changes
1
Expand
0
0
Merge request reports
Viewing commit
900b1b6a
Prev
Next
Show latest version
1 file
+
55
−
13
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
900b1b6a
Issue
#382
- Add rank, URL, and show if witness is deactivated
· 900b1b6a
Dima Rifai
authored
4 months ago
components/account/MobileAccountNameCard.tsx
+
55
−
13
Options
import
Image
from
"
next/image
"
;
import
{
getHiveAvatarUrl
}
from
"
@/utils/HiveBlogUtils
"
;
import
{
Card
,
CardHeader
}
from
"
../ui/card
"
;
import
Explorer
from
"
@/types/Explorer
"
;
import
{
config
}
from
"
@/Config
"
;
import
{
cn
}
from
"
@/lib/utils
"
;
import
{
FontAwesomeIcon
}
from
"
@fortawesome/react-fontawesome
"
;
import
{
faLink
,
faStar
}
from
"
@fortawesome/free-solid-svg-icons
"
;
import
useWitnessDetails
from
"
@/hooks/api/common/useWitnessDetails
"
;
interface
MobileAccountNameCardProps
{
accountName
:
string
;
@@ -15,29 +19,67 @@ const MobileAccountNameCard: React.FC<MobileAccountNameCardProps> = ({
liveDataEnabled
,
accountDetails
,
})
=>
{
const
{
witnessDetails
}
=
useWitnessDetails
(
accountName
,
accountDetails
.
is_witness
);
const
isWitnessActive
=
witnessDetails
?.
witness
.
signing_key
!==
config
.
inactiveWitnessKey
;
if
(
!
accountDetails
)
return
;
return
(
<
Card
>
<
CardHeader
>
<
div
className
=
"flex justify-between bg-theme dark:bg-theme text-explorer-orange text-2xl my-4"
>
{
accountDetails
.
is_witness
?
(
<
div
data-testid
=
"account-name"
>
{
accountDetails
.
name
}
<
span
className
=
"text-sm"
>
(witness)
</
span
>
</
div
>
)
:
(
<
div
>
{
accountDetails
.
name
}
</
div
>
)
}
<
span
>
<
div
className
=
"flex flex-wrap items-center justify-between gap-4 bg-theme dark:bg-theme"
>
{
/* Avatar and Name */
}
<
div
className
=
"flex items-center gap-4"
>
<
Image
className
=
"rounded-full border-2 border-explorer-orange"
src
=
{
getHiveAvatarUrl
(
accountName
)
}
alt
=
"avatar"
width
=
{
5
0
}
height
=
{
5
0
}
width
=
{
6
0
}
height
=
{
6
0
}
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
&&
(
<
span
className
=
"flex items-center gap-1"
>
<
FontAwesomeIcon
icon
=
{
faStar
}
data-testid
=
"witness-rank-icon"
/>
<
span
>
{
witnessDetails
.
witness
.
rank
}
</
span
>
</
span
>
)
}
{
witnessDetails
?.
witness
.
url
&&
isWitnessActive
&&
(
<
a
href
=
{
witnessDetails
.
witness
.
url
}
target
=
"_blank"
rel
=
"noopener noreferrer"
>
<
FontAwesomeIcon
icon
=
{
faLink
}
data-testid
=
"witness-url-icon"
/>
</
a
>
)
}
</
div
>
)
}
</
div
>
</
div
>
</
div
>
</
CardHeader
>
</
Card
>
Loading