Skip to content

feat(web): ruling-and-rewards-indicators #1676

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

Merged
merged 2 commits into from
Aug 23, 2024

Conversation

tractorss
Copy link
Contributor

@tractorss tractorss commented Aug 20, 2024

  • Adds indicators for Ruling executed and Juror rewards dispersed in Voting Tab.

PR-Codex overview

The focus of this PR is to add new indicators in the voting history UI and improve vote details visibility.

Detailed summary

  • Added ruled and jurorRewardsDispersed fields in voting history UI.
  • Created RulingAndRewardsIndicators component.
  • Updated VotesAccordion and related components to handle new fields.
  • Improved vote details visibility with hiddenVotes and commited indicators.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Summary by CodeRabbit

  • New Features

    • Enhanced voting history with additional fields for rulings and juror rewards.
    • Introduced a new component to display indicators for rulings and rewards in the user interface.
    • Integrated new voting status indicators into the Voting History component for improved context on disputes.
    • Added support for conditional rendering of vote commitment status in voting-related components.
  • Bug Fixes

    • Improved layout spacing in the Voting History component for better visual presentation.

Copy link
Contributor

coderabbitai bot commented Aug 20, 2024

Walkthrough

The recent changes enhance the voting history functionality by adding new GraphQL fields to retrieve more detailed information about disputes. A new React component, RulingAndRewardsIndicators, has been introduced to display status indicators for rulings and juror rewards. Furthermore, enhancements in the VotingHistory component now utilize these new indicators, improving the user interface and providing clearer insights into the voting process.

Changes

Files Change Summary
web/src/hooks/queries/useVotingHistory.ts Added ruled and jurorRewardsDispersed fields to the GraphQL query for enhanced dispute information.
web/src/pages/Cases/CaseDetails/Voting/RulingAndRewardsIndicators.tsx Introduced a new React component that displays conditional indicators for rulings and juror rewards using props.
web/src/pages/Cases/CaseDetails/Voting/VotingHistory.tsx Integrated RulingAndRewardsIndicators, enhanced layout spacing, and optimized performance with new logic for rewards distribution.
web/src/pages/Cases/CaseDetails/Voting/VotesDetails/AccordionTitle.tsx Updated VoteStatus and AccordionTitle components to accept new props for vote commitment and visibility.
web/src/pages/Cases/CaseDetails/Voting/VotesDetails/index.tsx Added hiddenVotes property to IVotesAccordion interface, enhancing the votes visibility functionality.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant VotingHistory
    participant RulingAndRewardsIndicators
    participant GraphQL

    User->>VotingHistory: Request voting details
    VotingHistory->>GraphQL: Fetch dispute data
    GraphQL-->>VotingHistory: Return dispute data with new fields
    VotingHistory->>RulingAndRewardsIndicators: Provide ruling and rewards data
    RulingAndRewardsIndicators-->>VotingHistory: Render indicators
    VotingHistory-->>User: Display voting history with indicators
Loading

Poem

🐇 In the meadow where votes take flight,
New fields shimmer, oh what a sight!
Rulings and rewards, we cheer and dance,
With indicators bright, we take a chance.
Hopping along, let’s celebrate today,
For knowledge and fun in every way! 🎉


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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

netlify bot commented Aug 20, 2024

Deploy Preview for kleros-v2-testnet ready!

Name Link
🔨 Latest commit 4029771
🔍 Latest deploy log https://app.netlify.com/sites/kleros-v2-testnet/deploys/66c5a04728689c000839e329
😎 Deploy Preview https://deploy-preview-1676--kleros-v2-testnet.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Aug 20, 2024

Deploy Preview for kleros-v2-neo ready!

Name Link
🔨 Latest commit 4029771
🔍 Latest deploy log https://app.netlify.com/sites/kleros-v2-neo/deploys/66c5a0479d87160008b867c0
😎 Deploy Preview https://deploy-preview-1676--kleros-v2-neo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Aug 20, 2024

Deploy Preview for kleros-v2-university failed. Why did it fail? →

Name Link
🔨 Latest commit 4029771
🔍 Latest deploy log https://app.netlify.com/sites/kleros-v2-university/deploys/66c5a047f637e400083e09d9

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (1)
web/src/hooks/queries/useVotingHistory.ts (1)

Line range hint 41-45: Ensure proper error handling for the query function.

Consider adding error handling for the queryFn in case the GraphQL query fails. This can improve the robustness of the application.

Add error handling to the query function:

queryFn: async () => {
  try {
    return await graphqlBatcher.fetch({ id: crypto.randomUUID(), document: votingHistoryQuery, variables: { disputeID } });
  } catch (error) {
    console.error("Error fetching voting history:", error);
    throw error;
  }
}
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between cc4ccc5 and 60cb52c.

Files selected for processing (3)
  • web/src/hooks/queries/useVotingHistory.ts (1 hunks)
  • web/src/pages/Cases/CaseDetails/Voting/RulingAndRewardsIndicators.tsx (1 hunks)
  • web/src/pages/Cases/CaseDetails/Voting/VotingHistory.tsx (3 hunks)
