Browse Source

Merge branch 'master' into feature/package-binary

renovate/lint-staged-8.x
JimmyMow 7 years ago
committed by GitHub
parent
commit
0a9f623462
  1. 4
      app/components/ModalRoot/ModalRoot.js
  2. 22
      app/components/ModalRoot/SuccessfulSendPayment.js
  3. 37
      app/components/ModalRoot/SuccessfulSendPayment.scss
  4. 13
      app/main.dev.js
  5. 3
      app/reducers/ipc.js
  6. 8
      app/reducers/payform.js
  7. 3
      app/reducers/payment.js
  8. 15
      test/components/ModalRoot.spec.js

4
app/components/ModalRoot/ModalRoot.js

@ -2,10 +2,12 @@ import React from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import { MdClose } from 'react-icons/lib/md' import { MdClose } from 'react-icons/lib/md'
import SuccessfulSendCoins from './SuccessfulSendCoins' import SuccessfulSendCoins from './SuccessfulSendCoins'
import SuccessfulSendPayment from './SuccessfulSendPayment'
import styles from './ModalRoot.scss' import styles from './ModalRoot.scss'
const MODAL_COMPONENTS = { const MODAL_COMPONENTS = {
SUCCESSFUL_SEND_COINS: SuccessfulSendCoins SUCCESSFUL_SEND_COINS: SuccessfulSendCoins,
SUCCESSFUL_SEND_PAYMENT: SuccessfulSendPayment
/* other modals */ /* other modals */
} }

22
app/components/ModalRoot/SuccessfulSendPayment.js

@ -0,0 +1,22 @@
import React from 'react'
import PropTypes from 'prop-types'
import AnimatedCheckmark from 'components/AnimatedCheckmark'
import styles from './SuccessfulSendPayment.scss'
const SuccessfulSendPayment = ({ hideModal }) => (
<div className={styles.container}>
<AnimatedCheckmark />
<h1>
<span>Successfully sent payment</span>&nbsp;
</h1>
<div className={styles.button} onClick={hideModal}>
Done
</div>
</div>
)
SuccessfulSendPayment.propTypes = {
hideModal: PropTypes.func.isRequired
}
export default SuccessfulSendPayment

37
app/components/ModalRoot/SuccessfulSendPayment.scss

@ -0,0 +1,37 @@
@import '../../variables.scss';
.container {
position: relative;
min-height: 250px;
top: calc(50% - 250px);
text-align: center;
h1 {
font-size: 20px;
margin: 50px 0;
.link {
cursor: pointer;
color: $main;
text-decoration: underline;
}
.amount, .addr {
font-weight: bold;
}
}
.button {
text-align: center;
border-radius: 8px;
background: $main;
padding: 20px 10px;
font-weight: bold;
cursor: pointer;
text-transform: uppercase;
letter-spacing: .2px;
color: $white;
width: 15%;
margin: 0 auto;
}
}

13
app/main.dev.js

@ -36,9 +36,6 @@ if (process.env.NODE_ENV === 'development' || process.env.DEBUG_PROD === 'true')
const path = require('path'); const path = require('path');
const p = path.join(__dirname, '..', 'app', 'node_modules'); const p = path.join(__dirname, '..', 'app', 'node_modules');
require('module').globalPaths.push(p); require('module').globalPaths.push(p);
// set icon
// app.dock.setIcon(`${path.join(__dirname, '..', 'resources')}/zap_2.png`)
} }
const installExtensions = async () => { const installExtensions = async () => {
@ -182,4 +179,14 @@ app.on('ready', async () => {
}) })
} }
}) })
});
app.setAsDefaultProtocolClient('lightning')
app.on('open-url', function (event, url) {
event.preventDefault()
const payreq = url.split(':')[1]
mainWindow.webContents.send('lightningPaymentUri', { payreq })
mainWindow.show()
}) })

3
app/reducers/ipc.js

