X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/986ff42ab49d2fd9a2da53fcc0f08a7933719b64..546052817ac18623f5389914a3077e8cc6a3d4f4:/src/views-components/sharing-dialog/sharing-dialog.tsx

diff --git a/src/views-components/sharing-dialog/sharing-dialog.tsx b/src/views-components/sharing-dialog/sharing-dialog.tsx
index 69c467e9..b295f6d1 100644
--- a/src/views-components/sharing-dialog/sharing-dialog.tsx
+++ b/src/views-components/sharing-dialog/sharing-dialog.tsx
@@ -6,7 +6,7 @@ import { compose, Dispatch } from 'redux';
 import { connect } from 'react-redux';
 
 import * as React from 'react';
-import { connectSharingDialog, saveSharingDialogChanges, connectSharingDialogProgress } from '~/store/sharing-dialog/sharing-dialog-actions';
+import { connectSharingDialog, saveSharingDialogChanges, connectSharingDialogProgress, sendSharingInvitations } from '~/store/sharing-dialog/sharing-dialog-actions';
 import { WithDialogProps } from '~/store/dialog/with-dialog';
 import { RootState } from '~/store/store';
 
@@ -26,12 +26,20 @@ const mapStateToProps = (state: RootState, { advancedViewOpen, working, ...props
     children: <SharingDialogContent {...{ advancedViewOpen }} />,
 });
 
-const mapDispatchToProps = (dispatch: Dispatch, { toggleAdvancedView, ...props }: Props): SharingDialogActionProps => ({
+const mapDispatchToProps = (dispatch: Dispatch, { toggleAdvancedView, advancedViewOpen, ...props }: Props): SharingDialogActionProps => ({
     ...props,
     onClose: props.closeDialog,
-    onExited: toggleAdvancedView,
+    onExited: () => {
+        if (advancedViewOpen) {
+            toggleAdvancedView();
+        }
+    },
     onSave: () => {
-        dispatch<any>(saveSharingDialogChanges);
+        if (advancedViewOpen) {
+            dispatch<any>(saveSharingDialogChanges);
+        } else {
+            dispatch<any>(sendSharingInvitations);
+        }
     },
     onAdvanced: toggleAdvancedView,
 });
