From: Lucas Di Pentima Date: Wed, 5 May 2021 13:41:41 +0000 (-0300) Subject: 17568: Adds relative time information to token expiration time display. X-Git-Tag: 2.2.0~10^2 X-Git-Url: https://git.arvados.org/arvados-workbench2.git/commitdiff_plain/ec121e0e865fe99c5df5453ed5fa819594b1cdd6 17568: Adds relative time information to token expiration time display. Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- 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