Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pending tx estates #448

Merged
merged 5 commits into from
Sep 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion shared/estate.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const MAX_PARCELS_PER_TX = 12

export function isNewEstate(estate) {
return !estate || !estate.token_id
return !estate || !estate.id
}

export function isEstate(asset) {
Expand Down
3 changes: 1 addition & 2 deletions src/Translation/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@
"maximum_parcels_message":
"If you add or removes more than {max} parcels in a single transaction it may run out of gas. You can submit this transaction and then add or remove more parcels in a subsequent transaction by editing the estate.",
"maximum_parcels_title": "You reached the maximum parcels per transaction",
"parcels": "Parcels included",
"pending_tx": "This estate"
"parcels": "Parcels included"
},
"estate_dissolve": {
"too_big": "This estate is too big",
Expand Down
5 changes: 2 additions & 3 deletions src/Translation/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,12 @@
"estate_detail": {
"dissolve": "Disolver Propiedad",
"dissolve_desc": "Vas a disolver la propiedad {name}",
"edit_parcels": "Editar paquetes",
"edit_parcels": "Editar parcelas",
"empty_estate": "La propiedad {name} ha sido disuelta",
"maximum_parcels_message":
"Si agrega o elimina más de {max} parcelas en una sola transacción, puede quedarse sin gas. Puedes enviar esta transacción y luego agregar o quitar más parcelas en otra transacción editando la propiedad",
"maximum_parcels_title": "Alcanzaste el máximo de parcelas por transacción",
"parcels": "Parcelas incluidas",
"pending_tx": "Esta propiedad"
"parcels": "Parcelas incluidas"
},
"estate_dissolve": {
"too_big": "Esta propiedad es demasiado grande",
Expand Down
3 changes: 1 addition & 2 deletions src/Translation/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@
"Si vous ajoutez ou supprimez plus de paquets {max} en une seule transaction, vous risquez de manquer de gas. ",
"maximum_parcels_title":
"Vous avez atteint le maximum de parcelles par transaction",
"parcels": "Parcelles incluses",
"pending_tx": "Ce domaine"
"parcels": "Parcelles incluses"
},
"estate_dissolve": {
"too_big": "Ce domaine est trop grand",
Expand Down
3 changes: 1 addition & 2 deletions src/Translation/locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@
"1回のトランザクションで{max}区画を追加または削除すると、ガスがなくなる可能性があります。",
"maximum_parcels_title":
"あなたはトランザクションごとに最大の小包に達しました",
"parcels": "次の区画を含む",
"pending_tx": "このエステート"
"parcels": "次の区画を含む"
},
"estate_dissolve": {
"too_big": "このエステートは大きすぎます",
Expand Down
3 changes: 1 addition & 2 deletions src/Translation/locales/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@
"maximum_parcels_message":
"단일 트랜잭션에서 {max} 개 이상의 소포를 추가하거나 제거하면 가스가 고갈 될 수 있습니다. ",
"maximum_parcels_title": "거래 당 최대 소포에 도달했습니다.",
"parcels": "소포 포함",
"pending_tx": "이 재산"
"parcels": "소포 포함"
},
"estate_dissolve": {
"too_big": "이 부동산은 너무 큽니다.",
Expand Down
3 changes: 1 addition & 2 deletions src/Translation/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@
"maximum_parcels_message":
"如果您在单个交易中添加或删除超过 {max} 个地块,交易费用可能会不足。您可以先提交此交易,然后在编辑连块土地中再增加或删除地块。",
"maximum_parcels_title": "您达到了每笔交易的最大土地数",
"parcels": "包括地块",
"pending_tx": "连块土地"
"parcels": "包括地块"
},
"estate_dissolve": {
"too_big": "连块土地太大了",
Expand Down
4 changes: 0 additions & 4 deletions webapp/src/components/BuyParcelPage/BuyParcelPage.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
font-weight: bolder;
}

.BuyParcelPage button + button {
margin-left: 15px !important;
}

.BuyParcelPage .sign-in {
display: block;
text-align: center;
Expand Down
6 changes: 3 additions & 3 deletions webapp/src/components/DeleteEstatePage/DeleteEstatePage.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import PropTypes from 'prop-types'
import { Container, Message } from 'semantic-ui-react'
import { Message } from 'semantic-ui-react'
import EstateModal from 'components/EstateDetailPage/EditEstateMetadata/EstateModal'
import Estate from 'components/Estate'
import { isNewEstate, MAX_PARCELS_PER_TX } from 'shared/estate'
Expand All @@ -20,7 +20,7 @@ export default class DeleteEstatePage extends React.PureComponent {
render() {
const { id, isTxIdle, onCancel, onConfirm } = this.props
return (
<Container className="DeleteEstatePage">
<div className="DeleteEstatePage">
<Estate id={id} ownerOnly>
{estate => (
<React.Fragment>
Expand Down Expand Up @@ -49,7 +49,7 @@ export default class DeleteEstatePage extends React.PureComponent {
</React.Fragment>
)}
</Estate>
</Container>
</div>
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { t } from 'modules/translation/utils'
import EstateModal from './EstateModal'
import EditEstateMetadataForm from './EditEstateMetadataForm'
import { estateType } from 'components/types'
import TxStatus from 'components/TxStatus'
import EstateName from 'components/EstateName'

export default class EditEstateMetadata extends React.PureComponent {
static propTypes = {
Expand Down Expand Up @@ -46,6 +48,10 @@ export default class EditEstateMetadata extends React.PureComponent {
onChange={onChange}
isTxIdle={isTxIdle}
/>
<TxStatus.Asset
asset={estate}
name={<EstateName estate={estate} />}
/>
</EstateModal>
</div>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@
}

.EstateModal .modal-children {
margin: 0px 0px 0px 50px;
margin: 0 0 0 50px;
}

.EstateModal .tx-idle {
margin: 0 auto 20px;
width: 310px;
.EstateModal .tx-idle{
margin: 0 0 20px;
}

/* TODO: rules are duplicated on ParcelModal */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { coordsType, estateType } from 'components/types'
import { t } from 'modules/translation/utils'
import { calculateMapProps } from 'shared/estate'
import TxStatus from 'components/TxStatus'
import EstateName from 'components/EstateName'
import './EstateModal.css'

export default class EstateModal extends React.PureComponent {
Expand Down Expand Up @@ -75,40 +76,42 @@ export default class EstateModal extends React.PureComponent {
<span className="modal-subtitle">{subtitle}</span>
</div>
<br />
{children ? (
<React.Fragment>
<div className="modal-children">{children}</div>
<br />
</React.Fragment>
) : null}
{hasCustomFooter ? null : (
<div>
<Grid.Column>
<div className="modal-buttons">
<div className="modal-children">
nachomazzara marked this conversation as resolved.
Show resolved Hide resolved
{children ? (
<React.Fragment>
{children}
<br />
</React.Fragment>
) : null}
{hasCustomFooter ? null : (
<React.Fragment>
<Grid.Column>
{isTxIdle && (
<div className="tx-idle">
<TxStatus.Idle isIdle={isTxIdle} />
</div>
)}
<Button onClick={onCancel} type="button">
{cancelLabel || t('global.cancel')}
</Button>
<Button
onClick={onConfirm}
type="button"
primary
disabled={isDisabled}
>
{confirmLabel || t('global.confirm')}
</Button>
</div>
</Grid.Column>
</div>
)}
<TxStatus.Asset
asset={estate}
name={<span>{t('estate_detail.pending_tx')}</span>}
/>
<div className="modal-buttons">
<Button onClick={onCancel} type="button">
{cancelLabel || t('global.cancel')}
</Button>
<Button
onClick={onConfirm}
type="button"
primary
disabled={isDisabled}
>
{confirmLabel || t('global.confirm')}
</Button>
</div>
<TxStatus.Asset
asset={estate}
name={<EstateName estate={estate} />}
/>
</Grid.Column>
</React.Fragment>
)}
</div>
</div>
</div>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import {
MAX_PARCELS_PER_TX
} from 'shared/estate'
import { getParcelsNotIncluded } from 'shared/utils'
import TxStatus from 'components/TxStatus'
import EstateName from 'components/EstateName'
import './EstateSelect.css'

export default class EstateSelect extends React.PureComponent {
Expand All @@ -49,7 +51,7 @@ export default class EstateSelect extends React.PureComponent {
const { estate, onChange } = this.props
const parcels = estate.data.parcels

if (isEstate(asset) && asset.token_id !== estate.token_id) {
if (isEstate(asset) && asset.id !== estate.id) {
return
}

Expand Down Expand Up @@ -265,6 +267,10 @@ export default class EstateSelect extends React.PureComponent {
canSubmit={this.hasParcelsChanged(parcels)}
/>
{!isCreation && this.renderTxLabel()}
<TxStatus.Asset
asset={estate}
name={<EstateName estate={estate} />}
/>
</Grid.Column>
)}
</Grid.Row>
Expand Down
22 changes: 22 additions & 0 deletions webapp/src/components/EstateName/EstateName.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* TODO: rules are duplicated on ParcelName */
.EstateName {
max-width: 400px;
overflow: hidden;
text-overflow: ellipsis;
display: inline;
}

.EstateName a {
display: inline-block;
margin-top: 0;
}

.EstateName a:hover {
text-decoration: underline;
}

.EstateName .name {
color: var(--primary);
white-space: nowrap;
font-weight: bold;
}
23 changes: 23 additions & 0 deletions webapp/src/components/EstateName/EstateName.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react'
import { Link } from 'react-router-dom'

import { locations } from 'locations'
import { estateType } from 'components/types'
import './EstateName.css'

export default class EstateName extends React.PureComponent {
static propTypes = {
estate: estateType
}

render() {
const { id, data } = this.props.estate
return (
<div className="EstateName">
<Link to={locations.estateDetail(id)} className="ui">
<span className="name">{data.name}&nbsp;</span>
</Link>
</div>
)
}
}
3 changes: 3 additions & 0 deletions webapp/src/components/EstateName/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import EstateName from './EstateName'

export default EstateName
48 changes: 25 additions & 23 deletions webapp/src/components/ParcelModal/ParcelModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,29 +59,31 @@ export default class ParcelModal extends React.PureComponent {
<span className="modal-subtitle">{subtitle}</span>
</div>
<br />
{children ? (
<React.Fragment>
<div className="modal-children">{children}</div>
<br />
</React.Fragment>
) : null}
{hasCustomFooter ? null : (
<div className="modal-children">
<Grid.Column className="modal-buttons">
<Button onClick={onCancel} type="button">
{cancelLabel || t('global.cancel')}
</Button>
<Button
onClick={onConfirm}
type="button"
primary
disabled={isDisabled}
>
{confirmLabel || t('global.confirm')}
</Button>
</Grid.Column>
</div>
)}
<div className="modal-children">
{children ? (
<React.Fragment>
{children}
<br />
</React.Fragment>
) : null}
{hasCustomFooter ? null : (
<React.Fragment>
<Grid.Column className="modal-buttons">
<Button onClick={onCancel} type="button">
{cancelLabel || t('global.cancel')}
</Button>
<Button
onClick={onConfirm}
type="button"
primary
disabled={isDisabled}
>
{confirmLabel || t('global.confirm')}
</Button>
</Grid.Column>
</React.Fragment>
)}
</div>
</div>
</div>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import EstateModal from 'components/EstateDetailPage/EditEstateMetadata/EstateMo
import TxStatus from 'components/TxStatus'
import { t, t_html } from 'modules/translation/utils'
import TransferAssetForm from 'components/TransferAssetForm'
import EstateName from 'components/EstateName'

export default class TransferEstatePage extends React.PureComponent {
static propTypes = {
Expand Down Expand Up @@ -40,7 +41,7 @@ export default class TransferEstatePage extends React.PureComponent {
/>
<TxStatus.Asset
asset={estate}
name={<span>{t('estate_detail.pending_tx')}</span>}
name={<EstateName estate={estate} />}
/>
</EstateModal>
</div>
Expand Down
Loading