[ARVADOS-WORKBENCH2] updated: 1.2.0-759-gaf96778

Git user git at public.curoverse.com
Tue Oct 30 07:32:03 EDT 2018


Summary of changes:
 src/store/sharing-dialog/sharing-dialog-actions.ts | 71 +++++++++++++---------
 src/store/sharing-dialog/sharing-dialog-types.ts   |  9 ++-
 .../sharing-dialog/sharing-management-form.tsx     | 23 +------
 .../sharing-dialog/sharing-public-access-form.tsx  | 16 ++---
 .../sharing-dialog/visibility-level-select.tsx     |  1 -
 5 files changed, 56 insertions(+), 64 deletions(-)

       via  af967786d2c2b02c4f7c18afd7d4694a8eaba34c (commit)
      from  59fc59f324194f2762dae92cf94bd4a05e33cb09 (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 af967786d2c2b02c4f7c18afd7d4694a8eaba34c
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date:   Tue Oct 30 12:31:47 2018 +0100

    Add visibility level select
    
    Feature #14365
    
    Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>

diff --git a/src/store/sharing-dialog/sharing-dialog-actions.ts b/src/store/sharing-dialog/sharing-dialog-actions.ts
index 2b28668..c2108ae 100644
--- a/src/store/sharing-dialog/sharing-dialog-actions.ts
+++ b/src/store/sharing-dialog/sharing-dialog-actions.ts
@@ -4,7 +4,7 @@
 
 import { dialogActions } from "~/store/dialog/dialog-actions";
 import { withDialog } from "~/store/dialog/with-dialog";
-import { SHARING_DIALOG_NAME, SharingPublicAccessFormData, SHARING_PUBLIC_ACCESS_FORM_NAME, SHARING_INVITATION_FORM_NAME, SharingManagementFormData, SharingInvitationFormData, VisibilityLevel } from './sharing-dialog-types';
+import { SHARING_DIALOG_NAME, SharingPublicAccessFormData, SHARING_PUBLIC_ACCESS_FORM_NAME, SHARING_INVITATION_FORM_NAME, SharingManagementFormData, SharingInvitationFormData, VisibilityLevel, getSharingMangementFormData, getSharingPublicAccessFormData } from './sharing-dialog-types';
 import { Dispatch } from 'redux';
 import { ServiceRepository } from "~/services/services";
 import { FilterBuilder } from '~/services/api/filter-builder';
@@ -29,11 +29,9 @@ export const closeSharingDialog = () =>
 export const connectSharingDialog = withDialog(SHARING_DIALOG_NAME);
 
 export const saveSharingDialogChanges = async (dispatch: Dispatch) => {
-    await Promise.all([
-        dispatch<any>(savePublicPermissionChanges),
-        dispatch<any>(saveManagementChanges),
-        dispatch<any>(sendInvitations),
-    ]);
+    await dispatch<any>(savePublicPermissionChanges);
+    await dispatch<any>(saveManagementChanges);
+    await dispatch<any>(sendInvitations);
     dispatch(reset(SHARING_INVITATION_FORM_NAME));
     await dispatch<any>(loadSharingDialog);
 };
@@ -113,7 +111,7 @@ const savePublicPermissionChanges = async (_: Dispatch, getState: () => RootStat
     const { user } = state.auth;
     const dialog = getDialog<string>(state.dialog, SHARING_DIALOG_NAME);
     if (dialog && user) {
-        const { permissionUuid, visibility } = getFormValues(SHARING_PUBLIC_ACCESS_FORM_NAME)(state) as SharingPublicAccessFormData;
+        const { permissionUuid, visibility } = getSharingPublicAccessFormData(state);
 
         if (permissionUuid) {
             if (visibility === VisibilityLevel.PUBLIC) {
@@ -142,22 +140,32 @@ const saveManagementChanges = async (_: Dispatch, getState: () => RootState, { p
     const dialog = getDialog<string>(state.dialog, SHARING_DIALOG_NAME);
     if (dialog && user) {
 
-        const { initialPermissions, permissions } = getFormValues(SHARING_MANAGEMENT_FORM_NAME)(state) as SharingManagementFormData;
+        const { initialPermissions, permissions } = getSharingMangementFormData(state);
+        const { visibility } = getSharingPublicAccessFormData(state);
 
-        const cancelledPermissions = differenceWith(
-            initialPermissions,
-            permissions,
-            (a, b) => a.permissionUuid === b.permissionUuid
-        );
 
-        await Promise.all(cancelledPermissions.map(({ permissionUuid }) =>
-            permissionService.delete(permissionUuid)
-        ));
+        if (visibility === VisibilityLevel.PRIVATE) {
 
-        await Promise.all(permissions.map(({ permissionUuid, permissions }) =>
-            permissionService.update(permissionUuid, { name: permissions })
-        ));
+            await Promise.all(initialPermissions.map(({ permissionUuid, permissions }) =>
+                permissionService.delete(permissionUuid)
+            ));
 
+        } else {
+
+            const cancelledPermissions = differenceWith(
+                initialPermissions,
+                permissions,
+                (a, b) => a.permissionUuid === b.permissionUuid
+            );
+
+            await Promise.all(cancelledPermissions.map(({ permissionUuid }) =>
+                permissionService.delete(permissionUuid)
+            ));
+
+            await Promise.all(permissions.map(({ permissionUuid, permissions }) =>
+                permissionService.update(permissionUuid, { name: permissions })
+            ));
+        }
     }
 };
 
@@ -168,16 +176,19 @@ const sendInvitations = async (_: Dispatch, getState: () => RootState, { permiss
     if (dialog && user) {
 
         const invitations = getFormValues(SHARING_INVITATION_FORM_NAME)(state) as SharingInvitationFormData;
-
-        const promises = invitations.invitedPeople
-            .map(person => ({
-                ownerUuid: user.uuid,
-                headUuid: dialog.data,
-                tailUuid: person.uuid,
-                name: invitations.permissions
-            }))
-            .map(data => permissionService.create(data));
-
-        await Promise.all(promises);
+        const { visibility } = getSharingPublicAccessFormData(state);
+
+        if (visibility !== VisibilityLevel.PRIVATE) {
+            const promises = invitations.invitedPeople
+                .map(person => ({
+                    ownerUuid: user.uuid,
+                    headUuid: dialog.data,
+                    tailUuid: person.uuid,
+                    name: invitations.permissions
+                }))
+                .map(data => permissionService.create(data));
+
+            await Promise.all(promises);
+        }
     }
 };
diff --git a/src/store/sharing-dialog/sharing-dialog-types.ts b/src/store/sharing-dialog/sharing-dialog-types.ts
index b897a9e..97e1979 100644
--- a/src/store/sharing-dialog/sharing-dialog-types.ts
+++ b/src/store/sharing-dialog/sharing-dialog-types.ts
@@ -3,6 +3,7 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import { PermissionLevel } from '~/models/permission';
+import { getFormValues } from 'redux-form';
 
 export const SHARING_DIALOG_NAME = 'SHARING_DIALOG_NAME';
 export const SHARING_PUBLIC_ACCESS_FORM_NAME = 'SHARING_PUBLIC_ACCESS_FORM_NAME';
@@ -40,4 +41,10 @@ export interface SharingInvitationFormPersonData {
     email: string;
     name: string;
     uuid: string;
-}
\ No newline at end of file
+}
+
+export const getSharingMangementFormData = (state: any) =>
+    getFormValues(SHARING_MANAGEMENT_FORM_NAME)(state) as SharingManagementFormData;
+
+export const getSharingPublicAccessFormData = (state: any) =>
+    getFormValues(SHARING_PUBLIC_ACCESS_FORM_NAME)(state) as SharingPublicAccessFormData;
diff --git a/src/views-components/sharing-dialog/sharing-management-form.tsx b/src/views-components/sharing-dialog/sharing-management-form.tsx
index d4081a4..d78c6fe 100644
--- a/src/views-components/sharing-dialog/sharing-management-form.tsx
+++ b/src/views-components/sharing-dialog/sharing-management-form.tsx
@@ -3,26 +3,9 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import { reduxForm } from 'redux-form';
-import { connect } from 'react-redux';
-import { compose } from 'redux';
 import SharingManagementFormComponent from './sharing-management-form-component';
 import { SHARING_MANAGEMENT_FORM_NAME } from '~/store/sharing-dialog/sharing-dialog-types';
-import { PermissionLevel } from '~/models/permission';
 
-export const SharingManagementForm = compose(
-    connect(() => ({
-        initialValues: {
-            permissions: [
-                {
-                    email: 'chrystian.klingenberg at contractors.roche.com',
-                    permissions: PermissionLevel.CAN_MANAGE,
-                },
-                {
-                    email: 'artur.janicki at contractors.roche.com',
-                    permissions: PermissionLevel.CAN_WRITE,
-                },
-            ],
-        }
-    })),
-    reduxForm({ form: SHARING_MANAGEMENT_FORM_NAME })
-)(SharingManagementFormComponent);
\ No newline at end of file
+export const SharingManagementForm = reduxForm(
+    { form: SHARING_MANAGEMENT_FORM_NAME }
+)(SharingManagementFormComponent);
diff --git a/src/views-components/sharing-dialog/sharing-public-access-form.tsx b/src/views-components/sharing-dialog/sharing-public-access-form.tsx
index bf64ba3..1b39a65 100644
--- a/src/views-components/sharing-dialog/sharing-public-access-form.tsx
+++ b/src/views-components/sharing-dialog/sharing-public-access-form.tsx
@@ -3,17 +3,9 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import { reduxForm } from 'redux-form';
-import { connect } from 'react-redux';
-import { compose } from 'redux';
 import SharingPublicAccessFormComponent from './sharing-public-access-form-component';
 import { SHARING_PUBLIC_ACCESS_FORM_NAME } from '~/store/sharing-dialog/sharing-dialog-types';
-import { PermissionLevel } from '~/models/permission';
-export const SharingPublicAccessForm = compose(
-    connect(() => ({
-        initialValues: {
-            enabled: false,
-            permissions: PermissionLevel.CAN_READ,
-        }
-    })),
-    reduxForm({ form: SHARING_PUBLIC_ACCESS_FORM_NAME })
-)(SharingPublicAccessFormComponent);
\ No newline at end of file
+
+export const SharingPublicAccessForm = reduxForm(
+    { form: SHARING_PUBLIC_ACCESS_FORM_NAME }
+)(SharingPublicAccessFormComponent);
diff --git a/src/views-components/sharing-dialog/visibility-level-select.tsx b/src/views-components/sharing-dialog/visibility-level-select.tsx
index f03b5e9..7213155 100644
--- a/src/views-components/sharing-dialog/visibility-level-select.tsx
+++ b/src/views-components/sharing-dialog/visibility-level-select.tsx
@@ -20,7 +20,6 @@ const VisibilityLevelSelectStyles: StyleRulesCallback<VisibilityLevelSelectClass
         marginLeft: theme.spacing.unit,
     }
 });
-
 export const VisibilityLevelSelect = withStyles(VisibilityLevelSelectStyles)(
     ({ classes, ...props }: SelectProps & WithStyles<VisibilityLevelSelectClasses>) =>
         <Select

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list