Browse Source

Merge pull request #324 from NastiaS/minorFeaturesBranch

wip
master
Gaëtan Renaudeau 7 years ago
committed by GitHub
parent
commit
e74e032f4f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      src/components/GlobalSearch.js
  2. 2
      src/components/TopBar.js
  3. 32
      src/components/modals/SettingsAccount.js

10
src/components/GlobalSearch.js

@ -1,6 +1,6 @@
// @flow // @flow
import React, { PureComponent } from 'react' import React, { PureComponent, Fragment } from 'react'
import styled from 'styled-components' import styled from 'styled-components'
import type { T } from 'types/common' import type { T } from 'types/common'
@ -29,6 +29,7 @@ type State = {
type Props = { type Props = {
t: T, t: T,
isHidden: boolean,
} }
class GlobalSearch extends PureComponent<Props, State> { class GlobalSearch extends PureComponent<Props, State> {
@ -55,11 +56,12 @@ class GlobalSearch extends PureComponent<Props, State> {
}) })
render() { render() {
const { t } = this.props const { t, isHidden } = this.props
const { isFocused } = this.state const { isFocused } = this.state
return ( return (
<Container isFocused={isFocused}> <Container isFocused={isFocused}>
{!isHidden && (
<Fragment>
<Box justifyContent="center" onClick={this.focusInput} pr={2}> <Box justifyContent="center" onClick={this.focusInput} pr={2}>
<IconSearch size={16} /> <IconSearch size={16} />
</Box> </Box>
@ -70,6 +72,8 @@ class GlobalSearch extends PureComponent<Props, State> {
onFocus={this.handleFocus} onFocus={this.handleFocus}
isFocused={isFocused} isFocused={isFocused}
/> />
</Fragment>
)}
</Container> </Container>
) )
} }

2
src/components/TopBar.js

@ -164,7 +164,7 @@ class TopBar extends PureComponent<Props, State> {
<Container bg="lightGrey" color="graphite"> <Container bg="lightGrey" color="graphite">
<Inner> <Inner>
<Box grow horizontal flow={4}> <Box grow horizontal flow={4}>
<GlobalSearch t={t} /> <GlobalSearch t={t} isHidden />
<Box justifyContent="center"> <Box justifyContent="center">
<IconDevices size={16} /> <IconDevices size={16} />
</Box> </Box>

32
src/components/modals/SettingsAccount.js

@ -4,7 +4,7 @@ import React, { PureComponent } from 'react'
import { connect } from 'react-redux' import { connect } from 'react-redux'
import get from 'lodash/get' import get from 'lodash/get'
import { push } from 'react-router-redux' import { push } from 'react-router-redux'
import type { Account } from '@ledgerhq/live-common/lib/types' import type { Account, Unit } from '@ledgerhq/live-common/lib/types'
import { MODAL_SETTINGS_ACCOUNT } from 'config/constants' import { MODAL_SETTINGS_ACCOUNT } from 'config/constants'
@ -14,6 +14,7 @@ import { setDataModal, closeModal } from 'reducers/modals'
import Box from 'components/base/Box' import Box from 'components/base/Box'
import Button from 'components/base/Button' import Button from 'components/base/Button'
import Input from 'components/base/Input' import Input from 'components/base/Input'
import Select from 'components/base/Select/index'
import Modal, { ModalBody, ModalTitle, ModalFooter, ModalContent } from 'components/base/Modal' import Modal, { ModalBody, ModalTitle, ModalFooter, ModalContent } from 'components/base/Modal'
import Label from 'components/base/Label' import Label from 'components/base/Label'
@ -24,6 +25,7 @@ type State = {
minConfirmations: number | null, minConfirmations: number | null,
editName: boolean, editName: boolean,
nameHovered: boolean, nameHovered: boolean,
editUnit: boolean,
} }
type Props = { type Props = {
@ -47,6 +49,7 @@ const defaultState = {
accountName: null, accountName: null,
minConfirmations: null, minConfirmations: null,
nameHovered: false, nameHovered: false,
editUnit: false,
} }
function hasNoOperations(account: Account) { function hasNoOperations(account: Account) {
@ -62,7 +65,6 @@ class SettingsAccount extends PureComponent<Props, State> {
const { accountName, minConfirmations } = this.state const { accountName, minConfirmations } = this.state
const account = get(data, 'account', {}) const account = get(data, 'account', {})
return { return {
...account, ...account,
...(accountName !== null ...(accountName !== null
@ -146,8 +148,15 @@ class SettingsAccount extends PureComponent<Props, State> {
...defaultState, ...defaultState,
}) })
handleChangeUnit = (value: Unit, account: Account) => {
const { updateAccount, setDataModal } = this.props
account = { ...account, unit: value }
updateAccount(account)
setDataModal(MODAL_SETTINGS_ACCOUNT, { account })
}
render() { render() {
const { editName, nameHovered } = this.state const { editName, nameHovered, editUnit } = this.state
return ( return (
<Modal <Modal
@ -155,7 +164,6 @@ class SettingsAccount extends PureComponent<Props, State> {
onHide={this.handleHide} onHide={this.handleHide}
render={({ data, onClose }) => { render={({ data, onClose }) => {
const account = this.getAccount(data) const account = this.getAccount(data)
return ( return (
<ModalBody onClose={onClose}> <ModalBody onClose={onClose}>
<ModalTitle>{'Account settings'}</ModalTitle> <ModalTitle>{'Account settings'}</ModalTitle>
@ -205,12 +213,26 @@ class SettingsAccount extends PureComponent<Props, State> {
onChange={this.handleChangeMinConfirmations(account)} onChange={this.handleChangeMinConfirmations(account)}
/> />
</Box> </Box>
{editUnit && (
<Box>
<Label>{'Edit Units'}</Label>
<Select
keyProp="code"
onChange={value => this.handleChangeUnit(value, account)}
renderSelected={item => item && item.code}
value={account.unit}
items={account.currency.units}
/>
</Box>
)}
</ModalContent> </ModalContent>
<ModalFooter horizontal justify="flex-end" flow={2}> <ModalFooter horizontal justify="flex-end" flow={2}>
<Button onClick={this.handleArchiveAccount(account)}> <Button onClick={this.handleArchiveAccount(account)}>
{hasNoOperations(account) ? 'Remove account' : 'Archive account'} {hasNoOperations(account) ? 'Remove account' : 'Archive account'}
</Button> </Button>
<Button primary>Go to account</Button> <Button primary onClick={onClose}>
Go to account
</Button>
</ModalFooter> </ModalFooter>
</ModalBody> </ModalBody>
) )

Loading…
Cancel
Save