-
Notifications
You must be signed in to change notification settings - Fork 5
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 vote type to governance comment section #1544
Conversation
WalkthroughThe pull request introduces enhancements to the governance comment section, including restructuring the Changes
Assessment against linked issues
Poem
Tip Announcements
Recent review detailsConfiguration used: CodeRabbit UI Files selected for processing (1)
Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 3
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (5)
- packages/extension-polkagate/src/fullscreen/governance/post/Comment.tsx (3 hunks)
- packages/extension-polkagate/src/fullscreen/governance/post/Comments.tsx (3 hunks)
- packages/extension-polkagate/src/fullscreen/governance/post/Replies.tsx (1 hunks)
- packages/extension-polkagate/src/fullscreen/governance/utils/types.tsx (2 hunks)
- packages/extension/public/locales/en/translation.json (1 hunks)
Files skipped from review due to trivial changes (1)
- packages/extension-polkagate/src/fullscreen/governance/post/Replies.tsx
Additional comments not posted (5)
packages/extension-polkagate/src/fullscreen/governance/post/Comments.tsx (2)
56-56
: Improved handling of theaddress
prop.Passing
address ?? ''
ensures that theCommentView
component receives a non-undefined string, enhancing the robustness of the component's rendering logic.
31-31
: Sorting logic updated to descending order.The change in sorting logic ensures that the most recent comments are displayed first, enhancing user experience by making recent discussions more accessible.
Run the following script to verify the sorting logic:
Verification successful
Sorting logic correctly implemented.
The sorting logic for comments in
Comments.tsx
is correctly implemented to display the most recent comments first, enhancing the user experience by prioritizing recent discussions.
- The
sortedComments
variable sorts comments bycreated_at
in descending order.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the sorting logic for comments. # Test: Check if the sorting logic correctly sorts comments in descending order. rg --type typescript -A 5 $'sortedComments'Length of output: 77
Script:
#!/bin/bash # Description: Verify the sorting logic for comments. # Test: Check if the sorting logic correctly sorts comments in descending order. rg 'sortedComments' --glob '*.ts' --glob '*.tsx' -A 5Length of output: 1790
packages/extension-polkagate/src/fullscreen/governance/utils/types.tsx (2)
13-13
: Addedreply_reactions
to theReply
interface.This addition enhances the
Reply
interface by allowing it to track reactions, supporting the new feature of displaying reactions in the governance comment section.
45-45
: Addedvotes
property to theCommentType
interface.This addition allows the
CommentType
interface to track voting decisions, directly supporting the new feature of displaying the vote type of each commenter in the governance comment section.packages/extension-polkagate/src/fullscreen/governance/post/Comment.tsx (1)
Line range hint
18-122
: Enhancements to theComment
component.The introduction of the
CommentProps
interface and theVoteType
component, along with the use of memoization for reactions, significantly enhances the functionality and performance of theComment
component. These changes align well with the PR's objectives to display the vote type and optimize the governance comment section.
@@ -1384,5 +1384,8 @@ | |||
"Help?": "", | |||
"Ignore": "", | |||
"Rewards Destination": "", | |||
"{{accountName}} has been successfully removed!": "" | |||
"{{accountName}} has been successfully removed!": "", | |||
"Voted Aye": "", |
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.
Translation entry for "Voted Aye" is missing its translation value.
The key "Voted Aye"
has been added to the translation file but lacks an actual translation value. This should be populated to reflect the intended translation in English or marked clearly if it's intended to be filled later.
"{{accountName}} has been successfully removed!": "" | ||
"{{accountName}} has been successfully removed!": "", | ||
"Voted Aye": "", | ||
"Voted Nay": "", |
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.
Translation entry for "Voted Nay" is missing its translation value.
Similar to the previous entry, the key "Voted Nay"
is present without a corresponding translation value. Ensure that the translation values are provided to complete the localization support.
"{{accountName}} has been successfully removed!": "", | ||
"Voted Aye": "", | ||
"Voted Nay": "", | ||
"Voted Abstain": "" |
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.
Translation entry for "Voted Abstain" is missing its translation value.
The key "Voted Abstain"
also lacks a translation value. It's important to provide these values to ensure the application's localization features are fully functional and clear to end-users.
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.
Actionable comments posted: 1
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- packages/extension-polkagate/src/fullscreen/governance/post/Comment.tsx (3 hunks)
- packages/extension-polkagate/src/fullscreen/governance/post/Comments.tsx (4 hunks)
- packages/extension-polkagate/src/hooks/useReferendum.ts (3 hunks)
Files skipped from review due to trivial changes (1)
- packages/extension-polkagate/src/hooks/useReferendum.ts
Files skipped from review as they are similar to previous changes (1)
- packages/extension-polkagate/src/fullscreen/governance/post/Comment.tsx
Additional comments not posted (1)
packages/extension-polkagate/src/fullscreen/governance/post/Comments.tsx (1)
36-36
: Sorting logic change is effective and aligns with PR objectives.The updated sorting logic correctly prioritizes the most recent comments by sorting them in descending order based on their creation date. This change enhances the user experience by displaying the most relevant comments first.
However, consider handling potential exceptions or errors in date parsing, as
new Date()
could fail ifcreated_at
is not a valid date string.Run the following script to verify the date parsing:
@@ -54,7 +58,7 @@ export default function Comments ({ address, referendum }: { address: string | u | |||
<Grid container item xs={12}> | |||
{sortedComments?.map((comment, index) => ( | |||
<Grid container key={index} sx={{ borderBottom: index !== sortedComments.length - 1 ? `0.01px solid ${theme.palette.text.disabled}` : undefined }}> | |||
<CommentView address={address} comment={comment} /> | |||
<CommentView address={address ?? ''} comment={comment} /> |
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.
Enhanced robustness in handling the address
prop.
The update to provide a fallback value (''
) for the address
prop when it is undefined
is a good practice. This ensures that the CommentView
component always receives a string value, preventing potential runtime errors.
Consider documenting this behavior in the CommentView
component's propTypes or TypeScript definitions to make it clear that address
can expect a string and not undefined
.
Displaying commenters vote type!
address #1495
Summary by CodeRabbit
Summary by CodeRabbit
New Features
VoteType
component for displaying voting information.Bug Fixes
address
prop to prevent undefined values in theCommentView
component.Style