From: Lucas Di Pentima Date: Wed, 17 Feb 2021 20:53:05 +0000 (-0300) Subject: 16848: Always use wb2 token when LoginCluster is set and isn't the home cluster X-Git-Tag: 2.1.2.1~10^2~13 X-Git-Url: https://git.arvados.org/arvados-workbench2.git/commitdiff_plain/211054b9494b034611467321203618d8fbdf05e2 16848: Always use wb2 token when LoginCluster is set and isn't the home cluster Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- diff --git a/src/store/auth/auth-action.ts b/src/store/auth/auth-action.ts index 49a82b95..fb94746f 100644 --- a/src/store/auth/auth-action.ts +++ b/src/store/auth/auth-action.ts @@ -99,7 +99,9 @@ export const saveApiToken = (token: string) => (dispatch: Dispatch, getState: () export const getNewExtraToken = () => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { const user = getState().auth.user; + const loginCluster = getState().auth.config.clusterConfig.Login.LoginCluster; if (user === undefined) { return; } + if (loginCluster !== "" && getState().auth.homeCluster !== loginCluster) { return; } try { // Do not show errors on the create call, cluster security configuration may not // allow token creation and there's no way to know that from workbench2 side in advance. diff --git a/src/store/token-dialog/token-dialog-actions.tsx b/src/store/token-dialog/token-dialog-actions.tsx index 656f532b..2cf573bc 100644 --- a/src/store/token-dialog/token-dialog-actions.tsx +++ b/src/store/token-dialog/token-dialog-actions.tsx @@ -13,14 +13,21 @@ const API_HOST_PROPERTY_NAME = 'apiHost'; export interface TokenDialogData { token: string; 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(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(API_HOST_PROPERTY_NAME)(state.properties) || '', + token: state.auth.extraApiToken || state.auth.apiToken || '', + canCreateNewTokens, + }; +}; export const openTokenDialog = dialogActions.OPEN_DIALOG({ id: TOKEN_DIALOG_NAME, data: {} }); diff --git a/src/views-components/token-dialog/token-dialog.tsx b/src/views-components/token-dialog/token-dialog.tsx index 063bb2a5..5bbcaf57 100644 --- a/src/views-components/token-dialog/token-dialog.tsx +++ b/src/views-components/token-dialog/token-dialog.tsx @@ -121,7 +121,7 @@ unset ARVADOS_API_HOST_INSECURE` COPY TO CLIPBOARD - + } Arvados virtual machines