Skip to content

Commit

Permalink
fix: Atlas not rendering tenants (#2421)
Browse files Browse the repository at this point in the history
  • Loading branch information
LautaroPetaccio authored Nov 11, 2022
1 parent 8e30b6e commit 216ad74
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 19 deletions.
18 changes: 12 additions & 6 deletions src/components/Atlas/Atlas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const Atlas: React.FC<Props> = props => {
emptyTiles,
showOwner,
showOperator,
showTenant,
showControls,
hasPopup,
className,
Expand Down Expand Up @@ -79,32 +80,37 @@ const Atlas: React.FC<Props> = props => {
[props.x, props.y, landId, isEstate, selection]
)

const shouldShowLayer = (tile?: LandTile, showOwner?: boolean, showOperator?: boolean) => {
return !!tile && ((showOwner && tile.land.role === RoleType.OWNER) || (showOperator && tile.land.role === RoleType.OPERATOR))
const shouldShowLayer = (tile?: LandTile, showOwner?: boolean, showOperator?: boolean, showTenant?: boolean) => {
return (
!!tile &&
((showOwner && tile.land.role === RoleType.OWNER) ||
(showOperator && tile.land.role === RoleType.OPERATOR) ||
(showTenant && tile.land.role === RoleType.TENANT))
)
}

const landLayer: Layer = useCallback(
(x, y) => {
const id = coordsToId(x, y)
const tile = landTiles[id]
if (shouldShowLayer(tile, showOwner, showOperator)) {
if (shouldShowLayer(tile, showOwner, showOperator, showTenant)) {
return tile || null
}
return null
},
[landTiles, showOwner, showOperator]
[landTiles, showOwner, showOperator, showTenant]
)

const unoccupiedLayer: Layer = useCallback(
(x, y) => {
const id = coordsToId(x, y)
const tile = landTiles[id]
if (shouldShowLayer(tile, showOwner, showOperator)) {
if (shouldShowLayer(tile, showOwner, showOperator, showTenant)) {
return emptyTiles[id] || null
}
return null
},
[emptyTiles, landTiles, showOwner, showOperator]
[emptyTiles, landTiles, showOwner, showOperator, showTenant]
)

const handleHover = useCallback(
Expand Down
1 change: 1 addition & 0 deletions src/components/Atlas/Atlas.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export type Props = Partial<AtlasProps> & {
landTiles: Record<string, LandTile>
emptyTiles: Record<string, Tile>
showOperator?: boolean
showTenant?: boolean
showControls?: boolean
landId?: string
showOwner?: boolean
Expand Down
4 changes: 2 additions & 2 deletions src/components/LandDetailPage/LandDetailPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ export default class LandDetailPage extends React.PureComponent<Props, State> {
{land.operators.length > 0 ? (
<Stats title={t('land_detail_page.operated_by')} className="operators">
<Row>
{land.operators.map(operator => (
<Profile address={operator} size="large" />
{land.operators.map((operator, index) => (
<Profile key={index} address={operator} size="large" />
))}
</Row>
</Stats>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export default class DeployToLand extends React.PureComponent<Props, State> {
}

renderMap = () => {
const { ethAddress, media, project, deployments, deploymentsByCoord, landTiles, isLoggedIn } = this.props
const { media, project, deployments, deploymentsByCoord, landTiles, isLoggedIn } = this.props
const deployment = getDeployment(project, deployments)
return (
<div className="DeployToLand atlas">
Expand All @@ -242,7 +242,6 @@ export default class DeployToLand extends React.PureComponent<Props, State> {
<Icon name="modal-back" onClick={this.handleBack} />
</div>
<LandAtlas
ethAddress={ethAddress}
media={media}
project={project}
deploymentsByCoord={deploymentsByCoord}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export default class LandAtlas extends React.PureComponent<Props, State> {
handleSelectPlacement = () => {
const { placement } = this.state
const { onConfirmPlacement } = this.props
const overlappedDeployment = this.getOverlappedDeployemnt()
const overlappedDeployment = this.getOverlappedDeployment()
if (placement) {
overlappedDeployment ? onConfirmPlacement(placement, overlappedDeployment.id) : onConfirmPlacement(placement)
}
Expand Down Expand Up @@ -158,7 +158,7 @@ export default class LandAtlas extends React.PureComponent<Props, State> {
return input
}

getOverlappedDeployemnt = () => {
getOverlappedDeployment = () => {
const { deploymentsByCoord, project } = this.props
const { placement } = this.state
if (project && placement) {
Expand Down Expand Up @@ -197,7 +197,7 @@ export default class LandAtlas extends React.PureComponent<Props, State> {
const parcelCount = Object.keys(landTiles).length
const [targetX, targetY] = currentLandId ? idToCoords(currentLandId) : [0, 0]
const target: Coordinate = { x: targetX, y: targetY }
const overlappedDeployment = this.getOverlappedDeployemnt()
const overlappedDeployment = this.getOverlappedDeployment()
const conflictingDeployment =
overlappedDeployment &&
deployment &&
Expand Down Expand Up @@ -238,6 +238,8 @@ export default class LandAtlas extends React.PureComponent<Props, State> {
<div className="atlas-container">
<Atlas
showControls
showOperator
showTenant
onLocateLand={this.handleLocateLand}
layers={[this.strokeLayer, this.highlightLayer]}
onHover={this.handleHover}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { Coordinate, Rotation, Placement, Deployment } from 'modules/deployment/
import { LandTile } from 'modules/land/types'

export type Props = {
ethAddress: string | undefined
project: Project
media: Media | null
isLoggedIn: boolean
Expand Down
2 changes: 1 addition & 1 deletion src/components/SceneDetailPage/SceneDetailPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default class SceneDetailPage extends React.PureComponent<Props> {
<>
<div className="deployments">
{deployments.map(deployment => (
<DeploymentDetail project={project} deployment={deployment} />
<DeploymentDetail key={deployment.id} project={project} deployment={deployment} />
))}
</div>
<div className="notice">{t('analytics.notice')}</div>
Expand Down
8 changes: 4 additions & 4 deletions src/modules/land/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,25 @@ export const colorByRole: Record<RoleType, string> = {
export const emptyColorByRole: Record<RoleType, string> = {
[RoleType.OWNER]: '#ab2039',
[RoleType.OPERATOR]: '#8f1d9b',
[RoleType.TENANT]: '#8f1d9b'
[RoleType.TENANT]: '#D18157'
}

export const selectionBorderColorByRole: Record<RoleType, string> = {
[RoleType.OWNER]: '#ff8199',
[RoleType.OPERATOR]: '#d742e8',
[RoleType.TENANT]: '#d742e8'
[RoleType.TENANT]: '#FEBD9A'
}

export const hoverFillByRole = {
[RoleType.OWNER]: '#ff8199',
[RoleType.OPERATOR]: '#d742e8',
[RoleType.TENANT]: '#d742e8'
[RoleType.TENANT]: '#FEBD9A'
}

export const hoverStrokeByRole = {
[RoleType.OWNER]: '#fcc6d1',
[RoleType.OPERATOR]: '#ef5eff',
[RoleType.TENANT]: '#ef5eff'
[RoleType.TENANT]: '#FED5BF'
}

export const getSelection = (land: Land) =>
Expand Down

1 comment on commit 216ad74

@vercel
Copy link

@vercel vercel bot commented on 216ad74 Nov 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

builder – ./

builder-git-master-decentraland1.vercel.app
builder-decentraland1.vercel.app

Please sign in to comment.