From 64cbe55678a57a8926d2b022754eaf2032f48ba6 Mon Sep 17 00:00:00 2001 From: Maximiliano Ibarra Date: Wed, 7 Dec 2022 09:26:29 -0300 Subject: [PATCH 1/2] Added Rule editor validation --- .../components/management/common/file-editor.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/public/controllers/management/components/management/common/file-editor.tsx b/public/controllers/management/components/management/common/file-editor.tsx index f21ce7f5f6..17b3f0de05 100644 --- a/public/controllers/management/components/management/common/file-editor.tsx +++ b/public/controllers/management/components/management/common/file-editor.tsx @@ -91,6 +91,12 @@ class WzFileEditor extends Component { this._isMounted = true; } + /** + * Check if the file content has changed and is not empty + */ + contentHasChanged() { + return !!this.state.content.trim() && (this.state.content.trim() !== this.state.initContent.trim()); + } /** * Save the new content @@ -129,7 +135,7 @@ class WzFileEditor extends Component { let toastMessage; - if (this.props.state.addingFile != false) { + if (this.props.addingFile != false) { //remove current invalid file if the file is new. await this.resourcesHandler.deleteFile(name); toastMessage = 'The new file was deleted.'; @@ -243,7 +249,7 @@ class WzFileEditor extends Component { fill iconType={isEditable && xmlError ? 'alert' : 'save'} isLoading={this.state.isSaving} - isDisabled={nameForSaving.length <= 4 || !!(isEditable && xmlError)} + isDisabled={nameForSaving.length <= 4 || !!(isEditable && xmlError) || !this.contentHasChanged()} onClick={() => this.save(nameForSaving, overwrite)} > {isEditable && xmlError ? 'XML format error' : 'Save'} From 3e2bb870218f28d21eb6387cb711b89923694792 Mon Sep 17 00:00:00 2001 From: Maximiliano Ibarra Date: Wed, 7 Dec 2022 09:36:06 -0300 Subject: [PATCH 2/2] Updated CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 19e1f51f48..8e12b5f83d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ All notable changes to the Wazuh app project will be documented in this file. - Added powerPC architecture in redhat7, in the section 'Deploy new agent'. [4833](https://github.com/wazuh/wazuh-kibana-app/pull/4833) - Added a centralized service to handle the requests [#4831](https://github.com/wazuh/wazuh-kibana-app/pull/4831) - Added data-test-subj create policy [#4873](https://github.com/wazuh/wazuh-kibana-app/pull/4873) +- Added file saving conditions in File Editor [#4970](https://github.com/wazuh/wazuh-kibana-app/pull/4970) ### Changed