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

Update check service UI #6093

Merged
merged 26 commits into from
Nov 3, 2023
Merged

Conversation

lucianogorza
Copy link
Contributor

@lucianogorza lucianogorza commented Nov 2, 2023

Description

We need to notify the user when a new Wazuh update is available. To do this, the "wazuh-check-updates" plugin exposes a notification component to be consumed by the main plugin. If new updates are available, the component provided by the plugin will be displayed to the user. The user has the option to close the notification and can also specify if they do not want to receive further notifications about new updates.
Add check updates features to APIs table in Settings -> API. Add two columns to APIs table indicating the current version of the API and the available updates. To display the details of the available updates, a flyout should be implemented.
Replace the About page with a React component.

Issues Resolved

wazuh/wazuh-dashboard#84

Evidence

image
image
image
image
image
image

Test

Test Result
Go to the About page
"checkUpdates" doesn't appear in Session Storage before login
"checkUpdates" appears with value "executed" in Session Storage after login
"checkUpdates" doesn't appear in Session Storage after logout
After user logins there is a network request "/api/wazuh-check-updates/updates?checkAvailableUpdates=true"
After refresh the page there is a network request "/api/wazuh-check-updates/updates?checkAvailableUpdates=false"
Click the link "Go to the API configuration page por details" on the notification. The API configuration page should load
Close the notification, refresh the page. The notification shouldn't appear
Check if the saved object "wazuh-check-updates-user-preferences:[username]" is correct
API configuration page: The table should have columns "Version" and "Updates status"
API configuration page: Click "Check updates" button
API configuration page: Change user preference "Disable updates notification"
API configuration page: Open Flyout with updates details

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 and others added 25 commits September 25, 2023 11:27
* Add wazuh_check_updates plugin

Signed-off-by: Luciano Gorza <[email protected]>

* Manage saved object for plugin configurations

Signed-off-by: Luciano Gorza <[email protected]>

* New componente UpToDateStatus and improvements

Signed-off-by: Luciano Gorza <[email protected]>

* Current update component and improvements

Signed-off-by: Luciano Gorza <[email protected]>

* CurrentUpdateDetails improvements and others

Signed-off-by: Luciano Gorza <[email protected]>

* Improvements with unit tests

Signed-off-by: Luciano Gorza <[email protected]>

* Complete public unit tests

Signed-off-by: Luciano Gorza <[email protected]>

* Unit test updatesNotification component

Signed-off-by: Luciano Gorza <[email protected]>

* Backend unit tests

Signed-off-by: Luciano Gorza <[email protected]>

* Add current update details to currentUpdateDetails component

Signed-off-by: Luciano Gorza <[email protected]>

* Add translation to show details message

Signed-off-by: Luciano Gorza <[email protected]>

* Add DismissNotificationCheck component

Signed-off-by: Luciano Gorza <[email protected]>

* Modify styles

Signed-off-by: Luciano Gorza <[email protected]>

* Expose new component

Signed-off-by: Luciano Gorza <[email protected]>

* Update DismissNotificationCheck component

Signed-off-by: Luciano Gorza <[email protected]>

* Add getCurrentUser implementation

Signed-off-by: Luciano Gorza <[email protected]>

* Fix plugin start types

Signed-off-by: Luciano Gorza <[email protected]>

* Fix checks ids

Signed-off-by: Luciano Gorza <[email protected]>

* Delete console.log in component

Signed-off-by: Luciano Gorza <[email protected]>

* Fixes in PR

Signed-off-by: Luciano Gorza <[email protected]>

* Modify README

Signed-off-by: Luciano Gorza <[email protected]>

* Delete unused files

Signed-off-by: Luciano Gorza <[email protected]>

* Delete commented code

Signed-off-by: Luciano Gorza <[email protected]>

* Removing unnecessary packages

Signed-off-by: Luciano Gorza <[email protected]>

* Clear available updates value on error

Signed-off-by: Luciano Gorza <[email protected]>

* Change constant name

Signed-off-by: Luciano Gorza <[email protected]>

* Change message on new update

Signed-off-by: Luciano Gorza <[email protected]>

* Change camelCase to kebab-case

