Merge branch 'development' into fix/desktop-CI

This commit is contained in:
Mikhail Mikheev 2020-08-07 18:26:15 +04:00 committed by GitHub
commit b8d7310429
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 149 additions and 123 deletions

View File

@ -1,8 +1,8 @@
import Tab from '@material-ui/core/Tab' import Tab from '@material-ui/core/Tab'
import Tabs from '@material-ui/core/Tabs' import Tabs from '@material-ui/core/Tabs'
import { withStyles } from '@material-ui/core/styles' import { makeStyles } from '@material-ui/core/styles'
import React from 'react' import React from 'react'
import { withRouter, RouteComponentProps } from 'react-router-dom' import { useRouteMatch, useLocation, useHistory } from 'react-router-dom'
import { styles } from './style' import { styles } from './style'
@ -19,10 +19,6 @@ import { AppsIcon } from 'src/routes/safe/components/assets/AppsIcon'
import { BalancesIcon } from 'src/routes/safe/components/assets/BalancesIcon' import { BalancesIcon } from 'src/routes/safe/components/assets/BalancesIcon'
import { TransactionsIcon } from 'src/routes/safe/components/assets/TransactionsIcon' import { TransactionsIcon } from 'src/routes/safe/components/assets/TransactionsIcon'
interface Props extends RouteComponentProps {
classes: Record<string, any>
}
const BalancesLabel = ( const BalancesLabel = (
<> <>
<BalancesIcon /> <BalancesIcon />
@ -51,12 +47,15 @@ const TransactionsLabel = (
</> </>
) )
const TabsComponent = (props: Props) => { const useStyles = makeStyles(styles)
const { classes, location, match } = props
const handleCallToRouter = (_, value) => { const TabsComponent = (): React.ReactElement => {
const { history } = props const classes = useStyles()
const match = useRouteMatch()
const location = useLocation()
const history = useHistory()
const handleCallToRouter = (_: unknown, value: string) => {
history.push(value) history.push(value)
} }
@ -128,4 +127,4 @@ const TabsComponent = (props: Props) => {
</Tabs> </Tabs>
) )
} }
export default withStyles(styles as any)(withRouter(TabsComponent)) export default TabsComponent

View File

