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

Add switch to toggle the use of custom branding #4507

Merged
merged 138 commits into from
Nov 2, 2022

Conversation

asteriscos
Copy link
Member

@asteriscos asteriscos commented Sep 13, 2022

Description

This PR adds a new configuration setting to enable or disable the whole branding customization. This makes it easier to switch on or off all the white-labeling configurations without changing or deleting all the custom branding configurations.
Changing customization.enabled configuration to true or false is enough to deactivate all the branding customizations.

  • Add a new setting:
    • customization.enabled: Enable or disable the application of others customization.* settings.
key description values requirements on change
customization.enabled Enable or disable the application of others customization.* settings true/false reload browser tab
  • Add tests related to the setting

Closes #4506

Screenshot

localhost_5601_app_wazuh (1)

Test

Manual tests

Scenario: Modify the value of customization.enabled setting through Settings/Configuration
When the user modifies the custmization.enabled setting and saves the configuration.
Then the configuration file should be updated and the frontend

Scenario: Modify the value of customization.enabled setting through an API request with a valid value.
When the user does an API request to update the setting customization.enabled with a valid value: true or false
Then the response should be successful
And the configuration file should be updated

Scenario: Modify the value of customization.enabled setting through an API request with an invalid value.
When the user does an API request to update the setting customization.enabled with an invalid value.
Then the response should be a bad request

Scenario: Customization is applied when the customization.enabled setting is enabled.
Given the customization.enabled setting value is true and the customization.* settings have custom values
When the user goes to the plugin,
Then the menu displays the custom image
And the plugin category displays the custom image
And the plugin health check displays the custom image
And the PDF report image displays the custom image
And the PDF header displays the custom text
And the PDF footer displays the custom text

Scenario: Customization is not applied when the customization.enabled setting is disabled.
Given the customization.enabled setting value is false and the customization.* settings have custom values
When the user goes to the plugin,
Then the menu displays the default image
And the plugin category displays the default image
And the plugin health check displays the default image
And the PDF report image displays the default image
And the PDF header displays the default text
And the PDF footer displays the default text


To manually test the configuration endpoint here are 2 scripts to update different configuration values.

switch-toggle.zip

To use it, first unzip the files in the same folder and allow both executing the file as a program. Afterwards you can run the manual-test-switch-toggle.sh script.

You can also use wz-api-conf.sh script with custom configuration parameters, like:

\- s setting_name
\- v setting_value

