1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { dialogActions } from "store/dialog/dialog-actions";
6 import { getProperty } from 'store/properties/properties';
7 import { propertiesActions } from 'store/properties/properties-actions';
8 import { RootState } from 'store/store';
10 export const TOKEN_DIALOG_NAME = 'tokenDialog';
11 const API_HOST_PROPERTY_NAME = 'apiHost';
13 export interface TokenDialogData {
15 tokenExpiration?: Date;
17 canCreateNewTokens: boolean;
20 export const setTokenDialogApiHost = (apiHost: string) =>
21 propertiesActions.SET_PROPERTY({ key: API_HOST_PROPERTY_NAME, value: apiHost });
23 export const getTokenDialogData = (state: RootState): TokenDialogData => {
24 const loginCluster = state.auth.config.clusterConfig.Login.LoginCluster;
25 const canCreateNewTokens = !(loginCluster !== "" && state.auth.homeCluster !== loginCluster);
28 apiHost: getProperty<string>(API_HOST_PROPERTY_NAME)(state.properties) || '',
29 token: state.auth.extraApiToken || state.auth.apiToken || '',
30 tokenExpiration: state.auth.extraApiToken
31 ? state.auth.extraApiTokenExpiration
32 : state.auth.apiTokenExpiration,
37 export const openTokenDialog = dialogActions.OPEN_DIALOG({ id: TOKEN_DIALOG_NAME, data: {} });