diff --git a/CHANGELOG.md b/CHANGELOG.md
index f7a9285112..568edaaa2c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -58,6 +58,7 @@ All notable changes to the Wazuh app project will be documented in this file.
- Fixed Wazuh main menu and breadcrumb render issues [#3347](https://github.com/wazuh/wazuh-kibana-app/pull/3347)
- Fixed generation of huge logs from backend errors [#3397](https://github.com/wazuh/wazuh-kibana-app/pull/3397)
- Fixed vulnerabilities flyout not showing alerts if the vulnerability had a field missing [#3593](https://github.com/wazuh/wazuh-kibana-app/pull/3593)
+- Fixed index pattern selector not showing whithout refreshing when new index patterns are created [#3598](https://github.com/wazuh/wazuh-kibana-app/pull/3598)
## Wazuh v4.2.0 - Kibana 7.10.2 , 7.11.2 - Revision 4201
diff --git a/public/components/health-check/services/check-index-pattern/check-index-pattern-object.service.ts b/public/components/health-check/services/check-index-pattern/check-index-pattern-object.service.ts
index df0bedfc2a..1dd9e117e7 100644
--- a/public/components/health-check/services/check-index-pattern/check-index-pattern-object.service.ts
+++ b/public/components/health-check/services/check-index-pattern/check-index-pattern-object.service.ts
@@ -15,46 +15,54 @@ import { AppState, SavedObject } from '../../../../react-services';
import { getDataPlugin } from '../../../../kibana-services';
import { HEALTH_CHECK } from '../../../../../common/constants';
import { CheckLogger } from '../../types/check_logger';
+import { PatternHandler } from '../../../../react-services/pattern-handler';
-export const checkIndexPatternObjectService = async (appConfig, checkLogger: CheckLogger) => {
+export const checkIndexPatternObjectService = async (appConfig, checkLogger: CheckLogger) => {
const patternId: string = AppState.getCurrentPattern();
const defaultPatternId: string = appConfig.data['pattern'];
const shouldCreateIndex: boolean = appConfig.data['checks.pattern'];
checkLogger.info(`Index pattern id in cookie: ${patternId ? `yes [${patternId}]` : 'no'}`);
-
const defaultIndexPatterns: string[] = [
defaultPatternId,
- ...(patternId && patternId !== defaultPatternId ? [patternId] : [])
+ ...(patternId && patternId !== defaultPatternId ? [patternId] : []),
];
checkLogger.info(`Getting list of valid index patterns...`);
- let listValidIndexPatterns = await SavedObject.getListOfWazuhValidIndexPatterns(defaultIndexPatterns, HEALTH_CHECK);
+ let listValidIndexPatterns = await PatternHandler.getPatternList(HEALTH_CHECK);
checkLogger.info(`Valid index patterns found: ${listValidIndexPatterns.length || 0}`);
- const indexPatternDefaultFound = listValidIndexPatterns.find((indexPattern) => indexPattern.title === defaultPatternId);
- checkLogger.info(`Found default index pattern with title [${defaultPatternId}]: ${indexPatternDefaultFound ? 'yes' : 'no'}`);
+ const indexPatternDefaultFound = listValidIndexPatterns.find(
+ (indexPattern) => indexPattern.title === defaultPatternId
+ );
+ checkLogger.info(
+ `Found default index pattern with title [${defaultPatternId}]: ${
+ indexPatternDefaultFound ? 'yes' : 'no'
+ }`
+ );
if (!indexPatternDefaultFound && defaultPatternId) {
// if no valid index patterns are found we try to create the wazuh-alerts-*
try {
checkLogger.info(`Checking if index pattern [${defaultPatternId}] exists...`);
const existDefaultIndexPattern = await SavedObject.getExistingIndexPattern(defaultPatternId);
- checkLogger.info(`Index pattern id [${defaultPatternId}] exists: ${existDefaultIndexPattern ? 'yes' : 'no'}`);
+ checkLogger.info(
+ `Index pattern id [${defaultPatternId}] exists: ${existDefaultIndexPattern ? 'yes' : 'no'}`
+ );
if (existDefaultIndexPattern) {
checkLogger.info(`Refreshing index pattern fields [${defaultPatternId}]...`);
await SavedObject.refreshIndexPattern(defaultPatternId);
checkLogger.action(`Refreshed index pattern fields [${defaultPatternId}]`);
- } else if(shouldCreateIndex) {
+ } else if (shouldCreateIndex) {
checkLogger.info(`Creating index pattern [${defaultPatternId}]...`);
await SavedObject.createWazuhIndexPattern(defaultPatternId);
checkLogger.action(`Created index pattern [${defaultPatternId}]`);
- }else{
+ } else {
// show error
checkLogger.error(`Default index pattern not found`);
}
checkLogger.info(`Getting list of valid index patterns [${patternId}]...`);
- listValidIndexPatterns = await SavedObject.getListOfWazuhValidIndexPatterns(defaultIndexPatterns, HEALTH_CHECK);
+ listValidIndexPatterns = await PatternHandler.getPatternList(HEALTH_CHECK);
checkLogger.info(`Valid index patterns found: ${listValidIndexPatterns.length || 0}`);
- if(!AppState.getCurrentPattern()){
+ if (!AppState.getCurrentPattern()) {
AppState.setCurrentPattern(defaultPatternId);
checkLogger.info(`Index pattern set in cookie: [${defaultPatternId}]`);
}
@@ -67,30 +75,43 @@ export const checkIndexPatternObjectService = async (appConfig, checkLogger: Ch
}
if (AppState.getCurrentPattern() && listValidIndexPatterns.length) {
- const indexPatternToSelect = listValidIndexPatterns.find(item => item.id === AppState.getCurrentPattern());
- if (!indexPatternToSelect){
+ const indexPatternToSelect = listValidIndexPatterns.find(
+ (item) => item.id === AppState.getCurrentPattern()
+ );
+ if (!indexPatternToSelect) {
AppState.setCurrentPattern(indexPatternToSelect.id);
checkLogger.action(`Set index pattern id in cookie: [${indexPatternToSelect.id}]`);
}
}
-
- checkLogger.info(`Checking the app default pattern exists: id [${defaultPatternId}]...`);
+
+ checkLogger.info(`Checking the app default pattern exists: id [${defaultPatternId}]...`);
const existsDefaultPattern = await SavedObject.existsIndexPattern(defaultPatternId);
- checkLogger.info(`Default pattern with id [${defaultPatternId}] exists: ${existsDefaultPattern.status ? 'yes' : 'no'}`);
-
- existsDefaultPattern.status
- && getDataPlugin().indexPatterns.setDefault(defaultPatternId, true)
- && checkLogger.action(`Default pattern id [${defaultPatternId}] set as default index pattern`);
+ checkLogger.info(
+ `Default pattern with id [${defaultPatternId}] exists: ${
+ existsDefaultPattern.status ? 'yes' : 'no'
+ }`
+ );
+
+ existsDefaultPattern.status &&
+ getDataPlugin().indexPatterns.setDefault(defaultPatternId, true) &&
+ checkLogger.action(`Default pattern id [${defaultPatternId}] set as default index pattern`);
patternId && checkLogger.info(`Checking the index pattern id [${patternId}] exists...`);
- const patternData = patternId ? (await SavedObject.existsIndexPattern(patternId)) || {} : {} ;
- patternId && checkLogger.info(`Index pattern id exists [${patternId}]: ${patternData.status ? 'yes': 'no'}`);
+ const patternData = patternId ? (await SavedObject.existsIndexPattern(patternId)) || {} : {};
+ patternId &&
+ checkLogger.info(
+ `Index pattern id exists [${patternId}]: ${patternData.status ? 'yes' : 'no'}`
+ );
if (!patternData.status) {
if (listValidIndexPatterns.length) {
- const indexPatternDefaultFound = listValidIndexPatterns.find((indexPattern) => indexPattern.title === defaultPatternId);
- checkLogger.info(`Index pattern id exists [${defaultPatternId}]: ${indexPatternDefaultFound ? 'yes': 'no'}`);
- if(indexPatternDefaultFound){
+ const indexPatternDefaultFound = listValidIndexPatterns.find(
+ (indexPattern) => indexPattern.title === defaultPatternId
+ );
+ checkLogger.info(
+ `Index pattern id exists [${defaultPatternId}]: ${indexPatternDefaultFound ? 'yes' : 'no'}`
+ );
+ if (indexPatternDefaultFound) {
AppState.setCurrentPattern(indexPatternDefaultFound.id);
checkLogger.action(`Index pattern set in cookie: [${indexPatternDefaultFound.id}]`);
}
diff --git a/public/components/wz-menu/wz-menu.js b/public/components/wz-menu/wz-menu.js
index 53bfb51a71..11fc5d2bfa 100644
--- a/public/components/wz-menu/wz-menu.js
+++ b/public/components/wz-menu/wz-menu.js
@@ -24,14 +24,17 @@ import {
EuiLoadingSpinner,
EuiFormRow,
EuiSelect,
- EuiSpacer
+ EuiSpacer,
} from '@elastic/eui';
import { AppState } from '../../react-services/app-state';
import { PatternHandler } from '../../react-services/pattern-handler';
import { WazuhConfig } from '../../react-services/wazuh-config';
import { connect } from 'react-redux';
import WzReduxProvider from '../../redux/wz-redux-provider';
-import { updateCurrentAgentData, showExploreAgentModalGlobal } from '../../redux/actions/appStateActions';
+import {
+ updateCurrentAgentData,
+ showExploreAgentModalGlobal,
+} from '../../redux/actions/appStateActions';
import store from '../../redux/store';
import Management from './wz-menu-management';
import MenuSettings from './wz-menu-settings';
@@ -47,349 +50,331 @@ import WzTextWithTooltipIfTruncated from '../../components/common/wz-text-with-t
import { getDataPlugin } from '../../kibana-services';
import { withWindowSize } from '../../components/common/hocs/withWindowSize';
-
const sections = {
- 'overview': 'overview',
- 'manager': 'manager',
+ overview: 'overview',
+ manager: 'manager',
'agents-preview': 'agents-preview',
- 'agents': 'agents-preview',
- 'settings': 'settings',
+ agents: 'agents-preview',
+ settings: 'settings',
'wazuh-dev': 'wazuh-dev',
'health-check': 'health-check',
- 'security': 'security'
+ security: 'security',
};
-export const WzMenu = withWindowSize(class WzMenu extends Component {
- constructor(props) {
- super(props);
- this.state = {
- showMenu: false,
- menuOpened: false,
- currentMenuTab: '',
- currentAPI: '',
- APIlist: [],
- showSelector: false,
- theresPattern: false,
- currentPattern: '',
- patternList: [],
- currentSelectedPattern: '',
- isManagementPopoverOpen: false,
- isOverviewPopoverOpen: false
- };
- this.store = store;
- this.genericReq = GenericRequest;
- this.wazuhConfig = new WazuhConfig();
- this.indexPatterns = getDataPlugin().indexPatterns;
- this.isLoading = false;
- }
+export const WzMenu = withWindowSize(
+ class WzMenu extends Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ showMenu: false,
+ menuOpened: false,
+ currentMenuTab: '',
+ currentAPI: '',
+ APIlist: [],
+ showSelector: false,
+ theresPattern: false,
+ currentPattern: '',
+ currentSelectedPattern: '',
+ isManagementPopoverOpen: false,
+ isOverviewPopoverOpen: false,
+ };
+ this.patternList = this.props.state.indexPatterns;
+ this.wazuhConfig = new WazuhConfig();
+ this.indexPatterns = getDataPlugin().indexPatterns;
+ this.isLoading = false;
+ }
- async componentDidMount() {
- const $injector = getAngularModule().$injector;
- this.router = $injector.get('$route');
- try {
- const result = await this.genericReq.request('GET', '/hosts/apis', {});
- const APIlist = (result || {}).data || [];
- if (APIlist.length) {
- const { id: apiId } = JSON.parse(AppState.getCurrentAPI());
- const filteredApi = APIlist.filter(api => api.id === apiId);
- const selectedApi = filteredApi[0];
- if (selectedApi) {
- const apiData = await ApiCheck.checkStored(selectedApi.id);
- //update cluster info
- const cluster_info = (((apiData || {}).data || {}).data || {})
- .cluster_info;
- if (cluster_info) {
- AppState.setClusterInfo(cluster_info);
+ async componentDidMount() {
+ const $injector = getAngularModule().$injector;
+ this.router = $injector.get('$route');
+ try {
+ const result = await GenericRequest.request('GET', '/hosts/apis', {});
+ const APIlist = (result || {}).data || [];
+ if (APIlist.length) {
+ const { id: apiId } = JSON.parse(AppState.getCurrentAPI());
+ const selectedApi = APIlist.find((api) => api.id === apiId);
+ if (selectedApi) {
+ const apiData = await ApiCheck.checkStored(selectedApi.id);
+ //update cluster info
+ const cluster_info = (((apiData || {}).data || {}).data || {}).cluster_info;
+ if (cluster_info) {
+ AppState.setClusterInfo(cluster_info);
+ }
}
}
- }
- } catch (err) { }
-
- }
+ } catch (err) {}
+ }
- showToast = (color, title, text, time) => {
- getToasts().add({
- color: color,
- title: title,
- text: text,
- toastLifeTimeMs: time
- });
- };
+ showToast = (color, title, text, time) => {
+ getToasts().add({
+ color: color,
+ title: title,
+ text: text,
+ toastLifeTimeMs: time,
+ });
+ };
- getCurrentTab() {
- const currentWindowLocation = window.location.hash;
- let currentTab = '';
- Object.keys(sections).some((section) => {
- if (currentWindowLocation.match(`#/${section}`)) {
- currentTab = sections[section];
- return true;
- }
- });
- return currentTab;
- }
+ getCurrentTab() {
+ const currentWindowLocation = window.location.hash;
+ let currentTab = '';
+ Object.keys(sections).some((section) => {
+ if (currentWindowLocation.match(`#/${section}`)) {
+ currentTab = sections[section];
+ return true;
+ }
+ });
+ return currentTab;
+ }
- loadApiList = async () => {
- const result = await this.genericReq.request('GET', '/hosts/apis', {});
- const APIlist = (result || {}).data || [];
- if (APIlist.length) this.setState({ APIlist });
- };
+ loadApiList = async () => {
+ const result = await GenericRequest.request('GET', '/hosts/apis', {});
+ const APIlist = (result || {}).data || [];
+ if (APIlist.length) this.setState({ APIlist });
+ };
- loadIndexPatternsList = async () => {
- try {
- const list = await PatternHandler.getPatternList('api');
- if (!list) return;
+ loadIndexPatternsList = async () => {
+ try {
+ const list = await PatternHandler.getPatternList('api');
+ if (!list) return;
+
+ // Abort if we have disabled the pattern selector
+ if (!AppState.getPatternSelector()) return;
+
+ let filtered = false;
+ // If there is no current pattern, fetch it
+ if (!AppState.getCurrentPattern()) {
+ AppState.setCurrentPattern(list[0].id);
+ } else {
+ // Check if the current pattern cookie is valid
+ filtered = list.find((item) => item.id.includes(AppState.getCurrentPattern()));
+ if (!filtered) AppState.setCurrentPattern(list[0].id);
+ }
- // Abort if we have disabled the pattern selector
- if (!AppState.getPatternSelector()) return;
+ const data = filtered
+ ? filtered
+ : await this.indexPatterns.get(AppState.getCurrentPattern());
+ this.setState({ theresPattern: true, currentPattern: data.title });
- let filtered = false;
- // If there is no current pattern, fetch it
- if (!AppState.getCurrentPattern()) {
- AppState.setCurrentPattern(list[0].id);
- } else {
- // Check if the current pattern cookie is valid
- filtered = list.find(item =>
- item.id.includes(AppState.getCurrentPattern())
- );
- if (!filtered) AppState.setCurrentPattern(list[0].id);
+ // Getting the list of index patterns
+ if (list) {
+ this.setState({
+ currentSelectedPattern: AppState.getCurrentPattern(),
+ });
+ }
+ } catch (error) {
+ this.showToast('danger', 'Error', error, 4000);
}
+ };
- const data = filtered
- ? filtered
- : await this.indexPatterns.get(AppState.getCurrentPattern());
- this.setState({ theresPattern: true, currentPattern: data.title });
-
- // Getting the list of index patterns
- if (list) {
- this.setState({
- patternList: list,
- currentSelectedPattern: AppState.getCurrentPattern()
- });
+ async componentDidUpdate(prevProps) {
+ this.patternList = this.props.state.indexPatterns;
+ if (this.state.APIlist && !this.state.APIlist.length) {
+ this.loadApiList();
}
- } catch (error) {
- this.showToast('danger', 'Error', error, 4000);
- }
- }
-
-
- async componentDidUpdate(prevProps) {
+ const { id: apiId } = JSON.parse(AppState.getCurrentAPI());
+ const { currentAPI } = this.state;
+ const currentTab = this.getCurrentTab();
- if (this.state.APIlist && !this.state.APIlist.length) {
- this.loadApiList();
- }
- const { id: apiId } = JSON.parse(AppState.getCurrentAPI());
- const { currentAPI } = this.state;
- const currentTab = this.getCurrentTab();
-
- if (currentTab !== this.state.currentMenuTab) {
- this.setState({ currentMenuTab: currentTab });
- }
+ if (currentTab !== this.state.currentMenuTab) {
+ this.setState({ currentMenuTab: currentTab });
+ }
- if(this.props.windowSize){
- this.showSelectorsInPopover = this.props.windowSize.width < 1100;
- }
+ if (this.props.windowSize) {
+ this.showSelectorsInPopover = this.props.windowSize.width < 1100;
+ }
- if (
- prevProps.state.showMenu !== this.props.state.showMenu ||
- (this.props.state.showMenu === true && this.state.showMenu === false)
- ) {
- this.load();
- }
- if ((!currentAPI && apiId) || apiId !== currentAPI) {
- this.setState({ currentAPI: apiId });
- } else {
if (
- currentAPI &&
- this.props.state.currentAPI &&
- currentAPI !== this.props.state.currentAPI
+ prevProps.state.showMenu !== this.props.state.showMenu ||
+ (this.props.state.showMenu === true && this.state.showMenu === false) ||
+ this.props.state.indexPatterns !== prevProps.state.indexPatterns
) {
- this.setState({ currentAPI: this.props.state.currentAPI });
+ this.load();
+ }
+ if ((!currentAPI && apiId) || apiId !== currentAPI) {
+ this.setState({ currentAPI: apiId });
+ } else {
+ if (
+ currentAPI &&
+ this.props.state.currentAPI &&
+ currentAPI !== this.props.state.currentAPI
+ ) {
+ this.setState({ currentAPI: this.props.state.currentAPI });
+ }
}
}
- }
-
- async load() {
- try {
- this.setState({
- showMenu: true,
- isOverviewPopoverOpen: false,
- isManagementPopoverOpen: false,
- isSelectorsPopoverOpen: false
- });
+ async load() {
+ try {
+ this.setState({
+ showMenu: true,
+ isOverviewPopoverOpen: false,
+ isManagementPopoverOpen: false,
+ isSelectorsPopoverOpen: false,
+ });
- const currentTab = this.getCurrentTab();
- if (currentTab !== this.state.currentMenuTab) {
- this.setState({ currentMenuTab: currentTab, hover: currentTab });
- }
- const list = await PatternHandler.getPatternList('api');
- if (!list || (list && !list.length)) return;
+ const currentTab = this.getCurrentTab();
+ if (currentTab !== this.state.currentMenuTab) {
+ this.setState({ currentMenuTab: currentTab, hover: currentTab });
+ }
+ const list = await PatternHandler.getPatternList('api');
+ if (!list || (list && !list.length)) return;
+
+ // Abort if we have disabled the pattern selector
+ if (!AppState.getPatternSelector()) return;
+
+ let filtered = false;
+ // If there is no current pattern, fetch it
+ if (!AppState.getCurrentPattern()) {
+ AppState.setCurrentPattern(list[0].id);
+ } else {
+ // Check if the current pattern cookie is valid
+ filtered = list.filter((item) => item.id.includes(AppState.getCurrentPattern()));
+ if (!filtered.length) AppState.setCurrentPattern(list[0].id);
+ }
- // Abort if we have disabled the pattern selector
- if (!AppState.getPatternSelector()) return;
+ const data = filtered
+ ? filtered
+ : await this.indexPatterns.get(AppState.getCurrentPattern());
+ this.setState({ theresPattern: true, currentPattern: data.title });
- let filtered = false;
- // If there is no current pattern, fetch it
- if (!AppState.getCurrentPattern()) {
- AppState.setCurrentPattern(list[0].id);
- } else {
- // Check if the current pattern cookie is valid
- filtered = list.filter(item =>
- item.id.includes(AppState.getCurrentPattern())
- );
- if (!filtered.length) AppState.setCurrentPattern(list[0].id);
+ // Getting the list of index patterns
+ if (list) {
+ this.setState({
+ currentSelectedPattern: AppState.getCurrentPattern(),
+ });
+ }
+ } catch (error) {
+ this.showToast('danger', 'Error', error.message || error, 4000);
}
+ this.isLoading = false;
+ }
- const data = filtered
- ? filtered
- : await this.indexPatterns.get(AppState.getCurrentPattern());
- this.setState({ theresPattern: true, currentPattern: data.title });
+ changePattern = async (event) => {
+ try {
+ const newPattern = event.target;
+ if (!AppState.getPatternSelector()) return;
+ await PatternHandler.changePattern(newPattern.value);
+ this.setState({ currentSelectedPattern: newPattern.value });
+ if (this.state.currentMenuTab !== 'wazuh-dev') {
+ this.router.reload();
+ }
- // Getting the list of index patterns
- if (list) {
- this.setState({
- patternList: list,
- currentSelectedPattern: AppState.getCurrentPattern()
- });
+ if (newPattern?.id === 'selectIndexPatternBar') {
+ this.updatePatternAndApi();
+ } else {
+ this.switchMenuOpened();
+ }
+ } catch (error) {
+ this.showToast('danger', 'Error', error, 4000);
}
- } catch (error) {
- this.showToast('danger', 'Error', error.message || error, 4000);
- }
- this.isLoading = false;
- }
+ };
- changePattern = async (event) => {
- try {
- const newPattern = event.target;
- if (!AppState.getPatternSelector()) return;
- await PatternHandler.changePattern(newPattern.value);
- this.setState({ currentSelectedPattern: newPattern.value });
- if (this.state.currentMenuTab !== 'wazuh-dev') {
- this.router.reload();
- }
+ updatePatternAndApi = () => {
+ this.setState({ menuOpened: false, hover: this.state.currentMenuTab }, async () => {
+ await this.loadApiList();
+ await this.loadIndexPatternsList();
+ });
+ };
- if (newPattern?.id === 'selectIndexPatternBar') {
- this.updatePatternAndApi();
- } else {
- this.switchMenuOpened();
+ /**
+ * @param {String} id
+ * @param {Object} clusterInfo
+ * Updates the wazuh registry of an specific api id
+ */
+ updateClusterInfoInRegistry = async (id, clusterInfo) => {
+ try {
+ const url = `/hosts/update-hostname/${id}`;
+ await GenericRequest.request('PUT', url, {
+ cluster_info: clusterInfo,
+ });
+ } catch (error) {
+ return Promise.reject(error);
}
- } catch (error) {
- this.showToast('danger', 'Error', error, 4000);
- }
- };
-
- updatePatternAndApi = () => {
- this.setState({ menuOpened: false, hover: this.state.currentMenuTab }, async () => {
- await this.loadApiList();
- await this.loadIndexPatternsList();
- });
- }
+ };
- /**
- * @param {String} id
- * @param {Object} clusterInfo
- * Updates the wazuh registry of an specific api id
- */
- updateClusterInfoInRegistry = async (id, clusterInfo) => {
- try {
- const url = `/hosts/update-hostname/${id}`;
- await this.genericReq.request('PUT', url, {
- cluster_info: clusterInfo
- });
- } catch (error) {
- return Promise.reject(error);
- }
- };
+ changeAPI = async (event) => {
+ try {
+ const apiId = event.target[event.target.selectedIndex];
+ const apiEntry = this.state.APIlist.filter((item) => {
+ return item.id === apiId.value;
+ });
+ const response = await ApiCheck.checkApi(apiEntry[0]);
+ const clusterInfo = response.data || {};
+ const apiData = this.state.APIlist.filter((item) => {
+ return item.id === apiId.value;
+ });
- changeAPI = async event => {
- try {
- const apiId = event.target[event.target.selectedIndex];
- const apiEntry = this.state.APIlist.filter(item => {
- return item.id === apiId.value;
- });
- const response = await ApiCheck.checkApi(apiEntry[0]);
- const clusterInfo = response.data || {};
- const apiData = this.state.APIlist.filter(item => {
- return item.id === apiId.value;
- });
+ this.updateClusterInfoInRegistry(apiId.value, clusterInfo);
+ apiData[0].cluster_info = clusterInfo;
- this.updateClusterInfoInRegistry(apiId.value, clusterInfo);
- apiData[0].cluster_info = clusterInfo;
+ AppState.setClusterInfo(apiData[0].cluster_info);
+ AppState.setCurrentAPI(JSON.stringify({ name: apiData[0].manager, id: apiId.value }));
+ if (apiId?.id !== 'selectAPIBar') {
+ this.switchMenuOpened();
+ }
- AppState.setClusterInfo(apiData[0].cluster_info);
- AppState.setCurrentAPI(
- JSON.stringify({ name: apiData[0].manager, id: apiId.value })
- );
- if (apiId?.id !== 'selectAPIBar') {
- this.switchMenuOpened();
+ if (this.state.currentMenuTab !== 'wazuh-dev') {
+ this.router.reload();
+ }
+ } catch (error) {
+ this.showToast('danger', 'Error', error, 4000);
}
+ };
- if (this.state.currentMenuTab !== 'wazuh-dev') {
- this.router.reload();
- }
- } catch (error) {
- this.showToast('danger', 'Error', error, 4000);
+ buildPatternSelector() {
+ return (
+
+ {
+ return { value: item.id, text: item.title };
+ })}
+ value={this.state.currentSelectedPattern}
+ onChange={this.changePattern}
+ aria-label="Index pattern selector"
+ />
+
+ );
}
- };
- buildPatternSelector() {
- return (
-
- {
- return { value: item.id, text: item.title }
- })
- }
- value={this.state.currentSelectedPattern}
- onChange={this.changePattern}
- aria-label="Index pattern selector"
- />
-
- );
- }
-
- buildApiSelector() {
- return (
-
- {
- return { value: item.id, text: item.id }
- })
- }
- value={this.state.currentAPI}
- onChange={this.changeAPI}
- aria-label="API selector"
- />
-
- );
- }
+ buildApiSelector() {
+ return (
+
+ {
+ return { value: item.id, text: item.id };
+ })}
+ value={this.state.currentAPI}
+ onChange={this.changeAPI}
+ aria-label="API selector"
+ />
+
+ );
+ }
- buildWazuhNotReadyYet() {
- const container = document.getElementsByClassName('wazuhNotReadyYet');
- return ReactDOM.createPortal(
-
-
-
-
-
- {typeof this.props.state.wazuhNotReadyYet === "string" && this.props.state.wazuhNotReadyYet.includes('Restarting') && (
-
-
- {' '}
- {' '}
-
+ buildWazuhNotReadyYet() {
+ const container = document.getElementsByClassName('wazuhNotReadyYet');
+ return ReactDOM.createPortal(
+
+
+
+
- )}
- {this.props.state.wazuhNotReadyYet ===
- 'Wazuh could not be recovered.' && (
+ {typeof this.props.state.wazuhNotReadyYet === 'string' &&
+ this.props.state.wazuhNotReadyYet.includes('Restarting') && (
+
+
+ {' '}
+ {' '}
+
+
+ )}
+ {this.props.state.wazuhNotReadyYet === 'Wazuh could not be recovered.' && (
)}
-
- ,
- container[0]
- );
- }
-
- setMenuItem(item) {
- this.setState({ currentMenuTab: item });
- }
-
- toolsPopoverToggle() {
- if (!this.state.isToolsPopoverOpen) {
- this.setState(() => {
- return {
- isToolsPopoverOpen: true,
- currentMenuTab: 'wazuh-dev',
- isOverviewPopoverOpen: false,
- isManagementPopoverOpen: false,
- isSecurityPopoverOpen: false,
- isSettingsPopoverOpen: false,
- isSelectorsPopoverOpen: false
- };
- });
+
+ ,
+ container[0]
+ );
}
- }
- settingsPopoverToggle() {
- if (!this.state.isSettingsPopoverOpen) {
- this.setState(() => {
- return {
- isSettingsPopoverOpen: true,
- currentMenuTab: 'settings',
- isOverviewPopoverOpen: false,
- isManagementPopoverOpen: false,
- isSecurityPopoverOpen: false,
- isToolsPopoverOpen: false,
- isSelectorsPopoverOpen: false
- };
- });
+ setMenuItem(item) {
+ this.setState({ currentMenuTab: item });
}
- }
- securityPopoverToggle() {
- if (!this.state.isSecurityPopoverOpen) {
- this.setState(() => {
- return {
- isSecurityPopoverOpen: true,
- currentMenuTab: 'security',
- isOverviewPopoverOpen: false,
- isManagementPopoverOpen: false,
- isSettingsPopoverOpen: false,
- isToolsPopoverOpen: false,
- isSelectorsPopoverOpen: false
- };
- });
+ toolsPopoverToggle() {
+ if (!this.state.isToolsPopoverOpen) {
+ this.setState(() => {
+ return {
+ isToolsPopoverOpen: true,
+ currentMenuTab: 'wazuh-dev',
+ isOverviewPopoverOpen: false,
+ isManagementPopoverOpen: false,
+ isSecurityPopoverOpen: false,
+ isSettingsPopoverOpen: false,
+ isSelectorsPopoverOpen: false,
+ };
+ });
+ }
}
- }
- managementPopoverToggle() {
- if (!this.state.isManagementPopoverOpen) {
- this.setState(() => {
- return {
- isManagementPopoverOpen: true,
- currentMenuTab: 'manager',
- isOverviewPopoverOpen: false,
- isSettingsPopoverOpen: false,
- isSecurityPopoverOpen: false,
- isToolsPopoverOpen: false,
- isSelectorsPopoverOpen: false
- };
- });
+ settingsPopoverToggle() {
+ if (!this.state.isSettingsPopoverOpen) {
+ this.setState(() => {
+ return {
+ isSettingsPopoverOpen: true,
+ currentMenuTab: 'settings',
+ isOverviewPopoverOpen: false,
+ isManagementPopoverOpen: false,
+ isSecurityPopoverOpen: false,
+ isToolsPopoverOpen: false,
+ isSelectorsPopoverOpen: false,
+ };
+ });
+ }
}
- }
- overviewPopoverToggle() {
- if (!this.state.isOverviewPopoverOpen) {
- this.setState(state => {
- return {
- isOverviewPopoverOpen: true,
- currentMenuTab: 'overview',
- isManagementPopoverOpen: false,
- isSettingsPopoverOpen: false,
- isSecurityPopoverOpen: false,
- isToolsPopoverOpen: false,
- isSelectorsPopoverOpen: false
- };
- });
+ securityPopoverToggle() {
+ if (!this.state.isSecurityPopoverOpen) {
+ this.setState(() => {
+ return {
+ isSecurityPopoverOpen: true,
+ currentMenuTab: 'security',
+ isOverviewPopoverOpen: false,
+ isManagementPopoverOpen: false,
+ isSettingsPopoverOpen: false,
+ isToolsPopoverOpen: false,
+ isSelectorsPopoverOpen: false,
+ };
+ });
+ }
}
- }
- onClickToolsButton() {
- this.setMenuItem('wazuh-dev');
- this.toolsPopoverToggle();
- }
+ managementPopoverToggle() {
+ if (!this.state.isManagementPopoverOpen) {
+ this.setState(() => {
+ return {
+ isManagementPopoverOpen: true,
+ currentMenuTab: 'manager',
+ isOverviewPopoverOpen: false,
+ isSettingsPopoverOpen: false,
+ isSecurityPopoverOpen: false,
+ isToolsPopoverOpen: false,
+ isSelectorsPopoverOpen: false,
+ };
+ });
+ }
+ }
- onClickSettingsButton() {
- this.setMenuItem('settings');
- this.settingsPopoverToggle();
- }
+ overviewPopoverToggle() {
+ if (!this.state.isOverviewPopoverOpen) {
+ this.setState((state) => {
+ return {
+ isOverviewPopoverOpen: true,
+ currentMenuTab: 'overview',
+ isManagementPopoverOpen: false,
+ isSettingsPopoverOpen: false,
+ isSecurityPopoverOpen: false,
+ isToolsPopoverOpen: false,
+ isSelectorsPopoverOpen: false,
+ };
+ });
+ }
+ }
- onClickSecurityButton() {
- this.setMenuItem('security');
- this.securityPopoverToggle();
- }
+ onClickToolsButton() {
+ this.setMenuItem('wazuh-dev');
+ this.toolsPopoverToggle();
+ }
- onClickManagementButton() {
- this.setMenuItem('manager');
- this.managementPopoverToggle();
- }
+ onClickSettingsButton() {
+ this.setMenuItem('settings');
+ this.settingsPopoverToggle();
+ }
- onClickOverviewButton() {
- this.setMenuItem('overview');
- this.overviewPopoverToggle();
- }
+ onClickSecurityButton() {
+ this.setMenuItem('security');
+ this.securityPopoverToggle();
+ }
- onClickAgentButton() {
- this.setState({ menuOpened: false });
- window.location.href = '#/agents-preview';
+ onClickManagementButton() {
+ this.setMenuItem('manager');
+ this.managementPopoverToggle();
+ }
- }
+ onClickOverviewButton() {
+ this.setMenuItem('overview');
+ this.overviewPopoverToggle();
+ }
- closeAllPopover() {
- this.setState({
- isOverviewPopoverOpen: false,
- isManagementPopoverOpen: false,
- isSettingsPopoverOpen: false,
- isToolsPopoverOpen: false,
- isSelectorsPopoverOpen: false
- });
- }
+ onClickAgentButton() {
+ this.setState({ menuOpened: false });
+ window.location.href = '#/agents-preview';
+ }
- isAnyPopoverOpen() {
- return (
- this.state.isOverviewPopoverOpen ||
- this.state.isManagementPopoverOpen ||
- this.state.isSettingsPopoverOpen ||
- this.state.isSecurityPopoverOpen ||
- this.state.isToolsPopoverOpen ||
- this.state.isSelectorsPopoverOpen
- );
- }
+ closeAllPopover() {
+ this.setState({
+ isOverviewPopoverOpen: false,
+ isManagementPopoverOpen: false,
+ isSettingsPopoverOpen: false,
+ isToolsPopoverOpen: false,
+ isSelectorsPopoverOpen: false,
+ });
+ }
- switchMenuOpened = () => {
- const kibanaMenuBlockedOrOpened = document.body.classList.contains('euiBody--collapsibleNavIsDocked') || document.body.classList.contains('euiBody--collapsibleNavIsOpen');
- if (!this.state.menuOpened && this.state.currentMenuTab === 'manager') {
- this.managementPopoverToggle();
- } else if (this.state.currentMenuTab === 'overview') {
- this.overviewPopoverToggle();
- } else if (this.state.currentMenuTab === 'wazuh-dev') {
- this.toolsPopoverToggle();
- } else if (this.state.currentMenuTab === 'settings') {
- this.settingsPopoverToggle();
- } else if (this.state.currentMenuTab === 'security') {
- this.securityPopoverToggle();
- } else {
- this.closeAllPopover()
+ isAnyPopoverOpen() {
+ return (
+ this.state.isOverviewPopoverOpen ||
+ this.state.isManagementPopoverOpen ||
+ this.state.isSettingsPopoverOpen ||
+ this.state.isSecurityPopoverOpen ||
+ this.state.isToolsPopoverOpen ||
+ this.state.isSelectorsPopoverOpen
+ );
}
- this.setState({ menuOpened: !this.state.menuOpened, kibanaMenuBlockedOrOpened, hover: this.state.currentMenuTab }, async () => {
- await this.loadApiList();
- await this.loadIndexPatternsList();
- });
- };
+ switchMenuOpened = () => {
+ const kibanaMenuBlockedOrOpened =
+ document.body.classList.contains('euiBody--collapsibleNavIsDocked') ||
+ document.body.classList.contains('euiBody--collapsibleNavIsOpen');
+ if (!this.state.menuOpened && this.state.currentMenuTab === 'manager') {
+ this.managementPopoverToggle();
+ } else if (this.state.currentMenuTab === 'overview') {
+ this.overviewPopoverToggle();
+ } else if (this.state.currentMenuTab === 'wazuh-dev') {
+ this.toolsPopoverToggle();
+ } else if (this.state.currentMenuTab === 'settings') {
+ this.settingsPopoverToggle();
+ } else if (this.state.currentMenuTab === 'security') {
+ this.securityPopoverToggle();
+ } else {
+ this.closeAllPopover();
+ }
- color = (status, hex = false) => {
- if (status.toLowerCase() === 'active') { return hex ? '#017D73' : 'success'; }
- else if (status.toLowerCase() === 'disconnected') { return hex ? '#BD271E' : 'danger'; }
- else if (status.toLowerCase() === 'never connected') { return hex ? '#98A2B3' : 'subdued'; }
- }
+ this.setState(
+ {
+ menuOpened: !this.state.menuOpened,
+ kibanaMenuBlockedOrOpened,
+ hover: this.state.currentMenuTab,
+ },
+ async () => {
+ await this.loadApiList();
+ await this.loadIndexPatternsList();
+ }
+ );
+ };
- formatAgentStatus = (status) => {
- if (status === 'active') {
- return "Active";
- }
- if (status === 'disconnected') {
- return "Disconnected";
- }
- if (status === 'never_connected') {
- return "Never connected";
- }
- }
+ color = (status, hex = false) => {
+ if (status.toLowerCase() === 'active') {
+ return hex ? '#017D73' : 'success';
+ } else if (status.toLowerCase() === 'disconnected') {
+ return hex ? '#BD271E' : 'danger';
+ } else if (status.toLowerCase() === 'never connected') {
+ return hex ? '#98A2B3' : 'subdued';
+ }
+ };
+
+ formatAgentStatus = (status) => {
+ if (status === 'active') {
+ return 'Active';
+ }
+ if (status === 'disconnected') {
+ return 'Disconnected';
+ }
+ if (status === 'never_connected') {
+ return 'Never connected';
+ }
+ };
- addHealthRender(agent) {
- // this was rendered with a EuiHealth, but EuiHealth has a div wrapper, and this section is rendered within a
tag.
tags aren't allowed within
tags.
- return (
-
-
+ addHealthRender(agent) {
+ // this was rendered with a EuiHealth, but EuiHealth has a div wrapper, and this section is rendered within a tag.
tags aren't allowed within
tags.
+ return (
+
+
+
+
+
+
+
+
-
-
-
+
+ {agent.name}
+
-
-
-
- {agent.name}
-
-
- )
- }
-
- removeSelectedAgent() {
- store.dispatch(updateCurrentAgentData({}));
- if (window.location.href.includes("/agents?")) {
- window.location.href = "#/agents-preview";
- this.router.reload();
- return;
+ );
}
- const { filterManager } = getDataPlugin().query;
- const currentAppliedFilters = filterManager.getFilters();
- const agentFilters = currentAppliedFilters.filter(x => {
- return x.meta.key === 'agent.id';
- });
- agentFilters.map(x => {
- filterManager.removeFilter(x);
- });
- }
- getBadgeColor(agentStatus) {
- if (agentStatus.toLowerCase() === 'active') { return 'secondary'; }
- else if (agentStatus.toLowerCase() === 'disconnected') { return '#BD271E'; }
- else if (agentStatus.toLowerCase() === 'never connected') { return 'default'; }
- }
-
- thereAreSelectors() {
- return ((AppState.getAPISelector() && this.state.currentAPI && this.state.APIlist && this.state.APIlist.length > 1)
- || (!this.state.currentAPI)
- || (AppState.getPatternSelector() && this.state.theresPattern && this.state.patternList && this.state.patternList.length > 1))
- }
+ removeSelectedAgent() {
+ store.dispatch(updateCurrentAgentData({}));
+ if (window.location.href.includes('/agents?')) {
+ window.location.href = '#/agents-preview';
+ this.router.reload();
+ return;
+ }
+ const { filterManager } = getDataPlugin().query;
+ const currentAppliedFilters = filterManager.getFilters();
+ const agentFilters = currentAppliedFilters.filter((x) => {
+ return x.meta.key === 'agent.id';
+ });
+ agentFilters.map((x) => {
+ filterManager.removeFilter(x);
+ });
+ }
- getApiSelectorComponent() {
- let style = { maxWidth: 100 };
- if (this.showSelectorsInPopover){
- style = { width: '100%', minWidth: 200 };
+ getBadgeColor(agentStatus) {
+ if (agentStatus.toLowerCase() === 'active') {
+ return 'secondary';
+ } else if (agentStatus.toLowerCase() === 'disconnected') {
+ return '#BD271E';
+ } else if (agentStatus.toLowerCase() === 'never connected') {
+ return 'default';
+ }
}
- return (
- <>
-
- API
-
-
-
- {
- return { value: item.id, text: item.id }
- })
- }
- value={this.state.currentAPI}
- onChange={this.changeAPI}
- aria-label="API selector"
- />
-
-
- >
- )
- }
+ thereAreSelectors() {
+ return (
+ (AppState.getAPISelector() &&
+ this.state.currentAPI &&
+ this.state.APIlist &&
+ this.state.APIlist.length > 1) ||
+ !this.state.currentAPI ||
+ (AppState.getPatternSelector() &&
+ this.state.theresPattern &&
+ this.patternList &&
+ this.patternList.length > 1)
+ );
+ }
- getIndexPatternSelectorComponent(){
+ getApiSelectorComponent() {
+ let style = { maxWidth: 100 };
+ if (this.showSelectorsInPopover) {
+ style = { width: '100%', minWidth: 200 };
+ }
- let style = { maxWidth: 200, maxHeight: 50 };
- if (this.showSelectorsInPopover){
- style = { width: '100%', maxHeight: 50, minWidth: 200 };
+ return (
+ <>
+
+ API
+
+
+
+ {
+ return { value: item.id, text: item.id };
+ })}
+ value={this.state.currentAPI}
+ onChange={this.changeAPI}
+ aria-label="API selector"
+ />
+
+
+ >
+ );
}
- return(
- <>
-
- Index pattern
-
-
-
-
- {
- return { value: item.id, text: item.title }
- })
- }
- value={this.state.currentSelectedPattern}
- onChange={this.changePattern}
- aria-label="Index pattern selector"
- />
-
-
+ getIndexPatternSelectorComponent() {
+ let style = { maxWidth: 200, maxHeight: 50 };
+ if (this.showSelectorsInPopover) {
+ style = { width: '100%', maxHeight: 50, minWidth: 200 };
+ }
- >
- )
- }
+ return (
+ <>
+
+ Index pattern
+
- switchSelectorsPopOver(){
- this.setState({ isSelectorsPopoverOpen: !this.state.isSelectorsPopoverOpen })
- }
+
+
+ {
+ return { value: item.id, text: item.title };
+ })}
+ value={this.state.currentSelectedPattern}
+ onChange={this.changePattern}
+ aria-label="Index pattern selector"
+ />
+
+
+ >
+ );
+ }
- render() {
- const currentAgent = store.getState().appStateReducers.currentAgentData;
- const thereAreSelectors = this.thereAreSelectors();
-
- const menu = (
-
-
-
-
{ this.setState({ hover: "overview" }) }}
- className={
- 'wz-menu-button ' +
- (this.state.currentMenuTab === "overview" && !this.isAnyPopoverOpen() || (this.state.isOverviewPopoverOpen)
- ? 'wz-menu-active'
- : '')
- }
- color="text"
- onClick={this.onClickOverviewButton.bind(this)}
- >
-
- Modules
-
-
- {/*this.state.hover === 'overview' */this.state.isOverviewPopoverOpen && (
-
- )}
-
-
-
{ this.setState({ hover: "manager" }) }}
- className={
- 'wz-menu-button ' +
- (this.state.currentMenuTab === "manager" && !this.isAnyPopoverOpen() || (this.state.isManagementPopoverOpen)
- ? 'wz-menu-active'
- : '')
- }
- color="text"
- onClick={this.onClickManagementButton.bind(this)}
- >
-
- Management
-
- {/*this.state.hover === 'manager' */ this.state.isManagementPopoverOpen && (
-
- )}
-
-
-
{
- this.setMenuItem('agents-preview');
- this.setState({ menuOpened: false });
- }}
- >
-
- Agents
-
-
-
-
- Tools
-
- {this.state.isToolsPopoverOpen && (
-
- )}
-
-
-
-
-
- Security
-
- {this.state.isSecurityPopoverOpen && (
-
- )}
-
-
-
- Settings
-
- {this.state.isSettingsPopoverOpen && (
-
- )}
-
+ switchSelectorsPopOver() {
+ this.setState({ isSelectorsPopoverOpen: !this.state.isSelectorsPopoverOpen });
+ }
+
+ render() {
+ const currentAgent = store.getState().appStateReducers.currentAgentData;
+ const thereAreSelectors = this.thereAreSelectors();
+
+ const menu = (
+
+
+
+ {
+ this.setState({ hover: 'overview' });
+ }}
+ className={
+ 'wz-menu-button ' +
+ ((this.state.currentMenuTab === 'overview' && !this.isAnyPopoverOpen()) ||
+ this.state.isOverviewPopoverOpen
+ ? 'wz-menu-active'
+ : '')
+ }
+ color="text"
+ onClick={this.onClickOverviewButton.bind(this)}
+ >
+
+ Modules
+
+
+ {
+ /*this.state.hover === 'overview' */ this.state.isOverviewPopoverOpen && (
+
+ )
+ }
+
+
+ {
+ this.setState({ hover: 'manager' });
+ }}
+ className={
+ 'wz-menu-button ' +
+ ((this.state.currentMenuTab === 'manager' && !this.isAnyPopoverOpen()) ||
+ this.state.isManagementPopoverOpen
+ ? 'wz-menu-active'
+ : '')
+ }
+ color="text"
+ onClick={this.onClickManagementButton.bind(this)}
+ >
+
+ Management
+
+ {
+ /*this.state.hover === 'manager' */ this.state.isManagementPopoverOpen && (
+
+ )
+ }
+
+
+ {
+ this.setMenuItem('agents-preview');
+ this.setState({ menuOpened: false });
+ }}
+ >
+
+ Agents
+
+
+
+
+ Tools
+
+ {this.state.isToolsPopoverOpen && }
+
+
+
+
+
+ Security
+
+ {this.state.isSecurityPopoverOpen && }
+
+
+
+ Settings
+
+ {this.state.isSettingsPopoverOpen && }
+
+
-
-
- {/*this.state.hover === 'manager'*/ this.state.isManagementPopoverOpen && (
-
this.setState({ menuOpened: false })}
- >
- )}
+
+ {
+ /*this.state.hover === 'manager'*/ this.state.isManagementPopoverOpen && (
+ this.setState({ menuOpened: false })}>
+ )
+ }
- {/*this.state.hover === 'settings'*/ this.state.isSettingsPopoverOpen && (
- this.setState({ menuOpened: false })}
- >
- )}
+ {
+ /*this.state.hover === 'settings'*/ this.state.isSettingsPopoverOpen && (
+ this.setState({ menuOpened: false })}
+ >
+ )
+ }
- {/*this.state.hover === 'security'*/ this.state.isSecurityPopoverOpen && (
- this.setState({ menuOpened: false })}
- >
- )}
+ {
+ /*this.state.hover === 'security'*/ this.state.isSecurityPopoverOpen && (
+ this.setState({ menuOpened: false })}
+ >
+ )
+ }
- {this.state.isToolsPopoverOpen && (
- this.setState({ menuOpened: false })}
- >
- )}
+ {this.state.isToolsPopoverOpen && (
+ this.setState({ menuOpened: false })}
+ >
+ )}
- {/*this.state.hover === 'overview' */this.state.isOverviewPopoverOpen && currentAgent.id && (
-
- {/*
+ {
+ /*this.state.hover === 'overview' */ this.state.isOverviewPopoverOpen &&
+ currentAgent.id && (
+
+ {/*
{currentAgent.id}
*/}
-
- {this.addHealthRender(currentAgent)}
-
-
-
- { AppNavigate.navigateToModule(ev, 'agents', { "tab": "welcome", "agent": currentAgent.id }); this.router.reload(); this.setState({ menuOpened: false }) }}>
-
-
-
-
-
-
- { store.dispatch(showExploreAgentModalGlobal({})); this.setState({ menuOpened: false }) }}>
-
-
-
-
-
-
- { this.setState({ menuOpened: false }); this.removeSelectedAgent(); }}>
-
-
-
-
-
-
- )}
+
+ {this.addHealthRender(currentAgent)}
+
+
+
+ {
+ AppNavigate.navigateToModule(ev, 'agents', {
+ tab: 'welcome',
+ agent: currentAgent.id,
+ });
+ this.router.reload();
+ this.setState({ menuOpened: false });
+ }}
+ >
+
+
+
+
+
+
+ {
+ store.dispatch(showExploreAgentModalGlobal({}));
+ this.setState({ menuOpened: false });
+ }}
+ >
+
+
+
+
+
+
+ {
+ this.setState({ menuOpened: false });
+ this.removeSelectedAgent();
+ }}
+ >
+
+
+
+
+
+ )
+ }
- {/*this.state.hover === 'overview' */this.state.isOverviewPopoverOpen && (
- this.setState({ menuOpened: false })}
- >
- )}
+ {
+ /*this.state.hover === 'overview' */ this.state.isOverviewPopoverOpen && (
+ this.setState({ menuOpened: false })}>
+ )
+ }
+
-
- );
-
- const logotype_url = getHttp().basePath.prepend(`/plugins/wazuh/assets/${this.wazuhConfig.getConfig()['customization.logo.app']}`);
- const mainButton = (
-
this.switchMenuOpened()}>
- this.switchMenuOpened()}
>
-
-
-
-
- {this.state.menuOpened && (
-
- )}
- {!this.state.menuOpened && (
-
- )}
-
-
-
- );
-
-
- const openSelectorsButton = (
-
- this.switchSelectorsPopOver()}
- size="s"
- aria-label="Open selectors">
-
- )
-
-
- const container = document.getElementsByClassName('euiBreadcrumbs');
- return ReactDOM.createPortal(
-
- {this.state.showMenu && (
-
-
-
- this.setState({ menuOpened: false })}
- anchorPosition="downLeft"
- panelPaddingSize='none'
- hasArrow={false}
- >
- {menu}
-
+
+
+
-
-
-
+
+ {this.state.menuOpened && }
+ {!this.state.menuOpened && }
+
+
+ );
-
- <>>
-
+ const openSelectorsButton = (
+
+ this.switchSelectorsPopOver()}
+ size="s"
+ aria-label="Open selectors"
+ >
+
+ );
- { !this.showSelectorsInPopover && this.state.patternList.length > 1 &&
- this.getIndexPatternSelectorComponent()
- }
+ const container = document.getElementsByClassName('euiBreadcrumbs');
+ return ReactDOM.createPortal(
+
+ {this.state.showMenu && (
+
+
+ this.setState({ menuOpened: false })}
+ anchorPosition="downLeft"
+ panelPaddingSize="none"
+ hasArrow={false}
+ >
+ {menu}
+
+
- { !this.showSelectorsInPopover && this.state.APIlist.length > 1 &&
- this.getApiSelectorComponent()
- }
+
+
+
- { this.showSelectorsInPopover &&
- (this.state.patternList.length > 1 || this.state.APIlist.length > 1) &&
- <>
-
-
-
+ <>>
+
+
+ {!this.showSelectorsInPopover &&
+ this.patternList.length > 1 &&
+ this.getIndexPatternSelectorComponent()}
+
+ {!this.showSelectorsInPopover &&
+ this.state.APIlist.length > 1 &&
+ this.getApiSelectorComponent()}
+
+ {this.showSelectorsInPopover &&
+ (this.patternList.length > 1 || this.state.APIlist.length > 1) && (
+ <>
+
+ this.switchSelectorsPopOver()}>
- { this.state.patternList.length > 1 &&
-
- {this.getIndexPatternSelectorComponent()}
-
- }
- { this.state.APIlist.length > 1 &&
-
- {this.getApiSelectorComponent()}
-
- }
-
-
-
- >
-
- }
- {this.props.state.wazuhNotReadyYet && this.buildWazuhNotReadyYet()}
-
-
- )}
-
- , container[0]);
+ closePopover={() => this.switchSelectorsPopOver()}
+ >
+ {this.patternList.length > 1 && (
+
+ {this.getIndexPatternSelectorComponent()}
+
+ )}
+ {this.state.APIlist.length > 1 && (
+
+ {this.getApiSelectorComponent()}
+
+ )}
+
+
+ >
+ )}
+ {this.props.state.wazuhNotReadyYet && this.buildWazuhNotReadyYet()}
+
+ )}
+ ,
+ container[0]
+ );
+ }
}
-});
+);
-const mapStateToProps = state => {
+const mapStateToProps = (state) => {
return {
- state: state.appStateReducers
+ state: state.appStateReducers,
};
};
-export default connect(
- mapStateToProps,
- null
-)(WzMenu);
+export default connect(mapStateToProps, null)(WzMenu);
diff --git a/public/react-services/pattern-handler.js b/public/react-services/pattern-handler.js
index 99fde65c97..bf0b39dbad 100644
--- a/public/react-services/pattern-handler.js
+++ b/public/react-services/pattern-handler.js
@@ -14,6 +14,9 @@ import { SavedObject } from './saved-objects';
import { getDataPlugin, getToasts, getHttp } from '../kibana-services';
import { WazuhConfig } from '../react-services/wazuh-config';
import { HEALTH_CHECK } from '../../common/constants';
+import store from '../redux/store';
+import { updateIndexPatterns } from '../redux/actions/appStateActions';
+import _ from 'lodash';
export class PatternHandler {
/**
@@ -29,6 +32,9 @@ export class PatternHandler {
if (selectedPattern && selectedPattern !== pattern) defaultPatterns.push(selectedPattern);
let patternList = await SavedObject.getListOfWazuhValidIndexPatterns(defaultPatterns, origin);
+ if (!_.isEqual(patternList, store.getState().appStateReducers.indexPatterns)) {
+ store.dispatch(updateIndexPatterns(patternList));
+ }
return patternList;
} catch (error) {
console.error('getPatternList', error);
diff --git a/public/redux/actions/appStateActions.js b/public/redux/actions/appStateActions.js
index c0de02f987..1a5314f7ee 100644
--- a/public/redux/actions/appStateActions.js
+++ b/public/redux/actions/appStateActions.js
@@ -14,21 +14,31 @@
* Updates CurrentAPI in the appState store
* @param currentAPI
*/
-export const updateCurrentApi = currentAPI => {
+export const updateCurrentApi = (currentAPI) => {
return {
type: 'UPDATE_CURRENT_API',
- currentAPI: currentAPI
+ currentAPI: currentAPI,
};
};
+/**
+ * Updates IndexPatterns in the appState store
+ * @param indexPatterns
+ */
+export const updateIndexPatterns = (indexPatterns) => {
+ return {
+ type: 'UPDATE_INDEX_PATTERNS',
+ indexPatterns,
+ };
+};
/**
* Updates ShowMenu in the appState store
* @param showMenu
*/
-export const updateShowMenu = showMenu => {
+export const updateShowMenu = (showMenu) => {
return {
type: 'SHOW_MENU',
- showMenu: showMenu
+ showMenu: showMenu,
};
};
@@ -36,10 +46,10 @@ export const updateShowMenu = showMenu => {
* Updates WazuhNotReadyYet in the appState store
* @param wazuhNotReadyYet
*/
-export const updateWazuhNotReadyYet = wazuhNotReadyYet => {
+export const updateWazuhNotReadyYet = (wazuhNotReadyYet) => {
return {
type: 'UPDATE_WAZUH_NOT_READY_YET',
- wazuhNotReadyYet: wazuhNotReadyYet
+ wazuhNotReadyYet: wazuhNotReadyYet,
};
};
@@ -47,14 +57,13 @@ export const updateWazuhNotReadyYet = wazuhNotReadyYet => {
* Updates currentTab in the appState store
* @param currentTab
*/
-export const updateCurrentTab = currentTab => {
+export const updateCurrentTab = (currentTab) => {
return {
type: 'UPDATE_WAZUH_CURRENT_TAB',
- currentTab: currentTab
+ currentTab: currentTab,
};
};
-
/**
* Updates extensions in the appState store
* @param extensions
@@ -64,7 +73,7 @@ export const updateExtensions = (id, extensions) => {
tmpExtensions[id] = extensions;
return {
type: 'UPDATE_EXTENSIONS',
- extensions: tmpExtensions
+ extensions: tmpExtensions,
};
};
@@ -72,14 +81,13 @@ export const updateExtensions = (id, extensions) => {
* Updates currentPlatform in the appState store
* @param extensions
*/
-export const updateCurrentPlatform = currentPlatform => {
+export const updateCurrentPlatform = (currentPlatform) => {
return {
type: 'UPDATE_CURRENT_PLATFORM',
- currentPlatform
+ currentPlatform,
};
};
-
/**
* Updates currentAgentData in the appState store
* @param extensions
@@ -87,11 +95,10 @@ export const updateCurrentPlatform = currentPlatform => {
export const updateCurrentAgentData = (data) => {
return {
type: 'UPDATE_SELECTED_AGENT_DATA',
- currentAgentData: data
+ currentAgentData: data,
};
};
-
/**
* Updates showExploreAgentModal in the appState store
* @param extensions
@@ -99,11 +106,10 @@ export const updateCurrentAgentData = (data) => {
export const showExploreAgentModal = (shouldShow) => {
return {
type: 'SHOW_EXPLORE_AGENT_MODAL',
- showExploreAgentModal: shouldShow
+ showExploreAgentModal: shouldShow,
};
};
-
/**
* Updates showExploreAgentModalGlobal in the appState store
* @param extensions
@@ -111,7 +117,7 @@ export const showExploreAgentModal = (shouldShow) => {
export const showExploreAgentModalGlobal = (shouldShow) => {
return {
type: 'SHOW_EXPLORE_AGENT_MODAL_GLOBAL',
- showExploreAgentModalGlobal: shouldShow
+ showExploreAgentModalGlobal: shouldShow,
};
};
@@ -119,10 +125,10 @@ export const showExploreAgentModalGlobal = (shouldShow) => {
* Updates userRoles in the appState store
* @param extensions
*/
-export const updateUserRoles = userRoles => {
+export const updateUserRoles = (userRoles) => {
return {
type: 'UPDATE_USER_ROLES',
- userRoles
+ userRoles,
};
};
@@ -130,43 +136,43 @@ export const updateUserRoles = userRoles => {
* Updates userPermissions in the appState store
* @param extensions
*/
-export const updateUserPermissions = userPermissions => {
+export const updateUserPermissions = (userPermissions) => {
return {
type: 'UPDATE_USER_PERMISSIONS',
- userPermissions
+ userPermissions,
};
};
/**
-* Updates selectedSettingsSection in the appState store
-* @param selected_settings_section
-*/
-export const updateSelectedSettingsSection = selected_settings_section => {
- return {
- type: 'UPDATE_SELECTED_SETTINGS_SECTION',
- selected_settings_section
- };
+ * Updates selectedSettingsSection in the appState store
+ * @param selected_settings_section
+ */
+export const updateSelectedSettingsSection = (selected_settings_section) => {
+ return {
+ type: 'UPDATE_SELECTED_SETTINGS_SECTION',
+ selected_settings_section,
+ };
};
/**
* Updates selectedToolsSection in the appState store
* @param selected_tools_section
*/
-export const updateSelectedToolsSection = selected_tools_section => {
+export const updateSelectedToolsSection = (selected_tools_section) => {
return {
type: 'UPDATE_SELECTED_TOOLS_SECTION',
- selected_tools_section
+ selected_tools_section,
};
};
/**
-* Updates toastNotification in the appState store
-* @param toastNotification
-*/
-export const updateToastNotificationsModal = toastNotification => {
+ * Updates toastNotification in the appState store
+ * @param toastNotification
+ */
+export const updateToastNotificationsModal = (toastNotification) => {
return {
type: 'UPDATE_TOAST_NOTIFICATIONS_MODAL',
- toastNotification
+ toastNotification,
};
};
@@ -188,7 +194,7 @@ export const updateClusterStatus = (clusterStatus) => {
export const showFlyoutLogtest = (showFlyout) => {
return {
type: 'SHOW_FLYOUT_LOGTEST',
- showFlyoutLogtest: showFlyout
+ showFlyoutLogtest: showFlyout,
};
};
@@ -199,7 +205,7 @@ export const showFlyoutLogtest = (showFlyout) => {
export const updateDockedLogtest = (dockedFlyout) => {
return {
type: 'UPDATE_DOCKED_LOGTEST',
- dockedFlyoutLogtest: dockedFlyout
+ dockedFlyoutLogtest: dockedFlyout,
};
};
@@ -210,19 +216,18 @@ export const updateDockedLogtest = (dockedFlyout) => {
export const updateWithUserLogged = (withUserLogged) => {
return {
type: 'UPDATE_WITH_USER_LOGGED',
- withUserLogged,
+ withUserLogged,
};
};
-
/**
* Updates allowedAgents in the appState store
* @param allowedAgents
*/
-export const updateAllowedAgents = allowedAgents => {
+export const updateAllowedAgents = (allowedAgents) => {
return {
type: 'GET_ALLOWED_AGENTS',
- allowedAgents
+ allowedAgents,
};
};
@@ -233,6 +238,6 @@ export const updateAllowedAgents = allowedAgents => {
export const updateLogtestToken = (logtestToken) => {
return {
type: 'UPDATE_LOGTEST_TOKEN',
- logtestToken: logtestToken
+ logtestToken: logtestToken,
};
-};
\ No newline at end of file
+};
diff --git a/public/redux/reducers/appStateReducers.js b/public/redux/reducers/appStateReducers.js
index 7d5b6ba7c5..7cbd027945 100644
--- a/public/redux/reducers/appStateReducers.js
+++ b/public/redux/reducers/appStateReducers.js
@@ -31,99 +31,104 @@ const initialState = {
withUserLogged: false,
allowedAgents: [],
logtestToken: '',
+ indexPatterns: [],
};
const appStateReducers = (state = initialState, action) => {
+ if (action.type === 'UPDATE_INDEX_PATTERNS') {
+ return {
+ ...state,
+ indexPatterns: action.indexPatterns,
+ };
+ }
if (action.type === 'UPDATE_CURRENT_API') {
return {
...state,
- currentAPI: action.currentAPI
+ currentAPI: action.currentAPI,
};
}
if (action.type === 'SHOW_MENU') {
return {
...state,
- showMenu: action.showMenu
+ showMenu: action.showMenu,
};
}
if (action.type === 'UPDATE_WAZUH_NOT_READY_YET') {
return {
...state,
- wazuhNotReadyYet: action.wazuhNotReadyYet
+ wazuhNotReadyYet: action.wazuhNotReadyYet,
};
}
if (action.type === 'UPDATE_WAZUH_CURRENT_TAB') {
return {
...state,
- currentTab: action.currentTab
+ currentTab: action.currentTab,
};
}
if (action.type === 'UPDATE_EXTENSIONS') {
return {
...state,
- extensions: action.extensions
+ extensions: action.extensions,
};
}
if (action.type === 'UPDATE_CURRENT_PLATFORM') {
return {
...state,
- currentPlatform: action.currentPlatform
+ currentPlatform: action.currentPlatform,
};
}
if (action.type === 'UPDATE_SELECTED_AGENT_DATA') {
return {
...state,
- currentAgentData: action.currentAgentData
+ currentAgentData: action.currentAgentData,
};
}
-
if (action.type === 'SHOW_EXPLORE_AGENT_MODAL') {
return {
...state,
- showExploreAgentModal: action.showExploreAgentModal
+ showExploreAgentModal: action.showExploreAgentModal,
};
}
-
if (action.type === 'SHOW_EXPLORE_AGENT_MODAL_GLOBAL') {
return {
...state,
- showExploreAgentModalGlobal: action.showExploreAgentModalGlobal
+ showExploreAgentModalGlobal: action.showExploreAgentModalGlobal,
};
}
if (action.type === 'UPDATE_USER_ROLES') {
return {
...state,
- userRoles: action.userRoles
+ userRoles: action.userRoles,
};
}
if (action.type === 'UPDATE_USER_PERMISSIONS') {
return {
...state,
- userPermissions: action.userPermissions
+ userPermissions: action.userPermissions,
};
}
if (action.type === 'UPDATE_SELECTED_SETTINGS_SECTION') {
return {
...state,
- selected_settings_section: action.selected_settings_section
+ selected_settings_section: action.selected_settings_section,
};
}
if (action.type === 'UPDATE_TOAST_NOTIFICATIONS_MODAL') {
return {
...state,
- toastNotification: action.toastNotification
+ toastNotification: action.toastNotification,
};
}
@@ -137,21 +142,21 @@ const appStateReducers = (state = initialState, action) => {
if (action.type === 'UPDATE_WITH_USER_LOGGED') {
return {
...state,
- withUserLogged: action.withUserLogged,
+ withUserLogged: action.withUserLogged,
};
- }
+ }
if (action.type === 'GET_ALLOWED_AGENTS') {
return {
...state,
- allowedAgents: action.allowedAgents
+ allowedAgents: action.allowedAgents,
};
}
-
+
if (action.type === 'UPDATE_LOGTEST_TOKEN') {
return {
...state,
- logtestToken: action.logtestToken
+ logtestToken: action.logtestToken,
};
}