diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ab98ad01d..ab1d73701a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ All notable changes to the Wazuh app project will be documented in this file. - Changed of regular expression in RBAC. [#5201](https://github.com/wazuh/wazuh-kibana-app/pull/5201) - Migrate the timeFilter, metaFields, maxBuckets health checks inside the pattern check. [#5384](https://github.com/wazuh/wazuh-kibana-app/pull/5384) +- Changed the search bar in management/log to the one used in the rest of the app. [#5476](https://github.com/wazuh/wazuh-kibana-app/pull/5476) ### Fixed diff --git a/public/components/wz-field-search-bar/wz-field-search-bar.tsx b/public/components/wz-field-search-bar/wz-field-search-bar.tsx deleted file mode 100644 index 9d1a5c55ab..0000000000 --- a/public/components/wz-field-search-bar/wz-field-search-bar.tsx +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Wazuh app - React component which renders a field search bar - * Copyright (C) 2015-2022 Wazuh, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Find more information about this on the LICENSE file. - */ -import React, { useState, useEffect, useRef } from 'react'; -import { - EuiFieldSearch -} from '@elastic/eui'; - -interface IWzFieldSearchBarProps{ - onSearch: (searchTerm: string) => any - onChange?: (searchTerm: string) => any - searchDelay?: number - [key: string]: any -} - -export const WzFieldSearch = ({searchDelay, onSearch, onChange, ...rest}: IWzFieldSearchBarProps) => { - const [searchTerm, setSearchTerm] = useState(''); - const timerRef = useRef(); - const onChangeSearchTerm = e => setSearchTerm(e.target.value); - - useEffect(() => { - onChange && onChange(searchTerm); - if(searchDelay){ - clearTimeout(timerRef.current); - timerRef.current = setTimeout(() => onSearch(searchTerm), searchDelay); - } - return () => clearTimeout(timerRef.current); - }, [searchTerm]) - - return onSearch(searchTerm)} - {...rest} - /> -} \ No newline at end of file diff --git a/public/controllers/management/components/management/mg-logs/logs.js b/public/controllers/management/components/management/mg-logs/logs.js index 7d54ee991b..a13d833d7b 100644 --- a/public/controllers/management/components/management/mg-logs/logs.js +++ b/public/controllers/management/components/management/mg-logs/logs.js @@ -37,10 +37,10 @@ import { withUserAuthorizationPrompt, } from '../../../../../components/common/hocs'; import { compose } from 'redux'; -import { WzFieldSearch } from '../../../../../components/wz-field-search-bar/wz-field-search-bar'; import { UI_LOGGER_LEVELS } from '../../../../../../common/constants'; import { UI_ERROR_SEVERITIES } from '../../../../../react-services/error-orchestrator/types'; import { getErrorOrchestrator } from '../../../../../react-services/common-services'; +import { WzFieldSearchDelay } from '../../../../../components/common/search'; export default compose( withGlobalBreadcrumb([{ text: '' }, { text: 'Management', href: '#/manager' }, { text: 'Logs' }]), @@ -182,8 +182,8 @@ export default compose( const tmpResult = await WzRequest.apiReq('GET', logsPath, { params: this.buildFilters(customOffset), }); - const resultItems = ((tmpResult || {}).data.data || {}).affected_items; - totalItems = ((tmpResult || {}).data.data || {}).total_affected_items; + const resultItems = tmpResult?.data?.data?.affected_items; + totalItems = tmpResult?.data?.data?.total_affected_items; result = this.parseLogsToText(resultItems) || ''; } catch (error) { throw new Error('Error fetching logs: ' + error); @@ -221,14 +221,14 @@ export default compose( try { const clusterStatus = await WzRequest.apiReq('GET', '/cluster/status', {}); const clusterEnabled = - (((clusterStatus || {}).data || {}).data || {}).running === 'yes' && - (((clusterStatus || {}).data || {}).data || {}).enabled === 'yes'; + clusterStatus?.data?.data?.running === 'yes' && + clusterStatus?.data?.data?.enabled === 'yes'; if (clusterEnabled) { let nodeList = ''; let selectedNode = ''; const nodeListTmp = await WzRequest.apiReq('GET', '/cluster/nodes', {}); - if (Array.isArray((((nodeListTmp || {}).data || {}).data || {}).affected_items)) { + if (Array.isArray(nodeListTmp?.data?.data?.affected_items)) { nodeList = nodeListTmp.data.data.affected_items; selectedNode = nodeListTmp.data.data.affected_items.filter( (item) => item.type === 'master' @@ -480,8 +480,8 @@ export default compose( - {this.state.logsList}