Skip to content

Commit

Permalink
Delete register agent files from controller
Browse files Browse the repository at this point in the history
  • Loading branch information
lucianogorza committed Dec 7, 2023
1 parent f7ed80f commit 4ae1902
Show file tree
Hide file tree
Showing 45 changed files with 30 additions and 5,256 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ import {
withReduxProvider,
withGlobalBreadcrumb,
withUserAuthorizationPrompt,
withErrorBoundary,
} from '../common/hocs';
import { formatUIDate } from '../../../public/react-services/time-service';
import { compose } from 'redux';
import { withErrorBoundary } from '../common/hocs';
import {
UI_LOGGER_LEVELS,
UI_ORDER_AGENT_STATUS,
Expand Down
1 change: 0 additions & 1 deletion plugins/main/public/components/endpoints-summary/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
EuiEmptyPrompt,
EuiProgress,
} from '@elastic/eui';
import { RegisterAgent } from '../../controllers/register-agent/containers/register-agent/register-agent';
import { EndpointsSummary } from './endpoints-summary';
import { WzRequest } from '../../react-services/wz-request';
import { endpointSumary } from '../../utils/applications';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@ import { WzRequest } from '../../../../../react-services/wz-request';
import { UI_LOGGER_LEVELS } from '../../../../../../common/constants';
import { UI_ERROR_SEVERITIES } from '../../../../../react-services/error-orchestrator/types';
import { ErrorHandler } from '../../../../../react-services/error-management';
import { getMasterRemoteConfiguration } from '../../../../../controllers/agent/components/register-agent-service';
import './register-agent.scss';
import { Steps } from '../steps/steps';
import { InputForm } from '../../../../common/form';
import { getGroups } from '../../services/register-agent-services';
import {
getGroups,
getMasterRemoteConfiguration,
} from '../../services/register-agent-services';
import { useForm } from '../../../../common/form/hooks';
import { FormConfiguration } from '../../../../common/form/types';
import { useSelector } from 'react-redux';
import {
withErrorBoundary,
withReduxProvider,
withGlobalBreadcrumb,
withUserAuthorizationPrompt,
Expand All @@ -37,21 +40,17 @@ import {
import { compose } from 'redux';
import { endpointSumary } from '../../../../../utils/applications';
import { getCore } from '../../../../../kibana-services';

interface IRegisterAgentProps {
getWazuhVersion: () => Promise<string>;
addNewAgent: (agent: any) => Promise<any>;
reload: () => void;
}
import { getErrorOrchestrator } from '../../../../../react-services/common-services';

export const RegisterAgent = compose(
withErrorBoundary,
withReduxProvider,
withGlobalBreadcrumb([
{ text: endpointSumary.title, href: `#${endpointSumary.redirectTo()}` },
{ text: 'Deploy new agent' },
]),
// withUserAuthorizationPrompt([[{ action: 'agent:read', resource: 'agent:group:*' }]])
)(({ getWazuhVersion, addNewAgent, reload }: IRegisterAgentProps) => {
)(() => {
const configuration = useSelector(
(state: { appConfig: { data: any } }) => state.appConfig.data,
);
Expand Down Expand Up @@ -118,6 +117,27 @@ export const RegisterAgent = compose(
}
};

const getWazuhVersion = async () => {
try {
const data = await WzRequest.apiReq('GET', '/', {});
const result = ((data || {}).data || {}).data || {};
return result.api_version;
} catch (error) {
const options = {
context: `RegisterAgent.getWazuhVersion`,
level: UI_LOGGER_LEVELS.ERROR,
severity: UI_ERROR_SEVERITIES.BUSINESS,
error: {
error: error,
message: error.message || error,
title: `Could not get the Wazuh version: ${error.message || error}`,
},
};
getErrorOrchestrator().handleError(options);
return version;
}
};

useEffect(() => {
const fetchData = async () => {
try {
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 4ae1902

Please sign in to comment.