Skip to content

Commit

Permalink
Merge branch 'master' into feat/dcl-and-ens-worlds-views
Browse files Browse the repository at this point in the history
  • Loading branch information
fzavalia committed Oct 3, 2023
2 parents a65e3d7 + 1473bc9 commit 882487a
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import CopyToClipboard from 'components/CopyToClipboard/CopyToClipboard'
import Icon from 'components/Icon'
import { InfoIcon } from 'components/InfoIcon'
import { DeployToWorldView, NameType, Props } from './DeployToWorld.types'
import { getSizesFromDeploymentError } from './utils'
import dclImage from './images/dcl.svg'
import ensImage from './images/ens.svg'

import styles from './DeployToWorld.module.css'

const EXPLORER_URL = config.get('EXPLORER_URL', '')
Expand Down Expand Up @@ -275,11 +275,28 @@ export default function DeployToWorld({
}

const renderFailureState = () => {
let subtitle: string = t('deployment_modal.deploy_world.failure.subtitle')

if (error) {
const sizes = getSizesFromDeploymentError(error)

if (sizes) {
const { maxSizeMbs, deployedSizedMbs } = sizes

subtitle = t('deployment_modal.deploy_world.failure.subtitle_size_error', {
maxSizeMbs,
deployedSizedMbs,
br: () => <br />,
b: (text: string) => <b>{text}</b>
})
}
}

return (
<div className={`${styles.modalBodyState} ${styles.modalBodyFailureState}`}>
<div className={styles.failureImage} aria-label={project?.description} role="img" />
<h1 className={styles.modalHeader}>{t('deployment_modal.deploy_world.failure.title')}</h1>
<span className={styles.description}>{t('deployment_modal.deploy_world.failure.subtitle')}</span>
<span className={styles.description}>{subtitle}</span>
</div>
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { getSizesFromDeploymentError } from './utils'

describe('when getting the sizes from the deployment error', () => {
let error: string

describe('when the error is not the expected one', () => {
beforeEach(() => {
error = 'invalid'
})

it('should return null', () => {
expect(getSizesFromDeploymentError(error)).toBeNull()
})
})

describe('when the error is the expected one', () => {
beforeEach(() => {
error = `Failed to fetch https://worlds-content-server.decentraland.org/entities. Got status 400. Response was '{"error":"Bad request","message":"Deployment failed: The deployment is too big. The maximum total size allowed is 25 MB for scenes. You can upload up to 26214400 bytes but you tried to upload 37528367."}'`
})

it('should return an object with the deployed and max sizes in mbs', () => {
expect(getSizesFromDeploymentError(error)).toEqual({
deployedSizedMbs: '36',
maxSizeMbs: '25'
})
})
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export const getSizesFromDeploymentError = (error: string) => {
const pattern = /.*You can upload up to (\d+) bytes but you tried to upload (\d+).*/

// eslint-disable-next-line
const match = error.match(pattern)

if (match?.length !== 3) {
return null
}

return {
maxSizeMbs: (Number(match[1]) / 1024 / 1024).toFixed(),
deployedSizedMbs: (Number(match[2]) / 1024 / 1024).toFixed()
}
}
3 changes: 2 additions & 1 deletion src/modules/translation/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,8 @@
},
"failure": {
"title": "Something went wrong",
"subtitle": "We couldn't publish your scene"
"subtitle": "We couldn't publish your scene",
"subtitle_size_error": "La escena es demasiado grande para publicarse en un mundo.<br></br>El tamaño máximo es de <b>{maxSizeMbs} mbs</b>, pero la escena actual es de <b>{deployedSizedMbs} mbs</b >."
},
"world_url_description": "The URL to jump in your World will be:<br></br><b>{world_url}</b>",
"world_has_content": "The existing content in {world} World will be replaced with the new content you're about to publish.",
Expand Down
3 changes: 2 additions & 1 deletion src/modules/translation/languages/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,8 @@
},
"failure": {
"title": "Algo salió mal",
"subtitle": "No pudimos publicar tu escena"
"subtitle": "No pudimos publicar tu escena",
"subtitle_size_error": "The scene is too big to be published in a World.<br></br>The maximum size is <b>{maxSizeMbs} mbs</b>, but the current scene is <b>{deployedSizedMbs} mbs</b> large."
},
"world_url_description": "La URL para ingresar en tu mundo será:<br></br><b>{world_url}</b>",
"world_has_content": "El contenido existente en {world} mundo se reemplazará con el nuevo contenido que está a punto de publicar.",
Expand Down
3 changes: 2 additions & 1 deletion src/modules/translation/languages/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,8 @@
},
"failure": {
"title": "出了些问题",
"subtitle": "我们无法发布您的场景"
"subtitle": "我们无法发布您的场景",
"subtitle_size_error": "场景太大,无法发布到世界。<br></br>最大大小为 <b>{maxSizeMbs} mbs</b>,但当前场景为 <b>{deployedSizedMbs} mbs</b> >。"
},
"world_url_description": "跳入您的世界的URL将是:<br></br><b>{world_url}</b>",
"world_has_content": "{world}梦中的现有内容将被您即将发布的新内容替换。",
Expand Down

0 comments on commit 882487a

Please sign in to comment.