From 536f0c4f8351e5b8539364b036fb40a2d105ef9a Mon Sep 17 00:00:00 2001 From: Noble Mittal Date: Thu, 29 Aug 2024 13:03:22 +0530 Subject: [PATCH] VTAdmin(web): Refetch workflows after performing workflow actions Signed-off-by: Noble Mittal --- .../src/components/routes/Workflows.tsx | 9 ++++++- .../routes/workflows/WorkflowAction.tsx | 14 ++++++++++- .../routes/workflows/WorkflowActions.tsx | 25 +++++++++++++------ 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/web/vtadmin/src/components/routes/Workflows.tsx b/web/vtadmin/src/components/routes/Workflows.tsx index 477d8bcb582..558d82ab8e8 100644 --- a/web/vtadmin/src/components/routes/Workflows.tsx +++ b/web/vtadmin/src/components/routes/Workflows.tsx @@ -37,10 +37,12 @@ import { QueryLoadingPlaceholder } from '../placeholders/QueryLoadingPlaceholder import { UseQueryResult } from 'react-query'; import { ReadOnlyGate } from '../ReadOnlyGate'; import WorkflowActions from './workflows/WorkflowActions'; +import { isReadOnlyMode } from '../../util/env'; export const ThrottleThresholdSeconds = 60; const COLUMNS = ['Workflow', 'Source', 'Target', 'Streams', 'Last Updated', 'Actions']; +const READ_ONLY_COLUMNS = ['Workflow', 'Source', 'Target', 'Streams', 'Last Updated']; export const Workflows = () => { useDocumentTitle('Workflows'); @@ -188,6 +190,7 @@ export const Workflows = () => { { value={filter || ''} /> - + diff --git a/web/vtadmin/src/components/routes/workflows/WorkflowAction.tsx b/web/vtadmin/src/components/routes/workflows/WorkflowAction.tsx index 707ae6a3f7b..8ff08801dff 100644 --- a/web/vtadmin/src/components/routes/workflows/WorkflowAction.tsx +++ b/web/vtadmin/src/components/routes/workflows/WorkflowAction.tsx @@ -14,6 +14,7 @@ interface WorkflowActionProps { description?: string; body?: JSX.Element; successBody?: JSX.Element; + refetchWorkflows: Function; closeDialog: () => void; } @@ -28,6 +29,7 @@ const WorkflowAction: React.FC = ({ successBody, loadingText, errorText, + refetchWorkflows, body, }) => { const onCloseDialog = () => { @@ -36,12 +38,22 @@ const WorkflowAction: React.FC = ({ }; const hasRun = mutation.data || mutation.error; + const onConfirm = () => { + mutation.mutate( + {}, + { + onSuccess: () => { + refetchWorkflows(); + }, + } + ); + }; return ( = ({ keyspace, clusterID, name }) => { +const WorkflowActions: React.FC = ({ refetchWorkflows, keyspace, clusterID, name }) => { const [currentDialog, setCurrentDialog] = useState(''); const closeDialog = () => setCurrentDialog(''); @@ -27,14 +28,14 @@ const WorkflowActions: React.FC = ({ keyspace, clusterID, {startWorkflowMutation.data && startWorkflowMutation.data.summary && ( @@ -42,17 +43,22 @@ const WorkflowActions: React.FC = ({ keyspace, clusterID, )} } + body={ +
+ Starts the {name} workflow. +
+ } /> {stopWorkflowMutation.data && stopWorkflowMutation.data.summary && ( @@ -60,6 +66,11 @@ const WorkflowActions: React.FC = ({ keyspace, clusterID, )} } + body={ +
+ Stops the {name} workflow. +
+ } /> );