[ARVADOS-WORKBENCH2] created: 1.3.0-352-g0bc3340c

Git user git at public.curoverse.com
Tue Feb 5 09:00:00 EST 2019


        at  0bc3340cdc59ede7a02552bcc9f22890f0ef4f91 (commit)


commit 0bc3340cdc59ede7a02552bcc9f22890f0ef4f91
Author: Pawel Kowalczyk <pawel.kowalczyk at contractors.roche.com>
Date:   Tue Feb 5 14:59:44 2019 +0100

    cancel-running-workflow
    
    Feature #14721
    
    Arvados-DCO-1.1-Signed-off-by: Pawel Kowalczyk <pawel.kowalczyk at contractors.roche.com>

diff --git a/src/store/processes/processes-actions.ts b/src/store/processes/processes-actions.ts
index 2c7b8cff..65a9a24c 100644
--- a/src/store/processes/processes-actions.ts
+++ b/src/store/processes/processes-actions.ts
@@ -67,6 +67,16 @@ export const loadContainers = (filters: string) =>
         return items;
     };
 
+export const cancelRunningWorkflow = (uuid: string) =>
+    async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+        try {
+            const process = await services.containerRequestService.update(uuid, { priority: 0 });
+            return process;
+        } catch (e) {
+            throw new Error('Could not cancel the process.');
+        }
+    };
+
 export const reRunProcess = (processUuid: string, workflowUuid: string) =>
     (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
         const process = getResource<any>(processUuid)(getState().resources);
@@ -81,15 +91,15 @@ export const reRunProcess = (processUuid: string, workflowUuid: string) =>
             const basicInitialData: RunProcessBasicFormData = { name: `Copy of: ${process.name}`, description: process.description };
             dispatch<any>(initialize(RUN_PROCESS_BASIC_FORM, basicInitialData));
 
-            const advancedInitialData: RunProcessAdvancedFormData = { 
-                output: process.outputName, 
-                runtime: process.schedulingParameters.maxRunTime, 
+            const advancedInitialData: RunProcessAdvancedFormData = {
+                output: process.outputName,
+                runtime: process.schedulingParameters.maxRunTime,
                 ram: process.runtimeConstraints.ram,
                 vcpus: process.runtimeConstraints.vcpus,
                 keepCacheRam: process.runtimeConstraints.keepCacheRam,
                 api: process.runtimeConstraints.API
-             };
-             dispatch<any>(initialize(RUN_PROCESS_ADVANCED_FORM, advancedInitialData));
+            };
+            dispatch<any>(initialize(RUN_PROCESS_ADVANCED_FORM, advancedInitialData));
 
             dispatch<any>(navigateToRunProcess);
             dispatch<any>(goToStep(1));
diff --git a/src/views/process-panel/process-information-card.tsx b/src/views/process-panel/process-information-card.tsx
index db0769f1..8754768b 100644
--- a/src/views/process-panel/process-information-card.tsx
+++ b/src/views/process-panel/process-information-card.tsx
@@ -14,8 +14,9 @@ import { Process } from '~/store/processes/process';
 import { getProcessStatus, getProcessStatusColor } from '~/store/processes/process';
 import { formatDate } from '~/common/formatters';
 import * as classNames from 'classnames';
+import { ContainerState } from '~/models/container';
 
-type CssRules = 'card' | 'iconHeader' | 'label' | 'value' | 'chip' | 'link' | 'content' | 'title' | 'avatar';
+type CssRules = 'card' | 'iconHeader' | 'label' | 'value' | 'chip' | 'link' | 'content' | 'title' | 'avatar' | 'cancelButton';
 
 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
     card: {
@@ -62,6 +63,14 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
     title: {
         overflow: 'hidden',
         paddingTop: theme.spacing.unit * 0.5
+    },
+    cancelButton: {
+        paddingRight: theme.spacing.unit * 2,
+        fontSize: '14px',
+        color: theme.customs.colors.red900,
+        "&:hover": {
+            cursor: 'pointer'
+        }
     }
 });
 
