Skip to content

Commit

Permalink
Fixed no agent alert spawn with selected agent in agent welcome (#7029)
Browse files Browse the repository at this point in the history
* Fixed no-agent spawn

* Added Changelog

---------

Co-authored-by: Federico Rodriguez <federico.rodriguez@wazuh.com>
  • Loading branch information
JuanGarriuz and asteriscos authored Sep 30, 2024
1 parent 930e5d5 commit 05ebac5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ All notable changes to the Wazuh app project will be documented in this file.
### Fixed

- Fixed read-only users could not access to Statistics application [#7001](https://github.com/wazuh/wazuh-dashboard-plugins/pull/7001)
- Fixed no-agent-alert spawn with selected agent in agent-welcome view[#7029](https://github.com/wazuh/wazuh-dashboard-plugins/pull/7029)

### Removed

Expand Down
26 changes: 26 additions & 0 deletions plugins/main/public/components/common/hocs/withAgentSync.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Wazuh app - React HOCs handles rendering errors
* 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 } from 'react';
import { PinnedAgentManager } from '../../wz-agent-selector/wz-agent-selector-service';
import { withGuardAsync } from './withGuard';

export const withAgentSync = WrappedComponent => props => {
const [loading, setLoading] = useState(true);
useEffect(() => {
const pinnedAgentManager = new PinnedAgentManager();
pinnedAgentManager.syncPinnedAgentSources().finally(() => {
setLoading(false);
});
}, []);
return loading ? null : <WrappedComponent {...props}></WrappedComponent>;
};
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { PromptNoSelectedAgent } from '../../agents/prompts';
import { RedirectAppLinks } from '../../../../../../src/plugins/opensearch_dashboards_react/public';
import { getCore } from '../../../kibana-services';
import { endpointSummary } from '../../../utils/applications';
import { withAgentSync } from '../../common/hocs/withAgentSync';

const mapStateToProps = state => ({
agent: state.appStateReducers?.currentAgentData,
Expand All @@ -36,6 +37,7 @@ export const AgentView = compose(
withErrorBoundary,
withRouteResolvers({ enableMenu, ip, nestedResolve, savedSearch }),
connect(mapStateToProps),
withAgentSync,
withGuard(
props => !(props.agent && props.agent.id),
() => (
Expand Down

0 comments on commit 05ebac5

Please sign in to comment.