[ARVADOS-WORKBENCH2] updated: 1.3.0-88-gfc1f170

Git user git at public.curoverse.com
Tue Dec 11 04:47:42 EST 2018


Summary of changes:
 src/store/groups-panel/groups-panel-actions.ts | 39 ++++++++++++++++++++++----
 1 file changed, 34 insertions(+), 5 deletions(-)

       via  fc1f170015c5ffd5f4ee5b990d530f3c9782f549 (commit)
      from  e15800c9e0cb809dc212b4133a011cc3f50a7eec (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 fc1f170015c5ffd5f4ee5b990d530f3c9782f549
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date:   Tue Dec 11 10:47:09 2018 +0100

    Implement basic group submission
    
    Feature #14505
    
    Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>

diff --git a/src/store/groups-panel/groups-panel-actions.ts b/src/store/groups-panel/groups-panel-actions.ts
index b5465d0..65ca66b 100644
--- a/src/store/groups-panel/groups-panel-actions.ts
+++ b/src/store/groups-panel/groups-panel-actions.ts
@@ -3,10 +3,13 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import { Dispatch } from 'redux';
-import { reset } from 'redux-form';
+import { reset, startSubmit, stopSubmit, FormErrors } from 'redux-form';
 import { bindDataExplorerActions } from "~/store/data-explorer/data-explorer-action";
 import { dialogActions } from '~/store/dialog/dialog-actions';
 import { Person } from '~/views-components/sharing-dialog/people-select';
+import { ServiceRepository } from '~/services/services';
+import { getCommonResourceServiceError, CommonResourceServiceError } from '~/services/common-service/common-resource-service';
+import { snackbarActions, SnackbarKind } from '~/store/snackbar/snackbar-actions';
 
 export const GROUPS_PANEL_ID = "groupsPanel";
 export const CREATE_GROUP_DIALOG = "createGroupDialog";
@@ -26,10 +29,36 @@ export const openCreateGroupDialog = () =>
 
 export interface CreateGroupFormData {
     [CREATE_GROUP_NAME_FIELD_NAME]: string;
-    [CREATE_GROUP_USERS_FIELD_NAME]: Person[];
+    [CREATE_GROUP_USERS_FIELD_NAME]?: Person[];
 }
 
-export const createGroup = (data: CreateGroupFormData) =>
-    (dispatch: Dispatch) => {
-        console.log(data);
+export const createGroup = ({ name }: CreateGroupFormData) =>
+    async (dispatch: Dispatch, _: {}, { groupsService }: ServiceRepository) => {
+
+        dispatch(startSubmit(CREATE_GROUP_FORM));
+
+        try {
+
+            const newGroup = await groupsService.create({ name });
+
+            dispatch(dialogActions.CLOSE_DIALOG({ id: CREATE_GROUP_DIALOG }));
+            dispatch(reset(CREATE_GROUP_FORM));
+            dispatch(loadGroupsPanel());
+            dispatch(snackbarActions.OPEN_SNACKBAR({
+                message: `${newGroup.name} group has been created`,
+                kind: SnackbarKind.SUCCESS
+            }));
+
+            return newGroup;
+
+        } catch (e) {
+
+            const error = getCommonResourceServiceError(e);
+            if (error === CommonResourceServiceError.UNIQUE_VIOLATION) {
+                dispatch(stopSubmit(CREATE_GROUP_FORM, { name: 'Group with the same name already exists.' } as FormErrors));
+            }
+
+            return;
+
+        }
     };

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list