From 562d0e8ff1d9fdc9be69449eeda8463bd611085d Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Thu, 18 Jul 2024 18:05:42 -0700 Subject: [PATCH] Disable input in edit data source when data_source.manageableBy is none (#7307) (#7310) * Disable input in edit data source when data_source.manageableBy is none * Changeset file for PR #7307 created/updated * Removed unnecessary canManageDataSource check * Fix lint issue * Update snapshot --------- (cherry picked from commit ddc26fc9eab6e6220a4375c65fdc84163d7c002a) Signed-off-by: Eemi Juntunen Signed-off-by: github-actions[bot] Co-authored-by: github-actions[bot] Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> --- changelogs/fragments/7307.yml | 2 ++ .../edit_form/edit_data_source_form.tsx | 16 ++++++++++++++-- .../update_aws_credential_modal.test.tsx | 1 + .../update_aws_credential_modal.tsx | 4 ++++ .../update_password_modal.test.tsx.snap | 11 +++++++++++ .../update_password_modal.test.tsx | 1 + .../update_password_modal.tsx | 4 ++++ 7 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/7307.yml diff --git a/changelogs/fragments/7307.yml b/changelogs/fragments/7307.yml new file mode 100644 index 000000000000..ad874b0e9b03 --- /dev/null +++ b/changelogs/fragments/7307.yml @@ -0,0 +1,2 @@ +feat: +- Disable inputs in edit data source screen when data_source.manageableBy is none ([#7307](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7307)) \ No newline at end of file diff --git a/src/plugins/data_source_management/public/components/edit_data_source/components/edit_form/edit_data_source_form.tsx b/src/plugins/data_source_management/public/components/edit_data_source/components/edit_form/edit_data_source_form.tsx index 74ec7362381a..64cb56eb2aa5 100644 --- a/src/plugins/data_source_management/public/components/edit_data_source/components/edit_form/edit_data_source_form.tsx +++ b/src/plugins/data_source_management/public/components/edit_data_source/components/edit_form/edit_data_source_form.tsx @@ -586,6 +586,7 @@ export class EditDataSourceForm extends React.Component { @@ -601,6 +602,7 @@ export class EditDataSourceForm extends React.Component ) : null} @@ -613,6 +615,7 @@ export class EditDataSourceForm extends React.Component { ) : null} @@ -725,6 +729,7 @@ export class EditDataSourceForm extends React.Component {/* Description */} @@ -745,6 +750,7 @@ export class EditDataSourceForm extends React.Component @@ -837,7 +843,7 @@ export class EditDataSourceForm extends React.Component this.onChangeAuthType(value)} - disabled={this.authOptions.length <= 1} + disabled={this.authOptions.length <= 1 || !this.props.canManageDataSource} name="Credential" data-test-subj="editDataSourceSelectAuthType" /> @@ -883,6 +889,7 @@ export class EditDataSourceForm extends React.Component @@ -895,6 +902,7 @@ export class EditDataSourceForm extends React.Component this.onChangeSigV4ServiceName(value)} name="ServiceName" data-test-subj="editDataSourceFormSigV4ServiceTypeSelect" @@ -989,6 +997,7 @@ export class EditDataSourceForm extends React.Component @@ -1018,7 +1027,10 @@ export class EditDataSourceForm extends React.Component diff --git a/src/plugins/data_source_management/public/components/edit_data_source/components/update_aws_credential_modal/update_aws_credential_modal.test.tsx b/src/plugins/data_source_management/public/components/edit_data_source/components/update_aws_credential_modal/update_aws_credential_modal.test.tsx index e7c7f0209438..c0cab401a86d 100644 --- a/src/plugins/data_source_management/public/components/edit_data_source/components/update_aws_credential_modal/update_aws_credential_modal.test.tsx +++ b/src/plugins/data_source_management/public/components/edit_data_source/components/update_aws_credential_modal/update_aws_credential_modal.test.tsx @@ -20,6 +20,7 @@ describe('UpdateAwsCredentialModal', () => { service: SigV4ServiceName.OpenSearch, handleUpdateAwsCredential: mockHandleUpdateAwsCredential, closeUpdateAwsCredentialModal: mockCloseUpdateAwsCredentialModal, + canManageDataSource: true, }; it('updates new access key state on input change', () => { diff --git a/src/plugins/data_source_management/public/components/edit_data_source/components/update_aws_credential_modal/update_aws_credential_modal.tsx b/src/plugins/data_source_management/public/components/edit_data_source/components/update_aws_credential_modal/update_aws_credential_modal.tsx index 2fbae293132f..e4ecf0766690 100644 --- a/src/plugins/data_source_management/public/components/edit_data_source/components/update_aws_credential_modal/update_aws_credential_modal.tsx +++ b/src/plugins/data_source_management/public/components/edit_data_source/components/update_aws_credential_modal/update_aws_credential_modal.tsx @@ -28,6 +28,7 @@ export interface UpdateAwsCredentialModalProps { service: SigV4ServiceName; handleUpdateAwsCredential: (accessKey: string, secretKey: string) => void; closeUpdateAwsCredentialModal: () => void; + canManageDataSource: boolean; } export const UpdateAwsCredentialModal = ({ @@ -35,6 +36,7 @@ export const UpdateAwsCredentialModal = ({ service, handleUpdateAwsCredential, closeUpdateAwsCredentialModal, + canManageDataSource, }: UpdateAwsCredentialModalProps) => { /* State Variables */ const [newAccessKey, setNewAccessKey] = useState(''); @@ -134,6 +136,7 @@ export const UpdateAwsCredentialModal = ({ spellCheck={false} onChange={(e) => setNewAccessKey(e.target.value)} onBlur={validateNewAccessKey} + disabled={!canManageDataSource} /> @@ -159,6 +162,7 @@ export const UpdateAwsCredentialModal = ({ spellCheck={false} onChange={(e) => setNewSecretKey(e.target.value)} onBlur={validateNewSecretKey} + disabled={!canManageDataSource} /> diff --git a/src/plugins/data_source_management/public/components/edit_data_source/components/update_password_modal/__snapshots__/update_password_modal.test.tsx.snap b/src/plugins/data_source_management/public/components/edit_data_source/components/update_password_modal/__snapshots__/update_password_modal.test.tsx.snap index 21ec04bd300e..7f8bd04c86a2 100644 --- a/src/plugins/data_source_management/public/components/edit_data_source/components/update_password_modal/__snapshots__/update_password_modal.test.tsx.snap +++ b/src/plugins/data_source_management/public/components/edit_data_source/components/update_password_modal/__snapshots__/update_password_modal.test.tsx.snap @@ -5,6 +5,7 @@ exports[`Datasource Management: Update Stored Password Modal should render norma locale="en" > { username={mockUserName} handleUpdatePassword={mockFn} closeUpdatePasswordModal={mockFn} + canManageDataSource={true} /> ), { diff --git a/src/plugins/data_source_management/public/components/edit_data_source/components/update_password_modal/update_password_modal.tsx b/src/plugins/data_source_management/public/components/edit_data_source/components/update_password_modal/update_password_modal.tsx index 693a8a84234e..aef52c895a62 100644 --- a/src/plugins/data_source_management/public/components/edit_data_source/components/update_password_modal/update_password_modal.tsx +++ b/src/plugins/data_source_management/public/components/edit_data_source/components/update_password_modal/update_password_modal.tsx @@ -25,12 +25,14 @@ export interface UpdatePasswordModalProps { username: string; handleUpdatePassword: (password: string) => void; closeUpdatePasswordModal: () => void; + canManageDataSource: boolean; } export const UpdatePasswordModal = ({ username, handleUpdatePassword, closeUpdatePasswordModal, + canManageDataSource, }: UpdatePasswordModalProps) => { /* State Variables */ const [newPassword, setNewPassword] = useState(''); @@ -128,6 +130,7 @@ export const UpdatePasswordModal = ({ spellCheck={false} onChange={(e) => setNewPassword(e.target.value)} onBlur={validateNewPassword} + disabled={!canManageDataSource} /> {/* Password */} @@ -153,6 +156,7 @@ export const UpdatePasswordModal = ({ spellCheck={false} onChange={(e) => setConfirmNewPassword(e.target.value)} onBlur={validateConfirmNewPassword} + disabled={!canManageDataSource} />