Skip to content

Commit

Permalink
Fixed missing properties show and onCancel when calling BootstrapModa…
Browse files Browse the repository at this point in the history
…lForm
  • Loading branch information
c8y3 committed Jul 26, 2023
1 parent f000ac4 commit 5f18e24
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/web/wizard/components/ManageSettings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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',

Expand All @@ -42,6 +43,7 @@ const ManageSettings = createReactClass({
default_values: this.props.config.default_values,
import_policy: this.props.config.import_policy,
},
showModal: false
};
},

Expand All @@ -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() {
Expand Down Expand Up @@ -210,10 +212,10 @@ const ManageSettings = createReactClass({
return (
<span>
<Button bsStyle="info" onClick={this._openModal}><FormattedMessage id="wizard.manageSettings" defaultMessage="Manage settings" /></Button>
<BootstrapModalForm ref="configModal"
<BootstrapModalForm show={this.state.showModal}
title={<FormattedMessage id="wizard.manageWizardSettings" defaultMessage="Manage Wizard settings" />}
onSubmitForm={this._saveConfig}
onModalClose={this._resetConfig}
onCancel={this._resetConfig}
cancelButtonText={<FormattedMessage id="wizard.cancel" defaultMessage="Cancel" />}
submitButtonText={<FormattedMessage id="wizard.save" defaultMessage="Save" />}>
<div>
Expand Down
46 changes: 46 additions & 0 deletions src/web/wizard/components/ManageSettings.test.jsx
Original file line number Diff line number Diff line change
@@ -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
* <http://www.mongodb.com/licensing/server-side-public-license>.
*/

import React from 'react';
import { render } from 'wrappedTestingLibrary';
import ManageSettings from './ManageSettings';
import { IntlProvider } from 'react-intl';

describe('<ManageSettings>', () => {
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(<IntlProvider locale="en" >
<ManageSettings config={configuration} onSave={onSave} />
</IntlProvider>)
// config={configuration}
});
});
1 change: 1 addition & 0 deletions src/web/wizard/components/lists/AlertListForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const AlertListForm = createReactClass({

render() {
return (
// TODO should remove ref
<BootstrapModalForm ref="modal"
title={<FormattedMessage id= "wizard.cloneList" defaultMessage= 'Cloning List "{title}"' values={{title: this.state.origTitle }} />}
onSubmitForm={this._onSubmit}
Expand Down

0 comments on commit 5f18e24

Please sign in to comment.