Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error when changing API in Agent preview of Endpoints Summary #6800

Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ All notable changes to the Wazuh app project will be documented in this file.
- Added HAProxy helper settings to cluster configuration [#6653](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6653)
- Added ability to open the report file or Reporting application from the toast message [#6558](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6558)
- Added support for agents to Office 365 [#6558](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6558)
- Added pinned agent data validation when rendering the Inventory data, Stats and Configuration tabs in Agent preview of Endpoints Summary [#6800](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6800)

### Changed

Expand Down
26 changes: 26 additions & 0 deletions plugins/main/public/components/agents/stats/agent-stats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
EuiPageBody,
EuiSpacer,
EuiText,
EuiLink,
} from '@elastic/eui';

import {
Expand All @@ -33,6 +34,7 @@ import { AgentStatTable } from './table';
import {
PromptNoActiveAgentWithoutSelect,
PromptAgentFeatureVersion,
PromptNoSelectedAgent,
} from '../prompts';
import {
UIErrorLog,
Expand All @@ -47,6 +49,8 @@ import {
import { getErrorOrchestrator } from '../../../react-services/common-services';
import { endpointSummary } from '../../../utils/applications';
import NavigationService from '../../../react-services/navigation-service';
import { getCore } from '../../../kibana-services';
import { RedirectAppLinks } from '../../../../../../src/plugins/opensearch_dashboards_react/public';

const tableColumns = [
{
Expand Down Expand Up @@ -115,6 +119,28 @@ export const MainAgentStats = compose(
text: 'Stats',
},
]),
withGuard(
props => !(props.agent && props.agent.id),
() => (
<>
<PromptNoSelectedAgent
body={
<>
You need to select an agent or return to
<RedirectAppLinks application={getCore().application}>
<EuiLink
aria-label='go to Endpoint summary'
href={`${endpointSummary.id}#/agents-preview`}
>
Endpoint summary
</EuiLink>
</RedirectAppLinks>
</>
}
/>
</>
),
),
withUserAuthorizationPrompt(({ agent }) => [
[
{ action: 'agent:read', resource: `agent:id:${agent.id}` },
Expand Down
32 changes: 31 additions & 1 deletion plugins/main/public/components/agents/syscollector/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,19 @@
*/

import React from 'react';
import { withErrorBoundary, withGlobalBreadcrumb } from '../../common/hocs';
import {
withErrorBoundary,
withGlobalBreadcrumb,
withGuard,
} from '../../common/hocs';
import { SyscollectorInventory } from './inventory';
import { compose } from 'redux';
import { endpointSummary } from '../../../utils/applications';
import NavigationService from '../../../react-services/navigation-service';
import { PromptNoSelectedAgent } from '../prompts';
import { getCore } from '../../../kibana-services';
import { EuiLink } from '@elastic/eui';
import { RedirectAppLinks } from '../../../../../../src/plugins/opensearch_dashboards_react/public';

export const MainSyscollector = compose(
withErrorBoundary,
Expand All @@ -33,4 +41,26 @@ export const MainSyscollector = compose(
},
];
}),
withGuard(
props => !(props.agent && props.agent.id),
() => (
<>
<PromptNoSelectedAgent
body={
<>
You need to select an agent or return to
<RedirectAppLinks application={getCore().application}>
<EuiLink
aria-label='go to Endpoint summary'
href={`${endpointSummary.id}#/agents-preview`}
>
Endpoint summary
</EuiLink>
</RedirectAppLinks>
</>
}
/>
</>
),
),
)(SyscollectorInventory);
16 changes: 3 additions & 13 deletions plugins/main/public/components/common/modules/main-agent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import React, { Component, Fragment } from 'react';
import {
EuiFlexGroup,
EuiFlexItem,
EuiCallOut,
EuiTitle,
EuiButtonEmpty,
} from '@elastic/eui';
Expand Down Expand Up @@ -106,7 +105,6 @@ export class MainModuleAgent extends Component {

render() {
const { agent, section, selectView } = this.props;
const title = this.renderTitle();
const ModuleTabView = (this.props.tabs || []).find(
tab => tab.id === selectView,
);
Expand All @@ -118,11 +116,11 @@ export class MainModuleAgent extends Component {
: 'wz-module'
}
>
<div className='wz-module-header-agent-wrapper'>
<div className='wz-module-header-agent'>{title}</div>
</div>
{agent && agent.os && (
<Fragment>
<div className='wz-module-header-agent-wrapper'>
<div className='wz-module-header-agent'>{this.renderTitle()}</div>
</div>
<div>
<div
className={
Expand Down Expand Up @@ -186,14 +184,6 @@ export class MainModuleAgent extends Component {
)}
</Fragment>
)}
{(!agent || !agent.os) && (
<EuiCallOut
style={{ margin: '66px 16px 0 16px' }}
title='This agent has never connected'
color='warning'
iconType='alert'
></EuiCallOut>
)}
</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*
* Find more information about this on the LICENSE file.
*/

import React from 'react';
Desvelao marked this conversation as resolved.
Show resolved Hide resolved
import WzConfigurationSwitch from './configuration-switch';
import {
withErrorBoundary,
Expand All @@ -18,12 +18,17 @@ import {
import { compose } from 'redux';
import { endpointSummary, settings } from '../../../../../utils/applications';
import NavigationService from '../../../../../react-services/navigation-service';
import { withGuard } from '../../../../../components/common/hocs';
import { PromptNoSelectedAgent } from '../../../../../components/agents/prompts';
import { getCore } from '../../../../../kibana-services';
import { EuiLink } from '@elastic/eui';
import { RedirectAppLinks } from '../../../../../../../../src/plugins/opensearch_dashboards_react/public';

export default compose(
withErrorBoundary,
withGlobalBreadcrumb(props => {
let breadcrumb = false;
if (props.agent.id === '000') {
if (props.agent?.id === '000') {
breadcrumb = [{ text: settings.breadcrumbLabel }];
} else {
breadcrumb = [
Expand All @@ -43,4 +48,26 @@ export default compose(
$('#breadcrumbNoTitle').attr('title', '');
return breadcrumb;
}),
withGuard(
props => !(props.agent && props.agent.id),
() => (
<>
<PromptNoSelectedAgent
body={
<>
You need to select an agent or return to
<RedirectAppLinks application={getCore().application}>
<EuiLink
aria-label='go to Endpoint summary'
href={`${endpointSummary.id}#/agents-preview`}
>
Endpoint summary
</EuiLink>
</RedirectAppLinks>
</>
}
/>
</>
),
),
)(WzConfigurationSwitch);
Loading