Additional comments not posted (10)
web/src/pages/Cases/CaseDetails/Voting/RulingAndRewardsIndicators.tsx (5)

9-13: Styling is appropriate and consistent.

The use of styled-components for the Container is appropriate, ensuring that the component layout is flexible and responsive.


15-18: Interface definition is clear and concise.

The IRulingAndRewardsIndicators interface is well-defined, clearly specifying the expected props for the component.


20-25: Component logic is straightforward and efficient.

The RulingAndRewardsIndicators component efficiently renders labels based on the boolean props. The use of conditional rendering ensures that elements are only rendered when necessary.


27-27: Export statement is correctly defined.

The default export of the RulingAndRewardsIndicators component is correctly implemented, facilitating its use in other parts of the application.


1-8: Ensure correct paths for SVG and component imports.

Verify that the paths for the SVG icons and the Label component are correct and accessible in the project structure.

Verification successful

Paths for SVG and component imports are correct and accessible.

The paths for the SVG icons and the Label component are correctly specified and accessible in the project structure:

  • check-circle-outline.svg is located at web/src/assets/svgs/icons/.
  • pile-coins.svg is located at web/src/assets/svgs/icons/.
  • Label.tsx is located at web/src/components/DisputeView/CardLabels/.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of SVG icon files and the Label component.

# Test: Check for the existence of SVG files and Label component.
fd --type f --name "check-circle-outline.svg"
fd --type f --name "pile-coins.svg"
fd --type f --name "Label.tsx"

Length of output: 865


Script:

#!/bin/bash
# Description: Verify the existence of SVG icon files and the Label component.

# Corrected Test: Check for the existence of SVG files and Label component.
fd --type f "check-circle-outline.svg"
fd --type f "pile-coins.svg"
fd --type f "Label.tsx"

Length of output: 301

web/src/hooks/queries/useVotingHistory.ts (1)

15-18: GraphQL query fields are correctly added.

The fields ruled and jurorRewardsDispersed are appropriately added to the GraphQL query, enhancing the data retrieved for each dispute.

web/src/pages/Cases/CaseDetails/Voting/VotingHistory.tsx (4)

33-33: Layout improvement with margin-top is effective.

The addition of margin-top to StyledTabs enhances the layout by providing better visual spacing.


74-74: Use of useMemo for performance optimization is appropriate.

The use of useMemo to compute jurorRewardsDispersed optimizes performance by memoizing the result based on the rounds dependency.


97-100: Integration of RulingAndRewardsIndicators is seamless.

The integration of the RulingAndRewardsIndicators component into the VotingHistory component is well-executed, enhancing the UI with additional status indicators.


25-25: Verify the import path for RulingAndRewardsIndicators.

Ensure that the import path for RulingAndRewardsIndicators is correct and that the component is accessible.

Verification successful

Import Path Verified

The import path for RulingAndRewardsIndicators is correct and the component is accessible in the same directory. No changes are needed.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of the RulingAndRewardsIndicators component.

# Test: Check for the existence of the RulingAndRewardsIndicators file.
fd --type f --name "RulingAndRewardsIndicators.tsx"

Length of output: 302


Script:

#!/bin/bash
# Description: Verify the existence of the RulingAndRewardsIndicators component.

# Test: Check for the existence of the RulingAndRewardsIndicators file.
fd "RulingAndRewardsIndicators.tsx" --type f

Length of output: 114

coderabbitai[bot]
coderabbitai bot previously approved these changes Aug 20, 2024
Copy link

codeclimate bot commented Aug 21, 2024

Code Climate has analyzed commit 4029771 and detected 3 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 2
Style 1

View more on Code Climate.

Copy link

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Outside diff range, codebase verification and nitpick comments (1)
web/src/pages/Cases/CaseDetails/Voting/VotesDetails/index.tsx (1)

Line range hint 98-153: Correct the typo in the prop name.

The prop commited should be spelled committed to maintain consistency and correctness.

Use this diff to correct the typo:

-  commited={Boolean(drawnJuror.vote.commited)}
+  committed={Boolean(drawnJuror.vote.committed)}
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 60cb52c and 4029771.

Files selected for processing (4)
  • web/src/hooks/queries/useVotingHistory.ts (2 hunks)
  • web/src/pages/Cases/CaseDetails/Voting/VotesDetails/AccordionTitle.tsx (2 hunks)
  • web/src/pages/Cases/CaseDetails/Voting/VotesDetails/index.tsx (4 hunks)
  • web/src/pages/Cases/CaseDetails/Voting/VotingHistory.tsx (4 hunks)
Files skipped from review as they are similar to previous changes (2)
  • web/src/hooks/queries/useVotingHistory.ts
  • web/src/pages/Cases/CaseDetails/Voting/VotingHistory.tsx

Copy link
Contributor

@alcercu alcercu left a comment

Choose a reason for hiding this comment

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

lgtm

@alcercu alcercu added this pull request to the merge queue Aug 23, 2024
Merged via the queue into dev with commit dc91d63 Aug 23, 2024
16 of 23 checks passed
@jaybuidl jaybuidl deleted the feat/rewards-and-execution-indicators branch October 8, 2024 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants