16115: Adds warning notice for private visibility with active sharing urls. 16115-sharing-links
authorLucas Di Pentima <lucas.dipentima@curii.com>
Tue, 24 May 2022 14:39:27 +0000 (11:39 -0300)
committerLucas Di Pentima <lucas.dipentima@curii.com>
Tue, 24 May 2022 14:39:27 +0000 (11:39 -0300)
Also, shows the number of sharing links on the tab's label.

Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima@curii.com>

src/views-components/sharing-dialog/sharing-dialog-component.tsx
src/views-components/sharing-dialog/sharing-dialog.tsx

index b54b3455399477224ee8f867ecd6bffbadf7a936..15d7f660e0638caffaf631f180b70dd9680fd017 100644 (file)
@@ -45,6 +45,8 @@ export interface SharingDialogDataProps {
     loading: boolean;
     saveEnabled: boolean;
     sharedResourceUuid: string;
     loading: boolean;
     saveEnabled: boolean;
     sharedResourceUuid: string;
+    sharingURLsNr: number;
+    privateAccess: boolean;
 }
 export interface SharingDialogActionProps {
     onClose: () => void;
 }
 export interface SharingDialogActionProps {
     onClose: () => void;
@@ -58,6 +60,7 @@ enum SharingDialogTab {
 }
 export default (props: SharingDialogDataProps & SharingDialogActionProps) => {
     const { open, loading, saveEnabled, sharedResourceUuid,
 }
 export default (props: SharingDialogDataProps & SharingDialogActionProps) => {
     const { open, loading, saveEnabled, sharedResourceUuid,
+        sharingURLsNr, privateAccess,
         onClose, onSave, onCreateSharingToken, refreshPermissions } = props;
     const showTabs = extractUuidObjectType(sharedResourceUuid) === ResourceObjectType.COLLECTION;
     const [tabNr, setTabNr] = React.useState<number>(SharingDialogTab.PERMISSIONS);
         onClose, onSave, onCreateSharingToken, refreshPermissions } = props;
     const showTabs = extractUuidObjectType(sharedResourceUuid) === ResourceObjectType.COLLECTION;
     const [tabNr, setTabNr] = React.useState<number>(SharingDialogTab.PERMISSIONS);
@@ -96,7 +99,7 @@ export default (props: SharingDialogDataProps & SharingDialogActionProps) => {
                 setTabNr(tb)}
             }>
             <Tab label="With users/groups" />
                 setTabNr(tb)}
             }>
             <Tab label="With users/groups" />
-            <Tab label="Sharing URLs" disabled={saveEnabled} />
+            <Tab label={`Sharing URLs ${sharingURLsNr > 0 ? '('+sharingURLsNr+')' : ''}`} disabled={saveEnabled} />
         </Tabs>
         }
         <DialogContent>
         </Tabs>
         }
         <DialogContent>
@@ -119,7 +122,8 @@ export default (props: SharingDialogDataProps & SharingDialogActionProps) => {
                 { tabNr === SharingDialogTab.PERMISSIONS &&
                 <Grid item md={12}>
                     <SharingInvitationForm />
                 { tabNr === SharingDialogTab.PERMISSIONS &&
                 <Grid item md={12}>
                     <SharingInvitationForm />
-                </Grid> }
+                </Grid>
+                }
                 { tabNr === SharingDialogTab.URLS && withExpiration && <>
                 <Grid item container direction='row' md={12}>
                     <MuiPickersUtilsProvider utils={DateFnsUtils}>
                 { tabNr === SharingDialogTab.URLS && withExpiration && <>
                 <Grid item container direction='row' md={12}>
                     <MuiPickersUtilsProvider utils={DateFnsUtils}>
@@ -145,7 +149,15 @@ export default (props: SharingDialogDataProps & SharingDialogActionProps) => {
                         Maximum expiration date may be limited by the cluster configuration.
                     </Typography>
                 </Grid>
                         Maximum expiration date may be limited by the cluster configuration.
                     </Typography>
                 </Grid>
-                </> }
+                </>
+                }
+                { tabNr === SharingDialogTab.PERMISSIONS && privateAccess && sharingURLsNr > 0 &&
+                <Grid item md={12}>
+                    <Typography variant='caption' align='center' color='error'>
+                        Although there aren't specific permissions set, this is publicly accessible via Sharing URL(s).
+                    </Typography>
+                </Grid>
+                }
                 <Grid item xs />
                 { tabNr === SharingDialogTab.URLS && <>
                 <Grid item><FormControlLabel
                 <Grid item xs />
                 { tabNr === SharingDialogTab.URLS && <>
                 <Grid item><FormControlLabel
@@ -160,7 +172,8 @@ export default (props: SharingDialogDataProps & SharingDialogActionProps) => {
                         Create sharing URL
                     </Button>
                 </Grid>
                         Create sharing URL
                     </Button>
                 </Grid>
-                </>}
+                </>
+                }
                 { tabNr === SharingDialogTab.PERMISSIONS &&
                 <Grid item>
                     <Button onClick={onSave} variant="contained" color="primary"
                 { tabNr === SharingDialogTab.PERMISSIONS &&
                 <Grid item>
                     <Button onClick={onSave} variant="contained" color="primary"
index 8cfc58f756dbd97c55ba338a5ca057bfc1851795..6b488e44d482f9108b9c68b107eb697808550693 100644 (file)
@@ -19,21 +19,35 @@ import SharingDialogComponent, {
     SharingDialogActionProps
 } from './sharing-dialog-component';
 import {
     SharingDialogActionProps
 } from './sharing-dialog-component';
 import {
+    getSharingPublicAccessFormData,
     hasChanges,
     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';
 } 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);
 
 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 || '';
     return ({
     ...props,
     saveEnabled: hasChanges(state),
     loading: working,
     return ({
     ...props,
     saveEnabled: hasChanges(state),
     loading: working,
-    sharedResourceUuid: dialog?.data.resourceUuid || '',
+    sharedResourceUuid,
+    sharingURLsNr: (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,
+    privateAccess: getSharingPublicAccessFormData(state)?.visibility === VisibilityLevel.PRIVATE,
     })
 };
 
     })
 };