19177: Hides 'Sharing URLs' tab from Sharing dialog when configured to do so.
[arvados-workbench2.git] / src / views-components / sharing-dialog / sharing-dialog.tsx
index 6b488e44d482f9108b9c68b107eb697808550693..01cd390b07f7a2263400954fbba3b9c41f17cb5d 100644 (file)
@@ -35,18 +35,21 @@ 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,
-    sharingURLsNr: (filterResources(
-        (resource: ApiClientAuthorization) =>
+    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,
+        )(state.resources) as ApiClientAuthorization[]).length
+        : 0,
     privateAccess: getSharingPublicAccessFormData(state)?.visibility === VisibilityLevel.PRIVATE,
     })
 };