Skip to content

Commit

Permalink
Fix a non-stop error in Manage agents when the user has no permissions (
Browse files Browse the repository at this point in the history
#2976)

* fix(frontend): Fix non-stop error in Manage agents when the user has not permissions

  - Manage the error loading the selected agent while loop
  - Added a prompt to th the required permission to the group detail view

* fix(frontend): Added a PR to changelog
  • Loading branch information
Desvelao authored and frankeros committed Mar 9, 2021
1 parent a41c82e commit 9292b40
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 14 deletions.
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);

0 comments on commit 9292b40

Please sign in to comment.