From 2965b70e87b72294a5e1d81979e983512096c98a Mon Sep 17 00:00:00 2001 From: adewyer Date: Tue, 25 Jan 2022 13:32:52 -0800 Subject: [PATCH] moved maxAtom check to validate function, updated made-js commit hash --- package.json | 2 +- src/components/source_editor/BasisText.js | 25 +++++++++-------------- src/i18n/en/messages.js | 2 +- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index 454f1b4e..a515af8a 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "@babel/preset-react": "7.0.0", "@babel/runtime": "^7.5.0", "@babel/runtime-corejs2": "^7.5.0", - "@exabyte-io/made.js": "git+https://github.com/Exabyte-io/made.js.git#831a02cb6e2c6e6ba2be46fe2216ca0218b72189", + "@exabyte-io/made.js": "git+https://github.com/Exabyte-io/made.js.git#f033ce206a42a61cdd36df615608f2c1130eedcb", "@exabyte-io/wave.js": "3.1.5", "bootstrap": "^3.3.7", "classnames": "^2.2.5", diff --git a/src/components/source_editor/BasisText.js b/src/components/source_editor/BasisText.js index 74fc9572..99e46189 100644 --- a/src/components/source_editor/BasisText.js +++ b/src/components/source_editor/BasisText.js @@ -35,28 +35,23 @@ class BasisText extends React.Component { Made.parsers.xyz.validate(content); // only show the success message first time after last failure if (!this.state.isContentValidated) { - const validNumberOfAtoms = Made.parsers.xyz.validateNumberOfAtoms(content); - if (!validNumberOfAtoms) { - this.setState({ - isContentValidated: false, - message: displayMessage('basis.maxAtomError') - }); - return false; - } else { - this.setState({ - isContentValidated: true, - // TODO: consider removing the success message after a timeout period - message: displayMessage('basis.validationSuccess') - }); - } + this.setState({ + isContentValidated: true, + // TODO: consider removing the success message after a timeout period + message: displayMessage('basis.validationSuccess') + }); } else { // already validated before -> remove message this.setState({message: ''}); } } catch (err) { + let message = "basis.validationError" + if (err.message === "Non-Periodic max atom limit exceeded") { + message = "basis.maxAtomError" + } this.setState({ isContentValidated: false, - message: displayMessage('basis.validationError') + message: displayMessage(message) }); return false; } diff --git a/src/i18n/en/messages.js b/src/i18n/en/messages.js index 805edb7d..9f7a2a83 100644 --- a/src/i18n/en/messages.js +++ b/src/i18n/en/messages.js @@ -6,7 +6,7 @@ export default { "elementsNotEqual": "Atomic elements differ", "validationError": "Invalid basis format. Please see documentation", "validationSuccess": "Valid basis format", - "maxAtomError": "Maximum Number of Atoms Exceeded.\nLimit = 1000 Atoms." + "maxAtomError": "For Non-Periodic Structures: Maximum Number of Atoms Exceeded. Limit = 1000 Atoms." }, "resetToLast": "Material is reset to last valid state", "combinatorialBasesCountExceeded": "Number of combinations exceeded the limit (%s)"