Skip to content

Commit

Permalink
feat: add address field (#3020)
Browse files Browse the repository at this point in the history
  • Loading branch information
Melisa Anabella Rossi authored Jan 25, 2024
1 parent d51fa3c commit 1a4ae01
Show file tree
Hide file tree
Showing 25 changed files with 4,138 additions and 123 deletions.
3,995 changes: 3,954 additions & 41 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@
"decentraland": "^3.3.0",
"decentraland-builder-scripts": "^0.24.0",
"decentraland-crypto-fetch": "^2.0.1",
"decentraland-dapps": "^17.0.0",
"decentraland-dapps": "^17.4.0",
"decentraland-ecs": "^6.6.1-20201020183014.commit-bdc29ef-hotfix",
"decentraland-experiments": "^1.0.2",
"decentraland-transactions": "^1.47.0",
"decentraland-ui": "^5.4.0",
"decentraland-ui": "^5.4.6",
"ethers": "^5.6.8",
"file-saver": "^2.0.1",
"graphql": "^15.8.0",
Expand Down Expand Up @@ -136,7 +136,8 @@
"^@babylonjs.*$": "identity-obj-proxy",
"^.*/modules/curations/collectionCuration/toasts.*$": "identity-obj-proxy",
"@dcl/ecs": "identity-obj-proxy",
"@dcl/single-sign-on-client": "identity-obj-proxy"
"@dcl/single-sign-on-client": "identity-obj-proxy",
"@0xsquid/sdk": "identity-obj-proxy"
}
},
"engines": {
Expand Down
35 changes: 22 additions & 13 deletions src/components/ENSListPage/ENSListPage.css
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
background: #393640;
width: fit-content;
padding: 5px;
border-radius: 16px;
border-radius: 32px;
font-weight: bold;
padding-right: 10px;
}
Expand All @@ -139,7 +139,7 @@

.ENSListPage .ens-list-land-coord {
display: flex;
height: 34px;
height: 40px;
align-items: center;
padding: 0 10px;
background: #393640;
Expand All @@ -153,7 +153,7 @@
.ENSListPage .ens-list-land-redirect {
width: fit-content;
min-width: unset;
height: 34px;
height: 40px;
padding: 0 6px;
display: flex;
align-items: center;
Expand All @@ -167,11 +167,11 @@
background: #393640;
width: fit-content;
padding: 5px;
border-radius: 16px;
border-radius: 32px;
}

.ENSListPage .ens-list-address-icon {
width: 25px;
width: 32px;
}

.ENSListPage .ens-page-content {
Expand Down Expand Up @@ -217,6 +217,15 @@
padding-left: 10px;
padding-right: 10px;
text-transform: none;
height: 40px;
display: flex;
align-items: center;
}

.ENSListPage .ens-list-edit-btn.ui.button i,
.ENSListPage .ens-list-transfer-btn.ui.button i {
font-size: 13px;
line-height: 13px;
}

.ENSListPage .ens-list-transfer-btn.ui.button {
Expand All @@ -229,15 +238,15 @@
}

.ENSListPage .ens-list-name-icon {
width: 30px;
height: 30px;
width: 32px;
height: 32px;
border-radius: 5px;
margin-right: 5px;
}

.ENSListPage .ens-list-avatar-img {
width: 25px;
height: 25px;
width: 32px;
height: 32px;
border-radius: 50%;
background: #43404a;
}
Expand Down Expand Up @@ -324,15 +333,15 @@
}

.ENSListPage .ens-list-name-icon {
width: 30px;
height: 30px;
width: 40px;
height: 40px;
border-radius: 5px;
margin-right: 5px;
}

.ENSListPage .ens-list-avatar-img {
width: 30px;
height: 30px;
width: 32px;
height: 32px;
border-radius: 50%;
background: #43404a;
}
Expand Down
6 changes: 1 addition & 5 deletions src/components/ENSSelectLandPage/ENSSelectLandPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ export default class ENSSelectLandPage extends React.PureComponent<Props, State>
}
}

handleBack = () => {
this.props.onNavigate(locations.root())
}

