From 5f18e24f7d124f21b68c7627db2c720d24dc115a Mon Sep 17 00:00:00 2001 From: c8y3 <25362953+c8y3@users.noreply.github.com> Date: Wed, 26 Jul 2023 10:57:23 +0200 Subject: [PATCH] Fixed missing properties show and onCancel when calling BootstrapModalForm --- src/web/wizard/components/ManageSettings.jsx | 10 ++-- .../wizard/components/ManageSettings.test.jsx | 46 +++++++++++++++++++ .../wizard/components/lists/AlertListForm.jsx | 1 + 3 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 src/web/wizard/components/ManageSettings.test.jsx diff --git a/src/web/wizard/components/ManageSettings.jsx b/src/web/wizard/components/ManageSettings.jsx index a5dfd11b..cb904ed0 100755 --- a/src/web/wizard/components/ManageSettings.jsx +++ b/src/web/wizard/components/ManageSettings.jsx @@ -27,6 +27,7 @@ import ObjectUtils from 'util/ObjectUtils'; import { FormattedMessage } from 'react-intl'; import FormsUtils from 'util/FormsUtils'; +// TODO convert into functional component const ManageSettings = createReactClass({ displayName: 'ManageSettings', @@ -42,6 +43,7 @@ const ManageSettings = createReactClass({ default_values: this.props.config.default_values, import_policy: this.props.config.import_policy, }, + showModal: false }; }, @@ -50,11 +52,11 @@ const ManageSettings = createReactClass({ }, _openModal() { - this.refs.configModal.open(); + this.setState({ showModal: true }); }, _closeModal() { - this.refs.configModal.close(); + this.setState({ showModal: false }); }, _saveConfig() { @@ -210,10 +212,10 @@ const ManageSettings = createReactClass({ return ( - } onSubmitForm={this._saveConfig} - onModalClose={this._resetConfig} + onCancel={this._resetConfig} cancelButtonText={} submitButtonText={}>
diff --git a/src/web/wizard/components/ManageSettings.test.jsx b/src/web/wizard/components/ManageSettings.test.jsx new file mode 100644 index 00000000..b3b6946d --- /dev/null +++ b/src/web/wizard/components/ManageSettings.test.jsx @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2018 Airbus CyberSecurity (SAS) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the Server Side Public License, version 1, + * as published by MongoDB, Inc. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * Server Side Public License for more details. + * + * You should have received a copy of the Server Side Public License + * along with this program. If not, see + * . + */ + +import React from 'react'; +import { render } from 'wrappedTestingLibrary'; +import ManageSettings from './ManageSettings'; +import { IntlProvider } from 'react-intl'; + +describe('', () => { + it('should not fail', () => { + const onSave = jest.fn(); + const configuration = { + field_order: [{ name: 'User', enabled: true }], + default_values: { + title: 'title', + severity: 'info', + matching_type: 'AND', + threshold_type: '>', + threshold: 0, + time: 1, + time_type: 1, + backlog: 500, + grace: 1 + }, + import_policy: 'REPLACE' + }; + render( + + ) + // config={configuration} + }); +}); diff --git a/src/web/wizard/components/lists/AlertListForm.jsx b/src/web/wizard/components/lists/AlertListForm.jsx index 9d681e66..1277adb2 100644 --- a/src/web/wizard/components/lists/AlertListForm.jsx +++ b/src/web/wizard/components/lists/AlertListForm.jsx @@ -70,6 +70,7 @@ const AlertListForm = createReactClass({ render() { return ( + // TODO should remove ref } onSubmitForm={this._onSubmit}