X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/0259b9ba3e4b296fd4d360a7f48f6d9ac53ce38e..589629e80967dc1f318561fbe6a4174e1da231a6:/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 b50c74c755..b295f6d167 100644
--- a/src/views-components/sharing-dialog/sharing-dialog.tsx
+++ b/src/views-components/sharing-dialog/sharing-dialog.tsx
@@ -6,27 +6,40 @@ import { compose, Dispatch } from 'redux';
 import { connect } from 'react-redux';
 
 import * as React from 'react';
-import { connectSharingDialog, saveSharingDialogChanges, hasChanges } 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';
 
 import SharingDialogComponent, { SharingDialogDataProps, SharingDialogActionProps } from './sharing-dialog-component';
 import { SharingDialogContent } from './sharing-dialog-content';
 import { connectAdvancedViewSwitch, AdvancedViewSwitchInjectedProps } from './advanced-view-switch';
+import { hasChanges } from '~/store/sharing-dialog/sharing-dialog-types';
+import { WithProgressStateProps } from '~/store/progress-indicator/with-progress';
 
-const mapStateToProps = (state: RootState, { advancedViewOpen, ...props }: WithDialogProps<string> & AdvancedViewSwitchInjectedProps): SharingDialogDataProps => ({
+type Props = WithDialogProps<string> & AdvancedViewSwitchInjectedProps & WithProgressStateProps;
+
+const mapStateToProps = (state: RootState, { advancedViewOpen, working, ...props }: Props): SharingDialogDataProps => ({
     ...props,
     saveEnabled: hasChanges(state),
+    loading: working,
     advancedEnabled: !advancedViewOpen,
     children: <SharingDialogContent {...{ advancedViewOpen }} />,
 });
 
-const mapDispatchToProps = (dispatch: Dispatch, { toggleAdvancedView, ...props }: WithDialogProps<string> & AdvancedViewSwitchInjectedProps): 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,
 });
@@ -34,6 +47,7 @@ const mapDispatchToProps = (dispatch: Dispatch, { toggleAdvancedView, ...props }
 export const SharingDialog = compose(
     connectAdvancedViewSwitch,
     connectSharingDialog,
+    connectSharingDialogProgress,
     connect(mapStateToProps, mapDispatchToProps)
 )(SharingDialogComponent);
 