handleSelectLand = (x: number, y: number) => {
const selectedLand = this.getOwnedLand(x, y)
if (selectedLand) {
Expand Down Expand Up @@ -101,7 +97,7 @@ export default class ENSSelectLandPage extends React.PureComponent<Props, State>
<NotFound />
) : (
<>
<Back absolute onClick={this.handleBack} />
<Back absolute onClick={onBack} />
<Narrow>
<Row>
<Column>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@
.LandOperatorForm.ui.form .dcl.field .ui.input.is-revokable input {
padding-right: 86px;
}

.LandOperatorForm .dui-address-field__address {
font-size: 16px;
bottom: 38px;
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import * as React from 'react'
import { Network } from '@dcl/schemas'
import { Form, Field, Row, Button, InputOnChangeData } from 'decentraland-ui'
import { Form, Row, Button, InputOnChangeData, Field } from 'decentraland-ui'
import { NetworkButton } from 'decentraland-dapps/dist/containers'
import { t } from 'decentraland-dapps/dist/modules/translation/utils'
import { AddressField } from 'decentraland-dapps/dist/components/AddressField'
import { Link } from 'react-router-dom'
import { getUpdateOperator, hasAnyRole } from 'modules/land/utils'
import { locations } from 'routing/locations'
Expand Down Expand Up @@ -51,7 +52,7 @@ export default class LandOperatorForm extends React.PureComponent<Props, State>
}

render() {
const { land } = this.props
const { land, isEnsAddressEnabled } = this.props
const { address, loading, dirty, revoked, editing, initial } = this.state

const isRevokable = editing && isEqual(address, initial)
Expand All @@ -72,18 +73,34 @@ export default class LandOperatorForm extends React.PureComponent<Props, State>

return (
<Form className="LandOperatorForm">
<Field
placeholder="0x..."
label={t('operator_page.address')}
className={classes.join(' ')}
value={address}
onChange={this.handleChange}
loading={loading}
action={isRevokable ? (revoked ? t('operator_page.undo') : t('operator_page.revoke')) : undefined}
onAction={isRevokable ? (revoked ? this.handleUndo : this.handleRevoke) : undefined}
error={hasError}
message={hasError ? t('operator_page.invalid_address') : undefined}
/>
{isEnsAddressEnabled ? (
<AddressField
placeholder="0x..."
label={t('operator_page.address')}
className={classes.join(' ')}
value={address}
onChange={this.handleChange}
loading={loading}
action={isRevokable ? (revoked ? t('operator_page.undo') : t('operator_page.revoke')) : undefined}
onAction={isRevokable ? (revoked ? this.handleUndo : this.handleRevoke) : undefined}
error={hasError}
message={hasError ? t('operator_page.invalid_address') : undefined}
/>
) : (
<Field
placeholder="0x..."
label={t('operator_page.address')}
className={classes.join(' ')}
value={address}
onChange={this.handleChange}
loading={loading}
action={isRevokable ? (revoked ? t('operator_page.undo') : t('operator_page.revoke')) : undefined}
onAction={isRevokable ? (revoked ? this.handleUndo : this.handleRevoke) : undefined}
error={hasError}
message={hasError ? t('operator_page.invalid_address') : undefined}
/>
)}

<Row>
<Link className="cancel" to={locations.landDetail(land.id)}>
<Button>{t('global.cancel')}</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Land } from 'modules/land/types'

export type Props = {
land: Land
isEnsAddressEnabled: boolean
onSetOperator: (land: Land, address: string | null) => void
}

Expand Down
10 changes: 8 additions & 2 deletions src/components/LandOperatorPage/LandOperatorPage.container.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import { connect } from 'react-redux'
import { MapDispatchProps, MapDispatch } from './LandOperatorPage.types'
import { setOperatorRequest } from 'modules/land/actions'
import { RootState } from 'modules/common/types'
import { getIsEnsAddressEnabled } from 'modules/features/selectors'
import LandOperatorPage from './LandOperatorPage'
import { MapDispatchProps, MapDispatch, MapStateProps } from './LandOperatorPage.types'

const mapState = (state: RootState): MapStateProps => ({
isEnsAddressEnabled: getIsEnsAddressEnabled(state)
})

const mapDispatch = (dispatch: MapDispatch): MapDispatchProps => ({
onSetOperator: (land, address) => dispatch(setOperatorRequest(land, address))
})

export default connect(null, mapDispatch)(LandOperatorPage)
export default connect(mapState, mapDispatch)(LandOperatorPage)
4 changes: 2 additions & 2 deletions src/components/LandOperatorPage/LandOperatorPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Props } from './LandOperatorPage.types'

export default class LandOperatorPage extends React.PureComponent<Props> {
render() {
const { onSetOperator } = this.props
const { isEnsAddressEnabled, onSetOperator } = this.props
return (
<LandProviderPage>
{land => (
Expand All @@ -25,7 +25,7 @@ export default class LandOperatorPage extends React.PureComponent<Props> {
/>
}
>
<LandOperatorForm land={land} onSetOperator={onSetOperator} />
<LandOperatorForm land={land} onSetOperator={onSetOperator} isEnsAddressEnabled={isEnsAddressEnabled} />
</LandAction>
)}
</LandProviderPage>
Expand Down
2 changes: 2 additions & 0 deletions src/components/LandOperatorPage/LandOperatorPage.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import { Dispatch } from 'redux'
import { setOperatorRequest } from 'modules/land/actions'

export type Props = {
isEnsAddressEnabled: boolean
onSetOperator: typeof setOperatorRequest
}

export type MapStateProps = Pick<Props, 'isEnsAddressEnabled'>
export type MapDispatchProps = Pick<Props, 'onSetOperator'>
export type MapDispatch = Dispatch
10 changes: 8 additions & 2 deletions src/components/LandTransferPage/LandTransferPage.container.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import { connect } from 'react-redux'
import { MapDispatchProps, MapDispatch } from './LandTransferPage.types'
import { transferLandRequest } from 'modules/land/actions'
import { RootState } from 'modules/common/types'
import { getIsEnsAddressEnabled } from 'modules/features/selectors'
import { MapDispatchProps, MapDispatch, MapStateProps } from './LandTransferPage.types'
import LandTransferPage from './LandTransferPage'

const mapState = (state: RootState): MapStateProps => ({
isEnsAddressEnabled: getIsEnsAddressEnabled(state)
})

const mapDispatch = (dispatch: MapDispatch): MapDispatchProps => ({
onTransfer: (land, address) => dispatch(transferLandRequest(land, address))
})

export default connect(null, mapDispatch)(LandTransferPage)
export default connect(mapState, mapDispatch)(LandTransferPage)
32 changes: 22 additions & 10 deletions src/components/LandTransferPage/LandTransferPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Field, InputOnChangeData, Form, Row, Button, Section } from 'decentrala
import { Network } from '@dcl/schemas'
import { NetworkButton } from 'decentraland-dapps/dist/containers'
import { T, t } from 'decentraland-dapps/dist/modules/translation/utils'
import { AddressField } from 'decentraland-dapps/dist/components/AddressField'
import LandAction from 'components/LandAction'
import LandProviderPage from 'components/LandProviderPage'
import { RoleType } from 'modules/land/types'
Expand All @@ -23,7 +24,7 @@ export default class LandTransferPage extends React.PureComponent<Props, State>
}

render() {
const { onTransfer } = this.props
const { onTransfer, isEnsAddressEnabled } = this.props
const { address, isValid } = this.state
return (
<LandProviderPage className="LandTransferPage">
Expand All @@ -42,15 +43,26 @@ export default class LandTransferPage extends React.PureComponent<Props, State>
subtitle={<T id="transfer_page.subtitle" values={{ name: <strong>{land.name}</strong> }} />}
>
<Form onSubmit={() => onTransfer(land, address)}>
<Field
label="Address"
type="address"
value={address}
onChange={this.handleChange}
placeholder="0x..."
error={!isValid || isOwner}
message={message}
/>
{isEnsAddressEnabled ? (
<AddressField
label="Address"
value={address}
onChange={this.handleChange}
placeholder="0x..."
error={!isValid || isOwner}
message={message}
/>
) : (
<Field
label="Address"
type="address"
value={address}
onChange={this.handleChange}
placeholder="0x..."
error={!isValid || isOwner}
message={message}
/>
)}
<Section className="disclaimer">
<p className="danger-text">
<T id="transfer_page.disclaimer" values={{ br: <br /> }} />
Expand Down
2 changes: 2 additions & 0 deletions src/components/LandTransferPage/LandTransferPage.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { transferLandRequest, TransferLandRequestAction } from 'modules/land/act
import { Dispatch } from 'redux'

export type Props = {
isEnsAddressEnabled: boolean
onTransfer: typeof transferLandRequest
}

Expand All @@ -10,5 +11,6 @@ export type State = {
isValid: boolean
}

export type MapStateProps = Pick<Props, 'isEnsAddressEnabled'>
export type MapDispatchProps = Pick<Props, 'onTransfer'>
export type MapDispatch = Dispatch<TransferLandRequestAction>
Loading

0 comments on commit 1a4ae01

Please sign in to comment.