Merge branch '16159-logout-request-with-token'
authorLucas Di Pentima <lucas@di-pentima.com.ar>
Wed, 14 Apr 2021 13:33:32 +0000 (10:33 -0300)
committerLucas Di Pentima <lucas@di-pentima.com.ar>
Wed, 14 Apr 2021 13:33:32 +0000 (10:33 -0300)
Closes #16159

Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas@di-pentima.com.ar>

README.md
cypress/integration/favorites.spec.js
src/services/api/filter-builder.ts
src/store/run-process-panel/run-process-panel-actions.ts
src/store/workflow-panel/workflow-panel-actions.test.ts [new file with mode: 0644]
src/store/workflow-panel/workflow-panel-actions.ts
src/views/run-process-panel/inputs/directory-input.tsx
src/views/run-process-panel/run-process-inputs-form.tsx

index f6a7e48587522f8dcf90592582dd47ca571b14e6..8bb50dbeb91c90aa06c801e8d036fa74a31578ea 100644 (file)
--- a/README.md
+++ b/README.md
@@ -17,6 +17,17 @@ Install [redux-devtools-extension](https://chrome.google.com/webstore/detail/red
 yarn start
 ```
 
+## Start project for development inside Docker container
+
+```
+make workbench2-build-image
+# (create public/config.json, see "Run time configuration" below)
+docker run -ti -v$PWD:$PWD -p 3000:3000 -w$PWD workbench2-build /bin/bash
+# (inside docker container)
+yarn install
+yarn start
+```
+
 ## Run unit tests
 ```
 make unit-tests
@@ -37,12 +48,12 @@ make integration-tests-in-docker
 ## Run tests interactively in container
 
 ```
-xhost +local:root
-ARVADOS_DIR=/path/to/arvados
-docker run -ti -v$PWD:$PWD -v$ARVADOS_DIR:/usr/src/arvados -w$PWD --env="DISPLAY" --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" workbench2-build /bin/bash
+xhost +local:root
+ARVADOS_DIR=/path/to/arvados
+docker run -ti -v$PWD:$PWD -v$ARVADOS_DIR:/usr/src/arvados -w$PWD --env="DISPLAY" --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" workbench2-build /bin/bash
 (inside container)
-yarn run cypress install
-tools/run-integration-tests.sh -i -a /usr/src/arvados
+yarn run cypress install
+tools/run-integration-tests.sh -i -a /usr/src/arvados
 ```
 
 ## Production build
index 2afdf92e5c4c11229a16009206e01027fd5e1490..c745e267174050a4c901d323d37ac0bf90921f90 100644 (file)
@@ -185,6 +185,13 @@ describe('Favorites tests', function () {
                 })
                     .as('testWorkflow');
 
+                cy.createWorkflow(adminUser.token, {
+                    name: `TestWorkflow2-${Math.floor(Math.random() * 999999)}.cwl`,
+                    definition: "{     \"$graph\": [         {             \"$namespaces\": {                 \"arv\": \"http://arvados.org/cwl#\"             },             \"class\": \"Workflow\",             \"doc\": \"Detect blurriness of WSI data.\",             \"id\": \"#main\",             \"inputs\": [                 {                     \"default\": {                         \"basename\": \"3d3cb547725e72ddb442bc620adbc342+2463\",                         \"class\": \"Directory\",                         \"location\": \"keep:3d3cb547725e72ddb442bc620adbc342+2463\"                     },                     \"doc\": \"Collection containing all pipeline input images\",                     \"id\": \"#main/image_collection\",                     \"type\": \"Directory\"                 }             ],             \"outputs\": [                 {                     \"id\": \"#main/blur_report\",                     \"outputSource\": \"#main/blurdetection/report\",                     \"type\": \"Any\"                 }             ],             \"steps\": [                 {                     \"id\": \"#main/blurdetection\",                     \"in\": [                         {                             \"id\": \"#main/blurdetection/image_collection\",                             \"source\": \"#main/image_collection\"                         }                     ],                     \"out\": [                         \"#main/blurdetection/report\"                     ],                     \"run\": \"#blurdetection.cwl\"                 }             ]         },         {             \"arguments\": [                 \"--num_workers\",                 \"0\",                 \"--wsi_dir\",                 \"$(inputs.image_collection)\",                 \"--tile_out_dir\",                 \"$(runtime.outdir)\"             ],             \"baseCommand\": [                 \"python3\",                 \"/updated_blur_on_folder.py\"             ],             \"class\": \"CommandLineTool\",             \"hints\": [                 {                     \"class\": \"DockerRequirement\",                     \"dockerPull\": \"updated_score_aws:cpu2\",                     \"http://arvados.org/cwl#dockerCollectionPDH\": \"0d6702518d1408ce2c471ffec40695cf+4924\"                 },                 {                     \"class\": \"ResourceRequirement\",                     \"coresMin\": 8,                     \"ramMin\": 20000                 },                 {                     \"class\": \"http://arvados.org/cwl#RuntimeConstraints\",                     \"keep_cache\": 2000                 }             ],             \"id\": \"#blurdetection.cwl\",             \"inputs\": [                 {                     \"doc\": \"Collection containing all pipeline input images\",                     \"id\": \"#blurdetection.cwl/image_collection\",                     \"type\": \"Directory\"                 }             ],             \"outputs\": [                 {                     \"id\": \"#blurdetection.cwl/report\",                     \"outputBinding\": {                         \"glob\": \"*.csv\"                     },                     \"type\": \"Any\"                 }             ]         }     ],     \"cwlVersion\": \"v1.0\" }",
+                    owner_uuid: myProject1.uuid,
+                })
+                    .as('testWorkflow2');
+
                 cy.contains('Shared with me').click();
 
                 cy.doSearch(`${activeUser.user.uuid}`);
@@ -204,6 +211,21 @@ describe('Favorites tests', function () {
                         cy.get('[data-cy=projects-tree-favourites-tree-picker]').contains('Favorites').closest('ul').find('i').click();
                         cy.get('@chooseFileDialog').find(`[data-id=${mySharedWritableProject.uuid}]`);
                         cy.get('@chooseFileDialog').find(`[data-id=${mySharedReadonlyProject.uuid}]`);
+                        cy.get('button').contains('Cancel').click();
+                    });
+
+                cy.get('button').contains('Back').click();
+
+                cy.get('@testWorkflow2')
+                    .then((testWorkflow2) => {
+                        cy.get('main').contains(testWorkflow2.name).click();
+                        cy.get('button').contains('Change Workflow').click();
+                        cy.get('[data-cy=run-process-next-button]').click();
+                        cy.get('[readonly]').click();
+                        cy.get('[data-cy=choose-a-directory-dialog]').as('chooseDirectoryDialog');
+                        cy.get('[data-cy=projects-tree-favourites-tree-picker]').contains('Favorites').closest('ul').find('i').click();
+                        cy.get('@chooseDirectoryDialog').find(`[data-id=${mySharedWritableProject.uuid}]`);
+                        cy.get('@chooseDirectoryDialog').find(`[data-id=${mySharedReadonlyProject.uuid}]`);
                     });
             });
     });
