Skip to content

refactor(web): case details overview file too big #1340

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
Nov 24, 2023

Conversation

tractorss
Copy link
Contributor

@tractorss tractorss commented Nov 23, 2023

Refactored pages/Case/CaseDetails/Overview file into smaller components.


PR-Codex overview

Detailed summary

  • Added a new component called Policies in the Overview folder.
  • Added a new component called DisputeContext in the Overview folder.
  • Imported necessary dependencies and styled components.
  • Updated the Overview component to use the new components and display dispute information.
  • Deleted two files: Overview.tsx and Policies.tsx.

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

@tractorss tractorss requested a review from alcercu November 23, 2023 14:48
Copy link

netlify bot commented Nov 23, 2023

Deploy Preview for kleros-v2 ready!

Name Link
🔨 Latest commit a0a583c
🔍 Latest deploy log https://app.netlify.com/sites/kleros-v2/deploys/65608d253fd0dd0008519f15
😎 Deploy Preview https://deploy-preview-1340--kleros-v2.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.

Comment on lines 7 to 13
const QuestionAndDescription = styled.div`
display: flex;
flex-direction: column;
> * {
margin: 0px;
}
`;
Copy link
Contributor

Choose a reason for hiding this comment

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

let's take the margin out and make it more specific using styled components

Suggested change
const QuestionAndDescription = styled.div`
display: flex;
flex-direction: column;
> * {
margin: 0px;
}
`;
const QuestionAndDescription = styled.div`
display: flex;
flex-direction: column;
`;
const StyledReactMarkDown = styled(ReactMarkDown)`
margin: 0px;
`

Comment on lines 21 to 30
const Answers = styled.div`
display: flex;
flex-direction: column;

span {
margin: 0px;
display: flex;
gap: 8px;
}
`;
Copy link
Contributor

Choose a reason for hiding this comment

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

same here:

Suggested change
const Answers = styled.div`
display: flex;
flex-direction: column;
span {
margin: 0px;
display: flex;
gap: 8px;
}
`;
const AnswersContainer = styled.div`
display: flex;
flex-direction: column;
`;
const Answer = styled.span`
margin: 0px;
display: flex;
gap: 8px;
`

Comment on lines 48 to 52
{disputeTemplate?.frontendUrl && (
<a href={disputeTemplate?.frontendUrl} target="_blank" rel="noreferrer">
Go to arbitrable
</a>
)}
Copy link
Contributor

Choose a reason for hiding this comment

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

I have been trying to favor the following syntax on these situations (make sure to run it through the linter 😅 ):

Suggested change
{disputeTemplate?.frontendUrl && (
<a href={disputeTemplate?.frontendUrl} target="_blank" rel="noreferrer">
Go to arbitrable
</a>
)}
{isUndefined(disputeTemplate?.frontendUrl)
? null
: (
<a href={disputeTemplate?.frontendUrl} target="_blank" rel="noreferrer">
Go to arbitrable
</a>
)
}

</a>
)}
<VotingOptions>
{disputeTemplate && <h3>Voting Options</h3>}
Copy link
Contributor

Choose a reason for hiding this comment

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

same as with the previous comment, let's try the other syntax

Comment on lines 40 to 43
> svg {
width: 16px;
fill: ${({ theme }) => theme.primaryBlue};
}
Copy link
Contributor

Choose a reason for hiding this comment

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

let's take this out into its own styled component

Comment on lines 25 to 27
> h1 {
margin: 0;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

which component is this style for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was for the title, moved it to DisputeContext now

{...{ rewards, category }}
/>
</Container>
<Policies disputePolicyURI={disputeTemplate?.policyURI} courtId={courtPolicy && court?.id} />
Copy link
Contributor

Choose a reason for hiding this comment

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

check if the courtID being passed as props (line 48) can be used here instead of courtPolicy && court?.id

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it works , passing that to the Policies component now

const localRounds = getLocalRounds(votingHistory?.dispute?.disputeKitDispute);
const courtName = courtPolicy?.name;
const court = disputeDetails?.dispute?.court;
const rewards = court ? `≥ ${formatEther(court.feeForJuror)} ETH` : undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

let's use useMemo here

return (
<>
<Container>
<DisputeBasicInfo disputeTemplate={disputeTemplate} />
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe change the name of this component so that it doesn't get mixed up with DisputeInfo 🤔 something like DisputeQuestion or DisputeContext seems fine I think 🤔

Copy link

codeclimate bot commented Nov 24, 2023

Code Climate has analyzed commit a0a583c and detected 17 issues on this pull request.

Here's the issue category breakdown:

Category Count
Duplication 6
Style 11

View more on Code Climate.

Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication

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 Nov 24, 2023
Merged via the queue into dev with commit 0795fbc Nov 24, 2023
@jaybuidl jaybuidl deleted the refactor(web)/case-details-overview branch December 7, 2023 18:54
@jaybuidl jaybuidl added this to the testnet-2.1 milestone Dec 7, 2023
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.

3 participants