Skip to content

Commit eb1f0ef

Browse files
committed
issue 2132 patch
1 parent ea41c59 commit eb1f0ef

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

src/shared/components/Settings/Tools/Devices/index.jsx

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ export default class Devices extends ConsentComponent {
187187
* Invalid value, can not save
188188
* @param newDevice object
189189
*/
190-
onCheckFormValue(newDevice) {
190+
onCheckFormValue(newDevice, updateState = true) {
191191
let invalid = false;
192192

193193
let errorMessage = '';
@@ -227,7 +227,9 @@ export default class Devices extends ConsentComponent {
227227
errorMessage += ' cannot be empty';
228228
}
229229

230-
this.setState({ errorMessage, formInvalid: invalid });
230+
if (updateState) {
231+
this.setState({ errorMessage, formInvalid: invalid });
232+
}
231233
return invalid;
232234
}
233235

@@ -282,13 +284,7 @@ export default class Devices extends ConsentComponent {
282284

283285
isFormValid() {
284286
const { newDevice } = this.state;
285-
if (!newDevice.deviceType) {
286-
valid = false;
287-
}
288-
if (newDevice.manufacturer.trim().length === 0) {
289-
valid = false;
290-
}
291-
return this.onCheckFormValue(newDevice);
287+
return this.onCheckFormValue(newDevice, false);
292288
}
293289

294290
render() {
@@ -299,7 +295,7 @@ export default class Devices extends ConsentComponent {
299295
? deviceTrait.traits.data.slice() : [];
300296
const { newDevice, formInvalid, errorMessage } = this.state;
301297
const canModifyTrait = !this.props.traitRequestCount;
302-
const isValidDeviceForm = this.isFormValid();
298+
const isInValidDeviceForm = this.isFormValid();
303299
return (
304300
<div styleName="devices-container">
305301
{
@@ -423,7 +419,7 @@ export default class Devices extends ConsentComponent {
423419
<PrimaryButton
424420
styleName="complete"
425421
onClick={this.onHandleAddDevice}
426-
disabled={!canModifyTrait}
422+
disabled={!canModifyTrait || isInValidDeviceForm}
427423
>
428424
Add device to your list
429425
</PrimaryButton>
@@ -508,7 +504,7 @@ export default class Devices extends ConsentComponent {
508504
<PrimaryButton
509505
styleName="complete"
510506
onClick={this.onHandleAddDevice}
511-
disabled={!canModifyTrait}
507+
disabled={!canModifyTrait || isInValidDeviceForm}
512508
>
513509
Add Device
514510
</PrimaryButton>

src/shared/components/Settings/Tools/ServiceProviders/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ export default class ServiceProviders extends ConsentComponent {
249249

250250
isFormValid() {
251251
const { newServiceProvider } = this.state;
252-
if(newServiceProvider.serviceProviderType && (newServiceProvider.name.trim().length !== 0)) {
252+
if (newServiceProvider.serviceProviderType && (newServiceProvider.name.trim().length !== 0)) {
253253
return true;
254254
}
255255
return false;

src/shared/components/Settings/Tools/Software/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ export default class Software extends ConsentComponent {
249249

250250
isFormValid() {
251251
const { newSoftware } = this.state;
252-
if(newSoftware.softwareType && (newSoftware.name.trim().length !== 0)) {
252+
if (newSoftware.softwareType && (newSoftware.name.trim().length !== 0)) {
253253
return true;
254254
}
255255
return false;

0 commit comments

Comments
 (0)