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

Select agents and add/remove groups #6274

Merged
merged 26 commits into from
Feb 27, 2024

Conversation

lucianogorza
Copy link
Contributor

@lucianogorza lucianogorza commented Jan 8, 2024

Description

This PR adds global actions to the agent's table to allow the user to add agents to groups or remove agents from groups.
To achieve this, a selector was added to the table, and the TableWzAPI component had to be modified. Global actions to edit agent groups open a modal from which groups to add or remove can be selected. Upon saving, the progress of the process is displayed, first retrieving agent information and then applying changes to each group.
Finally, the result of the transactions is shown, providing information to the user about agents that were successfully assigned or removed from groups and indicating the cause of any failures if they occurred.

In summary, the following modifications were made:

  • Add global actions to agent's table
    • Add agents to groups
    • Remove agents from groups
  • Add "addOnTitle" optional prop to TableWzAPI component to add selection options after the title on the table.
  • Enhance the TableWzAPI header for better visibility across various screen widths.
  • Utilize the ref prop in TableWithSearchBar to reset the selection when the table is refreshed, sorted, or the page is changed.
  • Enhance the apiReq method in the WzRequest class by introducing an optional parameter returnOriginalResponse. This parameter allows the method to return all affected and failed items when adding agents to groups or removing agents from groups.

Issues Resolved

#6257

Evidence

Select some agents

image
image
image

Select all filtered agents

image
image
image
image
image

Test

Test with manager
Create at least 11 agents and 3 groups

Test

Legend:
⚫: none
🟢: pass
🟡: warning
🔴: fail
⚪: not applicable

UI

General

Test Chrome Firefox Safari
Without select agents global actions must be disabled
Select some agents. Global actions must be enabled
Select agents and change filters. Selection must cleared
Select agents and change page. Selection must cleared
Select agents and sort data. Selection must cleared
With a read only user, select some agents. Global actions must be disabled

Details

⚫ Without select agents global actions must be disabled

Chrome - ⚫

Firefox - ⚫

Safari - ⚫

⚫ Select some agents. Global actions must be enabled

Chrome - ⚫

Firefox - ⚫

Safari - ⚫

⚫ Select agents and change filters. Selection must cleared

Chrome - ⚫

Firefox - ⚫

Safari - ⚫

⚫ Select agents and change page. Selection must cleared

Chrome - ⚫

Firefox - ⚫

Safari - ⚫

⚫ Select agents and sort data. Selection must cleared

Chrome - ⚫

Firefox - ⚫

Safari - ⚫

⚫ With a read only user, select some agents. Global actions must be disabled

Chrome - ⚫

Firefox - ⚫

Safari - ⚫

Select some agents

Test Chrome Firefox Safari
Go to Add/Remove groups -> Add groups to agents. Select groups, save, and check the results. Test with different agents and groups.
Go to Add/Remove groups -> Remove groups from agents. Select groups, save, and check the results. Test with different agents and groups.

Details

⚫ Go to Add/Remove groups -> Add groups to agents. Select groups, save, and check the results. Test with different agents and groups

Chrome - ⚫

Firefox - ⚫

Safari - ⚫

⚫ Go to Add/Remove groups -> Remove groups from agents. Select groups, save, and check the results. Test with different agents and groups

Chrome - ⚫

Firefox - ⚫

Safari - ⚫

Select all filtered agents

Test Chrome Firefox Safari
Go to Add/Remove groups -> Add groups to agents. A callout should be displayed warning that the changes will be applied to all filtered agents.
Go to Add/Remove groups -> Add groups to agents. Select groups, save, and check the results. Test with different groups.
Go to Add/Remove groups -> Remove groups from agents. A callout should be displayed warning that the changes will be applied to all filtered agents.
Go to Add/Remove groups -> Remove groups from agents. Select groups, save, and check the results. Test with different groups.

Details

⚫ Go to Add/Remove groups -> Add groups to agents. A callout should be displayed warning that the changes will be applied to all filtered agents

