16115: Sets expiration date's minutes & seconds to zero.
authorLucas Di Pentima <lucas.dipentima@curii.com>
Tue, 24 May 2022 13:10:21 +0000 (10:10 -0300)
committerLucas Di Pentima <lucas.dipentima@curii.com>
Tue, 24 May 2022 13:10:21 +0000 (10:10 -0300)
Default expiration date is now set in a way that it gives the sharing link
at least 1:01h of lifetime and up to 2h. The user can select other dates
with a minimum step resolution of 1h.
Also, the "Create sharing URL" button won't be enabled if the selected
date is in the past. This is done this way because the Time picker doesn't
seem to support a "minDate" (or minHour?) property.

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

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

index cd7ea9bb39a9e8dab099fbc7572767d2a6a685e8..b54b3455399477224ee8f867ecd6bffbadf7a936 100644 (file)
@@ -73,7 +73,7 @@ export default (props: SharingDialogDataProps & SharingDialogActionProps) => {
         if (!withExpiration) {
             setExpDate(undefined);
         } else {
         if (!withExpiration) {
             setExpDate(undefined);
         } else {
-            setExpDate(moment().add(1, 'hour').toDate());
+            setExpDate(moment().add(2, 'hour').minutes(0).seconds(0).toDate());
         }
     }, [withExpiration]);
 
         }
     }, [withExpiration]);
 
@@ -155,6 +155,7 @@ export default (props: SharingDialogDataProps & SharingDialogActionProps) => {
                 </Grid>
                 <Grid item>
                     <Button variant="contained" color="primary"
                 </Grid>
                 <Grid item>
                     <Button variant="contained" color="primary"
+                        disabled={expDate !== undefined && expDate <= new Date()}
                         onClick={onCreateSharingToken(expDate)}>
                         Create sharing URL
                     </Button>
                         onClick={onCreateSharingToken(expDate)}>
                         Create sharing URL
                     </Button>