From daa267414e72ced319c3217b607b9d98863dc740 Mon Sep 17 00:00:00 2001 From: Nelson Kopliku Date: Tue, 11 Jul 2023 16:08:41 +0200 Subject: [PATCH] Use rest prop passing from HostSettingsPage to HostChecksSelection --- .../HostDetails/HostChecksSelection.jsx | 16 ++------------ .../HostDetails/HostSettingsPage.jsx | 22 ++++++++++++++++++- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/assets/js/components/HostDetails/HostChecksSelection.jsx b/assets/js/components/HostDetails/HostChecksSelection.jsx index 93fca55d57..dd9b0b7876 100644 --- a/assets/js/components/HostDetails/HostChecksSelection.jsx +++ b/assets/js/components/HostDetails/HostChecksSelection.jsx @@ -11,10 +11,7 @@ function HostChecksSelection({ provider, agentVersion, selectedChecks, - catalog, - catalogError, - catalogLoading, - onUpdateCatalog, + ...rest }) { return (
@@ -25,20 +22,11 @@ function HostChecksSelection({ { - // TODO: dispatch check selection for a host - }} - onUpdateCatalog={() => onUpdateCatalog()} onClear={() => { // TODO }} - saving={false} - error={null} - success={false} + {...rest} />
); diff --git a/assets/js/components/HostDetails/HostSettingsPage.jsx b/assets/js/components/HostDetails/HostSettingsPage.jsx index 2b148ef6f5..80a2822705 100644 --- a/assets/js/components/HostDetails/HostSettingsPage.jsx +++ b/assets/js/components/HostDetails/HostSettingsPage.jsx @@ -4,9 +4,11 @@ import { useParams } from 'react-router-dom'; import LoadingBox from '@components/LoadingBox'; +import { checksSelected } from '@state/checksSelection'; import { updateCatalog } from '@state/actions/catalog'; import { getCatalog } from '@state/selectors/catalog'; import { getHost } from '@state/selectors'; +import { getCheckSelection } from '@state/selectors/checksSelection'; import HostChecksSelection from './HostChecksSelection'; function HostSettingsPage() { @@ -21,9 +23,14 @@ function HostSettingsPage() { loading: catalogLoading, } = useSelector(getCatalog()); + const { saving, savingError, savingSuccess } = useSelector( + getCheckSelection() + ); + if (!host) { return ; } + const { hostname: hostName, provider, @@ -40,7 +47,7 @@ function HostSettingsPage() { selectedChecks={selectedChecks} catalog={catalog} catalogError={catalogError} - catalogLoading={catalogLoading} + loading={catalogLoading} onUpdateCatalog={() => dispatch( updateCatalog({ @@ -49,6 +56,19 @@ function HostSettingsPage() { }) ) } + saving={saving} + error={savingError} + success={savingSuccess} + onSave={(selection, targetID) => + dispatch( + checksSelected({ + targetID, + targetType: 'host', + targetName: host.hostname, + checks: selection, + }) + ) + } /> ); }