-
Notifications
You must be signed in to change notification settings - Fork 77
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: add amendments list page #836
Merged
Merged
Changes from 14 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
f26e13d
initial commit
pdp2121 faedf14
add data retrieval
pdp2121 7289381
add stylings and tests
pdp2121 f0b86e3
add missing translations
pdp2121 34800b4
update id margin
pdp2121 2db04a9
Merge branch 'staging' into add-amendments-list
pdp2121 1d1659f
update types and move logic to template
pdp2121 bc882b3
Merge branch 'add-amendments-list' of https://github.com/pdp2121/expl…
pdp2121 52f9945
fix tests
pdp2121 bd3868c
update nav
pdp2121 cffd1bc
update translations
pdp2121 8d881af
rename variable
pdp2121 facec3e
suppress warning
pdp2121 9fae800
Merge branch 'staging' into add-amendments-list
pdp2121 6461b09
Merge branch 'staging' into add-amendments-list
pdp2121 d655d0a
fix translation
pdp2121 edf0845
fix route
pdp2121 c973159
Merge branch 'staging' into add-amendments-list
pdp2121 f43c41e
fix tests
pdp2121 6846175
Merge branch 'add-amendments-list' of https://github.com/pdp2121/expl…
pdp2121 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 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 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 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 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 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 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,116 @@ | ||
import { FC } from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
import { TRANSACTION_ROUTE } from '../App/routes' | ||
import { Loader } from '../shared/components/Loader' | ||
import { useLanguage } from '../shared/hooks' | ||
import { RouteLink } from '../shared/routing' | ||
import { localizeDate } from '../shared/utils' | ||
import { AmendmentData, Voter } from '../shared/vhsTypes' | ||
|
||
const DATE_OPTIONS_AMENDMENTS = { | ||
year: 'numeric', | ||
month: 'numeric', | ||
day: 'numeric', | ||
timeZone: 'UTC', | ||
} | ||
|
||
const DEFAULT_EMPTY_VALUE = '--' | ||
|
||
export const AmendmentsTable: FC<{ | ||
amendments: AmendmentData[] | undefined | ||
}> = ({ amendments }) => { | ||
const { t } = useTranslation() | ||
const language = useLanguage() | ||
|
||
const renderEnabled = (enabled: boolean) => | ||
enabled ? ( | ||
<span className="badge yes">{t('yes')}</span> | ||
) : ( | ||
<span className="badge no">{t('no')}</span> | ||
) | ||
|
||
const renderOnTx = (amendment) => { | ||
if (amendment.voted) { | ||
return <span className="voting">{t('voting')}</span> | ||
} | ||
|
||
if (amendment.date) { | ||
const dateLocalized = localizeDate( | ||
new Date(amendment.date), | ||
language, | ||
DATE_OPTIONS_AMENDMENTS, | ||
) | ||
return amendment.tx_hash ? ( | ||
<RouteLink | ||
to={TRANSACTION_ROUTE} | ||
params={{ identifier: amendment.tx_hash }} | ||
> | ||
{dateLocalized} | ||
</RouteLink> | ||
) : ( | ||
<span>{dateLocalized}</span> | ||
) | ||
} | ||
|
||
return DEFAULT_EMPTY_VALUE | ||
} | ||
|
||
const renderName = (name: string, deprecated: boolean) => | ||
deprecated ? ( | ||
<div className="name-deprecated"> | ||
<span className="name-text text-truncate">{name}</span> | ||
<span className="deprecated badge">{t('deprecated')}</span> | ||
</div> | ||
) : ( | ||
<span className="name-text">{name}</span> | ||
) | ||
|
||
const getVoter = (voted: Voter | undefined) => { | ||
if (!voted) return DEFAULT_EMPTY_VALUE | ||
return voted.validators.filter((val) => val.unl !== false).length | ||
} | ||
|
||
const renderAmendment = (amendment, index) => ( | ||
<tr key={amendment.id}> | ||
<td className="count">{index + 1}</td> | ||
<td className="version">{amendment.rippled_version}</td> | ||
<td className="amendment-id text-truncate">{amendment.id}</td> | ||
<td className="name text-truncate"> | ||
{renderName(amendment.name, amendment.deprecated)} | ||
</td> | ||
<td className="voters">{getVoter(amendment.voted)}</td> | ||
<td className="threshold"> | ||
{amendment.threshold ?? DEFAULT_EMPTY_VALUE} | ||
</td> | ||
<td className="consensus"> | ||
{amendment.consensus ?? DEFAULT_EMPTY_VALUE} | ||
</td> | ||
<td className="enabled"> | ||
{renderEnabled(amendment.voted === undefined)} | ||
</td> | ||
<td className="on_tx">{renderOnTx(amendment)}</td> | ||
</tr> | ||
) | ||
|
||
const content = amendments ? ( | ||
<table className="basic"> | ||
<thead> | ||
<tr> | ||
<th className="count">#</th> | ||
<th className="version">{t('Version')}</th> | ||
<th className="amendment-id">{t('amendment_id')}</th> | ||
<th className="name">{t('amendment_name')}</th> | ||
<th className="voters">{t('voters')}</th> | ||
<th className="threshold">{t('threshold')}</th> | ||
<th className="consensus">{t('consensus')}</th> | ||
<th className="enabled">{t('enabled')}</th> | ||
<th className="on_tx">{t('on_tx')}</th> | ||
</tr> | ||
</thead> | ||
<tbody>{amendments.map(renderAmendment)}</tbody> | ||
</table> | ||
) : ( | ||
<Loader /> | ||
) | ||
return <div className="amendments-table">{content}</div> | ||
} |
This file contains 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,137 @@ | ||
@import '../shared/css/variables'; | ||
@import '../shared/css/table'; | ||
|
||
.amendments-page{ | ||
.summary { | ||
padding: 0 16px; | ||
margin-top: 100px; | ||
|
||
@include for-size(tablet-portrait-up) { | ||
padding: 0; | ||
} | ||
|
||
.type { | ||
display: inline-block; | ||
padding-bottom: 24px; | ||
color: $white; | ||
font-size: 32px; | ||
|
||
@include for-size(tablet-portrait-up) { | ||
font-size: 42px; | ||
} | ||
|
||
@include bold; | ||
} | ||
} | ||
|
||
.wrap { | ||
overflow: auto; | ||
width: 100%; | ||
max-width: 1500px; | ||
min-height: 150px; | ||
margin: auto; | ||
} | ||
} | ||
|
||
.amendments-table { | ||
position: relative; | ||
|
||
table { | ||
.name { | ||
max-width: 120px; | ||
|
||
@include for-size(tablet-portrait-up) { | ||
max-width: 180px; | ||
} | ||
|
||
@include for-size(desktop-up) { | ||
max-width: 280px; | ||
} | ||
} | ||
|
||
.amendment-id { | ||
display: none; | ||
max-width: 120px; | ||
|
||
@include for-size(desktop-up) { | ||
display: table-cell; | ||
padding-right: 3%; | ||
} | ||
} | ||
|
||
.name-deprecated { | ||
display: flex; | ||
overflow: hidden; | ||
align-items: center; | ||
gap: 6px; | ||
|
||
@include for-size(tablet-portrait-up) { | ||
gap: 12px; | ||
} | ||
|
||
.name-text { | ||
overflow: hidden; | ||
max-width: fit-content; | ||
flex: 1; | ||
text-overflow: ellipsis; | ||
} | ||
|
||
.deprecated { | ||
overflow: hidden; | ||
max-width: 60%; | ||
font-size: 12px; | ||
text-overflow: ellipsis; | ||
text-transform: uppercase; | ||
|
||
&.badge { | ||
border: 1px solid $black-30; | ||
background-color: $black-80; | ||
color: $black-30; | ||
} | ||
} | ||
} | ||
|
||
.version, .enabled, .consensus { | ||
max-width: 70px; | ||
overflow-wrap: break-word; | ||
@include for-size(tablet-portrait-up) { | ||
max-width: 100px; | ||
} | ||
} | ||
} | ||
|
||
.badge { | ||
margin: 0; | ||
color: $black-100; | ||
|
||
&.yes { | ||
background-color: $green-60; | ||
} | ||
|
||
&.no { | ||
background-color: $black-30; | ||
} | ||
} | ||
|
||
.voting { | ||
color: $yellow-50; | ||
} | ||
|
||
.voters, | ||
.threshold { | ||
display: none; | ||
max-width: 70px; | ||
|
||
@include for-size(desktop-up) { | ||
display: table-cell; | ||
} | ||
} | ||
|
||
.count { | ||
display: none; | ||
|
||
@include for-size(tablet-portrait-up) { | ||
display: table-cell; | ||
} | ||
} | ||
} |
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.
Try using
<section>
tags instead. I think there is styling for that already that falls within these sizes.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.
I think the only place where the same style is being used in
.network-page .wrap
and I don't see any<section>
tag being used anywhere else in the code