[ARVADOS-WORKBENCH2] updated: 1.2.0-684-g63984c0

Git user git at public.curoverse.com
Wed Oct 17 11:43:50 EDT 2018


Summary of changes:
 src/store/collections/collection-create-actions.ts | 10 +++++--
 src/store/projects/project-create-actions.ts       | 29 ++++++++++++++++++--
 .../run-process-panel/run-process-panel-actions.ts |  4 ++-
 .../side-panel-button/side-panel-button.tsx        | 31 +++-------------------
 4 files changed, 41 insertions(+), 33 deletions(-)

       via  63984c0aeb05466a9561ac0ef2c0e9947430166b (commit)
      from  29831e16142dd0d5e529e76f6849068dd917e02c (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 63984c0aeb05466a9561ac0ef2c0e9947430166b
Author: Pawel Kowalczyk <pawel.kowalczyk at contractors.roche.com>
Date:   Wed Oct 17 17:43:35 2018 +0200

    show-new-button-any-route
    
    Feature #14318
    
    Arvados-DCO-1.1-Signed-off-by: Pawel Kowalczyk <pawel.kowalczyk at contractors.roche.com>

diff --git a/src/store/collections/collection-create-actions.ts b/src/store/collections/collection-create-actions.ts
index 7f21887..c42b4ef 100644
--- a/src/store/collections/collection-create-actions.ts
+++ b/src/store/collections/collection-create-actions.ts
@@ -11,6 +11,7 @@ import { getCommonResourceServiceError, CommonResourceServiceError } from "~/ser
 import { uploadCollectionFiles } from './collection-upload-actions';
 import { fileUploaderActions } from '~/store/file-uploader/file-uploader-actions';
 import { progressIndicatorActions } from "~/store/progress-indicator/progress-indicator-actions";
+import { isItemNotInProject, isProjectRoute } from '~/store/projects/project-create-actions';
 
 export interface CollectionCreateFormDialogData {
     ownerUuid: string;
@@ -21,8 +22,13 @@ export interface CollectionCreateFormDialogData {
 export const COLLECTION_CREATE_FORM_NAME = "collectionCreateFormName";
 
 export const openCollectionCreateDialog = (ownerUuid: string) =>
-    (dispatch: Dispatch) => {
-        dispatch(initialize(COLLECTION_CREATE_FORM_NAME, { ownerUuid }));
+    (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+        if (isItemNotInProject || !isProjectRoute) {
+            const userUuid = getState().auth.user!.uuid;
+            dispatch(initialize(COLLECTION_CREATE_FORM_NAME, { userUuid }));
+        } else {
+            dispatch(initialize(COLLECTION_CREATE_FORM_NAME, { ownerUuid }));
+        }
         dispatch(fileUploaderActions.CLEAR_UPLOAD());
         dispatch(dialogActions.OPEN_DIALOG({ id: COLLECTION_CREATE_FORM_NAME, data: { ownerUuid } }));
     };
diff --git a/src/store/projects/project-create-actions.ts b/src/store/projects/project-create-actions.ts
index 6d704c2..741ebfb 100644
--- a/src/store/projects/project-create-actions.ts
+++ b/src/store/projects/project-create-actions.ts
@@ -9,6 +9,7 @@ import { dialogActions } from "~/store/dialog/dialog-actions";
 import { getCommonResourceServiceError, CommonResourceServiceError } from '~/services/common-service/common-resource-service';
 import { ProjectResource } from '~/models/project';
 import { ServiceRepository } from '~/services/services';
+import { matchProjectRoute } from '~/routes/routes';
 
 export interface ProjectCreateFormDialogData {
     ownerUuid: string;
@@ -18,9 +19,33 @@ export interface ProjectCreateFormDialogData {
 
 export const PROJECT_CREATE_FORM_NAME = 'projectCreateFormName';
 
+export const isProjectRoute = ({ router }: RootState) => {
+    const pathname = router.location ? router.location.pathname : '';
+    const match = matchProjectRoute(pathname);
+    return !!match;
+};
+
+interface Properties {
+    breadcrumbs: Array<{ uuid: string, label: string }>;
+}
+
+export const isItemNotInProject = (properties: Properties) => {
+    if (properties.breadcrumbs) {
+        const isItemSharedWithMe = properties.breadcrumbs[0].label !== 'Projects';
+        return isItemSharedWithMe;
+    } else {
+        return false;
+    }
+};
+
 export const openProjectCreateDialog = (ownerUuid: string) =>
-    (dispatch: Dispatch) => {
-        dispatch(initialize(PROJECT_CREATE_FORM_NAME, { ownerUuid }));
+    (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+        if (isItemNotInProject || !isProjectRoute) {
+            const userUuid = getState().auth.user!.uuid;
+            dispatch(initialize(PROJECT_CREATE_FORM_NAME, { userUuid }));
+        } else {
+            dispatch(initialize(PROJECT_CREATE_FORM_NAME, { ownerUuid }));
+        }        
         dispatch(dialogActions.OPEN_DIALOG({ id: PROJECT_CREATE_FORM_NAME, data: {} }));
     };
 
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 7112f71..0256573 100644
--- a/src/store/run-process-panel/run-process-panel-actions.ts
+++ b/src/store/run-process-panel/run-process-panel-actions.ts
@@ -15,6 +15,7 @@ import { createWorkflowMounts } from '~/models/process';
 import { ContainerRequestState } from '~/models/container-request';
 import { navigateToProcess } from '../navigation/navigation-action';
 import { RunProcessAdvancedFormData, RUN_PROCESS_ADVANCED_FORM } from '~/views/run-process-panel/run-process-advanced-form';
+import { isItemNotInProject, isProjectRoute } from '~/store/projects/project-create-actions';
 
 export const runProcessPanelActions = unionize({
     SET_PROCESS_OWNER_UUID: ofType<string>(),
@@ -55,10 +56,11 @@ export const runProcess = async (dispatch: Dispatch<any>, getState: () => RootSt
     const basicForm = getFormValues(RUN_PROCESS_BASIC_FORM)(state) as RunProcessBasicFormData;
     const inputsForm = getFormValues(RUN_PROCESS_INPUTS_FORM)(state) as WorkflowInputsData;
     const advancedForm = getFormValues(RUN_PROCESS_ADVANCED_FORM)(state) as RunProcessAdvancedFormData;
+    const userUuid = getState().auth.user!.uuid;
     const { processOwnerUuid, selectedWorkflow } = state.runProcessPanel;
     if (selectedWorkflow) {
         const newProcessData = {
-            ownerUuid: processOwnerUuid,
+            ownerUuid: isItemNotInProject || !isProjectRoute ? userUuid : processOwnerUuid,
             name: basicForm.name,
             description: basicForm.description,
             state: ContainerRequestState.COMMITTED,
diff --git a/src/views-components/side-panel-button/side-panel-button.tsx b/src/views-components/side-panel-button/side-panel-button.tsx
index b4784bf..61e72d0 100644
--- a/src/views-components/side-panel-button/side-panel-button.tsx
+++ b/src/views-components/side-panel-button/side-panel-button.tsx
@@ -13,7 +13,6 @@ import { StyleRulesCallback, WithStyles, withStyles, Toolbar, Grid, Button, Menu
 import { AddIcon, CollectionIcon, ProcessIcon, ProjectIcon } from '~/components/icon/icon';
 import { openProjectCreateDialog } from '~/store/projects/project-create-actions';
 import { openCollectionCreateDialog } from '~/store/collections/collection-create-actions';
-import { matchProjectRoute } from '~/routes/routes';
 import { navigateToRunProcess } from '~/store/navigation/navigation-action';
 import { runProcessPanelActions } from '~/store/run-process-panel/run-process-panel-actions';
 
@@ -36,12 +35,6 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
 
 interface SidePanelDataProps {
     currentItemId: string;
-    isProjectRoute: boolean;
-    properties: Properties;
-}
-
-interface Properties {
-    breadcrumbs: Array<{uuid: string, label: string}>;
 }
 
 interface SidePanelState {
@@ -55,26 +48,9 @@ const transformOrigin: PopoverOrigin = {
     horizontal: 0
 };
 
-const isProjectRoute = ({ router }: RootState) => {
-    const pathname = router.location ? router.location.pathname : '';
-    const match = matchProjectRoute(pathname);
-    return !!match;
-};
-
-const isItemSharedWithMe = (properties: Properties) => {
-    if (properties.breadcrumbs) {
-        const isItemSharedWithMe = properties.breadcrumbs[0].label === 'Shared with me';
-        return isItemSharedWithMe;
-    } else {
-        return false;
-    }
-};
-
 export const SidePanelButton = withStyles(styles)(
     connect((state: RootState) => ({
-        currentItemId: getProperty(PROJECT_PANEL_CURRENT_UUID)(state.properties),
-        isProjectRoute: isProjectRoute(state),
-        properties: state.properties
+        currentItemId: getProperty(PROJECT_PANEL_CURRENT_UUID)(state.properties)
     }))(
         class extends React.Component<SidePanelProps> {
 
@@ -83,7 +59,7 @@ export const SidePanelButton = withStyles(styles)(
             };
 
             render() {
-                const { classes, isProjectRoute, properties } = this.props;
+                const { classes } = this.props;
                 const { anchorEl } = this.state;
                 return <Toolbar>
                     <Grid container>
@@ -91,8 +67,7 @@ export const SidePanelButton = withStyles(styles)(
                             <Button variant="contained" color="primary" size="small" className={classes.button}
                                 aria-owns={anchorEl ? 'aside-menu-list' : undefined}
                                 aria-haspopup="true"
-                                onClick={this.handleOpen}
-                                disabled={!isProjectRoute || isItemSharedWithMe(properties)}>
+                                onClick={this.handleOpen}>
                                 <AddIcon />
                                 New
                             </Button>

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list