X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/0bd774be1714eb7bb815cef3d44803eac6c735ec..f75b0aa3966895160535bad24b05c1a763665a5a:/src/views-components/sharing-dialog/sharing-dialog-component.tsx

diff --git a/src/views-components/sharing-dialog/sharing-dialog-component.tsx b/src/views-components/sharing-dialog/sharing-dialog-component.tsx
index 0fa0056c01..b2f313973e 100644
--- a/src/views-components/sharing-dialog/sharing-dialog-component.tsx
+++ b/src/views-components/sharing-dialog/sharing-dialog-component.tsx
@@ -38,12 +38,16 @@ import {
 } from 'material-ui-pickers';
 import DateFnsUtils from "@date-io/date-fns";
 import moment from 'moment';
+import { SharingPublicAccessForm } from './sharing-public-access-form';
 
 export interface SharingDialogDataProps {
     open: boolean;
     loading: boolean;
     saveEnabled: boolean;
     sharedResourceUuid: string;
+    sharingURLsNr: number;
+    privateAccess: boolean;
+    sharingURLsDisabled: boolean;
 }
 export interface SharingDialogActionProps {
     onClose: () => void;
@@ -55,10 +59,13 @@ enum SharingDialogTab {
     PERMISSIONS = 0,
     URLS = 1,
 }
-export default (props: SharingDialogDataProps & SharingDialogActionProps) => {
+export type SharingDialogComponentProps = SharingDialogDataProps & SharingDialogActionProps;
+
+export default (props: SharingDialogComponentProps) => {
     const { open, loading, saveEnabled, sharedResourceUuid,
+        sharingURLsNr, privateAccess, sharingURLsDisabled,
         onClose, onSave, onCreateSharingToken, refreshPermissions } = props;
-    const showTabs = extractUuidObjectType(sharedResourceUuid) === ResourceObjectType.COLLECTION;
+    const showTabs = !sharingURLsDisabled && extractUuidObjectType(sharedResourceUuid) === ResourceObjectType.COLLECTION;
     const [tabNr, setTabNr] = React.useState<number>(SharingDialogTab.PERMISSIONS);
     const [expDate, setExpDate] = React.useState<Date>();
     const [withExpiration, setWithExpiration] = React.useState<boolean>(false);
@@ -72,7 +79,7 @@ export default (props: SharingDialogDataProps & SharingDialogActionProps) => {
         if (!withExpiration) {
             setExpDate(undefined);
         } else {
-            setExpDate(moment().add(1, 'hour').toDate());
+            setExpDate(moment().add(2, 'hour').minutes(0).seconds(0).toDate());
         }
     }, [withExpiration]);
 
@@ -95,15 +102,18 @@ export default (props: SharingDialogDataProps & SharingDialogActionProps) => {
                 setTabNr(tb)}
             }>
             <Tab label="With users/groups" />
-            <Tab label="Sharing URLs" disabled={saveEnabled} />
+            <Tab label={`Sharing URLs ${sharingURLsNr > 0 ? '('+sharingURLsNr+')' : ''}`} disabled={saveEnabled} />
         </Tabs>
         }
         <DialogContent>
             { tabNr === SharingDialogTab.PERMISSIONS &&
             <Grid container direction='column' spacing={24}>
-              <Grid item>
-                  <SharingManagementForm />
-              </Grid>
+                <Grid item>
+                    <SharingPublicAccessForm />
+                </Grid>
+                <Grid item>
+                    <SharingManagementForm />
+                </Grid>
             </Grid>
             }
             { tabNr === SharingDialogTab.URLS &&
@@ -115,7 +125,8 @@ export default (props: SharingDialogDataProps & SharingDialogActionProps) => {
                 { tabNr === SharingDialogTab.PERMISSIONS &&
                 <Grid item md={12}>
                     <SharingInvitationForm />
-                </Grid> }
+                </Grid>
+                }
                 { tabNr === SharingDialogTab.URLS && withExpiration && <>
                 <Grid item container direction='row' md={12}>
                     <MuiPickersUtilsProvider utils={DateFnsUtils}>
@@ -141,7 +152,16 @@ export default (props: SharingDialogDataProps & SharingDialogActionProps) => {
                         Maximum expiration date may be limited by the cluster configuration.
                     </Typography>
                 </Grid>
-                </> }
+                </>
+                }
+                { tabNr === SharingDialogTab.PERMISSIONS && !sharingURLsDisabled &&
+                    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
@@ -151,11 +171,13 @@ export default (props: SharingDialogDataProps & SharingDialogActionProps) => {
                 </Grid>
                 <Grid item>
                     <Button variant="contained" color="primary"
+                        disabled={expDate !== undefined && expDate <= new Date()}
                         onClick={onCreateSharingToken(expDate)}>
                         Create sharing URL
                     </Button>
                 </Grid>
-                </>}
+                </>
+                }
                 { tabNr === SharingDialogTab.PERMISSIONS &&
                 <Grid item>
                     <Button onClick={onSave} variant="contained" color="primary"
