From: Eric Biagiotti Date: Wed, 15 May 2019 15:04:57 +0000 (-0400) Subject: Merge branch 'master' into 15088-merge-account X-Git-Tag: 1.4.0~1^2~13 X-Git-Url: https://git.arvados.org/arvados-workbench2.git/commitdiff_plain/3b53b656e65fdabc32b3bc748074eb35e9df98eb Merge branch 'master' into 15088-merge-account --- 3b53b656e65fdabc32b3bc748074eb35e9df98eb diff --cc src/store/auth/auth-action.ts index 7ee83992,c088418a..6ca71403 --- a/src/store/auth/auth-action.ts +++ b/src/store/auth/auth-action.ts @@@ -8,12 -8,12 +8,14 @@@ import { AxiosInstance } from "axios" import { RootState } from "../store"; import { ServiceRepository } from "~/services/services"; import { SshKeyResource } from '~/models/ssh-key'; -import { User } from "~/models/user"; +import { User, UserResource } from "~/models/user"; import { Session } from "~/models/session"; - import { Config } from '~/common/config'; + import { getDiscoveryURL, Config } from '~/common/config'; import { initSessions } from "~/store/auth/auth-action-session"; +import { cancelLinking } from '~/store/link-account-panel/link-account-panel-actions'; +import { matchTokenRoute } from '~/routes/routes'; + import Axios from "axios"; + import { AxiosError } from "axios"; export const authActions = unionize({ SAVE_API_TOKEN: ofType(), @@@ -48,15 -48,9 +51,16 @@@ function removeAuthorizationHeader(clie } export const initAuth = (config: Config) => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { + // Cancel any link account ops in progess unless the user has + // just logged in or there has been a successful link operation + const data = services.linkAccountService.getLinkOpStatus(); + if (!matchTokenRoute(location.pathname) && data === undefined) { + dispatch(cancelLinking()); + } + const user = services.authService.getUser(); const token = services.authService.getApiToken(); + const homeCluster = services.authService.getHomeCluster(); if (token) { setAuthorizationHeader(services, token); } @@@ -76,13 -82,8 +92,13 @@@ export const saveApiToken = (token: str dispatch(authActions.SAVE_API_TOKEN(token)); }; +export const saveUser = (user: UserResource) => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { + services.authService.saveUser(user); + dispatch(authActions.SAVE_USER(user)); +}; + - export const login = (uuidPrefix: string, homeCluster: string) => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { - services.authService.login(uuidPrefix, homeCluster); + export const login = (uuidPrefix: string, homeCluster: string, remoteHosts: { [key: string]: string }) => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { + services.authService.login(uuidPrefix, homeCluster, remoteHosts); dispatch(authActions.LOGIN()); }; diff --cc src/store/store.ts index 6a37572b,ff9a495e..8a2ca240 --- a/src/store/store.ts +++ b/src/store/store.ts @@@ -62,7 -62,9 +62,10 @@@ import { ApiClientAuthorizationMiddlewa import { PublicFavoritesMiddlewareService } from '~/store/public-favorites-panel/public-favorites-middleware-service'; import { PUBLIC_FAVORITE_PANEL_ID } from '~/store/public-favorites-panel/public-favorites-action'; import { publicFavoritesReducer } from '~/store/public-favorites/public-favorites-reducer'; +import { linkAccountPanelReducer } from './link-account-panel/link-account-panel-reducer'; + import { CollectionsWithSameContentAddressMiddlewareService } from '~/store/collections-content-address-panel/collections-content-address-middleware-service'; + import { COLLECTIONS_CONTENT_ADDRESS_PANEL_ID } from '~/store/collections-content-address-panel/collections-content-address-panel-actions'; + import { ownerNameReducer } from '~/store/owner-name/owner-name-reducer'; const composeEnhancers = (process.env.NODE_ENV === 'development' && diff --cc src/store/workbench/workbench-actions.ts index 0cffcace,2363b579..27ac76f3 --- a/src/store/workbench/workbench-actions.ts +++ b/src/store/workbench/workbench-actions.ts @@@ -95,7 -93,8 +94,9 @@@ import { groupDetailsPanelColumns } fro import { DataTableFetchMode } from "~/components/data-table/data-table"; import { loadPublicFavoritePanel, publicFavoritePanelActions } from '~/store/public-favorites-panel/public-favorites-action'; import { publicFavoritePanelColumns } from '~/views/public-favorites-panel/public-favorites-panel'; +import { USER_LINK_ACCOUNT_KEY } from '~/services/link-account-service/link-account-service'; + import { loadCollectionsContentAddressPanel, collectionsContentAddressActions } from '~/store/collections-content-address-panel/collections-content-address-panel-actions'; + import { collectionContentAddressPanelColumns } from '~/views/collection-content-address-panel/collection-content-address-panel'; export const WORKBENCH_LOADING_SCREEN = 'workbenchLoadingScreen'; @@@ -135,11 -134,8 +136,12 @@@ export const loadWorkbench = () = dispatch(linkPanelActions.SET_COLUMNS({ columns: linkPanelColumns })); dispatch(computeNodesActions.SET_COLUMNS({ columns: computeNodePanelColumns })); dispatch(apiClientAuthorizationsActions.SET_COLUMNS({ columns: apiClientAuthorizationPanelColumns })); + dispatch(collectionsContentAddressActions.SET_COLUMNS({ columns: collectionContentAddressPanelColumns })); + if (sessionStorage.getItem(USER_LINK_ACCOUNT_KEY)) { + dispatch(linkAccountPanelActions.HAS_SESSION_DATA()); + } + dispatch(initSidePanelTree()); if (router.location) { const match = matchRootRoute(router.location.pathname); diff --cc src/views-components/api-token/api-token.tsx index b0fd0313,b78e7192..2f8d87e1 --- a/src/views-components/api-token/api-token.tsx +++ b/src/views-components/api-token/api-token.tsx @@@ -28,12 -29,9 +30,14 @@@ export const ApiToken = connect() this.props.dispatch(getUserDetails()).then((user: User) => { this.props.dispatch(initSessions(this.props.authService, this.props.config, user)); }).finally(() => { + if (loadMainApp) { + if (this.props.dispatch(getAccountLinkData())) { + this.props.dispatch(navigateToLinkAccount); + } + else { this.props.dispatch(navigateToRootProject); } ++ } }); } render() { diff --cc src/views/workbench/workbench.tsx index e852150c,20cbbdea..d015d4ec --- a/src/views/workbench/workbench.tsx +++ b/src/views/workbench/workbench.tsx @@@ -93,7 -92,8 +93,9 @@@ import { GroupMemberAttributesDialog } import { AddGroupMembersDialog } from '~/views-components/dialog-forms/add-group-member-dialog'; import { PartialCopyToCollectionDialog } from '~/views-components/dialog-forms/partial-copy-to-collection-dialog'; import { PublicFavoritePanel } from '~/views/public-favorites-panel/public-favorites-panel'; +import { LinkAccountPanel } from '~/views/link-account-panel/link-account-panel'; + import { FedLogin } from './fed-login'; + import { CollectionsContentAddressPanel } from '~/views/collection-content-address-panel/collection-content-address-panel'; type CssRules = 'root' | 'container' | 'splitter' | 'asidePanel' | 'contentWrapper' | 'content'; @@@ -183,7 -178,7 +185,8 @@@ export const WorkbenchPanel + +