17568: Adds relative time information to token expiration time display. 17568-api-token-dialog-expiration-fix
authorLucas Di Pentima <lucas@di-pentima.com.ar>
Wed, 5 May 2021 13:41:41 +0000 (10:41 -0300)
committerLucas Di Pentima <lucas@di-pentima.com.ar>
Wed, 5 May 2021 13:41:41 +0000 (10:41 -0300)
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas@di-pentima.com.ar>

package.json
src/store/auth/auth-action.ts
src/views-components/token-dialog/token-dialog.tsx
yarn.lock

index 735224471b3762d4b85fecc3d6f02f2c57bcd467..18e0be8f8565575f0c2af969c7dd14e85310f455 100644 (file)
@@ -38,6 +38,7 @@
     "lodash.mergewith": "4.6.2",
     "lodash.template": "4.5.0",
     "mem": "4.0.0",
+    "moment": "2.29.1",
     "parse-duration": "0.4.4",
     "prop-types": "15.7.2",
     "query-string": "6.9.0",
index cca39bb0450a5e0671fca546ad043cb25e86b1cf..4fdb29a1c9b3217833176b70b64ec665013d05b0 100644 (file)
@@ -69,8 +69,9 @@ const init = (config: Config) => async (dispatch: Dispatch, getState: () => Root
         dispatch(progressIndicatorActions.START_WORKING(WORKBENCH_LOADING_SCREEN));
         try {
             await dispatch<any>(saveApiToken(token));
-        } catch (e) {}
-        dispatch(progressIndicatorActions.STOP_WORKING(WORKBENCH_LOADING_SCREEN));
+        } finally {
+            dispatch(progressIndicatorActions.STOP_WORKING(WORKBENCH_LOADING_SCREEN));
+        }
     }
 };
 
index 1aa3dd0790d393ace90b7149803ead89b6c901d8..fc01631d87d79d803264580f1b0f6ed3b04314ad 100644 (file)
@@ -28,6 +28,7 @@ import { DefaultCodeSnippet } from '~/components/default-code-snippet/default-co
 import { snackbarActions, SnackbarKind } from '~/store/snackbar/snackbar-actions';
 import { getNewExtraToken } from '~/store/auth/auth-action';
 import { DetailsAttributeComponent } from '~/components/details-attribute/details-attribute';
+import * as moment from 'moment';
 
 type CssRules = 'link' | 'paper' | 'button' | 'actionButton' | 'codeBlock';
 
@@ -95,7 +96,7 @@ unset ARVADOS_API_HOST_INSECURE`
     render() {
         const { classes, open, closeDialog, ...data } = this.props;
         const tokenExpiration = data.tokenExpiration
-            ? data.tokenExpiration.toLocaleString()
+            ? `${data.tokenExpiration.toLocaleString()} (${moment(data.tokenExpiration).fromNow()})`
             : `This token does not have an expiration date`;
 
         return <Dialog
index 465d82aa135f2d05fdeae335da66e5c27a5723f9..01bb75381bffdcbde19da1b62ffc346ff9a27663 100644 (file)
--- a/yarn.lock
+++ b/yarn.lock
@@ -7425,7 +7425,7 @@ mkdirp@^0.5.4:
   dependencies:
     minimist "^1.2.5"
 
-moment@^2.27.0:
+moment@2.29.1, moment@^2.27.0:
   version "2.29.1"
   resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.1.tgz#b2be769fa31940be9eeea6469c075e35006fa3d3"
   integrity sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==