Skip to content

Commit

Permalink
fix: getting back to old implementation for taskFetch to not raise gi…
Browse files Browse the repository at this point in the history
…thub api limit error and placing some dialogs to drawer
  • Loading branch information
alexanmtz committed Jun 10, 2024
1 parent 389a3b9 commit 73eb4bb
Show file tree
Hide file tree
Showing 8 changed files with 237 additions and 203 deletions.
8 changes: 4 additions & 4 deletions frontend/src/components/profile/transfers/transfer-detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const TransferDetails = ({ open, onClose, fetchTransfer, transfer, id, history,
title={
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 8 }}>
<Typography variant="body1">
<FormattedMessage id="transfer.amount" defaultMessage='Sending money to {value}'
<FormattedMessage id="transfer.to.label" defaultMessage='Sending money to {value}'
values={{ value: <strong>{data?.User?.username}</strong> }}
/>
</Typography>
Expand Down Expand Up @@ -153,9 +153,9 @@ const TransferDetails = ({ open, onClose, fetchTransfer, transfer, id, history,
{currentTab === 1 && data.paypalTransfer && (
<div style={{ margin: '20px 0' }}>
<TransactionRow label={<FormattedMessage id='transfer.details.transaction_id' defaultMessage='Transaction ID' />} value={'#' + data.paypalTransfer.batch_header.payout_batch_id} />
<TransactionRow label={<FormattedMessage id='transfer.details.transaction_id' defaultMessage='Status' />} value={data.paypalTransfer.batch_header.batch_status} />
<TransactionRow label={<FormattedMessage id='transfer.details.transaction_id' defaultMessage='Amount' />} value={data.paypalTransfer.batch_header.amount.value} />
<TransactionRow label={<FormattedMessage id='transfer.details.transaction_id' defaultMessage='Time' />} value={data.paypalTransfer.batch_header.time_completed} />
<TransactionRow label={<FormattedMessage id='transfer.details.status' defaultMessage='Status' />} value={data.paypalTransfer.batch_header.batch_status} />
<TransactionRow label={<FormattedMessage id='transfer.details.amount' defaultMessage='Amount' />} value={data.paypalTransfer.batch_header.amount.value} />
<TransactionRow label={<FormattedMessage id='transfer.details.time' defaultMessage='Time' />} value={data.paypalTransfer.batch_header.time_completed} />
</div>
)}
</div>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/task/task-header.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class TaskHeader extends React.Component {
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<Typography variant='h5' gutterBottom title={task.data.title}>
<strong>
{task.data.title || 'no title'}
{task.data.title}
</strong>
</Typography>
<IconButton onClick={this.handleMoreButton}>
Expand Down
363 changes: 182 additions & 181 deletions frontend/src/components/task/task-payment-form.js

Large diffs are not rendered by default.

25 changes: 12 additions & 13 deletions frontend/src/components/task/task-payment.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { injectIntl, defineMessages, FormattedMessage } from 'react-intl'
import Alert from '@material-ui/lab/Alert'
import AlertTitle from '@material-ui/lab/AlertTitle'
import {
Container,
withStyles,
Button,
Typography,
Expand All @@ -14,10 +15,7 @@ import {
ListItemAvatar,
ListItemText,
Divider,
Dialog,
DialogTitle,
DialogContent,
DialogContentText,
Drawer,
AppBar,
Tabs,
Tab,
Expand Down Expand Up @@ -233,17 +231,18 @@ class TaskPayment extends Component {
}

return (
<Dialog
<Drawer
onClose={ this.props.onClose }
aria-labelledby='simple-dialog-title'
fullWidth
maxWidth='md'
anchor='right'
{ ...other }
>
<DialogTitle id='simple-dialog-title'>
<FormattedMessage id='task.payment.action.title' defaultMessage='Pay for this task' />
</DialogTitle>
<DialogContent>
<Container style={{padding: 20}}>
<Typography variant='h5' id='simple-dialog-title' gutterBottom>
<FormattedMessage id='task.payment.action.title' defaultMessage='Send payment for this issue to an user' />
</Typography>
{ this.props.paid && (
<Typography type='subheading' color='primary' gutterBottom noWrap>
<FormattedMessage id='task.payment.transfers.concluded' defaultMessage='All transfers was succeeded to the destination account' />
Expand Down Expand Up @@ -374,7 +373,7 @@ class TaskPayment extends Component {
</List> }
</TabContainer>
</div>
<DialogContentText>

<div>
{ (!this.props.paid || this.props.task?.Transfer?.id) ? (
<div>
Expand Down Expand Up @@ -439,7 +438,7 @@ class TaskPayment extends Component {
</div>
) }
</div>
</DialogContentText>

<Divider />
{ hasOrders() ? (
<div>
Expand Down Expand Up @@ -474,8 +473,8 @@ class TaskPayment extends Component {
<FormattedMessage id='task.payment.action.close' defaultMessage='Close' />
</Button>
) }
</DialogContent>
</Dialog>
</Container>
</Drawer>
)
}
}
Expand Down
14 changes: 14 additions & 0 deletions frontend/src/translations/generated/br.json
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,12 @@
"profile.accountMenu.profile": "",
"profile.header.action.secondary": "",
"profile.payouts.headerCreated": "",
"profile.payouts.headerMethod": "",
"profile.payouts.headerStatus": "",
"profile.payouts.headerValue": "",
"profile.payouts.title": "",
"profile.transfer.notactive": "",
"profile.transfer.paypal.notactive": "",
"profile.transfer.title": "",
"skip": "",
"task.actions.account.logout": "",
Expand Down Expand Up @@ -450,6 +452,7 @@
"task.card.subtitle": "",
"task.card.table.header.actions": "",
"task.card.table.header.issue": "",
"task.card.table.header.method": "",
"task.card.table.header.paid": "",
"task.card.table.header.payment.created": "",
"task.card.table.header.payment.type": "",
Expand Down Expand Up @@ -503,6 +506,7 @@
"task.invite.text.label": "",
"task.invite.title": "",
"task.labels": "",
"task.learn": "",
"task.level.easy": "",
"task.level.easy.description": "",
"task.level.hard": "",
Expand Down Expand Up @@ -685,6 +689,13 @@
"topbar.link.prices": "",
"topbar.signin.label": "",
"topbar.signup.label": "",
"transfer.amount": "",
"transfer.details": "",
"transfer.details.amount": "",
"transfer.details.status": "",
"transfer.details.time": "",
"transfer.details.transaction_id": "",
"transfer.status": "",
"transfer.table.body.noPayouts": "",
"transfer.table.body.notransfer": "",
"transfer.table.date.none": "",
Expand All @@ -693,9 +704,12 @@
"transfer.table.page.next": "",
"transfer.table.page.previous": "",
"transfer.table.value.none": "",
"transfer.to.label": "",
"transfers.action.payout.button": "",
"transfers.alert.button": "",
"transfers.alert.button.paypal": "",
"transfers.button.cancel": "",
"transfers.button.details": "",
"transfers.table.page.first": "",
"user.account.page.title": "",
"user.confirm.password.error": "",
Expand Down
16 changes: 15 additions & 1 deletion frontend/src/translations/generated/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,12 @@
"profile.accountMenu.profile": "Profile",
"profile.header.action.secondary": "Work on an issue",
"profile.payouts.headerCreated": "Created",
"profile.payouts.headerMethod": "Method",
"profile.payouts.headerStatus": "Status",
"profile.payouts.headerValue": "Value",
"profile.payouts.title": "Payouts",
"profile.transfer.notactive": "Your account is not active, please finish the setup of your account to receive payouts",
"profile.transfer.paypal.notactive": "Your Paypal account is not active, please finish the setup of your account to receive the missing Paypal payment",
"profile.transfer.title": "Transfers",
"skip": "Skip",
"task.actions.account.logout": "Logout",
Expand Down Expand Up @@ -450,6 +452,7 @@
"task.card.subtitle": "This payments will be transfered after the task be finished",
"task.card.table.header.actions": "Actions",
"task.card.table.header.issue": "Issue",
"task.card.table.header.method": "Method",
"task.card.table.header.paid": "Paid",
"task.card.table.header.payment.created": "Created",
"task.card.table.header.payment.type": "Type",
Expand Down Expand Up @@ -503,6 +506,7 @@
"task.invite.text.label": "Write a text to be sent with the invite",
"task.invite.title": "Invite someone to work on this task",
"task.labels": "Labels",
"task.learn": "For learning purposes",
"task.level.easy": "Easy",
"task.level.easy.description": "Easy issue to solve",
"task.level.hard": "Hard",
Expand Down Expand Up @@ -554,7 +558,7 @@
"task.payment.action.close": "Close",
"task.payment.action.pendingConfirmation": "Pending User Confirmation",
"task.payment.action.rejected": "Rejected by User",
"task.payment.action.title": "Pay for this task",
"task.payment.action.title": "Send payment for this issue to an user",
"task.payment.creditcard.action": "Pay {amount} with Credit Card",
"task.payment.done.to": "You made a payment to $ {user}",
"task.payment.filter.all": "All payments",
Expand Down Expand Up @@ -685,6 +689,13 @@
"topbar.link.prices": "Prices",
"topbar.signin.label": "Signin",
"topbar.signup.label": "Signup",
"transfer.amount": "Amount",
"transfer.details": "Transfer details",
"transfer.details.amount": "Amount",
"transfer.details.status": "Status",
"transfer.details.time": "Time",
"transfer.details.transaction_id": "Transaction ID",
"transfer.status": "Status",
"transfer.table.body.noPayouts": "No Payouts",
"transfer.table.body.notransfer": "No Transfers",
"transfer.table.date.none": "Not yet defined",
Expand All @@ -693,9 +704,12 @@
"transfer.table.page.next": "Next page",
"transfer.table.page.previous": "Previous page",
"transfer.table.value.none": "No bounty added",
"transfer.to.label": "Sending money to {value}",
"transfers.action.payout.button": "Request payout",
"transfers.alert.button": "Update your account",
"transfers.alert.button.paypal": "Link your Paypal account",
"transfers.button.cancel": "Send bounty",
"transfers.button.details": "Details",
"transfers.table.page.first": "First page",
"user.account.page.title": "Account",
"user.confirm.password.error": "Passwords do not match",
Expand Down
6 changes: 6 additions & 0 deletions modules/tasks/taskFetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,12 @@ module.exports = Promise.method(function taskFetch (taskParams) {
}
}
return responseGithub
}).catch(e => {
// eslint-disable-next-line no-console
console.log('Github response error')
// eslint-disable-next-line no-console
console.log(e)
return data.dataValues
})

case 'bitbucket':
Expand Down
6 changes: 3 additions & 3 deletions test/task.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,15 @@ describe("tasks", () => {
}).catch(done)
})

it('should give an error on fetch if the issue build responds with limit exceeded', (done) => {
it('should not raise an error on fetch if the issue build responds with limit exceeded', (done) => {
registerAndLogin(agent).then(res => {
createTask(res.headers.authorization, {url: 'https://github.com/worknenjoy/gitpay/issues/1080', provider: 'github'}).then(task => {
nockAuthLimitExceeded()
agent
.get(`/tasks/fetch/${task.id}`)
.end((err, res) => {
expect(res.body.error).exist
expect(res.body.error).to.contain('API rate limit exceeded')
expect(res.body).exist
expect(res.body.id).to.equal(task.id)
done();
})
}).catch(done)
Expand Down

0 comments on commit 73eb4bb

Please sign in to comment.