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

Remove groups.js angular controller #6543

Merged
merged 7 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export const WzButtonPermissions = ({

return additionalProps;
}}
{...rest}
>
<Button {...rest} />
</WzElementPermissions>
Expand Down
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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);
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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);
Loading
Loading