Skip to content

Commit

Permalink
Use the new check selection in HostSettingsPage
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonkopliku committed Jul 18, 2023
1 parent c8cf478 commit 180bc6d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
18 changes: 10 additions & 8 deletions assets/js/components/HostDetails/HostSettingsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import { useParams } from 'react-router-dom';

import LoadingBox from '@components/LoadingBox';

import { checksSelected } from '@state/hostChecksSelection';
import { TARGET_HOST } from '@lib/model';

import { hostChecksSelected, isSaving } 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/hostChecksSelection';
import { getHostCheckSelection } from '@state/selectors/checksSelection';
import HostChecksSelection from './HostChecksSelection';

function HostSettingsPage() {
Expand All @@ -23,7 +25,7 @@ function HostSettingsPage() {
loading: catalogLoading,
} = useSelector(getCatalog());

const { saving } = useSelector(getCheckSelection());
const { status } = useSelector(getHostCheckSelection(hostID));

if (!host) {
return <LoadingBox text="Loading..." />;
Expand All @@ -40,16 +42,16 @@ function HostSettingsPage() {
dispatch(
updateCatalog({
provider: host.provider,
target_type: 'host',
target_type: TARGET_HOST,
})
);

const saveSelection = (selection, targetID, targetName) =>
const saveSelection = (newSelection, targetID, targetName) =>
dispatch(
checksSelected({
hostChecksSelected({
hostID: targetID,
hostName: targetName,
checks: selection,
checks: newSelection,
})
);

Expand All @@ -64,7 +66,7 @@ function HostSettingsPage() {
catalogError={catalogError}
catalogLoading={catalogLoading}
onUpdateCatalog={refreshCatalog}
isSavingSelection={saving}
isSavingSelection={isSaving(status)}
onSaveSelection={saveSelection}
/>
);
Expand Down
4 changes: 4 additions & 0 deletions assets/js/state/checksSelection.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ const SAVING = 'SAVING';
const SUCCESSFULLY_SAVED = 'SUCCESSFULLY_SAVED';
const SAVING_FAILED = 'SAVING_FAILED';

export const isSaving = (status) => SAVING === status;
export const isSuccessfullySaved = (status) => SUCCESSFULLY_SAVED === status;
export const isSavingFailed = (status) => SAVING_FAILED === status;

const supportsTarget = (target) =>
[TARGET_CLUSTER, TARGET_HOST].includes(target);

Expand Down

0 comments on commit 180bc6d

Please sign in to comment.