From ec121e0e865fe99c5df5453ed5fa819594b1cdd6 Mon Sep 17 00:00:00 2001 From: Lucas Di Pentima Date: Wed, 5 May 2021 10:41:41 -0300 Subject: [PATCH] 17568: Adds relative time information to token expiration time display. Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- package.json | 1 + src/store/auth/auth-action.ts | 5 +++-- src/views-components/token-dialog/token-dialog.tsx | 3 ++- yarn.lock | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 73522447..18e0be8f 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/store/auth/auth-action.ts b/src/store/auth/auth-action.ts index cca39bb0..4fdb29a1 100644 --- a/src/store/auth/auth-action.ts +++ b/src/store/auth/auth-action.ts @@ -69,8 +69,9 @@ const init = (config: Config) => async (dispatch: Dispatch, getState: () => Root dispatch(progressIndicatorActions.START_WORKING(WORKBENCH_LOADING_SCREEN)); try { await dispatch(saveApiToken(token)); - } catch (e) {} - dispatch(progressIndicatorActions.STOP_WORKING(WORKBENCH_LOADING_SCREEN)); + } finally { + dispatch(progressIndicatorActions.STOP_WORKING(WORKBENCH_LOADING_SCREEN)); + } } }; diff --git a/src/views-components/token-dialog/token-dialog.tsx b/src/views-components/token-dialog/token-dialog.tsx index 1aa3dd07..fc01631d 100644 --- a/src/views-components/token-dialog/token-dialog.tsx +++ b/src/views-components/token-dialog/token-dialog.tsx @@ -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