X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/f326404ea8ff55f3b177877eeef1136af34d18ba..refs/heads/18881-process-runtime-status:/src/store/token-dialog/token-dialog-actions.tsx

diff --git a/src/store/token-dialog/token-dialog-actions.tsx b/src/store/token-dialog/token-dialog-actions.tsx
index 656f532b..6d07fa0a 100644
--- a/src/store/token-dialog/token-dialog-actions.tsx
+++ b/src/store/token-dialog/token-dialog-actions.tsx
@@ -2,25 +2,36 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import { dialogActions } from "~/store/dialog/dialog-actions";
-import { getProperty } from '~/store/properties/properties';
-import { propertiesActions } from '~/store/properties/properties-actions';
-import { RootState } from '~/store/store';
+import { dialogActions } from "store/dialog/dialog-actions";
+import { getProperty } from 'store/properties/properties';
+import { propertiesActions } from 'store/properties/properties-actions';
+import { RootState } from 'store/store';
 
 export const TOKEN_DIALOG_NAME = 'tokenDialog';
 const API_HOST_PROPERTY_NAME = 'apiHost';
 
 export interface TokenDialogData {
     token: string;
+    tokenExpiration?: Date;
     apiHost: string;
+    canCreateNewTokens: boolean;
 }
 
 export const setTokenDialogApiHost = (apiHost: string) =>
     propertiesActions.SET_PROPERTY({ key: API_HOST_PROPERTY_NAME, value: apiHost });
 
-export const getTokenDialogData = (state: RootState): TokenDialogData => ({
-    apiHost: getProperty<string>(API_HOST_PROPERTY_NAME)(state.properties) || '',
-    token: state.auth.extraApiToken || state.auth.apiToken || '',
-});
+export const getTokenDialogData = (state: RootState): TokenDialogData => {
+    const loginCluster = state.auth.config.clusterConfig.Login.LoginCluster;
+    const canCreateNewTokens = !(loginCluster !== "" && state.auth.homeCluster !== loginCluster);
+
+    return {
+        apiHost: getProperty<string>(API_HOST_PROPERTY_NAME)(state.properties) || '',
+        token: state.auth.extraApiToken || state.auth.apiToken || '',
+        tokenExpiration: state.auth.extraApiToken
+            ? state.auth.extraApiTokenExpiration
+            : state.auth.apiTokenExpiration,
+        canCreateNewTokens,
+    };
+};
 
 export const openTokenDialog = dialogActions.OPEN_DIALOG({ id: TOKEN_DIALOG_NAME, data: {} });
