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

The agents dashboard is displayed when using the Add agent button from plugin home #6175

Closed
Desvelao opened this issue Nov 29, 2023 · 2 comments · Fixed by #6185
Closed

The agents dashboard is displayed when using the Add agent button from plugin home #6175

Desvelao opened this issue Nov 29, 2023 · 2 comments · Fixed by #6185
Assignees
Labels
level/task Task issue type/bug Bug issue

Comments

@Desvelao
Copy link
Member

Desvelao commented Nov 29, 2023

Description
The agents dashboard is displayed when using the Add agent button from the Modules directory section for a little period of time.

Preconditions

  1. No registered agents

Steps to reproduce

  1. Navigate to Modules directory
  2. Click on Add agent button

Expected Result
The displayed view should be what we want to navigate to instead of this redirection behavior.

Evidences
https://github.com/wazuh/wazuh-dashboard-plugins/assets/34042064/69c6d5de-37f0-4a54-8dcd-e488bbd1c11c

@Desvelao Desvelao added type/enhancement Enhancement issue level/task Task issue labels Nov 29, 2023
@wazuhci wazuhci moved this to Backlog in Release 4.8.0 Nov 29, 2023
@lucianogorza lucianogorza self-assigned this Nov 29, 2023
@lucianogorza
Copy link
Contributor

lucianogorza commented Nov 29, 2023

Current behavior

The component OverviewWelcome (plugins/wazuh/public/components/common/welcome/overview-welcome.js) has a button that is renderer only when there is no registered agents. The button has a href to the page #/agents-preview

image

The page #/agents-preview is renderer by the template plugins/wazuh/public/templates/agents-prev/agents-prev.html. This template uses the agentsPreviewController controller.

At the end of the template, we can see that the React component RegisterAgent is rendered (ng-if) only if the addingNewAgent controller value is true, and another component, AgentsPreview, is rendered but only displayed (ng-how) if the addingNewAgent value is false. Therefore, the AgentsPreview component is always rendered.

image

Why is it necessary to always render the AgentsPreview component?

The component is responsible for retrieving and updating general information about the agents through the tableProps.updateSummary function obtained in the props.

image

The updateSummary function is declared in the controller and it updates the value of addingNewAgent, which determines whether the RegisterAgent component is rendered or not.

image
image

Therefore, when the page #/agents-preview is initially loaded, the AgentsPreview component is first rendered and displayed. If there are no registered agents, the AgentsPreview component stops being displayed, and the RegisterAgent component is rendered.

Possible solutions

Solution 1:

  • Retrieve general information about the agents in the controller so that the addingNewAgent value is set before rendering the components.
  • Pass the retrieved information to the components through props and remove the parts where this information is retrieved in the components.
  • Additionally, the ng-show option in the HTML template for the AgentsPreview component should be modified to ng-if.

Solution 2:

  • In AgentsPreview component return a loading while summary data is being retrieved.
  • In AgentsPreview component add a condition and only return the dashboard and table if agent count > 0.
  • In AgentsPreview controller in the RegisterAgent component replace ng-if with ng-show.

One must analyze what impact the changes may have on other use cases.

@wazuhci wazuhci moved this from Backlog to In progress in Release 4.8.0 Nov 30, 2023
@wazuhci wazuhci moved this to In progress in Release 4.7.2 Nov 30, 2023
@wazuhci wazuhci removed this from Release 4.8.0 Nov 30, 2023
@davidjiglesias davidjiglesias added type/bug Bug issue and removed type/enhancement Enhancement issue labels Nov 30, 2023
@lucianogorza lucianogorza linked a pull request Nov 30, 2023 that will close this issue
6 tasks
@lucianogorza
Copy link
Contributor

In a meeting with @asteriscos we decided to go for solution 2

@lucianogorza lucianogorza moved this from In progress to Pending review in Release 4.7.2 Dec 4, 2023
@github-project-automation github-project-automation bot moved this from Pending review to Done in Release 4.7.2 Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
level/task Task issue type/bug Bug issue
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants