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

Fix a non-stop error in Manage agents when the user has no permissions #2976

Merged
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 @@ -14,6 +14,7 @@ All notable changes to the Wazuh app project will be documented in this file.
- Fix the statusCode error message [#2971](https://github.com/wazuh/wazuh-kibana-app/pull/2971)
- Fix the SCA policy stats didn't refresh [#2973](https://github.com/wazuh/wazuh-kibana-app/pull/2973)
- Fix some date fields format in FIM and SCA modules [#2975](https://github.com/wazuh/wazuh-kibana-app/pull/2975)
- Fix a non-stop error in Manage agents when the user has no permissions [#2976](https://github.com/wazuh/wazuh-kibana-app/pull/2976)
- Can't edit empty rules and decoders files that already exist in the manager [#2978](https://github.com/wazuh/wazuh-kibana-app/pull/2978)

## Wazuh v4.1.0 - Kibana 7.10.0 , 7.10.2 - Revision 4101
Expand Down
26 changes: 16 additions & 10 deletions public/components/management/groups/multiple-agent-selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,27 @@ export class MultipleAgentSelector extends Component {
async componentDidMount() {
this.setState({ load: true });
try {
while (!this.state.selectedAgents.loadedAll) {
await this.loadSelectedAgents();
this.setState({
selectedAgents: {
...this.state.selectedAgents,
offset: this.state.selectedAgents.offset + 499,
}
})
}
try{
while (!this.state.selectedAgents.loadedAll) {
await this.loadSelectedAgents();
this.setState({
selectedAgents: {
...this.state.selectedAgents,
offset: this.state.selectedAgents.offset + 499,
}
});
}
}catch(error){}
this.firstSelectedList = [...this.state.selectedAgents.data];
await this.loadAllAgents("", true);
this.setState({
load: false
});
} catch (error) {
ErrorHandler.handle(error, 'Error adding agents');
ErrorHandler.handle(error, 'Error loading agents');
this.setState({
load: false
});
}
}

Expand Down Expand Up @@ -188,6 +193,7 @@ export class MultipleAgentSelector extends Component {
}
} catch (error) {
ErrorHandler.handle(error, 'Error fetching group agents');
throw error;
}
this.setState({
selectedAgents: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ class WzGroupsActionButtonsAgents extends Component {
showManageAgents() {
const { itemDetail } = this.props.state;

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

closePopover() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import WzGroupsActionButtonsAgents from './actions-buttons-agents';
import WzGroupsActionButtonsFiles from './actions-buttons-files';
import WzGroupAgentsTable from './group-agents-table';
import WzGroupFilesTable from './group-files-table';
import { withUserAuthorizationPrompt } from '../../../../../components/common/hocs';
import { compose } from 'redux';

class WzGroupDetail extends Component {
constructor(props) {
Expand Down Expand Up @@ -184,7 +186,10 @@ const mapDispatchToProps = dispatch => {
};
};

export default connect(
mapStateToProps,
mapDispatchToProps
export default compose(
connect(
mapStateToProps,
mapDispatchToProps
),
withUserAuthorizationPrompt((props) => [{action: 'group:read', resource: `group:id:${props.state.itemDetail.name}`}]),
)(WzGroupDetail);