X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/074cc61145869165217e2d35a4b949f92a6829e7..2a7fd99c212c33a1ec9911f8529fa5afc59a7bb2:/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 01cd390b07..1c9e4d0393 100644
--- a/src/views-components/sharing-dialog/sharing-dialog.tsx
+++ b/src/views-components/sharing-dialog/sharing-dialog.tsx
@@ -5,6 +5,7 @@
 import { compose, Dispatch } from 'redux';
 import { connect } from 'react-redux';
 import { RootState } from 'store/store';
+import { formValueSelector } from 'redux-form'
 import {
     connectSharingDialog,
     saveSharingDialogChanges,
@@ -22,6 +23,7 @@ import {
     getSharingPublicAccessFormData,
     hasChanges,
     SHARING_DIALOG_NAME,
+    SHARING_MANAGEMENT_FORM_NAME,
     VisibilityLevel
 } from 'store/sharing-dialog/sharing-dialog-types';
 import { WithProgressStateProps } from 'store/progress-indicator/with-progress';
@@ -32,25 +34,28 @@ import { ResourceKind } from 'models/resource';
 
 type Props = WithDialogProps<string> & WithProgressStateProps;
 
+const sharingManagementFormSelector = formValueSelector(SHARING_MANAGEMENT_FORM_NAME);
+
 const mapStateToProps = (state: RootState, { working, ...props }: Props): SharingDialogDataProps => {
     const dialog = getDialog<SharingDialogData>(state.dialog, SHARING_DIALOG_NAME);
     const sharedResourceUuid = dialog?.data.resourceUuid || '';
     const sharingURLsDisabled = state.auth.config.clusterConfig.Workbench.DisableSharingURLsUI;
     return ({
-    ...props,
-    saveEnabled: hasChanges(state),
-    loading: working,
-    sharedResourceUuid,
-    sharingURLsDisabled,
-    sharingURLsNr: !sharingURLsDisabled
-        ? (filterResources( (resource: ApiClientAuthorization) =>
-            resource.kind === ResourceKind.API_CLIENT_AUTHORIZATION  &&
-            resource.scopes.includes(`GET /arvados/v1/collections/${sharedResourceUuid}`) &&
-            resource.scopes.includes(`GET /arvados/v1/collections/${sharedResourceUuid}/`) &&
-            resource.scopes.includes('GET /arvados/v1/keep_services/accessible')
-        )(state.resources) as ApiClientAuthorization[]).length
-        : 0,
-    privateAccess: getSharingPublicAccessFormData(state)?.visibility === VisibilityLevel.PRIVATE,
+        ...props,
+        permissions: sharingManagementFormSelector(state, 'permissions'),
+        saveEnabled: hasChanges(state),
+        loading: working,
+        sharedResourceUuid,
+        sharingURLsDisabled,
+        sharingURLsNr: !sharingURLsDisabled
+            ? (filterResources((resource: ApiClientAuthorization) =>
+                resource.kind === ResourceKind.API_CLIENT_AUTHORIZATION &&
+                resource.scopes.includes(`GET /arvados/v1/collections/${sharedResourceUuid}`) &&
+                resource.scopes.includes(`GET /arvados/v1/collections/${sharedResourceUuid}/`) &&
+                resource.scopes.includes('GET /arvados/v1/keep_services/accessible')
+            )(state.resources) as ApiClientAuthorization[]).length
+            : 0,
+        privateAccess: getSharingPublicAccessFormData(state)?.visibility === VisibilityLevel.PRIVATE,
     })
 };
 
@@ -58,7 +63,7 @@ const mapDispatchToProps = (dispatch: Dispatch, { ...props }: Props): SharingDia
     ...props,
     onClose: props.closeDialog,
     onSave: () => {
-        dispatch<any>(saveSharingDialogChanges);
+        setTimeout(() => dispatch<any>(saveSharingDialogChanges), 0);
     },
     onCreateSharingToken: (d: Date) => () => {
         dispatch<any>(createSharingToken(d));
@@ -73,4 +78,3 @@ export const SharingDialog = compose(
     connectSharingDialogProgress,
     connect(mapStateToProps, mapDispatchToProps)
 )(SharingDialogComponent);
-
