Skip to content

Commit

Permalink
Remove groups.js angular controller (#6543)
Browse files Browse the repository at this point in the history
* Remove groups.js angular controller

* Update CHANGELOG

* Fix unit test

* Update unit test snapshot

* Fix WzButtonPermissions

---------

Co-authored-by: Antonio <34042064+Desvelao@users.noreply.github.com>
Co-authored-by: Federico Rodriguez <federico.rodriguez@wazuh.com>
  • Loading branch information
3 people committed Mar 22, 2024
1 parent c5824d7 commit ef51ca4
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 265 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -23,6 +23,7 @@ All notable changes to the Wazuh app project will be documented in this file.
- Change the view of API is down and check connection to Server APIs application [#6337](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6337)
- Changed the usage of the endpoint GET /groups/{group_id}/files/{file_name} [#6385](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6385)
- Refactoring and redesign endpoints summary visualizations [#6268](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6268)
- Remove AngularJS controller for manage groups [#6543](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6543)

### Fixed

Expand Down
Expand Up @@ -70,6 +70,7 @@ export const WzButtonPermissions = ({

return additionalProps;
}}
{...rest}
>
<Button {...rest} />
</WzElementPermissions>
Expand Down
Expand Up @@ -33,23 +33,6 @@ exports[`Group main component renders correctly to match the snapshot 1`] = `
},
}
}
groupsProps={
Object {
"closeAddingAgents": false,
"exportConfigurationProps": Object {
"type": "group",
},
"items": Array [
Object {
"configSum": "ab73af41699f13fdd81903b5f23d8d00",
"count": 1,
"mergedSum": "2c45c95db2954d2c7d0ea533f09e81a5",
"name": "default",
},
],
"selectedGroup": false,
}
}
logtestProps={
Object {
"onFlyout": true,
Expand Down
Expand Up @@ -15,9 +15,7 @@ import { EuiFlexItem, EuiButtonEmpty } from '@elastic/eui';

import { connect } from 'react-redux';

import {
updateShowAddAgents,
} from '../../../../../redux/actions/groupsActions';
import { updateShowAddAgents } from '../../../../../redux/actions/groupsActions';

import GroupsHandler from './utils/groups-handler';
import { ExportConfiguration } from '../../../../agent/components/export-configuration';
Expand All @@ -30,37 +28,36 @@ class WzGroupsActionButtonsAgents extends Component {
super(props);
this.reportingService = new ReportingService();


this.groupsHandler = GroupsHandler;
}


showManageAgents() {
const { itemDetail } = this.props.state;

this.props.groupsProps.showAddingAgents(true, itemDetail);
this.props.updateShowAddAgents(true);
}

render() {
// Add new group button
const manageAgentsButton = (
<EuiButtonEmpty iconSide="left" iconType="folderOpen" onClick={() => this.showManageAgents()}>
<EuiButtonEmpty
iconSide='left'
iconType='folderOpen'
onClick={() => this.showManageAgents()}
>
Manage agents
</EuiButtonEmpty>
);

// Export PDF button
const exportPDFButton = (
<ExportConfiguration
exportConfiguration={(enabledComponents) =>
exportConfiguration={enabledComponents =>
this.reportingService.startConfigReport(
this.props.state.itemDetail,
'groupConfig',
enabledComponents
enabledComponents,
)
}
type="group"
type='group'
/>
);

Expand All @@ -73,16 +70,20 @@ class WzGroupsActionButtonsAgents extends Component {
}
}

const mapStateToProps = (state) => {
const mapStateToProps = state => {
return {
state: state.groupsReducers,
};
};

const mapDispatchToProps = (dispatch) => {
const mapDispatchToProps = dispatch => {
return {
updateShowAddAgents: (showAddAgents) => dispatch(updateShowAddAgents(showAddAgents)),
updateShowAddAgents: showAddAgents =>
dispatch(updateShowAddAgents(showAddAgents)),
};
};

export default connect(mapStateToProps, mapDispatchToProps)(WzGroupsActionButtonsAgents);
export default connect(
mapStateToProps,
mapDispatchToProps,
)(WzGroupsActionButtonsAgents);
Expand Up @@ -30,6 +30,7 @@ import { getErrorOrchestrator } from '../../../../../react-services/common-servi
import { compose } from 'redux';
import { withGlobalBreadcrumb } from '../../../../../components/common/hocs';
import { endpointGroups } from '../../../../../utils/applications';
import { MultipleAgentSelector } from '../../../../../components/management/groups/multiple-agent-selector';

class WzGroups extends Component {
constructor(props) {
Expand Down Expand Up @@ -71,36 +72,28 @@ class WzGroups extends Component {
}

UNSAFE_componentWillReceiveProps(nextProps) {
if (
nextProps.groupsProps.closeAddingAgents &&
this.props.state.showAddAgents
) {
if (this.props.state.showAddAgents) {
this.props.updateShowAddAgents(false);
}
if (
nextProps.groupsProps.selectedGroup &&
nextProps.groupsProps.selectedGroup !==
this.props.groupsProps.selectedGroup
) {
store.dispatch(updateGroupDetail(nextProps.groupsProps.selectedGroup));
}
}
componentWillUnmount() {
// When the component is going to be unmounted the groups state is reset
this.props.resetGroup();
}
componentDidUpdate() {
if (this.props.groupsProps.selectedGroup) {
this.props.groupsProps.updateProps();
}
}

render() {
const { itemDetail, showAddAgents, fileContent } = this.props.state;
return (
<WzReduxProvider>
{!showAddAgents &&
((itemDetail && !fileContent && <WzGroupDetail {...this.props} />) ||
(fileContent && <WzGroupEditor />) || <WzGroupsOverview />)}
{showAddAgents && itemDetail && (
<MultipleAgentSelector
currentGroup={itemDetail}
cancelButton={() => this.props.updateShowAddAgents(false)}
/>
)}
</WzReduxProvider>
);
}
Expand Down
Expand Up @@ -28,21 +28,6 @@ jest.mock('../../../../../kibana-services', () => ({

const mockProps = {
section: 'groups',
groupsProps: {
items: [
{
name: 'default',
count: 1,
mergedSum: '2c45c95db2954d2c7d0ea533f09e81a5',
configSum: 'ab73af41699f13fdd81903b5f23d8d00',
},
],
closeAddingAgents: false,
exportConfigurationProps: {
type: 'group',
},
selectedGroup: false,
},
configurationProps: {
agent: {
id: '000',
Expand Down
180 changes: 0 additions & 180 deletions plugins/main/public/controllers/management/groups.js

This file was deleted.

2 changes: 0 additions & 2 deletions plugins/main/public/controllers/management/index.js
Expand Up @@ -10,7 +10,6 @@
* Find more information about this on the LICENSE file.
*/

import { GroupsController } from './groups';
import { ManagementController } from './management';
import { ClusterController } from './monitoring';
import WzManagement from './components/management/management-provider';
Expand All @@ -24,7 +23,6 @@ WzManagementConfiguration.displayName = 'WzManagementConfiguration';

app
.controller('managementController', ManagementController)
.controller('groupsPreviewController', GroupsController)
.controller('clusterController', ClusterController)
.value('WzManagement', WzManagement)
.value('WzManagementConfiguration', WzManagementConfiguration);

0 comments on commit ef51ca4

Please sign in to comment.