Chrome - ⚫

Firefox - ⚫

Safari - ⚫

⚫ Go to Add/Remove groups -> Add groups to agents. Select groups, save, and check the results. Test with different groups

Chrome - ⚫

Firefox - ⚫

Safari - ⚫

⚫ Go to Add/Remove groups -> Remove groups from agents. A callout should be displayed warning that the changes will be applied to all filtered agents

Chrome - ⚫

Firefox - ⚫

Safari - ⚫

⚫ Remove groups from agents. Select groups, save, and check the results. Test with different groups

Chrome - ⚫

Firefox - ⚫

Safari - ⚫

Paginate requests

The following request must be paginated:

  • Agents list: When adding or removing groups for all filtered agents, the agents must be retrieved through paginated requests.
  • Groups list: When the modal is open, the list of groups is retrieved.
  • Modify groups: When selecting groups and saving, the changes must be applied to the agents through paginated requests.

The default pagination is set to 1000. To test, it is necessary to modify the default value, for example, to 2.

  • plugins/main/public/components/endpoints-summary/services/get-agents.tsx: Line 9.
  • plugins/main/public/components/endpoints-summary/services/get-groups.tsx: Line 9.
  • plugins/main/public/components/endpoints-summary/services/paginated-agents-group.tsx: Line 17.
Test Chrome Firefox Safari
Select agents > Go to Add/Remove groups -> Add groups to agents. Check the groups list and the network requests.
Select all filtered agents > Go to Add/Remove groups -> Add groups to agents. Select groups and save. Check the network requests to get the agents and add the groups. Check the displayed result.

Details

⚫ Select agents > Go to Add/Remove groups -> Add groups to agents. Check the groups list and the network requests

Chrome - ⚫

Firefox - ⚫

Safari - ⚫

⚫ Select all filtered agents > Go to Add/Remove groups -> Add groups to agents. Select groups and save. Check the network requests to get the agents and add the groups. Check the displayed result

Chrome - ⚫

Firefox - ⚫

Safari - ⚫

Check List

  • All tests pass
    • yarn test:jest
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

@lucianogorza lucianogorza self-assigned this Jan 8, 2024
@lucianogorza lucianogorza linked an issue Jan 8, 2024 that may be closed by this pull request
13 tasks
@lucianogorza lucianogorza changed the title Enhancement/6257 select agents and add remove groups Select agents and add remove groups Feb 2, 2024
@lucianogorza lucianogorza changed the title Select agents and add remove groups Select agents and add/remove groups Feb 2, 2024
@asteriscos asteriscos changed the base branch from master to 4.9.0 February 13, 2024 10:03
@lucianogorza lucianogorza force-pushed the enhancement/6257-select-agents-and-add-remove-groups branch from 23ebaf7 to 63446b0 Compare February 21, 2024 20:20
@lucianogorza lucianogorza marked this pull request as ready for review February 23, 2024 15:23
@lucianogorza lucianogorza force-pushed the enhancement/6257-select-agents-and-add-remove-groups branch from 60bcfa7 to 36fe172 Compare February 23, 2024 15:27
@Tostti Tostti self-requested a review February 23, 2024 18:17
@Tostti
Copy link
Member

Tostti commented Feb 23, 2024

UI

General

Test Chrome Firefox Safari
Without select agents global actions must be disabled 🟢 🟢 🟢
Select some agents. Global actions must be enabled 🟢 🟢 🟢
Select agents and change filters. Selection must cleared 🟢 🟢 🟢
Select agents and change page. Selection must cleared 🟢 🟢 🟢
Select agents and sort data. Selection must cleared 🟢 🟢 🟢
With a read only user, select some agents. Global actions must be disabled 🟢 🟢 🟢

Details

🟢 Without select agents global actions must be disabled

Chrome - 🟢

image

Firefox - 🟢

image

Safari - 🟢

image

🟢 Select some agents. Global actions must be enabled

