From: Janicki Artur Date: Mon, 30 Jul 2018 11:28:09 +0000 (+0200) Subject: Merge branch 'master' into 13853-collection-view-info-card X-Git-Tag: 1.2.0~21^2 X-Git-Url: https://git.arvados.org/arvados-workbench2.git/commitdiff_plain/7ae86efd9905582df4191910528c3803a68ba81b Merge branch 'master' into 13853-collection-view-info-card refs #13853 Arvados-DCO-1.1-Signed-off-by: Janicki Artur --- 7ae86efd9905582df4191910528c3803a68ba81b diff --cc src/models/project.ts index d3626d3b,eaf60904..b9194507 --- a/src/models/project.ts +++ b/src/models/project.ts @@@ -5,9 -5,5 +5,9 @@@ import { GroupResource, GroupClass } from "./group"; export interface ProjectResource extends GroupResource { - groupClass: GroupClass.Project; + groupClass: GroupClass.PROJECT; } + +export const getProjectUrl = (uuid: string) => { + return `/projects/${uuid}`; +}; diff --cc src/services/services.ts index f0afd76f,a08ed3cb..e0d15cc4 --- a/src/services/services.ts +++ b/src/services/services.ts @@@ -9,8 -9,8 +9,8 @@@ import { ProjectService } from "./proje import { LinkService } from "./link-service/link-service"; import { FavoriteService } from "./favorite-service/favorite-service"; - export const authService = new AuthService(serverApi); - export const groupsService = new GroupsService(serverApi); - export const projectService = new ProjectService(serverApi); - export const linkService = new LinkService(serverApi); - export const favoriteService = new FavoriteService(linkService, groupsService); + export const authService = new AuthService(authClient, apiClient); + export const groupsService = new GroupsService(apiClient); + export const projectService = new ProjectService(apiClient); + export const linkService = new LinkService(apiClient); -export const favoriteService = new FavoriteService(linkService, groupsService); ++export const favoriteService = new FavoriteService(linkService, groupsService); diff --cc src/store/collection-panel/collection-panel-action.ts index c2684e05,00000000..3c660165 mode 100644,000000..100644 --- a/src/store/collection-panel/collection-panel-action.ts +++ b/src/store/collection-panel/collection-panel-action.ts @@@ -1,30 -1,0 +1,30 @@@ +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: AGPL-3.0 + +import { unionize, ofType, UnionOf } from "unionize"; +import { CommonResourceService } from "../../common/api/common-resource-service"; ++import { apiClient } from "../../common/api/server-api"; +import { Dispatch } from "redux"; - import { serverApi } from "../../common/api/server-api"; +import { ResourceKind } from "../../models/resource"; +import { CollectionResource } from "../../models/collection"; + +export const collectionPanelActions = unionize({ + LOAD_COLLECTION: ofType<{ uuid: string, kind: ResourceKind }>(), + LOAD_COLLECTION_SUCCESS: ofType<{ item: CollectionResource }>(), +}, { tag: 'type', value: 'payload' }); + +export type CollectionPanelAction = UnionOf; + +export const loadCollection = (uuid: string, kind: ResourceKind) => + (dispatch: Dispatch) => { + dispatch(collectionPanelActions.LOAD_COLLECTION({ uuid, kind })); - return new CommonResourceService(serverApi, "collections") ++ return new CommonResourceService(apiClient, "collections") + .get(uuid) + .then(item => { + dispatch(collectionPanelActions.LOAD_COLLECTION_SUCCESS({ item: item as CollectionResource })); + }); + }; + + + diff --cc src/store/navigation/navigation-action.ts index d65685d2,52086231..f8687ed7 --- a/src/store/navigation/navigation-action.ts +++ b/src/store/navigation/navigation-action.ts @@@ -16,8 -14,8 +16,8 @@@ import { getProjectUrl } from "../../mo export const getResourceUrl = (resource: T): string => { switch (resource.kind) { - case ResourceKind.Project: return getProjectUrl(resource.uuid); - case ResourceKind.Collection: return getCollectionUrl(resource.uuid); - case ResourceKind.PROJECT: return `/projects/${resource.uuid}`; - case ResourceKind.COLLECTION: return `/collections/${resource.uuid}`; ++ case ResourceKind.PROJECT: return getProjectUrl(resource.uuid); ++ case ResourceKind.COLLECTION: return getCollectionUrl(resource.uuid); default: return resource.href; } }; diff --cc src/views/workbench/workbench.tsx index 6c7f85d8,3637528d..e2524401 --- a/src/views/workbench/workbench.tsx +++ b/src/views/workbench/workbench.tsx @@@ -231,21 -227,10 +231,22 @@@ export const Workbench = withStyles(sty ); } + renderCollectionPanel = (props: RouteComponentProps<{ id: string }>) => this.props.dispatch(loadCollection(collectionId, ResourceKind.Collection))} ++ onItemRouteChange={(collectionId) => this.props.dispatch(loadCollection(collectionId, ResourceKind.COLLECTION))} + onContextMenu={(event, item) => { + this.openContextMenu(event, { + uuid: item.uuid, + name: item.name, + kind: ContextMenuKind.COLLECTION + }); + }} + {...props} /> + renderProjectPanel = (props: RouteComponentProps<{ id: string }>) => this.props.dispatch(setProjectItem(itemId, ItemMode.ACTIVE))} onContextMenu={(event, item) => { - const kind = item.kind === ResourceKind.Project ? ContextMenuKind.PROJECT : ContextMenuKind.RESOURCE; ++ + const kind = item.kind === ResourceKind.PROJECT ? ContextMenuKind.PROJECT : ContextMenuKind.RESOURCE; this.openContextMenu(event, { uuid: item.uuid, name: item.name, @@@ -257,14 -242,8 +258,15 @@@ this.props.dispatch(loadDetails(item.uuid, item.kind as ResourceKind)); }} onItemDoubleClick={item => { - this.props.dispatch(setProjectItem(item.uuid, ItemMode.ACTIVE)); - this.props.dispatch(loadDetails(item.uuid, ResourceKind.PROJECT)); + switch (item.kind) { - case ResourceKind.Collection: ++ case ResourceKind.COLLECTION: + this.props.dispatch(loadCollection(item.uuid, item.kind as ResourceKind)); + this.props.dispatch(push(getCollectionUrl(item.uuid))); + default: + this.props.dispatch(setProjectItem(item.uuid, ItemMode.ACTIVE)); + this.props.dispatch(loadDetails(item.uuid, item.kind as ResourceKind)); + } ++ }} {...props} /> @@@ -283,15 -262,9 +285,16 @@@ this.props.dispatch(loadDetails(item.uuid, item.kind as ResourceKind)); }} onItemDoubleClick={item => { - this.props.dispatch(loadDetails(item.uuid, ResourceKind.PROJECT)); - this.props.dispatch(setProjectItem(item.uuid, ItemMode.ACTIVE)); - this.props.dispatch(sidePanelActions.TOGGLE_SIDE_PANEL_ITEM_ACTIVE(SidePanelIdentifiers.PROJECTS)); + switch (item.kind) { - case ResourceKind.Collection: ++ case ResourceKind.COLLECTION: + this.props.dispatch(loadCollection(item.uuid, item.kind as ResourceKind)); + this.props.dispatch(push(getCollectionUrl(item.uuid))); + default: - this.props.dispatch(loadDetails(item.uuid, ResourceKind.Project)); ++ this.props.dispatch(loadDetails(item.uuid, ResourceKind.PROJECT)); + this.props.dispatch(setProjectItem(item.uuid, ItemMode.ACTIVE)); - this.props.dispatch(sidePanelActions.TOGGLE_SIDE_PANEL_ITEM_ACTIVE(SidePanelIdentifiers.Projects)); ++ this.props.dispatch(sidePanelActions.TOGGLE_SIDE_PANEL_ITEM_ACTIVE(SidePanelIdentifiers.PROJECTS)); + } ++ }} {...props} />