forked from softvar/enhanced-github
-
Notifications
You must be signed in to change notification settings - Fork 4
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
Enhance/votestatusbuttons #86
Open
jex441
wants to merge
22
commits into
master
Choose a base branch
from
enhance/votestatusbuttons
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 16 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
6af5f7e
pr state simplified
92a317b
fix: vote totals never show 0%
5ce703e
new prs frozen
c90bf42
frozen state button styled
d082c6a
frozen front end working
ramirc5 1bb90cf
seeding users and transfering vp
dfcb4b8
voting
c34570d
new styled component
ramirc5 ef0660a
lock icon added
ramirc5 a7d8767
not sure why it's not rendering
ramirc5 cc46522
hashmap and styling
ramirc5 1176e67
small optimization, need to do some more later
ramirc5 5c999e0
added a progress bar, math is off
ramirc5 a234981
changed according to figma
ramirc5 2ec5cb3
fixed bug preventing modal from opening
ramirc5 be12ccb
button hover color transitions
ramirc5 4983f29
addressed comments
ramirc5 045f917
removed console log
ramirc5 85897be
added padding and removed % string
ramirc5 96ebbd3
fixed button onclick event over text and icon
ramirc5 fba2b0e
status badge condition
ramirc5 81a7c89
flexbox in buttons to accomodate different text
ramirc5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
let cypress = {}; | ||
try { | ||
cypress = require('../../cypress.env.json'); | ||
} catch (error) { | ||
console.warn('No cypress.env.json file in root directory. To run tests, follow the readme in /cypress'); | ||
} | ||
|
||
describe('Create users, transfer them VotePower', () => { | ||
it('should create users, and transfer 50_000 VotePower to each one.', () => { | ||
const { testers } = cypress; | ||
|
||
for (let objectKey in testers) { | ||
let bot = testers[objectKey]; | ||
let { key, user, apiToken } = bot; | ||
|
||
cy.findOrCreateUser( | ||
Cypress.env('turbosrcID'), | ||
Cypress.env('gitHubUsername'), | ||
Cypress.env('gitHubRepo'), | ||
key, | ||
user, | ||
key + key, | ||
apiToken | ||
); | ||
|
||
cy.getNameSpaceRepo(`${Cypress.env('gitHubUsername')}/${Cypress.env('gitHubRepo')}`).then(res => | ||
cy | ||
.request({ | ||
method: 'POST', | ||
url: 'http://localhost:4000/graphql', | ||
body: { | ||
operationName: 'transferTokens', | ||
query: ` | ||
query transferTokens { | ||
transferTokens( | ||
turboSrcID: "${Cypress.env('turboSrcID')}", | ||
owner: "${Cypress.env('gitHubUsername')}", | ||
repo: "${res.repoID}", | ||
from: "${Cypress.env('contributorID')}", | ||
to: "${key}", | ||
amount: ${5000}, | ||
token: "${Cypress.env('gitHubToken')}" | ||
) | ||
{ status } | ||
} | ||
` | ||
} | ||
}) | ||
.then(response => { | ||
// Your assertions and further actions here | ||
expect(response.body.data.transferTokens).to.have.property('status', 201); | ||
}) | ||
); | ||
} | ||
}); | ||
}); |
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,53 @@ | ||
let cypress = {}; | ||
try { | ||
cypress = require('../../cypress.env.json'); | ||
} catch (error) { | ||
console.warn('No cypress.env.json file in root directory. To run tests, follow the readme in /cypress'); | ||
} | ||
|
||
const createRepoRequestBody = (repoName, contributorID, token) => { | ||
return { | ||
method: 'POST', | ||
url: 'http://localhost:4000/graphql', | ||
body: { | ||
operationName: 'createRepo', | ||
query: ` | ||
query createRepo { | ||
createRepo( | ||
turboSrcID: "${Cypress.env('turboSrcID')}", | ||
owner: "", | ||
repo: "${repoName}", | ||
defaultHash: "", | ||
contributor_id: "${contributorID}", | ||
side: "", | ||
token: "${token}" | ||
) | ||
} | ||
` | ||
} | ||
}; | ||
}; | ||
|
||
describe('Create repo', () => { | ||
it('should create a user and a repo', () => { | ||
// See cypress/support/commands.js | ||
|
||
// Create maintainer user: | ||
cy.findOrCreateUser( | ||
Cypress.env('turbosrcID'), | ||
Cypress.env('gitHubUsername'), | ||
Cypress.env('gitHubRepo'), | ||
Cypress.env('contributorID'), | ||
Cypress.env('gitHubUsername'), | ||
Cypress.env('contributorSignature'), | ||
Cypress.env('gitHubToken') | ||
); | ||
|
||
const repoName = `${Cypress.env('gitHubUsername')}/${Cypress.env('gitHubRepo')}`; | ||
const createDemoRepoRequestBody = createRepoRequestBody(repoName, Cypress.env('contributorID'), Cypress.env('gitHubToken')) | ||
// Create demo repo | ||
cy.request(createDemoRepoRequestBody).then(response => { | ||
expect(Number(response.body.data.createRepo)).to.equal(201); | ||
}); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
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,63 @@ | ||
let cypress = {}; | ||
try { | ||
cypress = require('../../cypress.env.json'); | ||
} catch (error) { | ||
console.warn('No cypress.env.json file in root directory. To run tests, follow the readme in /cypress'); | ||
} | ||
|
||
const setVoteRequestBody = (turboSrcID, owner, repo, defaultHash, childDefaultHash, mergeable, contributor_id, side, token) => { | ||
return { | ||
method: 'POST', | ||
url: 'http://localhost:4000/graphql', | ||
body: { | ||
operationName: 'setVote', | ||
query: ` | ||
query setVote { | ||
setVote( | ||
turboSrcID: "${turboSrcID}", | ||
owner: "${owner}", | ||
repo: "${repo}", | ||
defaultHash: "${defaultHash}", | ||
childDefaultHash: "${childDefaultHash}", | ||
mergeable: ${mergeable}, | ||
contributor_id: "${contributor_id}", | ||
side: "${side}", | ||
token: "${token}" | ||
) | ||
} | ||
` | ||
} | ||
}; | ||
}; | ||
|
||
describe('Voting', () => { | ||
it('should vote on PR #1', () => { | ||
cy.login(); | ||
|
||
cy.visit(`https://github.com/${Cypress.env('gitHubUsername')}/${Cypress.env('gitHubRepo')}/pulls`); | ||
|
||
const { testers } = cypress; | ||
for (let objectKey in testers) { | ||
let bot = testers[objectKey]; | ||
let { key, apiToken } = bot; | ||
|
||
const testerVoteRequestBody = setVoteRequestBody( | ||
Cypress.env('turboSrcID'), | ||
Cypress.env('gitHubUsername'), | ||
res.repoID, | ||
'issue_1', | ||
'issue_1', | ||
true, | ||
key, | ||
'yes', | ||
apiToken | ||
); | ||
|
||
cy.getNameSpaceRepo(`${Cypress.env('gitHubUsername')}/${Cypress.env('gitHubRepo')}`).then(res => | ||
cy.request(testerVoteRequestBody).then(response => { | ||
expect(response.body.data.setVote).to.equal('201'); | ||
}) | ||
); | ||
} | ||
}); | ||
}); |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,62 @@ | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
|
||
const YesBar = styled.div` | ||
background-color: #038800; | ||
height: 3px; | ||
flex-basis: ${props => props.flexBasis}%; | ||
border-radius: ${props => props.roundedCorners || '0px'}; | ||
`; | ||
|
||
const NoBar = styled(YesBar)` | ||
background-color: #d33131; | ||
flex-basis: ${props => props.flexBasis}%; | ||
`; | ||
|
||
const RemainingBar = styled(YesBar)` | ||
background-color: #d9d9d9; | ||
flex-basis: ${props => props.flexBasis}%; | ||
`; | ||
|
||
const VoteBar = styled.div` | ||
display: flex; | ||
height: 5px; | ||
width: 100%; | ||
margin-bottom: 4px; | ||
margin-top: 5px; | ||
filter: drop-shadow(0px 1px 1px rgba(0, 0, 0, 0.35)); | ||
`; | ||
|
||
const ButtonProgress = ({ yesPercent, noPercent, quorum, totalVotes }) => { | ||
const difference = 1 / quorum; | ||
const yesWidth = yesPercent * 100 * difference; | ||
const noWidth = noPercent * 100 * difference; | ||
const remainingVotesPercent = 100 - (yesWidth + noWidth); | ||
const yesRoundedCorners = remainingVotesPercent > 0 ? '0px' : '0px 2px 2px 0px'; | ||
const noRoundedCorners = remainingVotesPercent > 0 ? '0px' : '2px 0px 0px 2px'; | ||
const remainingRoundedCorners = '2px 0px 0px 2px'; | ||
if (totalVotes > 0) { | ||
return ( | ||
<> | ||
<VoteBar> | ||
{yesPercent >= noPercent ? ( | ||
<> | ||
<NoBar flexBasis={noWidth} roundedCorners={noRoundedCorners} /> | ||
<YesBar flexBasis={yesWidth} roundedCorners={yesRoundedCorners} /> | ||
</> | ||
) : ( | ||
<> | ||
<YesBar flexBasis={yesWidth} roundedCorners={yesRoundedCorners} /> | ||
<NoBar flexBasis={noWidth} roundedCorners={noRoundedCorners} /> | ||
</> | ||
)} | ||
{remainingVotesPercent > 0 && <RemainingBar flexBasis={remainingVotesPercent} roundedCorners={remainingRoundedCorners} />} | ||
</VoteBar> | ||
</> | ||
); | ||
|
||
} else { | ||
return null; | ||
} | ||
}; | ||
export default ButtonProgress; |
Empty file.
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.
Can this be achieved by having the div nth-child(first) and div nth-child(last) of the VoteBar have rounded corners on the left or the right respectively?