X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/0bd774be1714eb7bb815cef3d44803eac6c735ec..c21c6582a12fe3968e3ef3a4786de5dfacce3b18:/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 8cfc58f7..01cd390b 100644
--- a/src/views-components/sharing-dialog/sharing-dialog.tsx
+++ b/src/views-components/sharing-dialog/sharing-dialog.tsx
@@ -19,21 +19,38 @@ import SharingDialogComponent, {
     SharingDialogActionProps
 } from './sharing-dialog-component';
 import {
+    getSharingPublicAccessFormData,
     hasChanges,
-    SHARING_DIALOG_NAME
+    SHARING_DIALOG_NAME,
+    VisibilityLevel
 } from 'store/sharing-dialog/sharing-dialog-types';
 import { WithProgressStateProps } from 'store/progress-indicator/with-progress';
 import { getDialog } from 'store/dialog/dialog-reducer';
+import { filterResources } from 'store/resources/resources';
+import { ApiClientAuthorization } from 'models/api-client-authorization';
+import { ResourceKind } from 'models/resource';
 
 type Props = WithDialogProps<string> & WithProgressStateProps;
 
 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: dialog?.data.resourceUuid || '',
+    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,
     })
 };
 