Signed-off-by: Luciano Gorza <[email protected]>

* Change plugin name using kebab-case

Signed-off-by: Luciano Gorza <[email protected]>

* Add useEffect to component UpToDateStatus

Signed-off-by: Luciano Gorza <[email protected]>

* Improve return errors in routes

Signed-off-by: Luciano Gorza <[email protected]>

* Show update description in lines

Signed-off-by: Luciano Gorza <[email protected]>

* Add Logger

Signed-off-by: Luciano Gorza <[email protected]>

* Improve constant name

Signed-off-by: Luciano Gorza <[email protected]>

* Improve check texts and links icons

Signed-off-by: Luciano Gorza <[email protected]>

* Fix if statements

Signed-off-by: Luciano Gorza <[email protected]>

* Change folder name in dev.yml using kebab-case

Signed-off-by: Luciano Gorza <[email protected]>

* Update test snapshots

Signed-off-by: Luciano Gorza <[email protected]>

* Add I18nProvider wrapper to components

Signed-off-by: Luciano Gorza <[email protected]>

* Unit test for routes and kebab case fixes

Signed-off-by: Luciano Gorza <[email protected]>

* Add toast when on get updates error

Signed-off-by: Luciano Gorza <[email protected]>

* Omit username property on GET user preferences

Signed-off-by: Luciano Gorza <[email protected]>

* Improve try catch finally

Signed-off-by: Luciano Gorza <[email protected]>

* Add mock html_id_generator to component unit tests

Signed-off-by: Luciano Gorza <[email protected]>

* Fix unit test get-user-preferences

Signed-off-by: Luciano Gorza <[email protected]>

* Fix route unit tests port by adding a random port

Signed-off-by: Luciano Gorza <[email protected]>

* Improved user preferences saved object

Signed-off-by: Luciano Gorza <[email protected]>

* Fix toast message

Signed-off-by: Luciano Gorza <[email protected]>

* Change port in route unit tests

Signed-off-by: Luciano Gorza <[email protected]>

---------

Signed-off-by: Luciano Gorza <[email protected]>
* Integrate plugin wazuh-check-updates

* Replace the Angular template for a React component

* Add wazuh-check-updates plugin to the manifest main plugin

* Add CurrentUpdateDetails component

* Improve About page and unit tests

* Add information to Change Log

* Make the About page accessible to any user
* New React component WzUpdatesNotification

* Add unit test
* Add APIs table version status

* Add available updates columns

* Add changes to show one mayor, one minor and one patch update per API

* Improve messages

* Improve notification

* Change camelCase for snake_case in API response

* Fix server unit tests

* Fix frontend unit tests

* Fix main plugin about page unit tests

* Apis table components unit tests

* Update CHANGELOG.md

* Update unit test snapshot

* Update CHANGELOG

* Fix get updates status

* Fix release notes url with current

* Improve toast id on Apis table

* ApisUpdateStatus: Show error callout only the first time
* Add wazuh-core plugin

* Add API Wazuh Core services

* Wazuh Core Plugin API service POC

* Remove files not used

* Integrate Wazuh Core plugin with Wazuh Check Updates plugin

* Delete imposter endpoint

* Add field 'update_check' to saved object mapping

* Delete comment

* Delete getUpdates at cron job start

---------

Co-authored-by: Luciano Gorza <[email protected]>
* Delete cron job

* Delete settings managment

* Remove 'Wazuh' word from UI

* Remove unnecesary constants

* Expose and consume security from Wazuh Core

* Fix unit test types

* Delete 'Wazuh' from title

* Set sessionStorage with checkUpdates

* Fix snapshot unit test

* Improve default messages and colors in update status column

* Move constant definition to inside the component
* Add check updates columns to APIs table and other fixes

* Update notification link to the API configuration page

* Fix link to API configuration page

* Update plataform version in package.json for all plugins

* Update test snapshots

---------

Co-authored-by: Federico Rodriguez <[email protected]>
### Description
- In the About page delete the API table and leave a React component the
same as the previous Angular template.
-  Delete unused components related to the About page.
- In the UpdatesNotification component only ask for available updates if
the user doesn't check "Disable update notifications".
- In API Table handle check updates button errors and show a toast.
 