Chrome - 🟢

image

Firefox - 🟢

image

Safari - 🟢

image

🟢 Select agents and change filters. Selection must cleared

Chrome - 🟢

Video_2024-02-26_11-26-39.mp4

Firefox - 🟢

Video_2024-02-26_11-27-19.mp4

Safari - 🟢

Video_2024-02-26_11-29-45.mp4
🟢 Select agents and change page. Selection must cleared

Chrome - 🟢

Video_2024-02-26_11-32-01.mp4

Firefox - 🟢

Video_2024-02-26_11-32-23.mp4

Safari - 🟢

Video_2024-02-26_11-32-47.mp4
🟢 Select agents and sort data. Selection must cleared

Chrome - 🟢

Video_2024-02-26_11-34-55.mp4

Firefox - 🟢

Video_2024-02-26_11-35-33.mp4

Safari - 🟢

Video_2024-02-26_11-35-59.mp4
🟢 With a read only user, select some agents. Global actions must be disabled

Chrome - 🟢

image

Firefox - 🟢

image

Safari - 🟢

image

Select some agents

Test Chrome Firefox Safari
Go to Add/Remove groups -> Add groups to agents. Select groups, save, and check the results. Test with different agents and groups. 🟢 🟢 🟢
Go to Add/Remove groups -> Remove groups from agents. Select groups, save, and check the results. Test with different agents and groups. 🟢 🟢 🟢

Details

🟢 Go to Add/Remove groups -> Add groups to agents. Select groups, save, and check the results. Test with different agents and groups

Chrome - 🟢

Video_2024-02-26_12-09-43.mp4

Firefox - 🟢

Video_2024-02-26_12-11-53.mp4

Safari - 🟢

Video_2024-02-26_12-13-37.mp4
🟢 Go to Add/Remove groups -> Remove groups from agents. Select groups, save, and check the results. Test with different agents and groups

Chrome - 🟢

Video_2024-02-26_12-10-34.mp4

Firefox - 🟢

Video_2024-02-26_12-12-41.mp4

Safari - 🟢

Video_2024-02-26_12-14-26.mp4

Select all filtered agents

Test Chrome Firefox Safari
Go to Add/Remove groups -> Add groups to agents. A callout should be displayed warning that the changes will be applied to all filtered agents. 🟢 🟢 🟢
Go to Add/Remove groups -> Add groups to agents. Select groups, save, and check the results. Test with different groups. 🟢 🟢 🟢
Go to Add/Remove groups -> Remove groups from agents. A callout should be displayed warning that the changes will be applied to all filtered agents. 🟢 🟢 🟢
Go to Add/Remove groups -> Remove groups from agents. Select groups, save, and check the results. Test with different groups. 🟢 🟢 🟢

Details

🟢 Go to Add/Remove groups -> Add groups to agents. A callout should be displayed warning that the changes will be applied to all filtered agents

Chrome - 🟢

image

Firefox - 🟢

image

Safari - 🟢

image

🟢 Go to Add/Remove groups -> Add groups to agents. Select groups, save, and check the results. Test with different groups

Chrome - 🟢

image

Firefox - 🟢

image

Safari - 🟢

image

🟢 Go to Add/Remove groups -> Remove groups from agents. A callout should be displayed warning that the changes will be applied to all filtered agents

Chrome - 🟢

image

Firefox - 🟢

image

Safari - 🟢

image

🟢 Remove groups from agents. Select groups, save, and check the results. Test with different groups

Chrome - 🟢

image

Firefox - 🟢

image

Safari - 🟢

image

Paginate requests

The following request must be paginated:

  • Agents list: When adding or removing groups for all filtered agents, the agents must be retrieved through paginated requests.
  • Groups list: When the modal is open, the list of groups is retrieved.
  • Modify groups: When selecting groups and saving, the changes must be applied to the agents through paginated requests.

