[arvados-workbench2] updated: 2.4.0-72-g46c5d0d6

git repository hosting git at public.arvados.org
Tue May 24 17:55:30 UTC 2022


Summary of changes:
 .../run-process-panel/run-process-panel-actions.ts  |  6 +++++-
 src/store/workflow-panel/workflow-panel-actions.ts  | 10 +++++++++-
 .../run-process-panel/inputs/project-input.tsx      | 21 +++++++++++++++++----
 .../run-process-panel/run-process-basic-form.tsx    |  4 ++--
 4 files changed, 33 insertions(+), 8 deletions(-)

       via  46c5d0d6ab1e39af6a8c12a7d620e0b03cde8a53 (commit)
      from  2129d2a8fc553a0e89b374bdad2226ff3b3d377e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 46c5d0d6ab1e39af6a8c12a7d620e0b03cde8a53
Author: Peter Amstutz <peter.amstutz at curii.com>
Date:   Tue May 24 11:31:00 2022 -0400

    19143: Checks that project is writable when selecting workflow
    
    Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz at curii.com>

diff --git a/src/store/run-process-panel/run-process-panel-actions.ts b/src/store/run-process-panel/run-process-panel-actions.ts
index 95bac0c2..e0dada5c 100644
--- a/src/store/run-process-panel/run-process-panel-actions.ts
+++ b/src/store/run-process-panel/run-process-panel-actions.ts
@@ -102,7 +102,11 @@ export const setWorkflow = (workflow: WorkflowResource, isWorkflowChanged = true
 
         const advancedFormValues = getWorkflowRunnerSettings(workflow);
 
-        const owner = getResource<ProjectResource | UserResource>(getState().runProcessPanel.processOwnerUuid)(getState().resources);
+        let owner = getResource<ProjectResource | UserResource>(getState().runProcessPanel.processOwnerUuid)(getState().resources);
+        const userUuid = getUserUuid(getState());
+        if (!owner || !userUuid || owner.writableBy.indexOf(userUuid) === -1) {
+            owner = undefined;
+        }
 
         if (isStepChanged && isWorkflowChanged) {
             dispatch(runProcessPanelActions.SET_STEP_CHANGED(false));
diff --git a/src/store/workflow-panel/workflow-panel-actions.ts b/src/store/workflow-panel/workflow-panel-actions.ts
index 85f0b9bc..7c90fa6b 100644
--- a/src/store/workflow-panel/workflow-panel-actions.ts
+++ b/src/store/workflow-panel/workflow-panel-actions.ts
@@ -18,6 +18,7 @@ import { RUN_PROCESS_ADVANCED_FORM } from 'views/run-process-panel/run-process-a
 import { getResource, ResourcesState } from 'store/resources/resources';
 import { ProjectResource } from 'models/project';
 import { UserResource } from 'models/user';
+import { getUserUuid } from "common/getuser";
 
 export const WORKFLOW_PANEL_ID = "workflowPanel";
 const UUID_PREFIX_PROPERTY_NAME = 'uuidPrefix';
@@ -55,8 +56,15 @@ export const openRunProcess = (workflowUuid: string, ownerUuid?: string, name?:
             dispatch(initialize(RUN_PROCESS_ADVANCED_FORM, getWorkflowRunnerSettings(workflow)));
             let owner;
             if (ownerUuid) {
-                dispatch(runProcessPanelActions.SET_PROCESS_OWNER_UUID(ownerUuid));
+                // Must be writable.
+                const userUuid = getUserUuid(getState());
                 owner = getResource<ProjectResource | UserResource>(ownerUuid)(getState().resources);
+                if (!owner || !userUuid || owner.writableBy.indexOf(userUuid) === -1) {
+                    owner = undefined;
+                }
+            }
+            if (owner) {
+                dispatch(runProcessPanelActions.SET_PROCESS_OWNER_UUID(owner.uuid));
             }
 
             dispatch(initialize(RUN_PROCESS_BASIC_FORM, { name, owner }));
diff --git a/src/views/run-process-panel/inputs/project-input.tsx b/src/views/run-process-panel/inputs/project-input.tsx
index 95f3ad89..7b45a6d1 100644
--- a/src/views/run-process-panel/inputs/project-input.tsx
+++ b/src/views/run-process-panel/inputs/project-input.tsx
@@ -4,7 +4,7 @@
 
 import React from 'react';
 import { connect, DispatchProp } from 'react-redux';
-import { Field, WrappedFieldProps } from 'redux-form';
+import { Field } from 'redux-form';
 import { Input, Dialog, DialogTitle, DialogContent, DialogActions, Button } from '@material-ui/core';
 import {
     GenericCommandInputParameter
@@ -16,9 +16,13 @@ import { TreeItem } from 'components/tree/tree';
 import { ProjectsTreePickerItem } from 'views-components/projects-tree-picker/generic-projects-tree-picker';
 import { ProjectResource } from 'models/project';
 import { ResourceKind } from 'models/resource';
+import { RootState } from 'store/store';
+import { getUserUuid } from 'common/getuser';
 
 export type ProjectCommandInputParameter = GenericCommandInputParameter<ProjectResource, ProjectResource>;
 
+const require: any = (value?: ProjectResource) => (value === undefined);
+
 export interface ProjectInputProps {
     input: ProjectCommandInputParameter;
     options?: { showOnlyOwned: boolean, showOnlyWritable: boolean };
@@ -29,6 +33,7 @@ export const ProjectInput = ({ input, options }: ProjectInputProps) =>
         commandInput={input}
         component={ProjectInputComponent as any}
         format={format}
+        validate={require}
         {...{
             options
         }} />;
@@ -40,8 +45,14 @@ interface ProjectInputComponentState {
     project?: ProjectResource;
 }
 
-export const ProjectInputComponent = connect()(
-    class ProjectInputComponent extends React.Component<GenericInputProps & DispatchProp & {
+interface HasUserUuid {
+    userUuid: string;
+};
+
+const mapStateToProps = (state: RootState) => ({ userUuid: getUserUuid(state) });
+
+export const ProjectInputComponent = connect(mapStateToProps)(
+    class ProjectInputComponent extends React.Component<GenericInputProps & DispatchProp & HasUserUuid & {
         options?: { showOnlyOwned: boolean, showOnlyWritable: boolean };
     }, ProjectInputComponentState> {
         state: ProjectInputComponentState = {
@@ -81,6 +92,8 @@ export const ProjectInputComponent = connect()(
             }
         }
 
+        invalid = () => (!this.state.project || this.state.project.writableBy.indexOf(this.props.userUuid) === -1);
+
         renderInput() {
             return <GenericInput
                 component={props =>
@@ -112,7 +125,7 @@ export const ProjectInputComponent = connect()(
                 <DialogActions>
                     <Button onClick={this.closeDialog}>Cancel</Button>
                     <Button
-                        disabled={!this.state.project}
+                        disabled={this.invalid()}
                         variant='contained'
                         color='primary'
                         onClick={this.submit}>Ok</Button>
diff --git a/src/views/run-process-panel/run-process-basic-form.tsx b/src/views/run-process-panel/run-process-basic-form.tsx
index a8005ad2..32a126a4 100644
--- a/src/views/run-process-panel/run-process-basic-form.tsx
+++ b/src/views/run-process-panel/run-process-basic-form.tsx
@@ -29,7 +29,7 @@ export const RunProcessBasicForm =
                     <Field
                         name='name'
                         component={TextField as any}
-                        label="Enter a new name for run process"
+                        label="Name for this workflow run"
                         required
                         validate={PROCESS_NAME_VALIDATION} />
                 </Grid>
@@ -37,7 +37,7 @@ export const RunProcessBasicForm =
                     <Field
                         name='description'
                         component={TextField as any}
-                        label="Enter a description for run process" />
+                        label="Optional description of this workflow run" />
                 </Grid>
                 <Grid item xs={12} md={6}>
                     <ProjectInput input={{

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list