Skip to content

Commit

Permalink
moved maxAtom check to validate function, updated made-js commit hash
Browse files Browse the repository at this point in the history
  • Loading branch information
adewyer committed Jan 25, 2022
1 parent d8d040d commit 2965b70
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
25 changes: 10 additions & 15 deletions src/components/source_editor/BasisText.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/en/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down

0 comments on commit 2965b70

Please sign in to comment.