The default pagination is set to 1000. To test, it is necessary to modify the default value, for example, to 2.

  • plugins/main/public/components/endpoints-summary/services/get-agents.tsx: Line 9.
  • plugins/main/public/components/endpoints-summary/services/get-groups.tsx: Line 9.
  • plugins/main/public/components/endpoints-summary/services/paginated-agents-group.tsx: Line 17.

Value modified to 2

Test Chrome Firefox Safari
Select agents > Go to Add/Remove groups -> Add groups to agents. Check the groups list and the network requests. 🟢 🟢 🟢
Select all filtered agents > Go to Add/Remove groups -> Add groups to agents. Select groups and save. Check the network requests to get the agents and add the groups. Check the displayed result. 🟢 🟢 🟢

Details

🟢 Select agents > Go to Add/Remove groups -> Add groups to agents. Check the groups list and the network requests

Chrome - 🟢

image
image

Firefox - 🟢

image
image

Safari - 🟢

image
image

🟢 Select all filtered agents > Go to Add/Remove groups -> Add groups to agents. Select groups and save. Check the network requests to get the agents and add the groups. Check the displayed result

Chrome - 🟢

image
image
image

Firefox - 🟢

image
image
image

Safari - 🟢

image
image
image

@jbiset jbiset self-requested a review February 23, 2024 19:34
@jbiset
Copy link
Member

jbiset commented Feb 23, 2024

CR: ✔️

UI

General

Test Chrome Firefox Safari
Without select agents global actions must be disabled 🟢 🟢
Select some agents. Global actions must be enabled 🟢 🟢
Select agents and change filters. Selection must cleared 🟢 🟢
Select agents and change page. Selection must cleared 🟢 🟢
Select agents and sort data. Selection must cleared 🟢 🟢
With a read only user, select some agents. Global actions must be disabled 🟢 🟢

Details

🟢 Without select agents global actions must be disabled

Chrome - 🟢
image

Firefox - 🟢

image

Safari - ⚫

🟢 Select some agents. Global actions must be enabled

Chrome - 🟢

image

Firefox - 🟢

image

Safari - ⚫

🟢 Select agents and change filters. Selection must cleared

Chrome - 🟢

3_evidence_chrome.webm

Firefox - 🟢

3_evidence_firefox.webm

Safari - ⚫

🟢 Select agents and change page. Selection must cleared

Chrome - 🟢

4_evidence_chrome.webm

Firefox - 🟢

4_evidence_firefox.webm

Safari - ⚫

🟢 Select agents and sort data. Selection must cleared

Chrome - 🟢

5_evidence_chrome.webm

Firefox - 🟢

5_evidence_firefox.webm

Safari - ⚫

🟢 With a read only user, select some agents. Global actions must be disabled

Chrome - 🟢

image

Firefox - 🟢

image

Safari - ⚫

Select some agents

Test Chrome Firefox Safari
Go to Add/Remove groups -> Add groups to agents. Select groups, save, and check the results. Test with different agents and groups. 🟢 🟢
Go to Add/Remove groups -> Remove groups from agents. Select groups, save, and check the results. Test with different agents and groups. 🟢 🟢

Details

🟢 Go to Add/Remove groups -> Add groups to agents. Select groups, save, and check the results. Test with different agents and groups

Chrome - 🟢

6_evidence_chrome.webm

Firefox - 🟢

6_evidence_firefox.webm

Safari - ⚫

🟢 Go to Add/Remove groups -> Remove groups from agents. Select groups, save, and check the results. Test with different agents and groups

Chrome - 🟢

7_evidence_chrome.webm

Firefox - 🟢

7_evidence_firefox.webm

Safari - ⚫

COMMENT
When allowed to select a group that is not assigned, it failed. So, if possible, you can list only the groups that can be removed from the selected agent group.

7_evidence_chrome_yellow.webm

Select all filtered agents