### Issues Resolved
wazuh/wazuh-dashboard#96

### Evidence

#### About page

![image](https:/wazuh/wazuh-dashboard-plugins/assets/103193307/f63ef799-d74f-46b8-87c5-f9d5281c6e12)

#### Bottom bar notification

![image](https:/wazuh/wazuh-dashboard-plugins/assets/103193307/5904fc9f-595c-4984-b898-c8ae8f555d6e)

#### API Table

![image](https:/wazuh/wazuh-dashboard-plugins/assets/103193307/56f427c2-4d42-4caf-bdc1-c0ef0f56b9c2)

#### Updates status error message

![image](https:/wazuh/wazuh-dashboard-plugins/assets/103193307/1fcfcd95-b4d5-460e-990c-799d1a11d294)

#### Check updates button error

![image](https:/wazuh/wazuh-dashboard-plugins/assets/103193307/b6817794-30b7-49a0-9556-5f589ebde03e)

### Test

- Go to the About page and compare it to the current About page. They
must be the same.
- When the bottom bar notification appears, check `Disable update
notifications` and click the `Dismiss` button. Reload the page and check
the network requests. A request for user preferences (ending in `/me`)
should appear, but there should not be a request for available updates
(ending in `/updates?checkAvailableUpdates=false`).
- Go to Settings -> API configuration. Disable the network connection
and click on `Check Updates` button. A toast should appear with an
error.

### Check List
- [ ] All tests pass
  - [ ] `yarn test:jest`
- [ ] New functionality includes testing.
- [ ] New functionality has been documented.
- [ ] Update [CHANGELOG.md](./../CHANGELOG.md)
- [ ] Commits are signed per the DCO using --signoff
@lucianogorza lucianogorza self-assigned this Nov 2, 2023
@lucianogorza lucianogorza changed the title Enhancement/84 update check service UI Update check service UI Nov 2, 2023
@lucianogorza lucianogorza linked an issue Nov 2, 2023 that may be closed by this pull request
15 tasks
@lucianogorza lucianogorza marked this pull request as ready for review November 2, 2023 20:34
@lucianogorza lucianogorza requested a review from a team as a code owner November 2, 2023 20:34
@Machi3mfl
Copy link
Member

Machi3mfl commented Nov 2, 2023

Test

Test Result
Go to the About page 🟢
"checkUpdates" doesn't appear in Session Storage before login 🟢
"checkUpdates" appears with value "executed" in Session Storage after login 🟢
"checkUpdates" doesn't appear in Session Storage after logout 🟢
After user logins there is a network request "/api/wazuh-check-updates/updates?checkAvailableUpdates=true" 🟢
After refresh the page there is a network request "/api/wazuh-check-updates/updates?checkAvailableUpdates=false" 🟢
Click the link "Go to the API configuration page por details" on the notification. The API configuration page should load 🟢
Close the notification, refresh the page. The notification shouldn't appear 🟢
Check if the saved object "wazuh-check-updates-user-preferences:[username]" is correct 🟢
API configuration page: The table should have columns "Version" and "Updates status" 🟢
API configuration page: Click "Check updates" button 🟢
API configuration page: Change user preference "Disable updates notification" 🟢
API configuration page: Open Flyout with updates details 🟢
  • 🟢 Go to the About page

Screenshot 2023-11-02 at 18 14 29

Previous version

image

  • 🟢 "checkUpdates" doesn't appear in Session Storage before login

Screenshot 2023-11-02 at 18 02 49

  • 🟢 "checkUpdates" appears with value "executed" in Session Storage after login

Screenshot 2023-11-02 at 18 03 32

  • 🟢 "checkUpdates" doesn't appear in Session Storage after logout

Screenshot 2023-11-02 at 18 04 02

  • 🟢 After user logins there is a network request "/api/wazuh-check-updates/updates?checkAvailableUpdates=true"

Screenshot 2023-11-02 at 18 05 25

  • 🟢 After refresh the page there is a network request "/api/wazuh-check-updates/updates?checkAvailableUpdates=false"

