remove updateSafeName action

This commit is contained in:
mmv 2019-06-25 18:09:00 +04:00
parent 3f98ac903b
commit 951309eee5
8 changed files with 32 additions and 56 deletions

View File

@ -25,6 +25,7 @@ type Props = SelectorProps & {
classes: Object,
granted: boolean,
createTransaction: Function,
updateSafe: Function,
}
type State = {
@ -90,7 +91,7 @@ class Layout extends React.Component<Props, State> {
render() {
const {
safe, provider, network, classes, granted, tokens, activeTokens, createTransaction, updateSafeName,
safe, provider, network, classes, granted, tokens, activeTokens, createTransaction, updateSafe,
} = this.props
const { tabIndex } = this.state
@ -148,7 +149,7 @@ class Layout extends React.Component<Props, State> {
safeAddress={address}
safeName={name}
etherScanLink={etherScanLink}
updateSafeName={updateSafeName}
updateSafe={updateSafe}
threshold={safe.threshold}
owners={safe.owners}
createTransaction={createTransaction}

View File

@ -4,9 +4,7 @@ import { withStyles } from '@material-ui/core/styles'
import Block from '~/components/layout/Block'
import Col from '~/components/layout/Col'
import Field from '~/components/forms/Field'
import {
composeValidators, required, minMaxLength,
} from '~/components/forms/validator'
import { composeValidators, required, minMaxLength } from '~/components/forms/validator'
import TextField from '~/components/forms/TextField'
import GnoForm from '~/components/forms/GnoForm'
import Row from '~/components/layout/Row'
@ -30,19 +28,16 @@ type Props = {
classes: Object,
safeAddress: string,
safeName: string,
updateSafeName: Function
updateSafe: Function,
}
const UpdateSafeName = (props: Props) => {
const ChangeSafeName = (props: Props) => {
const {
classes,
safeAddress,
safeName,
updateSafeName,
classes, safeAddress, safeName, updateSafe,
} = props
const handleSubmit = (values) => {
updateSafeName(safeAddress, values.safeName)
updateSafe({ address: safeAddress, name: values.safeName })
}
return (
@ -52,7 +47,7 @@ const UpdateSafeName = (props: Props) => {
<React.Fragment>
<Block className={classes.formContainer}>
<Paragraph noMargin className={classes.title} size="lg" weight="bolder">
Modify Safe name
Modify Safe name
</Paragraph>
<Block className={classes.root}>
<Field
@ -69,14 +64,8 @@ const UpdateSafeName = (props: Props) => {
<Hairline />
<Row style={controlsStyle} align="end" grow>
<Col end="xs">
<Button
type="submit"
style={saveButtonStyle}
size="small"
variant="contained"
color="primary"
>
SAVE
<Button type="submit" style={saveButtonStyle} size="small" variant="contained" color="primary">
SAVE
</Button>
</Col>
</Row>
@ -87,4 +76,4 @@ const UpdateSafeName = (props: Props) => {
)
}
export default withStyles(styles)(UpdateSafeName)
export default withStyles(styles)(ChangeSafeName)

View File

@ -1,10 +0,0 @@
// @flow
import updateSafeName from '~/routes/safe/store/actions/updateSafeName'
export type Actions = {
updateSafeName: Function,
}
export default {
updateSafeName,
}

View File

@ -2,7 +2,6 @@
import * as React from 'react'
import cn from 'classnames'
import { List } from 'immutable'
import { connect } from 'react-redux'
import { withStyles } from '@material-ui/core/styles'
import Block from '~/components/layout/Block'
import Col from '~/components/layout/Col'
@ -11,17 +10,16 @@ import RemoveSafeModal from './RemoveSafeModal'
import Paragraph from '~/components/layout/Paragraph'
import Hairline from '~/components/layout/Hairline'
import { type Owner } from '~/routes/safe/store/models/owner'
import UpdateSafeName from './UpdateSafeName'
import ChangeSafeName from './ChangeSafeName'
import ThresholdSettings from './ThresholdSettings'
import actions, { type Actions } from './actions'
import { styles } from './style'
type State = {
showRemoveSafe: boolean,
menuOptionIndex: number
menuOptionIndex: number,
}
type Props = Actions & {
type Props = {
classes: Object,
granted: boolean,
etherScanLink: string,
@ -30,6 +28,7 @@ type Props = Actions & {
owners: List<Owner>,
threshold: number,
createTransaction: Function,
updateSafe: Function,
}
type Action = 'RemoveSafe'
@ -60,7 +59,7 @@ class Settings extends React.Component<Props, State> {
etherScanLink,
safeAddress,
safeName,
updateSafeName,
updateSafe,
owners,
threshold,
createTransaction,
@ -127,7 +126,7 @@ class Settings extends React.Component<Props, State> {
<Col xs={9} layout="column">
<Block className={classes.container}>
{menuOptionIndex === 1 && (
<UpdateSafeName safeAddress={safeAddress} safeName={safeName} updateSafeName={updateSafeName} />
<ChangeSafeName safeAddress={safeAddress} safeName={safeName} updateSafe={updateSafe} />
)}
{granted && menuOptionIndex === 2 && <p>To be done</p>}
{granted && menuOptionIndex === 3 && (
@ -147,9 +146,4 @@ class Settings extends React.Component<Props, State> {
}
}
const settingsComponent = withStyles(styles)(Settings)
export default connect(
undefined,
actions,
)(settingsComponent)
export default withStyles(styles)(Settings)

View File

@ -2,15 +2,18 @@
import fetchSafe from '~/routes/safe/store/actions/fetchSafe'
import fetchTokenBalances from '~/routes/safe/store/actions/fetchTokenBalances'
import createTransaction from '~/routes/safe/store/actions/createTransaction'
import updateSafe from '~/routes/safe/store/actions/updateSafe'
export type Actions = {
fetchSafe: typeof fetchSafe,
fetchTokenBalances: typeof fetchTokenBalances,
createTransaction: typeof createTransaction,
updateSafe: typeof updateSafe,
}
export default {
fetchSafe,
fetchTokenBalances,
createTransaction,
updateSafe,
}

View File

@ -53,7 +53,15 @@ class SafeView extends React.Component<Props> {
render() {
const {
safe, provider, activeTokens, granted, userAddress, network, tokens, createTransaction,
safe,
provider,
activeTokens,
granted,
userAddress,
network,
tokens,
createTransaction,
updateSafe,
} = this.props
return (
@ -67,6 +75,7 @@ class SafeView extends React.Component<Props> {
network={network}
granted={granted}
createTransaction={createTransaction}
updateSafe={updateSafe}
/>
</Page>
)

View File

@ -1,10 +0,0 @@
// @flow
import type { Dispatch as ReduxDispatch } from 'redux'
import { type GlobalState } from '~/store'
import updateSafe from './updateSafe'
const updateSafeName = (safeAddress: string, safeName: string) => async (dispatch: ReduxDispatch<GlobalState>) => {
dispatch(updateSafe({ address: safeAddress, name: safeName }))
}
export default updateSafeName