diff --git a/CHANGELOG.md b/CHANGELOG.md index cfc2bd2b0f..71c5449351 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 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'}