@ -20,6 +20,7 @@ import {
pushclosechannelstatus pushclosechannelstatus
} from './channels' } from './channels'
import { lightningPaymentUri } from './payform'
import { receivePayments, paymentSuccessful } from './payment' import { receivePayments, paymentSuccessful } from './payment'
import { receiveInvoices, createdInvoice, receiveFormInvoice, invoiceUpdate } from './invoice' import { receiveInvoices, createdInvoice, receiveFormInvoice, invoiceUpdate } from './invoice'
import { receiveBalance } from './balance' import { receiveBalance } from './balance'
@ -51,6 +52,8 @@ const ipc = createIpc({
receiveBalance, receiveBalance,
lightningPaymentUri,
paymentSuccessful, paymentSuccessful,
channelSuccessful, channelSuccessful,

8
app/reducers/payform.js

@ -3,6 +3,7 @@ import bitcoin from 'bitcoinjs-lib'
import isEmpty from 'lodash/isEmpty' import isEmpty from 'lodash/isEmpty'
import { setFormType } from './form'
import { tickerSelectors } from './ticker' import { tickerSelectors } from './ticker'
import { btc, bech32 } from '../utils' import { btc, bech32 } from '../utils'
@ -64,6 +65,13 @@ export function updatePayErrors(errorsObject) {
} }
} }
export const lightningPaymentUri = (event, { payreq }) => (dispatch) => {
// Open pay form
dispatch(setFormType('PAY_FORM'))
// Set payreq
dispatch(setPayInput(payreq))
}
export function resetPayForm() { export function resetPayForm() {
return { return {
type: RESET_FORM type: RESET_FORM

3
app/reducers/payment.js

@ -2,6 +2,7 @@ import { createSelector } from 'reselect'
import { ipcRenderer } from 'electron' import { ipcRenderer } from 'electron'
import { setFormType } from './form' import { setFormType } from './form'
import { resetPayForm } from './payform' import { resetPayForm } from './payform'
import { showModal } from './modal'
// ------------------------------------ // ------------------------------------
// Constants // Constants
@ -73,6 +74,8 @@ export const paymentSuccessful = () => (dispatch) => {
// Close the form modal once the payment was succesful // Close the form modal once the payment was succesful
dispatch(setFormType(null)) dispatch(setFormType(null))
// Show successful payment state
dispatch(showModal('SUCCESSFUL_SEND_PAYMENT'))
// Refetch payments (TODO: dont do a full refetch, rather append new tx to list) // Refetch payments (TODO: dont do a full refetch, rather append new tx to list)
dispatch(fetchPayments()) dispatch(fetchPayments())

15
test/components/ModalRoot.spec.js

@ -2,6 +2,7 @@ import React from 'react'
import { shallow } from 'enzyme' import { shallow } from 'enzyme'
import ModalRoot from '../../app/components/ModalRoot' import ModalRoot from '../../app/components/ModalRoot'
import SuccessfulSendCoins from '../../app/components/ModalRoot/SuccessfulSendCoins' import SuccessfulSendCoins from '../../app/components/ModalRoot/SuccessfulSendCoins'
import SuccessfulSendPayment from '../../app/components/ModalRoot/SuccessfulSendPayment'
const defaultProps = { const defaultProps = {
hideModal: () => {}, hideModal: () => {},
@ -32,4 +33,16 @@ describe('SuccessfulSendCoins modal', () => {
it('should render specific modal', () => { it('should render specific modal', () => {
expect(el.find(SuccessfulSendCoins).length).toBe(1) expect(el.find(SuccessfulSendCoins).length).toBe(1)
}) })
}); })
describe('SuccessfulSendPayment modal', () => {
const props = {
...defaultProps,
modalType: 'SUCCESSFUL_SEND_PAYMENT',
modalProps: {}
}
const el = shallow(<ModalRoot {...props} />)
it('should render specific modal', () => {
expect(el.find(SuccessfulSendPayment).length).toBe(1)
})
})

Loading…
Cancel
Save