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

Add an agent selector to IT Hygiene application #6005

Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@
import React from 'react';
import { useDispatch } from 'react-redux';
import { EuiEmptyPrompt, EuiButton } from '@elastic/eui';
import { showExploreAgentModal } from '../../redux/actions/appStateActions';
import { showExploreAgentModalGlobal } from '../../redux/actions/appStateActions';

export const PromptAgentNoSupportModule = () => {
const dispatch = useDispatch();
const openAgentSelector = () => dispatch(showExploreAgentModal(true));
const openAgentSelector = () => dispatch(showExploreAgentModalGlobal(true));
return (
<EuiEmptyPrompt
iconType="watchesApp"
iconType='watchesApp'
title={<h2>Module not supported by the agent</h2>}
actions={
<EuiButton color="primary" fill onClick={openAgentSelector}>
<EuiButton color='primary' fill onClick={openAgentSelector}>
Select agent
</EuiButton>
}
/>
)
}
);
};
1 change: 1 addition & 0 deletions plugins/main/public/components/agents/prompts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ export * from './prompt-no-selected-agent';
export * from './prompt-select-agent';
export * from './prompt-agent-feature-version';
export * from './prompt_module_not_for_agent';
export * from './prompt-agent-never-connected';
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Wazuh app - Prompt when status agent is Never connected.
* 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, { Fragment } from 'react';
import { EuiEmptyPrompt, EuiButton, EuiLink } from '@elastic/eui';
import { useDispatch } from 'react-redux';
import { webDocumentationLink } from '../../../../common/services/web_documentation';
import { showExploreAgentModalGlobal } from '../../../redux/actions/appStateActions';

const documentationLink = webDocumentationLink(
'user-manual/agents/agent-connection.html',
);

export const PromptAgentNeverConnected = () => {
const dispatch = useDispatch();
const openAgentSelector = () => dispatch(showExploreAgentModalGlobal(true));
return (
<EuiEmptyPrompt
iconType='securitySignalDetected'
style={{ marginTop: 20 }}
title={<h2>Agent has never connected.</h2>}
body={
<Fragment>
<p>
The agent has been registered but has not yet connected to the
manager.
</p>
<EuiLink
href={documentationLink}
target='_blank'
rel='noopener noreferrer'
external
>
Checking connection with the Wazuh server
</EuiLink>
</Fragment>
}
actions={
<EuiButton color='primary' fill onClick={openAgentSelector}>
Select agent
</EuiButton>
}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import React from 'react';
import { useDispatch } from 'react-redux';
import { EuiButton, EuiEmptyPrompt } from '@elastic/eui';
import { showExploreAgentModal } from '../../../redux/actions/appStateActions';
import { showExploreAgentModalGlobal } from '../../../redux/actions/appStateActions';

type PromptSelectAgentProps = {
body?: string;
Expand All @@ -22,14 +22,14 @@ type PromptSelectAgentProps = {

export const PromptSelectAgent = ({ body, title }: PromptSelectAgentProps) => {
const dispatch = useDispatch();
const openAgentSelector = () => dispatch(showExploreAgentModal(true));
const openAgentSelector = () => dispatch(showExploreAgentModalGlobal(true));
return (
<EuiEmptyPrompt
iconType="watchesApp"
iconType='watchesApp'
title={<h2>{title}</h2>}
body={body && <p>{body}</p>}
actions={
<EuiButton color="primary" fill onClick={openAgentSelector}>
<EuiButton color='primary' fill onClick={openAgentSelector}>
Select agent
</EuiButton>
}
Expand Down
65 changes: 13 additions & 52 deletions plugins/main/public/components/agents/syscollector/inventory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,7 @@
*/

import React from 'react';
import {
EuiEmptyPrompt,
EuiButton,
EuiFlexGroup,
EuiFlexItem,
EuiCallOut,
EuiLink,
EuiPanel,
} from '@elastic/eui';
import { EuiFlexGroup, EuiFlexItem, EuiCallOut, EuiPanel } from '@elastic/eui';
import { InventoryMetrics } from './components/syscollector-metrics';
import {
netaddrColumns,
Expand All @@ -33,54 +25,23 @@ import {
API_NAME_AGENT_STATUS,
SEARCH_BAR_WQL_VALUE_SUGGESTIONS_COUNT,
} from '../../../../common/constants';
import { webDocumentationLink } from '../../../../common/services/web_documentation';
import { TableWzAPI } from '../../common/tables';
import { WzRequest } from '../../../react-services';
import { get as getLodash } from 'lodash';
import { getCore } from '../../../kibana-services';
import { compose } from 'redux';
import { withGuard } from '../../common/hocs';
import { PromptAgentNeverConnected } from '../prompts';

const sortFieldSuggestion = (a, b) => (a.label > b.label ? 1 : -1);

export function SyscollectorInventory({ agent }) {
if (agent && agent.status === API_NAME_AGENT_STATUS.NEVER_CONNECTED) {
return (
<EuiEmptyPrompt
iconType='securitySignalDetected'
style={{ marginTop: 20 }}
title={<h2>Agent has never connected.</h2>}
body={
<>
<p>
The agent has been registered but has not yet connected to the
manager.
</p>
<EuiLink
href={webDocumentationLink(
'user-manual/agents/agent-connection.html',
)}
target='_blank'
rel='noopener noreferrer'
external
>
Checking connection with the Wazuh server
</EuiLink>
</>
}
actions={
<EuiButton
href={getCore().application.getUrlForApp('endpoints-summary', {
path: '#/agents-preview',
})}
color='primary'
fill
>
Back
</EuiButton>
}
/>
);
}

export const SyscollectorInventory = compose(
withGuard(
props =>
props.agent &&
props.agent.status === API_NAME_AGENT_STATUS.NEVER_CONNECTED,
PromptAgentNeverConnected,
),
)(function SyscollectorInventory({ agent }) {
let soPlatform;
if (agent?.os?.uname?.includes('Linux')) {
soPlatform = 'linux';
Expand Down Expand Up @@ -468,4 +429,4 @@ export function SyscollectorInventory({ agent }) {
</EuiFlexGroup>
</div>
);
}
});
Loading
Loading