From 9765aa2961f83c2611e93e382aa6d6c155da97e5 Mon Sep 17 00:00:00 2001 From: mpabba3003 Date: Fri, 19 Aug 2022 11:56:41 -0700 Subject: [PATCH] adding relation between credential selection and no auth checkbox Signed-off-by: mpabba3003 --- .../create_edit_data_source_wizard.tsx | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/plugins/data_source_management/public/components/create_edit_data_source_wizard/create_edit_data_source_wizard.tsx b/src/plugins/data_source_management/public/components/create_edit_data_source_wizard/create_edit_data_source_wizard.tsx index d6ad3b398951..479940f55d73 100644 --- a/src/plugins/data_source_management/public/components/create_edit_data_source_wizard/create_edit_data_source_wizard.tsx +++ b/src/plugins/data_source_management/public/components/create_edit_data_source_wizard/create_edit_data_source_wizard.tsx @@ -211,6 +211,20 @@ export class CreateEditDataSourceWizard extends React.Component< }); }; + onChangeNoAuth = () => { + this.setState( + { + noAuthentication: !this.state.noAuthentication, + }, + () => { + /* When credential is already selected and user checks the noAuth checkbox, reset previously selected credential*/ + if (this.state.noAuthentication && this.state.selectedCredentials.length) { + this.setState({ selectedCredentials: [] }); + } + } + ); + }; + onClickCreateNewDataSource = () => { if (this.isFormValid()) { const formValues: DataSourceEditPageItem = { @@ -231,6 +245,10 @@ export class CreateEditDataSourceWizard extends React.Component< onSelectExistingCredentials = (options: CredentialsComboBoxItem[]) => { this.setState({ selectedCredentials: options }, () => { + /* When noAuth checkbox is checked and user selects credentials, un-check the noAuth checkbox*/ + if (options.length && this.state.noAuthentication) { + this.onChangeNoAuth(); + } if (this.state.formErrorsByField.credential.length) { this.isFormValid(); } @@ -435,11 +453,7 @@ export class CreateEditDataSourceWizard extends React.Component< id="noAuthentication" label="Continue without authentication" checked={this.state.noAuthentication} - onChange={(e) => { - this.setState({ - noAuthentication: !this.state.noAuthentication, - }); - }} + onChange={this.onChangeNoAuth} compressed />