index 489f7b8947a4f962ce1768b57e383269b28800db..d1a4fd08b6aa5b32500c727cb1ea1acbf695fd61 100644 (file)
@@ -60,6 +60,9 @@ export class FilterBuilder {
     public addExists(value?: string, resourcePrefix?: string) {
         return this.addCondition("properties", "exists", value, "", "", resourcePrefix);
     }
+    public addDoesNotExist(field: string, resourcePrefix?: string) {
+        return this.addCondition("properties." + field, "exists", false, "", "", resourcePrefix);
+    }
 
     public addFullTextSearch(value: string) {
         const terms = value.trim().split(/(\s+)/);
index 8646164e42bbeba8957acc651295c5fa3e08d125..d9686feb4b2b7dcbe28681a6977b75cb7fd59518 100644 (file)
@@ -21,7 +21,6 @@ import {
 } from '~/views/run-process-panel/run-process-advanced-form';
 import { dialogActions } from '~/store/dialog/dialog-actions';
 import { setBreadcrumbs } from '~/store/breadcrumbs/breadcrumbs-actions';
-import { matchProjectRoute } from '~/routes/routes';
 
 export const runProcessPanelActions = unionize({
     SET_PROCESS_PATHNAME: ofType<string>(),
@@ -144,9 +143,8 @@ export const runProcess = async (dispatch: Dispatch<any>, getState: () => RootSt
     const inputsForm = getFormValues(RUN_PROCESS_INPUTS_FORM)(state) as WorkflowInputsData;
     const userUuid = getUserUuid(getState());
     if (!userUuid) { return; }
-    const pathname = getState().runProcessPanel.processPathname;
     const { processOwnerUuid, selectedWorkflow } = state.runProcessPanel;
-    const ownerUUid = !matchProjectRoute(pathname) ? userUuid : processOwnerUuid;
+    const ownerUUid = processOwnerUuid ? processOwnerUuid : userUuid;
     if (selectedWorkflow) {
         const advancedForm = getFormValues(RUN_PROCESS_ADVANCED_FORM)(state) as RunProcessAdvancedFormData || getWorkflowRunnerSettings(selectedWorkflow);
         const newProcessData = {
diff --git a/src/store/workflow-panel/workflow-panel-actions.test.ts b/src/store/workflow-panel/workflow-panel-actions.test.ts
new file mode 100644 (file)
index 0000000..4eff45d
--- /dev/null
@@ -0,0 +1,89 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { API_TOKEN_KEY } from "~/services/auth-service/auth-service";
+
+import 'jest-localstorage-mock';
+import { ServiceRepository, createServices } from "~/services/services";
+import { configureStore, RootStore } from "../store";
+import { createBrowserHistory } from "history";
+import { Config, mockConfig } from '~/common/config';
+import { ApiActions } from "~/services/api/api-actions";
+import { ACCOUNT_LINK_STATUS_KEY } from '~/services/link-account-service/link-account-service';
+import Axios from "axios";
+import MockAdapter from "axios-mock-adapter";
+import { ImportMock } from 'ts-mock-imports';
+import * as servicesModule from "~/services/services";
+import { SessionStatus } from "~/models/session";
+import { openRunProcess } from './workflow-panel-actions';
+import { runProcessPanelActions } from '~/store/run-process-panel/run-process-panel-actions';
+import { initialize } from 'redux-form';
+import { RUN_PROCESS_BASIC_FORM } from '~/views/run-process-panel/run-process-basic-form';
+import { RUN_PROCESS_INPUTS_FORM } from '~/views/run-process-panel/run-process-inputs-form';
+import { ResourceKind } from '~/models/resource';
+import { WorkflowResource } from '~/models/workflow';
+
+describe('workflow-panel-actions', () => {
+    const axiosInst = Axios.create({ headers: {} });
+    const axiosMock = new MockAdapter(axiosInst);
+
+    let store: RootStore;
+    let services: ServiceRepository;
+    const config: any = {};
+    const actions: ApiActions = {
+        progressFn: (id: string, working: boolean) => { },
+        errorFn: (id: string, message: string) => { }
+    };
+    let importMocks: any[];
+
+    beforeEach(() => {
+        axiosMock.reset();
+        services = createServices(mockConfig({}), actions, axiosInst);
+        store = configureStore(createBrowserHistory(), services, config);
+        localStorage.clear();
+        importMocks = [];
+    });
+
+    afterEach(() => {
+        importMocks.map(m => m.restore());
+    });
+
+    it('opens the run process panel', async () => {
+        const wflist: WorkflowResource[] = [{
+            uuid: "zzzzz-7fd4e-0123456789abcde",
+            name: "foo",
+            description: "",
+            definition: "$graph: []",
+            kind: ResourceKind.WORKFLOW,
+            ownerUuid: "",
+            createdAt: "",
+            modifiedByClientUuid: "",
+            modifiedByUserUuid: "",
+            modifiedAt: "",
+            href: "",
+            etag: ""
+        }];
+        axiosMock
+            .onGet("/workflows")
+            .reply(200, {
+                items: wflist
+            }).onGet("/links")
+            .reply(200, {
+                items: []
+            });
+
+        const dispatchMock = jest.fn();
+        const dispatchWrapper = (action: any) => {
+            dispatchMock(action);
+            return store.dispatch(action);
+        };
+
+        await openRunProcess("zzzzz-7fd4e-0123456789abcde", "zzzzz-tpzed-0123456789abcde", "testing", { inputparm: "value" })(dispatchWrapper, store.getState, services);
+        expect(dispatchMock).toHaveBeenCalledWith(runProcessPanelActions.SET_WORKFLOWS(wflist));
+        expect(dispatchMock).toHaveBeenCalledWith(runProcessPanelActions.SET_SELECTED_WORKFLOW(wflist[0]));
+        expect(dispatchMock).toHaveBeenCalledWith(runProcessPanelActions.SET_PROCESS_OWNER_UUID("zzzzz-tpzed-0123456789abcde"));
+        expect(dispatchMock).toHaveBeenCalledWith(initialize(RUN_PROCESS_BASIC_FORM, { name: "testing" }));
+        expect(dispatchMock).toHaveBeenCalledWith(initialize(RUN_PROCESS_INPUTS_FORM, { inputparm: "value" }));
+    });
+});
index 4cfcd8b9445e448741d27abb43ae77c47b3d3c6f..b48252093b42ddfe823ad77a620de2942bbe6365 100644 (file)
@@ -12,6 +12,8 @@ import { navigateToRunProcess } from '~/store/navigation/navigation-action';
 import { goToStep, runProcessPanelActions, loadPresets, getWorkflowRunnerSettings } from '~/store/run-process-panel/run-process-panel-actions';
 import { snackbarActions } from '~/store/snackbar/snackbar-actions';
 import { initialize } from 'redux-form';
+import { RUN_PROCESS_BASIC_FORM } from '~/views/run-process-panel/run-process-basic-form';
+import { RUN_PROCESS_INPUTS_FORM } from '~/views/run-process-panel/run-process-inputs-form';
 import { RUN_PROCESS_ADVANCED_FORM } from '~/views/run-process-panel/run-process-advanced-form';
 
 export const WORKFLOW_PANEL_ID = "workflowPanel";
@@ -33,17 +35,30 @@ export const getUuidPrefix = (state: RootState) => {
     return state.properties.uuidPrefix;
 };
 
-export const openRunProcess = (uuid: string) =>
-    (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+export const openRunProcess = (workflowUuid: string, ownerUuid?: string, name?: string, inputObj?: { [key: string]: any }) =>
+    async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+        const response = await services.workflowService.list();
+        dispatch(runProcessPanelActions.SET_WORKFLOWS(response.items));
+
         const workflows = getState().runProcessPanel.searchWorkflows;
-        const workflow = workflows.find(workflow => workflow.uuid === uuid);
+        const workflow = workflows.find(workflow => workflow.uuid === workflowUuid);
         if (workflow) {
             dispatch<any>(navigateToRunProcess);
             dispatch<any>(goToStep(1));
             dispatch(runProcessPanelActions.SET_STEP_CHANGED(true));
             dispatch(runProcessPanelActions.SET_SELECTED_WORKFLOW(workflow));
             dispatch<any>(loadPresets(workflow.uuid));
+
             dispatch(initialize(RUN_PROCESS_ADVANCED_FORM, getWorkflowRunnerSettings(workflow)));
+            if (ownerUuid) {
+                dispatch(runProcessPanelActions.SET_PROCESS_OWNER_UUID(ownerUuid));
+            }
+            if (name) {
+                dispatch(initialize(RUN_PROCESS_BASIC_FORM, { name }));
+            }
+            if (inputObj) {
+                dispatch(initialize(RUN_PROCESS_INPUTS_FORM, inputObj));
+            }
         } else {
             dispatch<any>(snackbarActions.OPEN_SNACKBAR({ message: `You can't run this process` }));
         }
index 29ccd6e0ddf7d544855840fd2420fcba78e90135..f687e28dcb2afc1a96ec0fca2ba0a1c152caceca 100644 (file)
@@ -24,14 +24,18 @@ import { ERROR_MESSAGE } from '~/validators/require';
 
 export interface DirectoryInputProps {
     input: DirectoryCommandInputParameter;
+    options?: { showOnlyOwned: boolean, showOnlyWritable: boolean };
 }
-export const DirectoryInput = ({ input }: DirectoryInputProps) =>
+export const DirectoryInput = ({ input, options }: DirectoryInputProps) =>
     <Field
         name={input.id}
         commandInput={input}
         component={DirectoryInputComponent}
         format={format}
         parse={parse}
+        {...{
+            options
+        }}
         validate={getValidation(input)} />;
 
 const format = (value?: Directory) => value ? value.basename : '';
@@ -56,7 +60,9 @@ interface DirectoryInputComponentState {
 }
 
 const DirectoryInputComponent = connect()(
-    class FileInputComponent extends React.Component<GenericInputProps & DispatchProp, DirectoryInputComponentState> {
+    class FileInputComponent extends React.Component<GenericInputProps & DispatchProp & {
+        options?: { showOnlyOwned: boolean, showOnlyWritable: boolean };
+    }, DirectoryInputComponentState> {
         state: DirectoryInputComponentState = {
             open: false,
         };
@@ -113,12 +119,14 @@ const DirectoryInputComponent = connect()(
                 open={this.state.open}
                 onClose={this.closeDialog}
                 fullWidth
+                data-cy="choose-a-directory-dialog"
                 maxWidth='md'>
                 <DialogTitle>Choose a directory</DialogTitle>
                 <DialogContent>
                     <ProjectsTreePicker
                         pickerId={this.props.commandInput.id}
                         includeCollections
+                        options={this.props.options}
                         toggleItemActive={this.setDirectory} />
                 </DialogContent>
                 <DialogActions>
index 3a0afd34868c91fc7ce86727b84f3e7112e7f9b8..e6a504dbb8d2e9852cde01920d9b4398096f2c36 100644 (file)
@@ -92,7 +92,7 @@ const getInputComponent = (input: CommandInputParameter) => {
             return <FileInput options={{ showOnlyOwned: false, showOnlyWritable: false }} input={input as FileCommandInputParameter} />;
 
         case isPrimitiveOfType(input, CWLType.DIRECTORY):
-            return <DirectoryInput input={input as DirectoryCommandInputParameter} />;
+            return <DirectoryInput options={{ showOnlyOwned: false, showOnlyWritable: false }} input={input as DirectoryCommandInputParameter} />;
 
         case typeof input.type === 'object' &&
             !(input.type instanceof Array) &&