Test Chrome Firefox Safari
Go to Add/Remove groups -> Add groups to agents. A callout should be displayed warning that the changes will be applied to all filtered agents. 🟢 🟢
Go to Add/Remove groups -> Add groups to agents. Select groups, save, and check the results. Test with different groups. 🟢 🟢
Go to Add/Remove groups -> Remove groups from agents. A callout should be displayed warning that the changes will be applied to all filtered agents. 🟢 🟢
Go to Add/Remove groups -> Remove groups from agents. Select groups, save, and check the results. Test with different groups. 🟢 🟢

Details

🟢 Go to Add/Remove groups -> Add groups to agents. A callout should be displayed warning that the changes will be applied to all filtered agents

Chrome - 🟢

image

Firefox - 🟢

image

Safari - ⚫

🟢 Go to Add/Remove groups -> Add groups to agents. Select groups, save, and check the results. Test with different groups

Chrome - 🟢

image

Firefox - 🟢

image

Safari - ⚫

🟢 Go to Add/Remove groups -> Remove groups from agents. A callout should be displayed warning that the changes will be applied to all filtered agents

Chrome - 🟢

image

Firefox - 🟢

image

Safari - ⚫

🟢 Remove groups from agents. Select groups, save, and check the results. Test with different groups

Chrome - 🟢

image

Firefox - 🟢

image

Safari - ⚫

Paginate requests

The following request must be paginated:

  • Agents list: When adding or removing groups for all filtered agents, the agents must be retrieved through paginated requests.
  • Groups list: When the modal is open, the list of groups is retrieved.
  • Modify groups: When selecting groups and saving, the changes must be applied to the agents through paginated requests.

The default pagination is set to 1000. To test, it is necessary to modify the default value, for example, to 2.

  • plugins/main/public/components/endpoints-summary/services/get-agents.tsx: Line 9.
  • plugins/main/public/components/endpoints-summary/services/get-groups.tsx: Line 9.
  • plugins/main/public/components/endpoints-summary/services/paginated-agents-group.tsx: Line 17.
Test Chrome Firefox Safari
Select agents > Go to Add/Remove groups -> Add groups to agents. Check the groups list and the network requests. 🟢 🟢
Select all filtered agents > Go to Add/Remove groups -> Add groups to agents. Select groups and save. Check the network requests to get the agents and add the groups. Check the displayed result. 🟢 🟢

Details

🟢 Select agents > Go to Add/Remove groups -> Add groups to agents. Check the groups list and the network requests

Chrome - 🟢

image

Firefox - 🟢

image

Safari - ⚫

🟢 Select all filtered agents > Go to Add/Remove groups -> Add groups to agents. Select groups and save. Check the network requests to get the agents and add the groups. Check the displayed result

Chrome - 🟢

image

image

image

Firefox - 🟢

image

image

image

Safari - ⚫

Copy link
Contributor

Wazuh Core plugin code coverage (Jest) test % values
Statements 21.38% ( 176 / 823 )
Branches 19.45% ( 79 / 406 )
Functions 14.17% ( 36 / 254 )
Lines 21.57% ( 173 / 802 )

Copy link
Contributor

Wazuh Check Updates plugin code coverage (Jest) test % values
Statements 76.44% ( 172 / 225 )
Branches 58.65% ( 61 / 104 )
Functions 61.7% ( 29 / 47 )
Lines 76.44% ( 172 / 225 )

Copy link
Contributor

Main plugin code coverage (Jest) test % values
Statements 12% ( 4164 / 34696 )
Branches 7.93% ( 1817 / 22901 )
Functions 11.5% ( 955 / 8302 )
Lines 12.18% ( 4048 / 33234 )

Copy link
Member

@Tostti Tostti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test ✅
CR ✅

LGTM

Copy link
Member

@jbiset jbiset left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CR 🟢

Test 🟢

@asteriscos asteriscos merged commit 1bc5bb6 into 4.9.0 Feb 27, 2024
4 checks passed
@asteriscos asteriscos deleted the enhancement/6257-select-agents-and-add-remove-groups branch February 27, 2024 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow select agents to add or remove groups
5 participants