diff --git a/src/views/Base/BandwidthStatusCard/BandwidthStatusCard.js b/src/views/Base/BandwidthStatusCard/BandwidthStatusCard.js index 00c15e791..a6fe0fc5b 100644 --- a/src/views/Base/BandwidthStatusCard/BandwidthStatusCard.js +++ b/src/views/Base/BandwidthStatusCard/BandwidthStatusCard.js @@ -36,13 +36,15 @@ class BandwidthStatusCard extends React.Component { const {bandwidthText, hasError} = this.state; if (!hasError) { const {setBandwidth} = this.props; - if (bandwidthText) + if (bandwidthText) { setBandwidth(bandwidthText); + this.toggleShowChangeBandwidth(); + } else { setBandwidth("0M"); } } else { - toast.error("Error in form"); + toast.error("Please check the errors before submitting"); } }; @@ -53,10 +55,22 @@ class BandwidthStatusCard extends React.Component { */ changeBandwidthInput = (e) => { const inputValue = e.target.value; - const validateInput = validateSizeSuffix(inputValue); + let validateInput = false; + if (inputValue === "") { + validateInput = true; + } else if (inputValue) { + const splitValue = inputValue.split(":"); + if(splitValue.length === 1) { + validateInput = validateSizeSuffix(splitValue[0]); + }else if(splitValue.length === 2) { + const validateDownloadLimit = validateSizeSuffix(splitValue[0]); + const validateUploadLimit = validateSizeSuffix(splitValue[1]); + validateInput = validateDownloadLimit && validateUploadLimit; + } + } this.setState({ bandwidthText: inputValue, - hasError: (inputValue !== "" ? !validateInput : false) + hasError: !validateInput }) }; @@ -94,15 +108,14 @@ class BandwidthStatusCard extends React.Component {

- + Keep empty to reset. - The bandwidth should be of the form 1M|2M|1G|1K|1.1K - etc + The bandwidth should be of the form 1M|2M|1G|1K|1.1K etc. Can also be specified as (upload:download) diff --git a/src/views/Base/BandwidthStatusCard/__snapshots__/BandwidthStatusCard.test.js.snap b/src/views/Base/BandwidthStatusCard/__snapshots__/BandwidthStatusCard.test.js.snap index 21aa83d79..6427e69e4 100644 --- a/src/views/Base/BandwidthStatusCard/__snapshots__/BandwidthStatusCard.test.js.snap +++ b/src/views/Base/BandwidthStatusCard/__snapshots__/BandwidthStatusCard.test.js.snap @@ -54,7 +54,7 @@ exports[`Bandwidth Status Card should match snapshot 1`] = ` ] } > - Enter new max speed + Enter new max speed (upload:download) - The bandwidth should be of the form 1M|2M|1G|1K|1.1K etc + The bandwidth should be of the form 1M|2M|1G|1K|1.1K etc. Can also be specified as (upload:download)