eg.
./wz-api-conf.sh -s disabled_roles -v [\"disabled\"]

Output


./manual-test-switch-toggle.sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   398  100   398    0     0    418      0 --:--:-- --:--:-- --:--:--   417
{"customization.enabled":25000}
{"statusCode":400,"error":"Bad Request","message":"[request body.customization.enabled]: expected value of type [boolean] but got [number]"}  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   398  100   398    0     0    884      0 --:--:-- --:--:-- --:--:--   884
{"customization.enabled":true}
{"data":{"requiresRunningHealthCheck":false,"requiresReloadingBrowserTab":false,"requiresRestartingPluginPlatform":false,"updatedConfiguration":{"customization.enabled":true}}}  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   398  100   398    0     0    852      0 --:--:-- --:--:-- --:--:--   852
{"customization.enabled":false}
{"data":{"requiresRunningHealthCheck":false,"requiresReloadingBrowserTab":false,"requiresRestartingPluginPlatform":false,"updatedConfiguration":{"customization.enabled":false}}}

Automatic tests

  • Tests
    • common/services/settings.test.ts
    • server/routes/wazuh-utils/wazuh-utils.test.ts
    • common/plugin-settings.test.ts
yarn test:jest common/services/settings.test.ts server/routes/wazuh-utils/wazuh-utils.test.ts common/plugin-settings.test.ts

Desvelao and others added 19 commits September 13, 2022 08:08
Create the plugin setting schema
Define the current plugin settings
Remove refactored code
Use dynamically the definition of the plugin settings
Add new hooks to manage when a input value or form has changed
Add new inputs components
Refactor Header, BottomBar, Configuration components
Remove deprecated files
Changed the endpoint that updating the plugin setting to support
  multiple settings at the same time
Refactor the getConfiguration service. Split the logic to:
  - Read the file and transform to JSON
  - Obfuscate the password key of the host configuration
Create services to validate
Add the validation to the plugin settings
@asteriscos asteriscos self-assigned this Sep 13, 2022
@asteriscos asteriscos linked an issue Sep 14, 2022 that may be closed by this pull request
8 tasks
@AlexRuiz7 AlexRuiz7 changed the title Add custom branding enabled switch configuration Add switch to toggle the use of custom branding Sep 14, 2022
@Desvelao Desvelao added the type/enhancement Enhancement issue label Sep 15, 2022
@Desvelao
Copy link
Member

I added some manual tests to the initial comment.

Copy link
Member

@AlexRuiz7 AlexRuiz7 left a comment

Choose a reason for hiding this comment

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

  • Code Review: 🟠 (ok, with comments)
  • Test: 🟢

common/services/settings.ts Outdated Show resolved Hide resolved
AlexRuiz7
AlexRuiz7 previously approved these changes Nov 2, 2022
AlexRuiz7
AlexRuiz7 previously approved these changes Nov 2, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Nov 2, 2022

Code coverage (Jest) % values
Statements 8.31% ( 3044 / 36650 )
Branches 3.87% ( 1092 / 28214 )
Functions 7.29% ( 662 / 9084 )
Lines 8.36% ( 2933 / 35080 )

@Mayons95 Mayons95 self-requested a review November 2, 2022 15:15
Copy link
Contributor

@Mayons95 Mayons95 left a comment

Choose a reason for hiding this comment

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

LGTM
TR: ✔️

Screencast.from.02-11-22.12.08.55.webm
Screencast.from.02-11-22.12.11.15.webm

@Desvelao Desvelao merged commit c1c39b3 into 4.4-7.10 Nov 2, 2022
@Desvelao Desvelao deleted the feat/add-custom-branding-enabled-configuration-4506 branch November 2, 2022 15:57
github-actions bot pushed a commit that referenced this pull request Nov 2, 2022
* feat(settings): centralize the plugin settings

Create the plugin setting schema
Define the current plugin settings
Remove refactored code

* feat(settings): add setting services and replaced the references to constants

* feat(settings): refactor the content of the default configuration file

Use dynamically the definition of the plugin settings

* feat(inputs): create new inputs components

Add new hooks to manage when a input value or form has changed
Add new inputs components

* feat(configuration): refactor the form of Settings/Configuration

Refactor Header, BottomBar, Configuration components
Remove deprecated files

* feat(settings): support updating multiple setting at the same time

Changed the endpoint that updating the plugin setting to support
  multiple settings at the same time
Refactor the getConfiguration service. Split the logic to:
  - Read the file and transform to JSON
  - Obfuscate the password key of the host configuration

* feat: add validation to the plugin settings

Create services to validate
Add the validation to the plugin settings

* feat(validation): add validation to the `PUT /utils/configuration`
endpoint

* feat(validation): add validation to the configuration form in
`Settings/Configuration`

* feat(validatio): remove no used import

* clean: remove not used code

* Add report header-footer configuration

* fix: fixed category name in `Settings/Configuration`

* fix(settings): Fix accessing to `validate` of undefined error

* fix(settings): fixed error due to missing service

* Add custom branding enabled switch

* Fix custom logo ratio in PDF sheet

* fix(settings): refactor the form and inputs of `Settings/Configuration` to control the global state of the form

* fix: add value transformation for the form inputs and output of fields changed

* fix: Fixed some settings validation

* fix(settings): fixed validation of literals

* fix(settings): removed unused import

* fix(settings): renamed properties related to transform the value of the input

* feat(settings): add description to the plugin setting definition properties

* fix(settings): fix getConfiguration service when the configuration file has no `hosts` entry

* fix(settings): Fixed error when do changes of the `useForm` hook an rename methods of this

* tests(settings): add test related to the plugin settings and its configuration from the UI

* feat(settings): rename plugin setting options of type select to match its type

* feat(settings): add plugin settings services and enhance the description of the plugin settings in default configuration file and UI

* tests(input-form): update tests of InputForm component

* test(configuration-file): add tests of the default configuration file

* feat(settings): remove `extensions.mitre` plugin setting

* test(settings): add test to validate the plugin setting when updating it through PUT /utils/configuration

fix some plugin settings validation

* feat(settings): add documentation to some setting services and test some of them

* fix: fixed documentation of setting service

* doc(settings): move the documentation of the plugin setting properties

* fix(settings): rename some plugin setting properties because of request changes

- Rename plugin setting properties:
  - `default` to `defaultValue`
  - `defaultHidden` to `defaultValueIfNotSet`
  - `configurableFile` to `isConfigurableFromFile`
  - configurableUI` to `isConfigurableFromUI`
  - `requireHealthCheck` to `requiresRunningHealthCheck`
  - `requireReload` to `requiresReloadingBrowserTab`
  - `requireRestart` to `requiresRestartingPluginPlatform`
- Fix tests

* tests: fix tests of InputForm component

* fix: response properties when saving the configuration

* fix(settings): fix validation plugin settings value in the UI

* fix(settings): fix `customization.reports.header` and `customization.reports.footer` setting properties

* fix(settings): fix validation of numbers

* fix(settings): fix validation of numbers

* test(settings): Add tests related to validation for the `useForm` hook and the `InputForm` component

* fix(settings): fix displaying toast to run the healthcheck when saving the configuration

* test(settings): add tests for the `customization.reports.footer` and `customization.reports.header` settings

* test(settings): Add tests for the `customization.enabled` setting

* Added category sorting + description + docs link

* Added settings sorting within their category

* Fixed constant types definition

* Checks if localCompare exists validation

* fix(settings): fixed plugin setting description doesn't display the minimum number value when it is falsy (0)

* fix(settings): fix setting type of `wazuh.monitoring.replicas` and limit the valid number for the number input

* feat(settins): add plugin settings category description

* fix(settings): fix a problem comparing the initial and current value for the plugin settings of the `number` type

* fix(settings): fix wrong conflict resolution

* fix(settings): fix typo in setting description

* Add set custom header footer unit test

* feat(settings): enhance the validation of plugin settings related to indices or index patterns taking in account the supported characters

* feat(settings): add validation of setting values in the inputs

* Added unit test to verify the PDF report integrity

* fix(tests): format tables of the tests

* fix: remove unnecessary import

* test(endpoints): add test to GET /reports endpoint

* test(settings): add test for `customization.enabled` setting in the form input

* Improved report unit test with more cases

* Fix small typo

* fix(settings): fix a typo in a toast related to modify the plugin settings from UI

* Changed Custom Branding documentation link

* Merge centralize plugin settings PR

* Fix white-labeling documentation link

* Fix white-labeling documentation link

* Code format

* Delete unused imports

* fix(settings): fix a problem with the useForm hook

* fix(settings): refactor the settings validation function to a class and rename the file

* feat(settings): add check for integer numbers and adapt the affected settings

* changelog: Add PR entry

* fix(settings): fix the customization settings do not apply when the `customization.enabled` setting is not defined in the configuration file

* fix(settings): the `customization.logo.sidebar` is updated without reloading the browser tab.

This solves an indirect problem when the `customization.enabled` setting
is changed from the UI, that should have in account the
rest of the `customization.*` settings to display some action.

This change enhances the UX because the change is instant and doesn't
require to reload the browser tab.

* Fix customization.enable on GET api/logos endpoint

* fix: revert unused change

* fix: revert the updating of the `customization.logo.sidebar` when the setting was changed or removed

* fix: removed unused code and removed space

* fix: undone unwanted changes

* fix: resolve setting when it is an empty string

* fix: request changes and rename function

* fix: fix settings tests

Co-authored-by: Antonio David Gutiérrez <[email protected]>
Co-authored-by: Álex <[email protected]>
(cherry picked from commit c1c39b3)
@github-actions
Copy link
Contributor

github-actions bot commented Nov 2, 2022

The backport to 4.4-2.3-wzd failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-4.4-2.3-wzd 4.4-2.3-wzd
# Navigate to the new working tree
cd .worktrees/backport-4.4-2.3-wzd
# Create a new branch
git switch --create backport-4507-to-4.4-2.3-wzd
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 c1c39b359148f788985da17c2ff2b8b0530c19e9
# Push it to GitHub
git push --set-upstream origin backport-4507-to-4.4-2.3-wzd
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-4.4-2.3-wzd

Then, create a pull request where the base branch is 4.4-2.3-wzd and the compare/head branch is backport-4507-to-4.4-2.3-wzd.

AlexRuiz7 pushed a commit that referenced this pull request Nov 2, 2022
…4790)

Add switch to toggle the use of custom branding (#4507)

* feat(settings): centralize the plugin settings

Create the plugin setting schema
Define the current plugin settings
Remove refactored code

* feat(settings): add setting services and replaced the references to constants

* feat(settings): refactor the content of the default configuration file

Use dynamically the definition of the plugin settings

* feat(inputs): create new inputs components

Add new hooks to manage when a input value or form has changed
Add new inputs components

* feat(configuration): refactor the form of Settings/Configuration

Refactor Header, BottomBar, Configuration components
Remove deprecated files

* feat(settings): support updating multiple setting at the same time

Changed the endpoint that updating the plugin setting to support
  multiple settings at the same time
Refactor the getConfiguration service. Split the logic to:
  - Read the file and transform to JSON
  - Obfuscate the password key of the host configuration

* feat: add validation to the plugin settings

Create services to validate
Add the validation to the plugin settings

* feat(validation): add validation to the `PUT /utils/configuration`
endpoint

* feat(validation): add validation to the configuration form in
`Settings/Configuration`

* feat(validatio): remove no used import

* clean: remove not used code

* Add report header-footer configuration

* fix: fixed category name in `Settings/Configuration`

* fix(settings): Fix accessing to `validate` of undefined error

* fix(settings): fixed error due to missing service

* Add custom branding enabled switch

* Fix custom logo ratio in PDF sheet

* fix(settings): refactor the form and inputs of `Settings/Configuration` to control the global state of the form

* fix: add value transformation for the form inputs and output of fields changed

* fix: Fixed some settings validation

* fix(settings): fixed validation of literals

* fix(settings): removed unused import

* fix(settings): renamed properties related to transform the value of the input

* feat(settings): add description to the plugin setting definition properties

* fix(settings): fix getConfiguration service when the configuration file has no `hosts` entry

* fix(settings): Fixed error when do changes of the `useForm` hook an rename methods of this

* tests(settings): add test related to the plugin settings and its configuration from the UI

* feat(settings): rename plugin setting options of type select to match its type

* feat(settings): add plugin settings services and enhance the description of the plugin settings in default configuration file and UI

* tests(input-form): update tests of InputForm component

* test(configuration-file): add tests of the default configuration file

* feat(settings): remove `extensions.mitre` plugin setting

* test(settings): add test to validate the plugin setting when updating it through PUT /utils/configuration

fix some plugin settings validation

* feat(settings): add documentation to some setting services and test some of them

* fix: fixed documentation of setting service

* doc(settings): move the documentation of the plugin setting properties

* fix(settings): rename some plugin setting properties because of request changes

- Rename plugin setting properties:
  - `default` to `defaultValue`
  - `defaultHidden` to `defaultValueIfNotSet`
  - `configurableFile` to `isConfigurableFromFile`
  - configurableUI` to `isConfigurableFromUI`
  - `requireHealthCheck` to `requiresRunningHealthCheck`
  - `requireReload` to `requiresReloadingBrowserTab`
  - `requireRestart` to `requiresRestartingPluginPlatform`
- Fix tests

* tests: fix tests of InputForm component

* fix: response properties when saving the configuration

* fix(settings): fix validation plugin settings value in the UI

* fix(settings): fix `customization.reports.header` and `customization.reports.footer` setting properties

* fix(settings): fix validation of numbers

* fix(settings): fix validation of numbers

* test(settings): Add tests related to validation for the `useForm` hook and the `InputForm` component

* fix(settings): fix displaying toast to run the healthcheck when saving the configuration

* test(settings): add tests for the `customization.reports.footer` and `customization.reports.header` settings

* test(settings): Add tests for the `customization.enabled` setting

* Added category sorting + description + docs link

* Added settings sorting within their category

* Fixed constant types definition

* Checks if localCompare exists validation

* fix(settings): fixed plugin setting description doesn't display the minimum number value when it is falsy (0)

* fix(settings): fix setting type of `wazuh.monitoring.replicas` and limit the valid number for the number input

* feat(settins): add plugin settings category description

* fix(settings): fix a problem comparing the initial and current value for the plugin settings of the `number` type

* fix(settings): fix wrong conflict resolution

* fix(settings): fix typo in setting description

* Add set custom header footer unit test

* feat(settings): enhance the validation of plugin settings related to indices or index patterns taking in account the supported characters

* feat(settings): add validation of setting values in the inputs

* Added unit test to verify the PDF report integrity

* fix(tests): format tables of the tests

* fix: remove unnecessary import

* test(endpoints): add test to GET /reports endpoint

* test(settings): add test for `customization.enabled` setting in the form input

* Improved report unit test with more cases

* Fix small typo

* fix(settings): fix a typo in a toast related to modify the plugin settings from UI

* Changed Custom Branding documentation link

* Merge centralize plugin settings PR

* Fix white-labeling documentation link

* Fix white-labeling documentation link

* Code format

* Delete unused imports

* fix(settings): fix a problem with the useForm hook

* fix(settings): refactor the settings validation function to a class and rename the file

* feat(settings): add check for integer numbers and adapt the affected settings

* changelog: Add PR entry

* fix(settings): fix the customization settings do not apply when the `customization.enabled` setting is not defined in the configuration file

* fix(settings): the `customization.logo.sidebar` is updated without reloading the browser tab.

This solves an indirect problem when the `customization.enabled` setting
is changed from the UI, that should have in account the
rest of the `customization.*` settings to display some action.

This change enhances the UX because the change is instant and doesn't
require to reload the browser tab.

* Fix customization.enable on GET api/logos endpoint

* fix: revert unused change

* fix: revert the updating of the `customization.logo.sidebar` when the setting was changed or removed

* fix: removed unused code and removed space

* fix: undone unwanted changes

* fix: resolve setting when it is an empty string

* fix: request changes and rename function

* fix: fix settings tests

Co-authored-by: Antonio David Gutiérrez <[email protected]>
Co-authored-by: Álex <[email protected]>
(cherry picked from commit c1c39b3)

Co-authored-by: Federico Rodriguez <[email protected]>
Desvelao pushed a commit that referenced this pull request Nov 2, 2022
* feat(settings): centralize the plugin settings

Create the plugin setting schema
Define the current plugin settings
Remove refactored code

* feat(settings): add setting services and replaced the references to constants

* feat(settings): refactor the content of the default configuration file

Use dynamically the definition of the plugin settings

* feat(inputs): create new inputs components

Add new hooks to manage when a input value or form has changed
Add new inputs components

* feat(configuration): refactor the form of Settings/Configuration

Refactor Header, BottomBar, Configuration components
Remove deprecated files

* feat(settings): support updating multiple setting at the same time

Changed the endpoint that updating the plugin setting to support
  multiple settings at the same time
Refactor the getConfiguration service. Split the logic to:
  - Read the file and transform to JSON
  - Obfuscate the password key of the host configuration

* feat: add validation to the plugin settings

Create services to validate
Add the validation to the plugin settings

* feat(validation): add validation to the `PUT /utils/configuration`
endpoint

* feat(validation): add validation to the configuration form in
`Settings/Configuration`

* feat(validatio): remove no used import

* clean: remove not used code

* Add report header-footer configuration

* fix: fixed category name in `Settings/Configuration`

* fix(settings): Fix accessing to `validate` of undefined error

* fix(settings): fixed error due to missing service

* Add custom branding enabled switch

* Fix custom logo ratio in PDF sheet

* fix(settings): refactor the form and inputs of `Settings/Configuration` to control the global state of the form

* fix: add value transformation for the form inputs and output of fields changed

* fix: Fixed some settings validation

* fix(settings): fixed validation of literals

* fix(settings): removed unused import

* fix(settings): renamed properties related to transform the value of the input

* feat(settings): add description to the plugin setting definition properties

* fix(settings): fix getConfiguration service when the configuration file has no `hosts` entry

* fix(settings): Fixed error when do changes of the `useForm` hook an rename methods of this

* tests(settings): add test related to the plugin settings and its configuration from the UI

* feat(settings): rename plugin setting options of type select to match its type

* feat(settings): add plugin settings services and enhance the description of the plugin settings in default configuration file and UI

* tests(input-form): update tests of InputForm component

* test(configuration-file): add tests of the default configuration file

* feat(settings): remove `extensions.mitre` plugin setting

* test(settings): add test to validate the plugin setting when updating it through PUT /utils/configuration

fix some plugin settings validation

* feat(settings): add documentation to some setting services and test some of them

* fix: fixed documentation of setting service

* doc(settings): move the documentation of the plugin setting properties

* fix(settings): rename some plugin setting properties because of request changes

- Rename plugin setting properties:
  - `default` to `defaultValue`
  - `defaultHidden` to `defaultValueIfNotSet`
  - `configurableFile` to `isConfigurableFromFile`
  - configurableUI` to `isConfigurableFromUI`
  - `requireHealthCheck` to `requiresRunningHealthCheck`
  - `requireReload` to `requiresReloadingBrowserTab`
  - `requireRestart` to `requiresRestartingPluginPlatform`
- Fix tests

* tests: fix tests of InputForm component

* fix: response properties when saving the configuration

* fix(settings): fix validation plugin settings value in the UI

* fix(settings): fix `customization.reports.header` and `customization.reports.footer` setting properties

* fix(settings): fix validation of numbers

* fix(settings): fix validation of numbers

* test(settings): Add tests related to validation for the `useForm` hook and the `InputForm` component

* fix(settings): fix displaying toast to run the healthcheck when saving the configuration

* test(settings): add tests for the `customization.reports.footer` and `customization.reports.header` settings

* test(settings): Add tests for the `customization.enabled` setting

* Added category sorting + description + docs link

* Added settings sorting within their category

* Fixed constant types definition

* Checks if localCompare exists validation

* fix(settings): fixed plugin setting description doesn't display the minimum number value when it is falsy (0)

* fix(settings): fix setting type of `wazuh.monitoring.replicas` and limit the valid number for the number input

* feat(settins): add plugin settings category description

* fix(settings): fix a problem comparing the initial and current value for the plugin settings of the `number` type

* fix(settings): fix wrong conflict resolution

* fix(settings): fix typo in setting description

* Add set custom header footer unit test

* feat(settings): enhance the validation of plugin settings related to indices or index patterns taking in account the supported characters

* feat(settings): add validation of setting values in the inputs

* Added unit test to verify the PDF report integrity

* fix(tests): format tables of the tests

* fix: remove unnecessary import

* test(endpoints): add test to GET /reports endpoint

* test(settings): add test for `customization.enabled` setting in the form input

* Improved report unit test with more cases

* Fix small typo

* fix(settings): fix a typo in a toast related to modify the plugin settings from UI

* Changed Custom Branding documentation link

* Merge centralize plugin settings PR

* Fix white-labeling documentation link

* Fix white-labeling documentation link

* Code format

* Delete unused imports

* fix(settings): fix a problem with the useForm hook

* fix(settings): refactor the settings validation function to a class and rename the file

* feat(settings): add check for integer numbers and adapt the affected settings

* changelog: Add PR entry

* fix(settings): fix the customization settings do not apply when the `customization.enabled` setting is not defined in the configuration file

* fix(settings): the `customization.logo.sidebar` is updated without reloading the browser tab.

This solves an indirect problem when the `customization.enabled` setting
is changed from the UI, that should have in account the
rest of the `customization.*` settings to display some action.

This change enhances the UX because the change is instant and doesn't
require to reload the browser tab.

* Fix customization.enable on GET api/logos endpoint

* fix: revert unused change

* fix: revert the updating of the `customization.logo.sidebar` when the setting was changed or removed

* fix: removed unused code and removed space

* fix: undone unwanted changes

* fix: resolve setting when it is an empty string

* fix: request changes and rename function

* fix: fix settings tests

Co-authored-by: Antonio David Gutiérrez <[email protected]>
Co-authored-by: Álex <[email protected]>
(cherry picked from commit c1c39b3)
asteriscos added a commit that referenced this pull request Nov 2, 2022
#4791)

* Add switch to toggle the use of custom branding (#4507)

* feat(settings): centralize the plugin settings

Create the plugin setting schema
Define the current plugin settings
Remove refactored code

* feat(settings): add setting services and replaced the references to constants

* feat(settings): refactor the content of the default configuration file

Use dynamically the definition of the plugin settings

* feat(inputs): create new inputs components

Add new hooks to manage when a input value or form has changed
Add new inputs components

* feat(configuration): refactor the form of Settings/Configuration

Refactor Header, BottomBar, Configuration components
Remove deprecated files

* feat(settings): support updating multiple setting at the same time

Changed the endpoint that updating the plugin setting to support
  multiple settings at the same time
Refactor the getConfiguration service. Split the logic to:
  - Read the file and transform to JSON
  - Obfuscate the password key of the host configuration

* feat: add validation to the plugin settings

Create services to validate
Add the validation to the plugin settings

* feat(validation): add validation to the `PUT /utils/configuration`
endpoint

* feat(validation): add validation to the configuration form in
`Settings/Configuration`

* feat(validatio): remove no used import

* clean: remove not used code

* Add report header-footer configuration

* fix: fixed category name in `Settings/Configuration`

* fix(settings): Fix accessing to `validate` of undefined error

* fix(settings): fixed error due to missing service

* Add custom branding enabled switch

* Fix custom logo ratio in PDF sheet

* fix(settings): refactor the form and inputs of `Settings/Configuration` to control the global state of the form

* fix: add value transformation for the form inputs and output of fields changed

* fix: Fixed some settings validation

* fix(settings): fixed validation of literals

* fix(settings): removed unused import

* fix(settings): renamed properties related to transform the value of the input

* feat(settings): add description to the plugin setting definition properties

* fix(settings): fix getConfiguration service when the configuration file has no `hosts` entry

* fix(settings): Fixed error when do changes of the `useForm` hook an rename methods of this

* tests(settings): add test related to the plugin settings and its configuration from the UI

* feat(settings): rename plugin setting options of type select to match its type

* feat(settings): add plugin settings services and enhance the description of the plugin settings in default configuration file and UI

* tests(input-form): update tests of InputForm component

* test(configuration-file): add tests of the default configuration file

* feat(settings): remove `extensions.mitre` plugin setting

* test(settings): add test to validate the plugin setting when updating it through PUT /utils/configuration

fix some plugin settings validation

* feat(settings): add documentation to some setting services and test some of them

* fix: fixed documentation of setting service

* doc(settings): move the documentation of the plugin setting properties

* fix(settings): rename some plugin setting properties because of request changes

- Rename plugin setting properties:
  - `default` to `defaultValue`
  - `defaultHidden` to `defaultValueIfNotSet`
  - `configurableFile` to `isConfigurableFromFile`
  - configurableUI` to `isConfigurableFromUI`
  - `requireHealthCheck` to `requiresRunningHealthCheck`
  - `requireReload` to `requiresReloadingBrowserTab`
  - `requireRestart` to `requiresRestartingPluginPlatform`
- Fix tests

* tests: fix tests of InputForm component

* fix: response properties when saving the configuration

* fix(settings): fix validation plugin settings value in the UI

* fix(settings): fix `customization.reports.header` and `customization.reports.footer` setting properties

* fix(settings): fix validation of numbers

* fix(settings): fix validation of numbers

* test(settings): Add tests related to validation for the `useForm` hook and the `InputForm` component

* fix(settings): fix displaying toast to run the healthcheck when saving the configuration

* test(settings): add tests for the `customization.reports.footer` and `customization.reports.header` settings

* test(settings): Add tests for the `customization.enabled` setting

* Added category sorting + description + docs link

* Added settings sorting within their category

* Fixed constant types definition

* Checks if localCompare exists validation

* fix(settings): fixed plugin setting description doesn't display the minimum number value when it is falsy (0)

* fix(settings): fix setting type of `wazuh.monitoring.replicas` and limit the valid number for the number input

* feat(settins): add plugin settings category description

* fix(settings): fix a problem comparing the initial and current value for the plugin settings of the `number` type

* fix(settings): fix wrong conflict resolution

* fix(settings): fix typo in setting description

* Add set custom header footer unit test

* feat(settings): enhance the validation of plugin settings related to indices or index patterns taking in account the supported characters

* feat(settings): add validation of setting values in the inputs

* Added unit test to verify the PDF report integrity

* fix(tests): format tables of the tests

* fix: remove unnecessary import

* test(endpoints): add test to GET /reports endpoint

* test(settings): add test for `customization.enabled` setting in the form input

* Improved report unit test with more cases

* Fix small typo

* fix(settings): fix a typo in a toast related to modify the plugin settings from UI

* Changed Custom Branding documentation link

* Merge centralize plugin settings PR

* Fix white-labeling documentation link

* Fix white-labeling documentation link

* Code format

* Delete unused imports

* fix(settings): fix a problem with the useForm hook

* fix(settings): refactor the settings validation function to a class and rename the file

* feat(settings): add check for integer numbers and adapt the affected settings

* changelog: Add PR entry

* fix(settings): fix the customization settings do not apply when the `customization.enabled` setting is not defined in the configuration file

* fix(settings): the `customization.logo.sidebar` is updated without reloading the browser tab.

This solves an indirect problem when the `customization.enabled` setting
is changed from the UI, that should have in account the
rest of the `customization.*` settings to display some action.

This change enhances the UX because the change is instant and doesn't
require to reload the browser tab.

* Fix customization.enable on GET api/logos endpoint

* fix: revert unused change

* fix: revert the updating of the `customization.logo.sidebar` when the setting was changed or removed

* fix: removed unused code and removed space

* fix: undone unwanted changes

* fix: resolve setting when it is an empty string

* fix: request changes and rename function

* fix: fix settings tests

Co-authored-by: Antonio David Gutiérrez <[email protected]>
Co-authored-by: Álex <[email protected]>
(cherry picked from commit c1c39b3)

* fix: fix a wrong resolving conflict in a previous merge

* Fix reporting unit test

* Update unit test PDF reports md5

Co-authored-by: Federico Rodriguez <[email protected]>
@Mayons95 Mayons95 mentioned this pull request Dec 7, 2022
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement Enhancement issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Custom branding: add customization.enabled configuration
5 participants