Browse Source

Open OperationDetail modal after transaction success

master
meriadec 7 years ago
parent
commit
63da0bdf0c
No known key found for this signature in database GPG Key ID: 1D2FC2305E2CB399
  1. 7
      src/components/modals/OperationDetails.js
  2. 16
      src/components/modals/Send/index.js
  3. 10
      src/components/modals/Send/steps/04-step-confirmation.js

7
src/components/modals/OperationDetails.js

@ -243,16 +243,13 @@ const OperationDetails = connect(mapStateToProps)((props: Props) => {
<GradientBox /> <GradientBox />
</ModalContent> </ModalContent>
{url && (
<ModalFooter horizontal justify="flex-end" flow={2}> <ModalFooter horizontal justify="flex-end" flow={2}>
<Button padded onClick={onClose}>
{t('app:common.cancel')}
</Button>
{url ? (
<Button primary padded onClick={() => shell.openExternal(url)}> <Button primary padded onClick={() => shell.openExternal(url)}>
{t('app:operationDetails.viewOperation')} {t('app:operationDetails.viewOperation')}
</Button> </Button>
) : null}
</ModalFooter> </ModalFooter>
)}
</ModalBody> </ModalBody>
) )
}) })

16
src/components/modals/Send/index.js

@ -20,7 +20,7 @@ import type { StepProps as DefaultStepProps } from 'components/base/Stepper'
import { getCurrentDevice } from 'reducers/devices' import { getCurrentDevice } from 'reducers/devices'
import { accountsSelector } from 'reducers/accounts' import { accountsSelector } from 'reducers/accounts'
import { closeModal } from 'reducers/modals' import { closeModal, openModal } from 'reducers/modals'
import Modal from 'components/base/Modal' import Modal from 'components/base/Modal'
import Stepper from 'components/base/Stepper' import Stepper from 'components/base/Stepper'
@ -38,6 +38,7 @@ type Props = {
device: ?Device, device: ?Device,
accounts: Account[], accounts: Account[],
closeModal: string => void, closeModal: string => void,
openModal: (string, any) => void,
updateAccountWithUpdater: (string, (Account) => Account) => void, updateAccountWithUpdater: (string, (Account) => Account) => void,
} }
@ -62,6 +63,7 @@ export type StepProps<Transaction> = DefaultStepProps & {
error: ?Error, error: ?Error,
optimisticOperation: ?Operation, optimisticOperation: ?Operation,
closeModal: void => void, closeModal: void => void,
openModal: (string, any) => void,
isAppOpened: boolean, isAppOpened: boolean,
onChangeAccount: (?Account) => void, onChangeAccount: (?Account) => void,
onChangeAppOpened: boolean => void, onChangeAppOpened: boolean => void,
@ -111,6 +113,7 @@ const mapStateToProps = createStructuredSelector({
const mapDispatchToProps = { const mapDispatchToProps = {
closeModal, closeModal,
openModal,
updateAccountWithUpdater, updateAccountWithUpdater,
} }
@ -128,10 +131,8 @@ const INITIAL_STATE = {
} }
class SendModal extends PureComponent<Props, State<*>> { class SendModal extends PureComponent<Props, State<*>> {
state = INITIAL_STATE state = INITIAL_STATE
STEPS = createSteps({ t: this.props.t })
_signTransactionSub = null
_isUnmounted = false
componentWillUnmount() { componentWillUnmount() {
if (this._signTransactionSub) { if (this._signTransactionSub) {
@ -139,6 +140,10 @@ class SendModal extends PureComponent<Props, State<*>> {
} }
} }
STEPS = createSteps({ t: this.props.t })
_signTransactionSub = null
_isUnmounted = false
handleReset = () => this.setState({ ...INITIAL_STATE }) handleReset = () => this.setState({ ...INITIAL_STATE })
handleCloseModal = () => this.props.closeModal(MODAL_SEND) handleCloseModal = () => this.props.closeModal(MODAL_SEND)
@ -218,7 +223,7 @@ class SendModal extends PureComponent<Props, State<*>> {
} }
render() { render() {
const { t, device } = this.props const { t, device, openModal } = this.props
const { const {
stepId, stepId,
account, account,
@ -239,6 +244,7 @@ class SendModal extends PureComponent<Props, State<*>> {
isAppOpened, isAppOpened,
error, error,
optimisticOperation, optimisticOperation,
openModal,
closeModal: this.handleCloseModal, closeModal: this.handleCloseModal,
onChangeAccount: this.handleChangeAccount, onChangeAccount: this.handleChangeAccount,
onChangeAppOpened: this.handleChangeAppOpened, onChangeAppOpened: this.handleChangeAppOpened,

10
src/components/modals/Send/steps/04-step-confirmation.js

@ -1,10 +1,10 @@
// @flow // @flow
import React, { Fragment } from 'react' import React, { Fragment } from 'react'
import { shell } from 'electron'
import styled from 'styled-components' import styled from 'styled-components'
import { getAccountOperationExplorer } from '@ledgerhq/live-common/lib/explorers' import { getAccountOperationExplorer } from '@ledgerhq/live-common/lib/explorers'
import { MODAL_OPERATION_DETAILS } from 'config/constants'
import { colors } from 'styles/theme' import { colors } from 'styles/theme'
import { multiline } from 'styles/helpers' import { multiline } from 'styles/helpers'
@ -83,6 +83,7 @@ export function StepConfirmationFooter({
onRetry, onRetry,
optimisticOperation, optimisticOperation,
error, error,
openModal,
closeModal, closeModal,
}: StepProps<*>) { }: StepProps<*>) {
const url = const url =
@ -96,8 +97,13 @@ export function StepConfirmationFooter({
<Button <Button
ml={2} ml={2}
onClick={() => { onClick={() => {
shell.openExternal(url)
closeModal() closeModal()
if (account && optimisticOperation) {
openModal(MODAL_OPERATION_DETAILS, {
operationId: optimisticOperation.id,
accountId: account.id,
})
}
}} }}
primary primary
> >

Loading…
Cancel
Save