Screenshot 2023-11-02 at 18 06 28

  • 🟢 Click the link "Go to the API configuration page per details" on the notification. The API configuration page should load
Screen.Recording.2023-11-02.at.18.07.03.mov

Screenshot 2023-11-02 at 18 07 38

  • 🟢 Close the notification, refresh the page. The notification shouldn't appear

Screenshot 2023-11-02 at 18 08 23

  • 🟢 Check if the saved object "wazuh-check-updates-user-preferences:[username]" is correct

Screenshot 2023-11-02 at 18 10 38

  • 🟢 API configuration page: The table should have columns "Version" and "Updates status"
    Screenshot 2023-11-02 at 18 11 27

  • 🟢 API configuration page: Click "Check updates" button
    Screenshot 2023-11-02 at 18 12 38

  • 🟢 API configuration page: Change user preference "Disable updates notification"
    Screenshot 2023-11-02 at 18 13 16

  • 🟢 API configuration page: Open Flyout with updates details
    Screenshot 2023-11-02 at 18 13 51

Machi3mfl
Machi3mfl previously approved these changes Nov 2, 2023
jbiset
jbiset previously approved these changes Nov 2, 2023
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 🟢

Test Result
Go to the About page 🟢
"checkUpdates" doesn't appear in Session Storage before login 🟢
"checkUpdates" appears with value "executed" in Session Storage after login 🟢
"checkUpdates" doesn't appear in Session Storage after logout 🟢
After user logins there is a network request "/api/wazuh-check-updates/updates?checkAvailableUpdates=true" 🟢
After refresh the page there is a network request "/api/wazuh-check-updates/updates?checkAvailableUpdates=false" 🟢
Click the link "Go to the API configuration page por details" on the notification. The API configuration page should load 🟢
Close the notification, refresh the page. The notification shouldn't appear 🟢
Check if the saved object "wazuh-check-updates-user-preferences:[username]" is correct 🟢
API configuration page: The table should have columns "Version" and "Updates status" 🟢
API configuration page: Click "Check updates" button 🟢
API configuration page: Change user preference "Disable updates notification" 🟢
API configuration page: Open Flyout with updates details 🟢
  • 🟢 Go to the About page

evidence_1

Previous version

image

  • 🟢 "checkUpdates" doesn't appear in Session Storage before login

evidence_2

  • 🟢 "checkUpdates" appears with value "executed" in Session Storage after login

evidence_3

  • 🟢 "checkUpdates" doesn't appear in Session Storage after logout

evidence_4

  • 🟢 After user logins there is a network request "/api/wazuh-check-updates/updates?checkAvailableUpdates=true"

evidence_5

  • 🟢 After refresh the page there is a network request "/api/wazuh-check-updates/updates?checkAvailableUpdates=false"

evidence_6

  • 🟢 Click the link "Go to the API configuration page per details" on the notification. The API configuration page should load

evidence_7_B

evidence_7_A.webm
  • 🟢 Close the notification, refresh the page. The notification shouldn't appear
evidence_8.webm
  • 🟢 Check if the saved object "wazuh-check-updates-user-preferences:[username]" is correct

evidence_9

  • 🟢 API configuration page: The table should have columns "Version" and "Updates status"

evidence_10

  • 🟢 API configuration page: Click "Check updates" button

evidence_11

  • 🟢 API configuration page: Change user preference "Disable updates notification"

evidence_12

  • 🟢 API configuration page: Open Flyout with updates details

evidence_13

@asteriscos asteriscos dismissed stale reviews from jbiset and Machi3mfl via cc0cfd9 November 3, 2023 10:18
Copy link
Contributor

github-actions bot commented Nov 3, 2023

Code coverage (Jest) % values
Statements 11.82% ( 4119 / 34832 )
Branches 8.06% ( 1893 / 23483 )
Functions 11.33% ( 945 / 8337 )
Lines 12% ( 4005 / 33354 )

@asteriscos asteriscos merged commit 7b12b0d into 4.8.0 Nov 3, 2023
2 checks passed
@asteriscos asteriscos deleted the enhancement/84-update-check-service-ui branch November 3, 2023 10:42
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.

Update check service UI
4 participants