From 73f91dca23b50266544b02bced0a3299dfcdfde8 Mon Sep 17 00:00:00 2001 From: Nelson Kopliku Date: Thu, 13 Jul 2023 14:57:46 +0200 Subject: [PATCH] Host Checks selection saga (#1618) * Move cluster check selection action next to the state * Move cluster check selection saga in dedicated saga file * Use cluster specific action name for checks selection * Add a new checksSelection slice for host checks selection * Add reducer to hosts to update checks selection * Add host checks selection saga * Use redux state in HostSettingsPage * Improve imports and faked test data * Simplify host check selection state * Add tests for current cluster checks selection saga * Extract callback functions to component functions * Add targetName prop to ChecksSelection * Rename checksSelection to hostChecksSelection * Use useCallback when passing saving function * Improve name for the new check selection emitted by the ChecksSelection component --- .../ChecksSelection/ChecksSelection.jsx | 3 +- .../ChecksSelection/ChecksSelection.test.jsx | 4 +- .../ClusterDetails/ChecksSelection.jsx | 17 ++-- .../ClusterDetails/ChecksSelection.test.jsx | 2 +- .../HostDetails/HostChecksSelection.jsx | 13 +-- .../HostDetails/HostSettingsPage.jsx | 33 ++++++-- assets/js/lib/test-utils/index.jsx | 1 + assets/js/state/actions/cluster.js | 6 -- assets/js/state/clusters.js | 5 +- assets/js/state/hostChecksSelection.js | 26 ++++++ assets/js/state/hostChecksSelection.test.js | 38 +++++++++ assets/js/state/hosts.js | 9 +++ assets/js/state/hosts.test.js | 25 ++++++ assets/js/state/index.js | 2 + assets/js/state/sagas/clusters.js | 52 +++++++++++- assets/js/state/sagas/clusters.test.js | 81 ++++++++++++++++++- assets/js/state/sagas/hosts.js | 41 +++++++++- assets/js/state/sagas/hosts.test.js | 57 +++++++++++++ assets/js/state/sagas/index.js | 54 ++----------- .../js/state/selectors/hostChecksSelection.js | 4 + .../selectors/hostChecksSelection.test.js | 15 ++++ 21 files changed, 408 insertions(+), 80 deletions(-) delete mode 100644 assets/js/state/actions/cluster.js create mode 100644 assets/js/state/hostChecksSelection.js create mode 100644 assets/js/state/hostChecksSelection.test.js create mode 100644 assets/js/state/selectors/hostChecksSelection.js create mode 100644 assets/js/state/selectors/hostChecksSelection.test.js diff --git a/assets/js/components/ChecksSelection/ChecksSelection.jsx b/assets/js/components/ChecksSelection/ChecksSelection.jsx index fae680de52..2e4e7840bb 100644 --- a/assets/js/components/ChecksSelection/ChecksSelection.jsx +++ b/assets/js/components/ChecksSelection/ChecksSelection.jsx @@ -34,6 +34,7 @@ const defaultSelectedChecks = []; function ChecksSelection({ className, targetID, + targetName, catalog, selected = defaultSelectedChecks, loading = false, @@ -119,7 +120,7 @@ function ChecksSelection({