@@ -71,12 +80,13 @@ export interface ProcessInformationCardDataProps {
     openProcessInputDialog: (uuid: string) => void;
     navigateToOutput: (uuid: string) => void;
     openWorkflow: (uuid: string) => void;
+    cancelProcess: (uuid: string) => void;
 }
 
 type ProcessInformationCardProps = ProcessInformationCardDataProps & WithStyles<CssRules, true>;
 
 export const ProcessInformationCard = withStyles(styles, { withTheme: true })(
-    ({ classes, process, onContextMenu, theme, openProcessInputDialog, navigateToOutput, openWorkflow }: ProcessInformationCardProps) => {
+    ({ classes, process, onContextMenu, theme, openProcessInputDialog, navigateToOutput, openWorkflow, cancelProcess }: ProcessInformationCardProps) => {
         const { container } = process;
         const startedAt = container ? formatDate(container.startedAt) : 'N/A';
         const finishedAt = container ? formatDate(container.finishedAt) : 'N/A';
@@ -89,6 +99,8 @@ export const ProcessInformationCard = withStyles(styles, { withTheme: true })(
                 avatar={<ProcessIcon className={classes.iconHeader} />}
                 action={
                     <div>
+                        {process.container && process.container.state === ContainerState.RUNNING &&
+                            <span className={classes.cancelButton} onClick={() => cancelProcess(process.containerRequest.uuid)}>Cancel</span>}
                         <Chip label={getProcessStatus(process)}
                             className={classes.chip}
                             style={{ backgroundColor: getProcessStatusColor(getProcessStatus(process), theme as ArvadosTheme) }} />
@@ -125,8 +137,8 @@ export const ProcessInformationCard = withStyles(styles, { withTheme: true })(
                             value={process.container ? formatDate(finishedAt) : 'N/A'} />
                         {process.containerRequest.properties.workflowUuid &&
                             <span onClick={() => openWorkflow(process.containerRequest.properties.workflowUuid)}>
-                                <DetailsAttribute classLabel={classes.label} classValue={classNames(classes.value, classes.link)} 
-                                label='Workflow' value={process.containerRequest.properties.workflowName}/>
+                                <DetailsAttribute classLabel={classes.label} classValue={classNames(classes.value, classes.link)}
+                                    label='Workflow' value={process.containerRequest.properties.workflowName} />
                             </span>}
                     </Grid>
                     <Grid item xs={6}>
diff --git a/src/views/process-panel/process-panel-root.tsx b/src/views/process-panel/process-panel-root.tsx
index eb8440f3..63b6aa4d 100644
--- a/src/views/process-panel/process-panel-root.tsx
+++ b/src/views/process-panel/process-panel-root.tsx
@@ -25,6 +25,7 @@ export interface ProcessPanelRootActionProps {
     openProcessInputDialog: (uuid: string) => void;
     navigateToOutput: (uuid: string) => void;
     navigateToWorkflow: (uuid: string) => void;
+    cancelProcess: (uuid: string) => void;
 }
 
 export type ProcessPanelRootProps = ProcessPanelRootDataProps & ProcessPanelRootActionProps;
@@ -39,6 +40,7 @@ export const ProcessPanelRoot = ({ process, ...props }: ProcessPanelRootProps) =
                     openProcessInputDialog={props.openProcessInputDialog}
                     navigateToOutput={props.navigateToOutput}
                     openWorkflow={props.navigateToWorkflow}
+                    cancelProcess={props.cancelProcess}
             />
             </Grid>
             <Grid item sm={12} md={5}>
diff --git a/src/views/process-panel/process-panel.tsx b/src/views/process-panel/process-panel.tsx
index b3895280..34215f88 100644
--- a/src/views/process-panel/process-panel.tsx
+++ b/src/views/process-panel/process-panel.tsx
@@ -13,6 +13,7 @@ import { ProcessPanel as ProcessPanelState} from '~/store/process-panel/process-
 import { groupBy } from 'lodash';
 import { toggleProcessPanelFilter, navigateToOutput, openWorkflow } from '~/store/process-panel/process-panel-actions';
 import { openProcessInputDialog } from '~/store/processes/process-input-actions';
+import { cancelRunningWorkflow } from '~/store/processes/processes-actions';
 
 const mapStateToProps = ({ router, resources, processPanel }: RootState): ProcessPanelRootDataProps => {
     const pathname = router.location ? router.location.pathname : '';
@@ -36,7 +37,8 @@ const mapDispatchToProps = (dispatch: Dispatch): ProcessPanelRootActionProps =>
     },
     openProcessInputDialog: (uuid) => dispatch<any>(openProcessInputDialog(uuid)),
     navigateToOutput: (uuid) => dispatch<any>(navigateToOutput(uuid)),
-    navigateToWorkflow: (uuid) => dispatch<any>(openWorkflow(uuid))
+    navigateToWorkflow: (uuid) => dispatch<any>(openWorkflow(uuid)),
+    cancelProcess: (uuid) => dispatch<any>(cancelRunningWorkflow(uuid))
 });
 
 export const ProcessPanel = connect(mapStateToProps, mapDispatchToProps)(ProcessPanelRoot);
diff --git a/src/views/process-panel/process-subprocesses-card.tsx b/src/views/process-panel/process-subprocesses-card.tsx
index 7b455b67..9607f49a 100644
--- a/src/views/process-panel/process-subprocesses-card.tsx
+++ b/src/views/process-panel/process-subprocesses-card.tsx
@@ -42,7 +42,7 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
         color: theme.palette.common.white,
     },
     status: {
-        paddingTop: theme.spacing.unit * 0.5,
+        paddingTop: theme.spacing.unit * 0.75,
         color: theme.palette.common.white,
     },
     rightSideHeader: {

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list