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>
}
/>
)
}
);
};
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
52 changes: 40 additions & 12 deletions plugins/main/public/components/common/welcome/agents-welcome.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,37 +47,58 @@ import { VisFactoryHandler } from '../../../react-services/vis-factory-handler';
import { AppState } from '../../../react-services/app-state';
import { FilterHandler } from '../../../utils/filter-handler';
import { TabVisualizations } from '../../../factories/tab-visualizations';
import { updateCurrentAgentData } from '../../../redux/actions/appStateActions';
import {
showExploreAgentModalGlobal,
updateCurrentAgentData,
} from '../../../redux/actions/appStateActions';
import { getAngularModule, getCore } from '../../../kibana-services';
import { hasAgentSupportModule } from '../../../react-services/wz-agents';
import {
withErrorBoundary,
withGlobalBreadcrumb,
withGuard,
withReduxProvider,
} from '../hocs';
import { compose } from 'redux';
import {
API_NAME_AGENT_STATUS,
WAZUH_AGENTS_OS_TYPE,
} from '../../../../common/constants';
import { API_NAME_AGENT_STATUS } from '../../../../common/constants';
import { webDocumentationLink } from '../../../../common/services/web_documentation';
import { WAZUH_MODULES } from '../../../../common/wazuh-modules';
import { PromptNoSelectedAgent } from '../../agents/prompts';
import { connect } from 'react-redux';

const mapStateToProps = state => ({
agent: state.appStateReducers.currentAgentData,
});

const mapDispatchToProps = dispatch => ({
showExploreAgentModalGlobal: data =>
dispatch(showExploreAgentModalGlobal(data)),
});

export const AgentsWelcome = compose(
withReduxProvider,
withErrorBoundary,
connect(mapStateToProps, mapDispatchToProps),
withGlobalBreadcrumb(({ agent }) => {
return [
{ text: '' },
{
text: 'IT Hygiene',
},
{
text: `${agent.name}`,
truncate: true,
},
...(agent?.name
? [
{
text: `${agent.name}`,
truncate: true,
},
]
: []),
];
}),
withGuard(
props => !(props.agent && props.agent.id),
() => <PromptNoSelectedAgent body='You need to select an agent.' />,
),
)(
class AgentsWelcome extends Component {
_isMount = false;
Expand Down Expand Up @@ -336,6 +357,13 @@ export const AgentsWelcome = compose(
</EuiFlexItem>
)}
<EuiFlexItem className='wz-agent-empty-item'></EuiFlexItem>
<EuiFlexItem grow={false} style={{ marginTop: 7 }}>
<EuiButtonEmpty
onClick={this.props.showExploreAgentModalGlobal}
>
Explore agent
</EuiButtonEmpty>
</EuiFlexItem>
<EuiFlexItem grow={false} style={{ marginTop: 7 }}>
<EuiButtonEmpty
iconType='inspect'
Expand Down Expand Up @@ -384,19 +412,19 @@ export const AgentsWelcome = compose(
<EuiFlexItem>
<h2 className='embPanel__title wz-headline-title'>
<EuiText size='xs'>
<h2>MITRE</h2>
<h2>MITRE ATT&CK</h2>
</EuiText>
</h2>
</EuiFlexItem>
<EuiFlexItem grow={false} style={{ alignSelf: 'center' }}>
<EuiToolTip position='top' content='Open MITRE'>
<EuiToolTip position='top' content='Open MITRE ATT&CK'>
<EuiButtonIcon
iconType='popout'
color='primary'
onClick={() => {
getCore().application.navigateToApp('mitre-attack');
}}
aria-label='Open MITRE'
aria-label='Open MITRE ATT&CK'
/>
</EuiToolTip>
</EuiFlexItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function FimTable({ agent }) {
const timeFilter = useTimeFilter();
useEffect(() => {
getFimAlerts(agent.id, timeFilter, sort).then(setFimAlerts);
}, [timeFilter, sort]);
}, [timeFilter, sort, agent.id]);
return (
<Fragment>
<EuiBasicTable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
* Find more information about this on the LICENSE file.
*/

export { MitreTopTactics } from './mitre_top';
export * from './mitre-top';
Loading
Loading