diff --git a/src/components/Modals/DeployModal/DeployToWorld_WorldsForEnsOwnersFeature/DeployToWorld.tsx b/src/components/Modals/DeployModal/DeployToWorld_WorldsForEnsOwnersFeature/DeployToWorld.tsx index 9f0134b90..5be8e0c51 100644 --- a/src/components/Modals/DeployModal/DeployToWorld_WorldsForEnsOwnersFeature/DeployToWorld.tsx +++ b/src/components/Modals/DeployModal/DeployToWorld_WorldsForEnsOwnersFeature/DeployToWorld.tsx @@ -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', '') @@ -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: () =>
, + b: (text: string) => {text} + }) + } + } + return (

{t('deployment_modal.deploy_world.failure.title')}

- {t('deployment_modal.deploy_world.failure.subtitle')} + {subtitle}
) } diff --git a/src/components/Modals/DeployModal/DeployToWorld_WorldsForEnsOwnersFeature/utils.spec.ts b/src/components/Modals/DeployModal/DeployToWorld_WorldsForEnsOwnersFeature/utils.spec.ts new file mode 100644 index 000000000..deb7550e1 --- /dev/null +++ b/src/components/Modals/DeployModal/DeployToWorld_WorldsForEnsOwnersFeature/utils.spec.ts @@ -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' + }) + }) + }) +}) diff --git a/src/components/Modals/DeployModal/DeployToWorld_WorldsForEnsOwnersFeature/utils.ts b/src/components/Modals/DeployModal/DeployToWorld_WorldsForEnsOwnersFeature/utils.ts new file mode 100644 index 000000000..217ef3917 --- /dev/null +++ b/src/components/Modals/DeployModal/DeployToWorld_WorldsForEnsOwnersFeature/utils.ts @@ -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() + } +} diff --git a/src/modules/translation/languages/en.json b/src/modules/translation/languages/en.json index 04de49b0e..1d602c8ab 100644 --- a/src/modules/translation/languages/en.json +++ b/src/modules/translation/languages/en.json @@ -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.

El tamaño máximo es de {maxSizeMbs} mbs, pero la escena actual es de {deployedSizedMbs} mbs." }, "world_url_description": "The URL to jump in your World will be:

{world_url}", "world_has_content": "The existing content in {world} World will be replaced with the new content you're about to publish.", diff --git a/src/modules/translation/languages/es.json b/src/modules/translation/languages/es.json index 3f4075214..22e51292b 100644 --- a/src/modules/translation/languages/es.json +++ b/src/modules/translation/languages/es.json @@ -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.

The maximum size is {maxSizeMbs} mbs, but the current scene is {deployedSizedMbs} mbs large." }, "world_url_description": "La URL para ingresar en tu mundo será:

{world_url}", "world_has_content": "El contenido existente en {world} mundo se reemplazará con el nuevo contenido que está a punto de publicar.", diff --git a/src/modules/translation/languages/zh.json b/src/modules/translation/languages/zh.json index 966a449ed..9d710bd2b 100644 --- a/src/modules/translation/languages/zh.json +++ b/src/modules/translation/languages/zh.json @@ -478,7 +478,8 @@ }, "failure": { "title": "出了些问题", - "subtitle": "我们无法发布您的场景" + "subtitle": "我们无法发布您的场景", + "subtitle_size_error": "场景太大,无法发布到世界。

最大大小为 {maxSizeMbs} mbs,但当前场景为 {deployedSizedMbs} mbs >。" }, "world_url_description": "跳入您的世界的URL将是:

{world_url}", "world_has_content": "{world}梦中的现有内容将被您即将发布的新内容替换。",