wazuh-dashboard-plugins icon indicating copy to clipboard operation
wazuh-dashboard-plugins copied to clipboard

Custom branding: add validation to the plugin's settings

Open Desvelao opened this issue 2 years ago • 4 comments

Description

We'll add validation to the settings of the plugin, so no invalid values can be set in the Settings / Configuration section.

Objective

  • Display errors when the input is invalid.
  • Highlight the settings which contain errors.
  • Disable configuration saving when there are errors.

Tasks

  • Frontend
    • [x] Add validation to each type of input component when its value changes.
    • [x] Highlight the errors of each input.
      • [x] Display the cause of error.
      • [x] Add warning icon to the setting with the errors.
    • [x] Disable the save button when there are errors due to invalid values.
    • [ ] Add unit tests
  • Backend
    • [x] Validate route and body parameters of the following endpoints:
      • [x] PUT /utils/configuration
      • [x] PUT /utils/configuration/files/{key}
    • [ ] Tests

Depends on: #4443

Desvelao avatar Sep 06 '22 14:09 Desvelao

Add feedback to the form's input

The management of the inputs for the plugin's settings has been improved. The following features have been added:

  • An error message is added to the input when its value is invalid.
  • The invalid settings are now highlighted in red.
  • A warning icon is appended to the invalid settings.
  • The total count of invalid settings is now shown in the bottom status bar.
  • The button to save the configuration is disabled when there are invalid values.

Screenshots

  • Input's validation, invalid settings highlight, error count display and disabled of the save button. image

  • Warning icon added to the invalid settings, reason displayed on mouse over. image

Desvelao avatar Sep 07 '22 07:09 Desvelao

  • Added validation to each setting of the plugin in the frontend and the backend.

Desvelao avatar Sep 08 '22 10:09 Desvelao

  • Fixed some settings validation errors
  • Updated the development branch with the last changes of the base branch

Desvelao avatar Sep 19 '22 13:09 Desvelao

  • Added tests to validate the updating of plugin settings using the API endpoint PUT /utils/configuration. (WIP)

Desvelao avatar Sep 21 '22 15:09 Desvelao

In the validation, we should consider the values used by cloud environments, to be sure these pass the setting validations.

Some plugin configurations to keep in mind:

  • https://github.com/wazuh/wazuh-saas/blob/master/services/internal/environments/common/data/kubernetes/wazuh-dashboard-wazuh-app-configmap.yaml

Desvelao avatar Oct 07 '22 08:10 Desvelao

I created a new PR related to this issue to add de validation description to multi-line inputs description.

image

asteriscos avatar Oct 31 '22 13:10 asteriscos