Skip to content

Commit

Permalink
Use rest prop passing from HostSettingsPage to HostChecksSelection
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonkopliku committed Jul 11, 2023
1 parent 9d52fb9 commit 812e5ac
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
16 changes: 2 additions & 14 deletions assets/js/components/HostDetails/HostChecksSelection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ function HostChecksSelection({
provider,
agentVersion,
selectedChecks,
catalog,
catalogError,
catalogLoading,
onUpdateCatalog,
...rest
}) {
return (
<div className="w-full px-2 sm:px-0">
Expand All @@ -25,20 +22,11 @@ function HostChecksSelection({
<HostInfoBox provider={provider} agentVersion={agentVersion} />
<ChecksSelection
targetID={hostID}
catalog={catalog}
catalogError={catalogError}
loading={catalogLoading}
selected={selectedChecks}
onSave={(_selectedChecks, _hostID) => {
// TODO: dispatch check selection for a host
}}
onUpdateCatalog={() => onUpdateCatalog()}
onClear={() => {
// TODO
}}
saving={false}
error={null}
success={false}
{...rest}
/>
</div>
);
Expand Down
22 changes: 21 additions & 1 deletion assets/js/components/HostDetails/HostSettingsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -21,9 +23,14 @@ function HostSettingsPage() {
loading: catalogLoading,
} = useSelector(getCatalog());

const { saving, savingError, savingSuccess } = useSelector(
getCheckSelection()
);

if (!host) {
return <LoadingBox text="Loading..." />;
}

const {
hostname: hostName,
provider,
Expand All @@ -40,7 +47,7 @@ function HostSettingsPage() {
selectedChecks={selectedChecks}
catalog={catalog}
catalogError={catalogError}
catalogLoading={catalogLoading}
loading={catalogLoading}
onUpdateCatalog={() =>
dispatch(
updateCatalog({
Expand All @@ -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,
})
)
}
/>
);
}
Expand Down

0 comments on commit 812e5ac

Please sign in to comment.