@ -1,6 +1,7 @@
import { secondary } from 'src/theme/variables' import { secondary } from 'src/theme/variables'
import { createStyles } from '@material-ui/core'
export const styles = () => ({ export const styles = createStyles({
tabWrapper: { tabWrapper: {
display: 'flex', display: 'flex',
flexDirection: 'row', flexDirection: 'row',

View File

@ -2,7 +2,7 @@ import { GenericModal } from '@gnosis.pm/safe-react-components'
import { makeStyles } from '@material-ui/core/styles' import { makeStyles } from '@material-ui/core/styles'
import React, { useState } from 'react' import React, { useState } from 'react'
import { useSelector } from 'react-redux' import { useSelector } from 'react-redux'
import { Redirect, Route, Switch, withRouter, RouteComponentProps } from 'react-router-dom' import { Redirect, Route, Switch, useRouteMatch } from 'react-router-dom'
import Receive from '../Balances/Receive' import Receive from '../Balances/Receive'
@ -32,7 +32,7 @@ const Balances = React.lazy(() => import('../Balances'))
const TxsTable = React.lazy(() => import('src/routes/safe/components/Transactions/TxsTable')) const TxsTable = React.lazy(() => import('src/routes/safe/components/Transactions/TxsTable'))
const AddressBookTable = React.lazy(() => import('src/routes/safe/components/AddressBook')) const AddressBookTable = React.lazy(() => import('src/routes/safe/components/AddressBook'))
interface Props extends RouteComponentProps { interface Props {
sendFunds: Record<string, any> sendFunds: Record<string, any>
showReceive: boolean showReceive: boolean
onShow: (value: string) => void onShow: (value: string) => void
@ -41,11 +41,12 @@ interface Props extends RouteComponentProps {
hideSendFunds: () => void hideSendFunds: () => void
} }
const useStyles = makeStyles(styles as any) const useStyles = makeStyles(styles)
const Layout = (props: Props) => { const Layout = (props: Props): React.ReactElement => {
const classes = useStyles() const classes = useStyles()
const { hideSendFunds, match, onHide, onShow, sendFunds, showReceive, showSendFunds } = props const { hideSendFunds, onHide, onShow, sendFunds, showReceive, showSendFunds } = props
const match = useRouteMatch()
const [modal, setModal] = useState({ const [modal, setModal] = useState({
isOpen: false, isOpen: false,
@ -117,4 +118,4 @@ const Layout = (props: Props) => {
) )
} }
export default withRouter(Layout) export default Layout

View File

@ -1,6 +1,7 @@
import { screenSm, sm } from 'src/theme/variables' import { screenSm, sm } from 'src/theme/variables'
import { createStyles } from '@material-ui/core'
export const styles = () => ({ export const styles = createStyles({
receiveModal: { receiveModal: {
height: 'auto', height: 'auto',
maxWidth: 'calc(100% - 30px)', maxWidth: 'calc(100% - 30px)',

View File

@ -7,19 +7,15 @@ import Paragraph from 'src/components/layout/Paragraph'
import { useWindowDimensions } from 'src/routes/safe/container/hooks/useWindowDimensions' import { useWindowDimensions } from 'src/routes/safe/container/hooks/useWindowDimensions'
import { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
interface OwnerAddressTableCellProps { type OwnerAddressTableCellProps = {
address: string address: string
knownAddress?: boolean knownAddress?: boolean
showLinks: boolean showLinks: boolean
userName?: string userName?: string
} }
const OwnerAddressTableCell = ({ const OwnerAddressTableCell = (props: OwnerAddressTableCellProps): React.ReactElement => {
address, const { address, knownAddress, showLinks, userName } = props
knownAddress,
showLinks,
userName,
}: OwnerAddressTableCellProps): React.ReactElement => {
const [cut, setCut] = useState(undefined) const [cut, setCut] = useState(undefined)
const { width } = useWindowDimensions() const { width } = useWindowDimensions()
@ -38,7 +34,7 @@ const OwnerAddressTableCell = ({
<Identicon address={address} diameter={32} /> <Identicon address={address} diameter={32} />
{showLinks ? ( {showLinks ? (
<div style={{ marginLeft: 10, flexShrink: 1, minWidth: 0 }}> <div style={{ marginLeft: 10, flexShrink: 1, minWidth: 0 }}>
{userName} {!userName || userName === 'UNKNOWN' ? null : userName}
<EtherScanLink knownAddress={knownAddress} type="address" value={address} cut={cut} /> <EtherScanLink knownAddress={knownAddress} type="address" value={address} cut={cut} />
</div> </div>
) : ( ) : (

View File

@ -1,4 +1,4 @@
import { withStyles } from '@material-ui/core/styles' import { makeStyles } from '@material-ui/core/styles'
import cn from 'classnames' import cn from 'classnames'
import React from 'react' import React from 'react'
import { useSelector } from 'react-redux' import { useSelector } from 'react-redux'
@ -18,31 +18,55 @@ import Button from 'src/components/layout/Button'
import Img from 'src/components/layout/Img' import Img from 'src/components/layout/Img'
import Paragraph from 'src/components/layout/Paragraph' import Paragraph from 'src/components/layout/Paragraph'
import { getNameFromAddressBook } from 'src/logic/addressBook/store/selectors' import { getNameFromAddressBook } from 'src/logic/addressBook/store/selectors'
import { OwnersWithoutConfirmations } from './index'
export const CONFIRM_TX_BTN_TEST_ID = 'confirm-btn' export const CONFIRM_TX_BTN_TEST_ID = 'confirm-btn'
export const EXECUTE_TX_BTN_TEST_ID = 'execute-btn' export const EXECUTE_TX_BTN_TEST_ID = 'execute-btn'
export const REJECT_TX_BTN_TEST_ID = 'reject-btn' export const REJECT_TX_BTN_TEST_ID = 'reject-btn'
export const EXECUTE_REJECT_TX_BTN_TEST_ID = 'execute-reject-btn' export const EXECUTE_REJECT_TX_BTN_TEST_ID = 'execute-reject-btn'
const OwnerComponent = ({ type OwnerComponentProps = {
classes, executor: string
confirmed, isCancelTx?: boolean
executor, onTxConfirm?: () => void
isCancelTx, onTxExecute?: () => void
onTxConfirm, onTxReject?: () => void
onTxExecute, ownersUnconfirmed: OwnersWithoutConfirmations
onTxReject, ownersWhoConfirmed: string[]
owner, showConfirmBtn?: boolean
pendingAcceptAction, showExecuteBtn?: boolean
pendingRejectAction, showExecuteRejectBtn?: boolean
showConfirmBtn, showRejectBtn?: boolean
showExecuteBtn, thresholdReached: boolean
showExecuteRejectBtn, userAddress: string
showRejectBtn, confirmed?: boolean
thresholdReached, owner: string
userAddress, pendingAcceptAction?: boolean
}: any) => { pendingRejectAction?: boolean
}
const useStyles = makeStyles(styles)
const OwnerComponent = (props: OwnerComponentProps): React.ReactElement => {
const {
owner,
pendingAcceptAction,
pendingRejectAction,
isCancelTx,
thresholdReached,
executor,
showConfirmBtn,
onTxConfirm,
onTxExecute,
showExecuteBtn,
showRejectBtn,
userAddress,
onTxReject,
showExecuteRejectBtn,
confirmed,
} = props
const nameInAdbk = useSelector((state) => getNameFromAddressBook(state, owner)) const nameInAdbk = useSelector((state) => getNameFromAddressBook(state, owner))
const classes = useStyles()
const [imgCircle, setImgCircle] = React.useState(ConfirmSmallGreyCircle) const [imgCircle, setImgCircle] = React.useState(ConfirmSmallGreyCircle)
React.useMemo(() => { React.useMemo(() => {
@ -155,8 +179,8 @@ const OwnerComponent = ({
</div> </div>
<Identicon address={owner} className={classes.icon} diameter={32} /> <Identicon address={owner} className={classes.icon} diameter={32} />
<Block> <Block>
<Paragraph className={classes.name} noMargin> <Paragraph className={nameInAdbk === 'UNKNOWN' ? null : classes.name} noMargin>
{nameInAdbk} {!nameInAdbk || nameInAdbk === 'UNKNOWN' ? null : nameInAdbk}
</Paragraph> </Paragraph>
<EtherscanLink className={classes.address} cut={4} type="address" value={owner} /> <EtherscanLink className={classes.address} cut={4} type="address" value={owner} />
</Block> </Block>
@ -167,4 +191,4 @@ const OwnerComponent = ({
) )
} }
export default withStyles(styles as any)(OwnerComponent) export default OwnerComponent

View File

@ -1,64 +1,42 @@
import { withStyles } from '@material-ui/core/styles'
import React from 'react' import React from 'react'
import OwnerComponent from './OwnerComponent' import OwnerComponent from './OwnerComponent'
import { styles } from './style' import { OwnersWithoutConfirmations } from './index'
const OwnersList = ({ type OwnersListProps = {
classes, executor: string
executor, isCancelTx?: boolean
isCancelTx, onTxConfirm?: () => void
onTxConfirm, onTxExecute?: () => void
onTxExecute, onTxReject?: () => void
onTxReject, ownersUnconfirmed: OwnersWithoutConfirmations
ownersUnconfirmed, ownersWhoConfirmed: string[]
ownersWhoConfirmed, showConfirmBtn?: boolean
showConfirmBtn, showExecuteBtn?: boolean
showExecuteBtn, showExecuteRejectBtn?: boolean
showExecuteRejectBtn, showRejectBtn?: boolean
showRejectBtn, thresholdReached: boolean
thresholdReached, userAddress: string
userAddress, }
}: any) => (
<>
{ownersWhoConfirmed.map((owner) => (
<OwnerComponent
classes={classes}
confirmed
executor={executor}
isCancelTx={isCancelTx}
key={owner}
onTxExecute={onTxExecute}
onTxReject={onTxReject}
owner={owner}
showExecuteBtn={showExecuteBtn}
showExecuteRejectBtn={showExecuteRejectBtn}
showRejectBtn={showRejectBtn}
thresholdReached={thresholdReached}
userAddress={userAddress}
/>
))}
{ownersUnconfirmed.map(({ hasPendingAcceptActions, hasPendingRejectActions, owner }) => (
<OwnerComponent
classes={classes}
executor={executor}
isCancelTx={isCancelTx}
key={owner}
onTxConfirm={onTxConfirm}
onTxExecute={onTxExecute}
onTxReject={onTxReject}
owner={owner}
pendingAcceptAction={hasPendingAcceptActions}
pendingRejectAction={hasPendingRejectActions}
showConfirmBtn={showConfirmBtn}
showExecuteBtn={showExecuteBtn}
showExecuteRejectBtn={showExecuteRejectBtn}
showRejectBtn={showRejectBtn}
thresholdReached={thresholdReached}
userAddress={userAddress}
/>
))}
</>
)
export default withStyles(styles as any)(OwnersList) const OwnersList = (props: OwnersListProps): React.ReactElement => {
const { ownersUnconfirmed, ownersWhoConfirmed } = props
return (
<>
{ownersWhoConfirmed.map((owner) => (
<OwnerComponent confirmed key={owner} owner={owner} {...props} />
))}
{ownersUnconfirmed.map(({ hasPendingAcceptActions, hasPendingRejectActions, owner }) => (
<OwnerComponent
key={owner}
owner={owner}
pendingAcceptAction={hasPendingAcceptActions}
pendingRejectAction={hasPendingRejectActions}
{...props}
/>
))}
</>
)
}
export default OwnersList

View File

@ -1,4 +1,3 @@
import { withStyles } from '@material-ui/core/styles'
import cn from 'classnames' import cn from 'classnames'
import React from 'react' import React from 'react'
import { useSelector } from 'react-redux' import { useSelector } from 'react-redux'
@ -9,7 +8,6 @@ import CheckLargeFilledRedCircle from './assets/check-large-filled-red.svg'
import ConfirmLargeGreenCircle from './assets/confirm-large-green.svg' import ConfirmLargeGreenCircle from './assets/confirm-large-green.svg'
import ConfirmLargeGreyCircle from './assets/confirm-large-grey.svg' import ConfirmLargeGreyCircle from './assets/confirm-large-grey.svg'
import ConfirmLargeRedCircle from './assets/confirm-large-red.svg' import ConfirmLargeRedCircle from './assets/confirm-large-red.svg'
import { styles } from './style'
import Block from 'src/components/layout/Block' import Block from 'src/components/layout/Block'
import Col from 'src/components/layout/Col' import Col from 'src/components/layout/Col'
@ -18,10 +16,19 @@ import Paragraph from 'src/components/layout/Paragraph/index'
import { userAccountSelector } from 'src/logic/wallets/store/selectors' import { userAccountSelector } from 'src/logic/wallets/store/selectors'
import { makeTransaction } from 'src/routes/safe/store/models/transaction' import { makeTransaction } from 'src/routes/safe/store/models/transaction'
import { safeOwnersSelector, safeThresholdSelector } from 'src/routes/safe/store/selectors' import { safeOwnersSelector, safeThresholdSelector } from 'src/routes/safe/store/selectors'
import { TransactionStatus } from 'src/routes/safe/store/models/types/transaction' import { Transaction, TransactionStatus } from 'src/routes/safe/store/models/types/transaction'
import { List } from 'immutable'
import { makeStyles } from '@material-ui/core/styles'
import { styles } from './style'
function getOwnersConfirmations(tx, userAddress) { export type OwnersWithoutConfirmations = {
const ownersWhoConfirmed = [] hasPendingAcceptActions: boolean
hasPendingRejectActions: boolean
owner: string
}[]
function getOwnersConfirmations(tx: Transaction, userAddress: string): [string[], boolean] {
const ownersWhoConfirmed: string[] = []
let currentUserAlreadyConfirmed = false let currentUserAlreadyConfirmed = false
tx.confirmations.forEach((conf) => { tx.confirmations.forEach((conf) => {
@ -34,7 +41,11 @@ function getOwnersConfirmations(tx, userAddress) {
return [ownersWhoConfirmed, currentUserAlreadyConfirmed] return [ownersWhoConfirmed, currentUserAlreadyConfirmed]
} }
function getPendingOwnersConfirmations(owners, tx, userAddress) { function getPendingOwnersConfirmations(
owners: List<{ name: string; address: string }>,
tx: Transaction,
userAddress: string,
): [OwnersWithoutConfirmations, boolean] {
const ownersWithNoConfirmations = [] const ownersWithNoConfirmations = []
let currentUserNotConfirmed = true let currentUserNotConfirmed = true
@ -74,10 +85,23 @@ function getPendingOwnersConfirmations(owners, tx, userAddress) {
return [ownersWithNoConfirmationsSorted, currentUserNotConfirmed] return [ownersWithNoConfirmationsSorted, currentUserNotConfirmed]
} }
const useStyles = makeStyles(styles)
type ownersColumnProps = {
tx: Transaction
cancelTx: Transaction
thresholdReached: boolean
cancelThresholdReached: boolean
onTxConfirm: () => void
onTxExecute: () => void
onTxReject: () => void
canExecute: boolean
canExecuteCancel: boolean
}
const OwnersColumn = ({ const OwnersColumn = ({
tx, tx,
cancelTx = makeTransaction({ isCancellationTx: true, status: TransactionStatus.AWAITING_YOUR_CONFIRMATION }), cancelTx = makeTransaction({ isCancellationTx: true, status: TransactionStatus.AWAITING_YOUR_CONFIRMATION }),
classes,
thresholdReached, thresholdReached,
cancelThresholdReached, cancelThresholdReached,
onTxConfirm, onTxConfirm,
@ -85,7 +109,8 @@ const OwnersColumn = ({
onTxReject, onTxReject,
canExecute, canExecute,
canExecuteCancel, canExecuteCancel,
}) => { }: ownersColumnProps): React.ReactElement => {
const classes = useStyles()
let showOlderTxAnnotation let showOlderTxAnnotation
if (tx.isExecuted || cancelTx.isExecuted) { if (tx.isExecuted || cancelTx.isExecuted) {
@ -234,4 +259,4 @@ const OwnersColumn = ({
) )
} }
export default withStyles(styles as any)(OwnersColumn) export default OwnersColumn

View File

@ -1,6 +1,7 @@
import { boldFont, border, error, primary, secondary, secondaryText, sm, warning } from 'src/theme/variables' import { boldFont, border, error, primary, secondary, secondaryText, sm, warning } from 'src/theme/variables'
import { createStyles } from '@material-ui/core/styles'
export const styles = () => ({ export const styles = createStyles({
ownersList: { ownersList: {
height: '192px', height: '192px',
overflowY: 'scroll', overflowY: 'scroll',
@ -18,7 +19,7 @@ export const styles = () => ({
position: 'absolute', position: 'absolute',
top: '-27px', top: '-27px',
width: '2px', width: '2px',
zIndex: '12', zIndex: 12,
}, },
verticalLinePending: { verticalLinePending: {
backgroundColor: secondaryText, backgroundColor: secondaryText,
@ -80,7 +81,7 @@ export const styles = () => ({
justifyContent: 'center', justifyContent: 'center',
marginRight: '18px', marginRight: '18px',
width: '20px', width: '20px',
zIndex: '13', zIndex: 13,
'& > img': { '& > img': {
display: 'block', display: 'block',
@ -88,7 +89,7 @@ export const styles = () => ({
}, },
button: { button: {
alignSelf: 'center', alignSelf: 'center',
flexGrow: '0', flexGrow: 0,
fontSize: '16px', fontSize: '16px',
justifyContent: 'center', justifyContent: 'center',
paddingLeft: '14px', paddingLeft: '14px',

View File

@ -17,7 +17,7 @@ import cookies, { COOKIES_REDUCER_ID } from 'src/logic/cookies/store/reducer/coo
import currencyValuesStorageMiddleware from 'src/logic/currencyValues/store/middleware' import currencyValuesStorageMiddleware from 'src/logic/currencyValues/store/middleware'
import currencyValues, { import currencyValues, {
CURRENCY_VALUES_KEY, CURRENCY_VALUES_KEY,
CurrencyReducerMap, CurrencyValuesState,
} from 'src/logic/currencyValues/store/reducer/currencyValues' } from 'src/logic/currencyValues/store/reducer/currencyValues'
import currentSession, { CURRENT_SESSION_REDUCER_ID } from 'src/logic/currentSession/store/reducer/currentSession' import currentSession, { CURRENT_SESSION_REDUCER_ID } from 'src/logic/currentSession/store/reducer/currentSession'
import notifications, { NOTIFICATIONS_REDUCER_ID } from 'src/logic/notifications/store/reducer/notifications' import notifications, { NOTIFICATIONS_REDUCER_ID } from 'src/logic/notifications/store/reducer/notifications'
@ -80,7 +80,7 @@ export type AppReduxState = CombinedState<{
[CANCELLATION_TRANSACTIONS_REDUCER_ID]: CancellationTxState [CANCELLATION_TRANSACTIONS_REDUCER_ID]: CancellationTxState
[INCOMING_TRANSACTIONS_REDUCER_ID]: Map<string, any> [INCOMING_TRANSACTIONS_REDUCER_ID]: Map<string, any>
[NOTIFICATIONS_REDUCER_ID]: Map<string, any> [NOTIFICATIONS_REDUCER_ID]: Map<string, any>
[CURRENCY_VALUES_KEY]: CurrencyReducerMap [CURRENCY_VALUES_KEY]: CurrencyValuesState
[COOKIES_REDUCER_ID]: Map<string, any> [COOKIES_REDUCER_ID]: Map<string, any>
[ADDRESS_BOOK_REDUCER_ID]: AddressBookReducerMap [ADDRESS_BOOK_REDUCER_ID]: AddressBookReducerMap
[CURRENT_SESSION_REDUCER_ID]: Map<string, any> [CURRENT_SESSION_REDUCER_ID]: Map<string, any>