Skip to content

Commit

Permalink
Refactor checks suggestion to take a callback when starting checks
Browse files Browse the repository at this point in the history
execution
  • Loading branch information
dottorblaster committed Jan 16, 2023
1 parent a242d21 commit 0b119f6
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 16 deletions.
16 changes: 11 additions & 5 deletions assets/js/components/ClusterDetails/ChecksSelection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
import React, { useState, useEffect } from 'react';
import { useSelector, useDispatch } from 'react-redux';

import ReactMarkdown from 'react-markdown';
import remarkGfm from 'remark-gfm';

import { Disclosure, Switch, Transition } from '@headlessui/react';

import {
Expand All @@ -12,14 +15,14 @@ import {
import classNames from 'classnames';
import { remove, uniq } from '@lib/lists';

import ReactMarkdown from 'react-markdown';
import remarkGfm from 'remark-gfm';
import LoadingBox from '@components/LoadingBox';
import NotificationBox from '@components/NotificationBox';
import { executionRequested } from '@state/actions/lastExecutions';

import {
SavingFailedAlert,
SuggestTriggeringChecksExecutionAfterSettingsUpdated,
} from './ClusterSettings';
import LoadingBox from '../LoadingBox';
import NotificationBox from '../NotificationBox';

const toggle = (list, element) =>
list.includes(element)
Expand Down Expand Up @@ -293,9 +296,12 @@ export function ChecksSelection({ clusterId, cluster }) {
)}
{localSavingSuccess && selectedChecks.length > 0 && (
<SuggestTriggeringChecksExecutionAfterSettingsUpdated
cluster={cluster}
clusterId={clusterId}
selectedChecks={selectedChecks}
onClose={() => setLocalSavingSuccess(null)}
onStartExecution={(clusterID, hosts, checks) =>
dispatch(executionRequested(clusterID, hosts, checks))
}
/>
)}
</div>
Expand Down
4 changes: 2 additions & 2 deletions assets/js/components/ClusterDetails/ClusterDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ function ClusterDetails() {

const checkResults = useChecksResult(cluster);
const dispatch = useDispatch();
const onStartExecution = (clusterId, hosts, selectedChecks) => {
dispatch(executionRequested(clusterId, hosts, selectedChecks));
const onStartExecution = (_, hosts, selectedChecks) => {
dispatch(executionRequested(clusterID, hosts, selectedChecks));
};
const hosts = useSelector(getClusterHostIDs(clusterID));
const hostsData = useSelector((state) =>
Expand Down
4 changes: 2 additions & 2 deletions assets/js/components/ClusterDetails/ClusterDetailsNew.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ export function ClusterDetailsNew() {
usingNewChecksEngine
hosts={hosts}
checks={cluster.selected_checks}
onStartExecution={(clusterId, hostList, selectedChecks) =>
dispatch(executionRequested(clusterId, hostList, selectedChecks))
onStartExecution={(_, hostList, selectedChecks) =>
dispatch(executionRequested(clusterID, hostList, selectedChecks))
}
>
<EOS_PLAY_CIRCLE
Expand Down
6 changes: 4 additions & 2 deletions assets/js/components/ClusterDetails/ClusterSettings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,11 @@ export function SavingFailedAlert({ onClose = () => {}, children }) {
}

export function SuggestTriggeringChecksExecutionAfterSettingsUpdated({
cluster,
clusterId,
usingNewChecksEngine = false,
selectedChecks,
onClose = () => {},
onStartExecution = () => {},
}) {
return (
<div>
Expand All @@ -134,7 +135,8 @@ export function SuggestTriggeringChecksExecutionAfterSettingsUpdated({
clusterId={clusterId}
usingNewChecksEngine={usingNewChecksEngine}
hosts={useSelector(getClusterHostIDs(clusterId))}
checks={cluster.selected_checks}
checks={selectedChecks}
onStartExecution={onStartExecution}
>
<EOS_PLAY_CIRCLE color="green" />
</TriggerChecksExecutionRequest>
Expand Down
15 changes: 10 additions & 5 deletions assets/js/components/ClusterDetails/ConnectionSettings.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { EOS_ERROR, EOS_LOADING_ANIMATED } from 'eos-icons-react';
import React, { useEffect, useState } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import Table from '@components/Table';
import classNames from 'classnames';
import { Switch } from '@headlessui/react';

import classNames from 'classnames';
import NotificationBox from '../NotificationBox';
import LoadingBox from '../LoadingBox';
import Table from '@components/Table';
import NotificationBox from '@components/NotificationBox';
import LoadingBox from '@components/LoadingBox';
import { executionRequested } from '@state/actions/lastExecutions';

import {
SavingFailedAlert,
SuggestTriggeringChecksExecutionAfterSettingsUpdated,
Expand Down Expand Up @@ -182,9 +184,12 @@ export function ConnectionSettings({ clusterId, cluster }) {
)}
{localSavingSuccess && cluster.selected_checks.length > 0 && (
<SuggestTriggeringChecksExecutionAfterSettingsUpdated
cluster={cluster}
clusterId={clusterId}
selectedChecks={cluster.selected_checks}
onClose={() => setLocalSavingSuccess(null)}
onStartExecution={(clusterID, hosts, checks) =>
dispatch(executionRequested(clusterID, hosts, checks))
}
/>
)}
</div>
Expand Down

0 comments on commit 0b119f6

Please sign in to comment.