Skip to content
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

feat(webapp): display fio address instead of owner value #1421

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion webapp/src/components/GeoMap/CountryMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const ClusterMap = ({ data, map, mapCode }) => {
const producer = this?.point?.producer

return producer?.owner
? `<a href=/${eosConfig.producersRoute}/${producer?.owner}>${producer?.owner}</a>`
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is fine but it would be better to escape the fio_address and owner to prevent potential XSS attacks. Consider using a library like DOMPurify.

? `<a href=/${eosConfig.producersRoute}/${producer?.owner}>${producer?.fio_address || producer?.owner}</a>`
: ''
},
},
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/components/ProducersChart/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const CustomBarLabel = memo(
fontFamily="Roboto, Helvetica, Arial, sans-serif;"
fontWeight={isProducing ? 'bold' : 'normal'}
>
{payload.owner}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The substring operation truncates names but doesn't account for the possibility of cutting in the middle of a multi-byte character. This could cause display issues. Consider using a proper truncation library that handles multi-byte and multi-codepoint characters.

{payload.name ? payload.name?.replace('@fiotestnet','')?.substring(0, 12) + '...' : payload.owner}
</text>
)

Expand Down
7 changes: 6 additions & 1 deletion webapp/src/gql/producer.gql.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const PRODUCERS_QUERY = gql`
) {
id
owner
fio_address
url
total_votes
bp_json
Expand All @@ -35,7 +36,6 @@ export const PRODUCERS_QUERY = gql`
type
value
}
fio_address
}
}
`
Expand All @@ -51,6 +51,7 @@ export const PRODUCER_INFO_QUERY = gql`
) {
id
owner
fio_address
url
bp_json
total_votes_eos
Expand Down Expand Up @@ -91,6 +92,7 @@ export const SMALL_PRODUCERS_QUERY = gql`
) {
id
owner
fio_address
url
bp_json
total_votes_eos
Expand Down Expand Up @@ -146,6 +148,7 @@ const NODES_OPERATION = type => gql`
) {
id
owner
fio_address
rank
producer_key
bp_json
Expand Down Expand Up @@ -190,6 +193,7 @@ const ENDPOINTS_OPERATION = type => gql`
) {
id
owner
fio_address
updated_at
endpoints: endpoints_list(where: $endpointFilter, order_by: { value: asc }) {
type
Expand Down Expand Up @@ -308,6 +312,7 @@ export const ALL_NODES_QUERY = gql`
) {
id
owner
fio_address
bp_json
updated_at
}
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/hooks/customHooks/useEndpointsState.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ const useEndpointsState = () => {
const inserted = []

const bpName =
producer.bp_json?.org?.candidate_name ||
producer?.fio_address ||
producer?.bp_json?.org?.candidate_name ||
producer?.bp_json?.org?.organization_name ||
producer?.owner

Expand Down
2 changes: 1 addition & 1 deletion webapp/src/routes/ProducerProfile/ProfileCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ const ProfileCard = ({ producer }) => {
<div className={classes.profile}>
<ProducerName
name={producer?.media?.name || producer?.owner}
account={producer?.media?.name ? producer?.owner : ''}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is fine but it would be better to escape the fio_address and owner to prevent potential XSS attacks. Consider using a library like DOMPurify.

account={producer?.media?.name ? (producer?.fio_address || producer?.owner) : ''}
text={t('BPonNetwork', {
networkName: eosConfig.networkLabel,
position: producer?.media?.account,
Expand Down
Loading