Merge branch '13751-shared-with-me-view'
authorMichal Klobukowski <michal.klobukowski@contractors.roche.com>
Tue, 18 Sep 2018 11:08:48 +0000 (13:08 +0200)
committerMichal Klobukowski <michal.klobukowski@contractors.roche.com>
Tue, 18 Sep 2018 11:08:48 +0000 (13:08 +0200)
refs #13751

Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski@contractors.roche.com>

15 files changed:
src/routes/route-change-handlers.ts
src/routes/routes.ts
src/services/ancestors-service/ancestors-service.ts
src/services/groups-service/groups-service.ts
src/store/breadcrumbs/breadcrumbs-actions.ts
src/store/navigation/navigation-action.ts
src/store/project-panel/project-panel-middleware-service.ts
src/store/shared-with-me-panel/shared-with-me-middleware-service.ts [new file with mode: 0644]
src/store/shared-with-me-panel/shared-with-me-panel-actions.ts [new file with mode: 0644]
src/store/side-panel-tree/side-panel-tree-actions.ts
src/store/side-panel/side-panel-action.ts
src/store/store.ts
src/store/workbench/workbench-actions.ts
src/views/shared-with-me-panel/shared-with-me-panel.tsx [new file with mode: 0644]
src/views/workbench/workbench.tsx

index 00fb4bc05acbfcf8a4dc47e3c20f19516443cf19..33e0bef753c6f5535a18a02e94b7e8e3012052ab 100644 (file)
@@ -4,9 +4,11 @@
 
 import { History, Location } from 'history';
 import { RootStore } from '~/store/store';
-import { matchProcessRoute, matchProcessLogRoute, matchProjectRoute, matchCollectionRoute, matchFavoritesRoute, matchTrashRoute, matchRootRoute } from './routes';
+import { matchProcessRoute, matchProcessLogRoute, matchProjectRoute, matchCollectionRoute, matchFavoritesRoute, matchTrashRoute, matchRootRoute, matchSharedWithMeRoute } from './routes';
 import { loadProject, loadCollection, loadFavorites, loadTrash, loadProcess, loadProcessLog } from '~/store/workbench/workbench-actions';
 import { navigateToRootProject } from '~/store/navigation/navigation-action';
+import { navigateToSharedWithMe } from '../store/navigation/navigation-action';
+import { loadSharedWithMe } from '../store/workbench/workbench-actions';
 
 export const addRouteChangeHandlers = (history: History, store: RootStore) => {
     const handler = handleLocationChange(store);
@@ -22,7 +24,8 @@ const handleLocationChange = (store: RootStore) => ({ pathname }: Location) => {
     const trashMatch = matchTrashRoute(pathname);
     const processMatch = matchProcessRoute(pathname);
     const processLogMatch = matchProcessLogRoute(pathname);
-    
+    const sharedWithMeMatch = matchSharedWithMeRoute(pathname);
+
     if (projectMatch) {
         store.dispatch(loadProject(projectMatch.params.id));
     } else if (collectionMatch) {
@@ -37,5 +40,7 @@ const handleLocationChange = (store: RootStore) => ({ pathname }: Location) => {
         store.dispatch(loadProcessLog(processLogMatch.params.id));
     } else if (rootMatch) {
         store.dispatch(navigateToRootProject);
+    } else if (sharedWithMeMatch) {
+        store.dispatch(loadSharedWithMe);
     }
 };
index 29941b47e89989cec2417e653c8364fa5b3a21f7..fb28bd05bee5ff360c17cedd01bf2487d7cf4f22 100644 (file)
@@ -15,7 +15,8 @@ export const Routes = {
     PROCESSES: `/processes/:id(${RESOURCE_UUID_PATTERN})`,
     FAVORITES: '/favorites',
     TRASH: '/trash',
-    PROCESS_LOGS: `/process-logs/:id(${RESOURCE_UUID_PATTERN})`
+    PROCESS_LOGS: `/process-logs/:id(${RESOURCE_UUID_PATTERN})`,
+    SHARED_WITH_ME: '/shared-with-me',
 };
 
 export const getResourceUrl = (uuid: string) => {
@@ -60,3 +61,6 @@ export const matchProcessRoute = (route: string) =>
 
 export const matchProcessLogRoute = (route: string) =>
     matchPath<ResourceRouteParams>(route, { path: Routes.PROCESS_LOGS });
+
+export const matchSharedWithMeRoute = (route: string) =>
+    matchPath(route, { path: Routes.SHARED_WITH_ME });
index f90b4a3053ca1744c2228a51c4c45177bf644c87..44e4eef5c944b271eba16c558b43a4d700c4f886 100644 (file)
@@ -14,17 +14,21 @@ export class AncestorService {
         private userService: UserService
     ) { }
 
-    async ancestors(uuid: string, rootUuid: string): Promise<Array<UserResource | GroupResource | TrashableResource>> {
+    async ancestors(uuid: string, rootUuid: string): Promise<Array<UserResource | GroupResource>> {
         const service = this.getService(extractUuidObjectType(uuid));
         if (service) {
-            const resource = await service.get(uuid);
-            if (uuid === rootUuid) {
-                return [resource];
-            } else {
-                return [
-                    ...await this.ancestors(resource.ownerUuid, rootUuid),
-                    resource
-                ];
+            try {
+                const resource = await service.get(uuid);
+                if (uuid === rootUuid) {
+                    return [resource];
+                } else {
+                    return [
+                        ...await this.ancestors(resource.ownerUuid, rootUuid),
+                        resource
+                    ];
+                }
+            } catch (e) {
+                return [];
             }
         } else {
             return [];
index b285e9285518505cf6e459d357ba72ee58acec05..299e6808546b224cb2e1b39f18bb3aeb73061b40 100644 (file)
@@ -3,13 +3,14 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import * as _ from "lodash";
-import { CommonResourceService, ListResults } from "~/services/common-service/common-resource-service";
+import { CommonResourceService, ListResults, ListArguments } from '~/services/common-service/common-resource-service';
 import { AxiosInstance } from "axios";
 import { CollectionResource } from "~/models/collection";
 import { ProjectResource } from "~/models/project";
 import { ProcessResource } from "~/models/process";
 import { TrashableResource } from "~/models/resource";
 import { TrashableResourceService } from "~/services/common-service/trashable-resource-service";
+import { GroupResource } from '~/models/group';
 
 export interface ContentsArguments {
     limit?: number;
@@ -20,12 +21,16 @@ export interface ContentsArguments {
     includeTrash?: boolean;
 }
 
+export interface SharedArguments extends ListArguments {
+    include?: string;
+}
+
 export type GroupContentsResource =
     CollectionResource |
     ProjectResource |
     ProcessResource;
 
-export class GroupsService<T extends TrashableResource = TrashableResource> extends TrashableResourceService<T> {
+export class GroupsService<T extends GroupResource = GroupResource> extends TrashableResourceService<T> {
 
     constructor(serverApi: AxiosInstance) {
         super(serverApi, "groups");
@@ -44,6 +49,12 @@ export class GroupsService<T extends TrashableResource = TrashableResource> exte
             })
             .then(CommonResourceService.mapResponseKeys);
     }
+
+    shared(params: SharedArguments = {}): Promise<ListResults<GroupContentsResource>> {
+        return this.serverApi
+            .get(this.resourceType + 'shared', { params })
+            .then(CommonResourceService.mapResponseKeys);
+    }
 }
 
 export enum GroupContentsResourcePrefix {
index cc7bb1dd2d2d6f9237e448dfe0c1fbca4692a6f3..4ac07b3bd5bbb39643e87d20fbba068999f4f03f 100644 (file)
@@ -7,9 +7,13 @@ import { RootState } from '~/store/store';
 import { Breadcrumb } from '~/components/breadcrumbs/breadcrumbs';
 import { getResource } from '~/store/resources/resources';
 import { TreePicker } from '../tree-picker/tree-picker';
-import { getSidePanelTreeBranch } from '../side-panel-tree/side-panel-tree-actions';
+import { getSidePanelTreeBranch, getSidePanelTreeNodeAncestorsIds } from '../side-panel-tree/side-panel-tree-actions';
 import { propertiesActions } from '../properties/properties-actions';
 import { getProcess } from '~/store/processes/process';
+import { ServiceRepository } from '~/services/services';
+import { SidePanelTreeCategory, activateSidePanelTreeItem } from '~/store/side-panel-tree/side-panel-tree-actions';
+import { updateResources } from '../resources/resources-actions';
+import { ResourceKind } from '~/models/resource';
 
 export const BREADCRUMBS = 'breadcrumbs';
 
@@ -35,7 +39,33 @@ export const setSidePanelBreadcrumbs = (uuid: string) =>
         dispatch(setBreadcrumbs(breadcrumbs));
     };
 
-export const setProjectBreadcrumbs = setSidePanelBreadcrumbs;
+export const setSharedWithMeBreadcrumbs = (uuid: string) =>
+    async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+        const ancestors = await services.ancestorsService.ancestors(uuid, '');
+        dispatch(updateResources(ancestors));
+        const initialBreadcrumbs: ResourceBreadcrumb[] = [
+            { label: SidePanelTreeCategory.SHARED_WITH_ME, uuid: SidePanelTreeCategory.SHARED_WITH_ME }
+        ];
+        const breadrumbs = ancestors.reduce((breadcrumbs, ancestor) =>
+            ancestor.kind === ResourceKind.GROUP
+                ? [...breadcrumbs, { label: ancestor.name, uuid: ancestor.uuid }]
+                : breadcrumbs,
+            initialBreadcrumbs);
+
+        dispatch(setBreadcrumbs(breadrumbs));
+    };
+
+export const setProjectBreadcrumbs = (uuid: string) =>
+    (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
+        const ancestors = getSidePanelTreeNodeAncestorsIds(uuid)(getState().treePicker);
+        const rootUuid = services.authService.getUuid();
+        if (uuid === rootUuid ||ancestors.find(uuid => uuid === rootUuid)) {
+            dispatch(setSidePanelBreadcrumbs(uuid));
+        } else {
+            dispatch(setSharedWithMeBreadcrumbs(uuid));
+            dispatch(activateSidePanelTreeItem(SidePanelTreeCategory.SHARED_WITH_ME));
+        }
+    };
 
 export const setCollectionBreadcrumbs = (collectionUuid: string) =>
     (dispatch: Dispatch, getState: () => RootState) => {
index 0e87769e24a57095f4e74fd578f5c46ed1358c59..c68c5398754e13c6a439af6176cf53a36def01d7 100644 (file)
@@ -24,6 +24,8 @@ export const navigateTo = (uuid: string) =>
         }
         if (uuid === SidePanelTreeCategory.FAVORITES) {
             dispatch<any>(navigateToFavorites);
+        } else if(uuid === SidePanelTreeCategory.SHARED_WITH_ME){
+            dispatch(navigateToSharedWithMe);
         }
     };
 
@@ -44,4 +46,6 @@ export const navigateToRootProject = (dispatch: Dispatch, getState: () => RootSt
     if (rootProjectUuid) {
         dispatch(navigateToProject(rootProjectUuid));
     }
-};
\ No newline at end of file
+};
+
+export const navigateToSharedWithMe = push(Routes.SHARED_WITH_ME);
index 4b4ec2697989831e734f963eb8c872b144b1ebee..519943c1f547a1b7c13c18f880dca8368dc4a635 100644 (file)
@@ -66,19 +66,19 @@ export const loadMissingProcessesInformation = (resources: GroupContentsResource
         }
     };
 
-const setItems = (listResults: ListResults<GroupContentsResource>) =>
+export const setItems = (listResults: ListResults<GroupContentsResource>) =>
     projectPanelActions.SET_ITEMS({
         ...listResultsToDataExplorerItemsMeta(listResults),
         items: listResults.items.map(resource => resource.uuid),
     });
 
-const getParams = (dataExplorer: DataExplorer) => ({
+export const getParams = (dataExplorer: DataExplorer) => ({
     ...dataExplorerToListParams(dataExplorer),
     order: getOrder(dataExplorer),
     filters: getFilters(dataExplorer),
 });
 
-const getFilters = (dataExplorer: DataExplorer) => {
+export const getFilters = (dataExplorer: DataExplorer) => {
     const columns = dataExplorer.columns as DataColumns<string, ProjectPanelFilter>;
     const typeFilters = getDataExplorerColumnFilters(columns, ProjectPanelColumnNames.TYPE);
     const statusFilters = getDataExplorerColumnFilters(columns, ProjectPanelColumnNames.STATUS);
@@ -90,7 +90,7 @@ const getFilters = (dataExplorer: DataExplorer) => {
         .getFilters();
 };
 
-const getOrder = (dataExplorer: DataExplorer) => {
+export const getOrder = (dataExplorer: DataExplorer) => {
     const sortColumn = dataExplorer.columns.find(c => c.sortDirection !== SortDirection.NONE);
     const order = new OrderBuilder<ProjectResource>();
     if (sortColumn) {
diff --git a/src/store/shared-with-me-panel/shared-with-me-middleware-service.ts b/src/store/shared-with-me-panel/shared-with-me-middleware-service.ts
new file mode 100644 (file)
index 0000000..1ebb13e
--- /dev/null
@@ -0,0 +1,82 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { DataExplorerMiddlewareService, listResultsToDataExplorerItemsMeta, dataExplorerToListParams } from '../data-explorer/data-explorer-middleware-service';
+import { ServiceRepository } from '~/services/services';
+import { MiddlewareAPI, Dispatch } from 'redux';
+import { RootState } from '~/store/store';
+import { getDataExplorer, DataExplorer } from '~/store/data-explorer/data-explorer-reducer';
+import { updateFavorites } from '~/store/favorites/favorites-actions';
+import { updateResources } from '~/store/resources/resources-actions';
+import { loadMissingProcessesInformation } from '~/store/project-panel/project-panel-middleware-service';
+import { snackbarActions } from '~/store/snackbar/snackbar-actions';
+import { sharedWithMePanelActions } from './shared-with-me-panel-actions';
+import { ListResults } from '~/services/common-service/common-resource-service';
+import { GroupContentsResource } from '~/services/groups-service/groups-service';
+import { SortDirection } from '~/components/data-table/data-column';
+import { OrderBuilder, OrderDirection } from '~/services/api/order-builder';
+import { ProjectResource } from '~/models/project';
+import { ProjectPanelColumnNames } from '~/views/project-panel/project-panel';
+import { FilterBuilder } from '~/services/api/filter-builder';
+
+export class SharedWithMeMiddlewareService extends DataExplorerMiddlewareService {
+    constructor(private services: ServiceRepository, id: string) {
+        super(id);
+    }
+
+    async requestItems(api: MiddlewareAPI<Dispatch, RootState>) {
+        const state = api.getState();
+        const dataExplorer = getDataExplorer(state.dataExplorer, this.getId());
+        try {
+            const response = await this.services.groupsService.shared(getParams(dataExplorer));
+            api.dispatch<any>(updateFavorites(response.items.map(item => item.uuid)));
+            api.dispatch(updateResources(response.items));
+            await api.dispatch<any>(loadMissingProcessesInformation(response.items));
+            api.dispatch(setItems(response));
+        } catch (e) {
+            api.dispatch(couldNotFetchSharedItems());
+        }
+
+    }
+}
+
+export const getParams = (dataExplorer: DataExplorer) => ({
+    ...dataExplorerToListParams(dataExplorer),
+    order: getOrder(dataExplorer),
+    filters: getFilters(dataExplorer),
+});
+
+export const getFilters = (dataExplorer: DataExplorer) => {
+    const filters = new FilterBuilder()
+        .addILike("name", dataExplorer.searchValue)
+        .getFilters();
+    return `[${filters}]`;
+};
+
+export const getOrder = (dataExplorer: DataExplorer) => {
+    const sortColumn = dataExplorer.columns.find(c => c.sortDirection !== SortDirection.NONE);
+    const order = new OrderBuilder<ProjectResource>();
+    if (sortColumn) {
+        const sortDirection = sortColumn && sortColumn.sortDirection === SortDirection.ASC
+            ? OrderDirection.ASC
+            : OrderDirection.DESC;
+        const columnName = sortColumn && sortColumn.name === ProjectPanelColumnNames.NAME ? "name" : "createdAt";
+        return order
+            .addOrder(sortDirection, columnName)
+            .getOrder();
+    } else {
+        return order.getOrder();
+    }
+};
+
+export const setItems = (listResults: ListResults<GroupContentsResource>) =>
+    sharedWithMePanelActions.SET_ITEMS({
+        ...listResultsToDataExplorerItemsMeta(listResults),
+        items: listResults.items.map(resource => resource.uuid),
+    });
+
+const couldNotFetchSharedItems = () =>
+    snackbarActions.OPEN_SNACKBAR({
+        message: 'Could not fetch shared items.'
+    });
diff --git a/src/store/shared-with-me-panel/shared-with-me-panel-actions.ts b/src/store/shared-with-me-panel/shared-with-me-panel-actions.ts
new file mode 100644 (file)
index 0000000..2553086
--- /dev/null
@@ -0,0 +1,18 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { bindDataExplorerActions } from "../data-explorer/data-explorer-action";
+import { Dispatch } from 'redux';
+import { ServiceRepository } from "~/services/services";
+import { RootState } from '~/store/store';
+
+export const SHARED_WITH_ME_PANEL_ID = "sharedWithMePanel";
+export const sharedWithMePanelActions = bindDataExplorerActions(SHARED_WITH_ME_PANEL_ID);
+
+export const loadSharedWithMePanel = () =>
+    (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+        dispatch(sharedWithMePanelActions.REQUEST_ITEMS());
+    };
+
+
index 95e409f5c5bfcd2ca6edfc08df4377dedb24dfae..073de22c4ea4b9fa30aae1b15fc2311dfc706fe0 100644 (file)
@@ -147,14 +147,14 @@ export const expandSidePanelTreeItem = (nodeId: string) =>
         }
     };
 
-const getSidePanelTreeNode = (nodeId: string) => (treePicker: TreePicker) => {
+export const getSidePanelTreeNode = (nodeId: string) => (treePicker: TreePicker) => {
     const sidePanelTree = getTreePicker(SIDE_PANEL_TREE)(treePicker);
     return sidePanelTree
         ? getNodeValue(nodeId)(sidePanelTree)
         : undefined;
 };
 
-const getSidePanelTreeNodeAncestorsIds = (nodeId: string) => (treePicker: TreePicker) => {
+export const getSidePanelTreeNodeAncestorsIds = (nodeId: string) => (treePicker: TreePicker) => {
     const sidePanelTree = getTreePicker(SIDE_PANEL_TREE)(treePicker);
     return sidePanelTree
         ? getNodeAncestorsIds(nodeId)(sidePanelTree)
index 3b66157dcd83262b1edfc35e5e3b131e7d885cd0..2a5fdd0c2d17c1aae6c3455034fd303ddb523a36 100644 (file)
@@ -4,7 +4,7 @@
 
 import { Dispatch } from 'redux';
 import { isSidePanelTreeCategory, SidePanelTreeCategory } from '~/store/side-panel-tree/side-panel-tree-actions';
-import { navigateToFavorites, navigateTo, navigateToTrash } from '../navigation/navigation-action';
+import { navigateToFavorites, navigateTo, navigateToTrash, navigateToSharedWithMe } from '../navigation/navigation-action';
 import { snackbarActions } from '~/store/snackbar/snackbar-actions';
 
 export const navigateFromSidePanel = (id: string) =>
@@ -22,6 +22,8 @@ const getSidePanelTreeCategoryAction = (id: string) => {
             return navigateToFavorites;
         case SidePanelTreeCategory.TRASH:
             return navigateToTrash;
+        case SidePanelTreeCategory.SHARED_WITH_ME:
+            return navigateToSharedWithMe;
         default:
             return sidePanelTreeCategoryNotAvailable(id);
     }
index 9b4f42b84fc81d8d64b2177c0187a6ee94fb60c9..43ab2310f754c91d63a58f25fd7ef3bfcbe7af90 100644 (file)
@@ -32,6 +32,8 @@ import { TrashPanelMiddlewareService } from "~/store/trash-panel/trash-panel-mid
 import { TRASH_PANEL_ID } from "~/store/trash-panel/trash-panel-action";
 import { processLogsPanelReducer } from './process-logs-panel/process-logs-panel-reducer';
 import { processPanelReducer } from '~/store/process-panel/process-panel-reducer';
+import { SHARED_WITH_ME_PANEL_ID } from '~/store/shared-with-me-panel/shared-with-me-panel-actions';
+import { SharedWithMeMiddlewareService } from './shared-with-me-panel/shared-with-me-middleware-service';
 
 const composeEnhancers =
     (process.env.NODE_ENV === 'development' &&
@@ -54,13 +56,17 @@ export function configureStore(history: History, services: ServiceRepository): R
     const trashPanelMiddleware = dataExplorerMiddleware(
         new TrashPanelMiddlewareService(services, TRASH_PANEL_ID)
     );
+    const sharedWithMePanelMiddleware = dataExplorerMiddleware(
+        new SharedWithMeMiddlewareService(services, SHARED_WITH_ME_PANEL_ID)
+    );
 
     const middlewares: Middleware[] = [
         routerMiddleware(history),
         thunkMiddleware.withExtraArgument(services),
         projectPanelMiddleware,
         favoritePanelMiddleware,
-        trashPanelMiddleware
+        trashPanelMiddleware,
+        sharedWithMePanelMiddleware,
     ];
     const enhancer = composeEnhancers(applyMiddleware(...middlewares));
     return createStore(rootReducer, enhancer);
index d1b0fae953281b562d7edebeb2c9c5d1bcf8435d..c79dc48f9f58e8c0bf81b659dcb3b00493001702 100644 (file)
@@ -9,13 +9,13 @@ import { loadCollectionPanel } from '~/store/collection-panel/collection-panel-a
 import { snackbarActions } from '../snackbar/snackbar-actions';
 import { loadFavoritePanel } from '../favorite-panel/favorite-panel-action';
 import { openProjectPanel, projectPanelActions } from '~/store/project-panel/project-panel-action';
-import { activateSidePanelTreeItem, initSidePanelTree, SidePanelTreeCategory, loadSidePanelTreeProjects } from '../side-panel-tree/side-panel-tree-actions';
+import { activateSidePanelTreeItem, initSidePanelTree, SidePanelTreeCategory, loadSidePanelTreeProjects, getSidePanelTreeNodeAncestorsIds } from '../side-panel-tree/side-panel-tree-actions';
 import { loadResource, updateResources } from '../resources/resources-actions';
 import { favoritePanelActions } from '~/store/favorite-panel/favorite-panel-action';
 import { projectPanelColumns } from '~/views/project-panel/project-panel';
 import { favoritePanelColumns } from '~/views/favorite-panel/favorite-panel';
 import { matchRootRoute } from '~/routes/routes';
-import { setCollectionBreadcrumbs, setProjectBreadcrumbs, setSidePanelBreadcrumbs, setProcessBreadcrumbs } from '../breadcrumbs/breadcrumbs-actions';
+import { setCollectionBreadcrumbs, setProjectBreadcrumbs, setSidePanelBreadcrumbs, setProcessBreadcrumbs, setSharedWithMeBreadcrumbs } from '../breadcrumbs/breadcrumbs-actions';
 import { navigateToProject } from '../navigation/navigation-action';
 import { MoveToFormDialogData } from '~/store/move-to-dialog/move-to-dialog';
 import { ServiceRepository } from '~/services/services';
@@ -36,6 +36,9 @@ import { trashPanelColumns } from "~/views/trash-panel/trash-panel";
 import { loadTrashPanel, trashPanelActions } from "~/store/trash-panel/trash-panel-action";
 import { initProcessLogsPanel } from '../process-logs-panel/process-logs-panel-actions';
 import { loadProcessPanel } from '~/store/process-panel/process-panel-actions';
+import { sharedWithMePanelActions } from '~/store/shared-with-me-panel/shared-with-me-panel-actions';
+import { loadSharedWithMePanel } from '../shared-with-me-panel/shared-with-me-panel-actions';
+
 import { CopyFormDialogData } from '~/store/copy-dialog/copy-dialog';
 
 export const loadWorkbench = () =>
@@ -48,6 +51,7 @@ export const loadWorkbench = () =>
                 dispatch(projectPanelActions.SET_COLUMNS({ columns: projectPanelColumns }));
                 dispatch(favoritePanelActions.SET_COLUMNS({ columns: favoritePanelColumns }));
                 dispatch(trashPanelActions.SET_COLUMNS({ columns: trashPanelColumns }));
+                dispatch(sharedWithMePanelActions.SET_COLUMNS({ columns: projectPanelColumns }));
                 dispatch<any>(initSidePanelTree());
                 if (router.location) {
                     const match = matchRootRoute(router.location.pathname);
@@ -78,10 +82,10 @@ export const loadTrash = () =>
     };
 
 export const loadProject = (uuid: string) =>
-    async (dispatch: Dispatch) => {
-        await dispatch<any>(activateSidePanelTreeItem(uuid));
-        dispatch<any>(setProjectBreadcrumbs(uuid));
-        dispatch<any>(openProjectPanel(uuid));
+    async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
+        dispatch(openProjectPanel(uuid));
+        await dispatch(activateSidePanelTreeItem(uuid));
+        dispatch(setProjectBreadcrumbs(uuid));
         dispatch(loadDetailsPanel(uuid));
     };
 
@@ -266,3 +270,9 @@ export const reloadProjectMatchingUuid = (matchingUuids: string[]) =>
             dispatch<any>(loadProject(currentProjectPanelUuid));
         }
     };
+
+export const loadSharedWithMe = (dispatch: Dispatch) => {
+    dispatch<any>(activateSidePanelTreeItem(SidePanelTreeCategory.SHARED_WITH_ME));
+    dispatch<any>(loadSharedWithMePanel());
+    dispatch<any>(setSidePanelBreadcrumbs(SidePanelTreeCategory.SHARED_WITH_ME));
+};
diff --git a/src/views/shared-with-me-panel/shared-with-me-panel.tsx b/src/views/shared-with-me-panel/shared-with-me-panel.tsx
new file mode 100644 (file)
index 0000000..9106f87
--- /dev/null
@@ -0,0 +1,77 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from 'react';
+import { StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core';
+import { DataExplorer } from "~/views-components/data-explorer/data-explorer";
+import { connect, DispatchProp } from 'react-redux';
+import { RootState } from '~/store/store';
+import { ArvadosTheme } from '~/common/custom-theme';
+import { ShareMeIcon } from '~/components/icon/icon';
+import { ResourcesState, getResource } from '~/store/resources/resources';
+import { navigateTo } from "~/store/navigation/navigation-action";
+import { loadDetailsPanel } from "~/store/details-panel/details-panel-action";
+import { DataTableDefaultView } from '~/components/data-table-default-view/data-table-default-view';
+import { SHARED_WITH_ME_PANEL_ID } from '~/store/shared-with-me-panel/shared-with-me-panel-actions';
+import { openContextMenu } from '~/store/context-menu/context-menu-actions';
+import { GroupResource } from '~/models/group';
+import { ContextMenuKind } from '~/views-components/context-menu/context-menu';
+
+type CssRules = "toolbar" | "button";
+
+const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
+    toolbar: {
+        paddingBottom: theme.spacing.unit * 3,
+        textAlign: "right"
+    },
+    button: {
+        marginLeft: theme.spacing.unit
+    },
+});
+
+interface SharedWithMePanelDataProps {
+    resources: ResourcesState;
+}
+
+type SharedWithMePanelProps = SharedWithMePanelDataProps & DispatchProp & WithStyles<CssRules>;
+
+export const SharedWithMePanel = withStyles(styles)(
+    connect((state: RootState) => ({
+        resources: state.resources
+    }))(
+        class extends React.Component<SharedWithMePanelProps> {
+            render() {
+                return <DataExplorer
+                    id={SHARED_WITH_ME_PANEL_ID}
+                    onRowClick={this.handleRowClick}
+                    onRowDoubleClick={this.handleRowDoubleClick}
+                    onContextMenu={this.handleContextMenu}
+                    contextMenuColumn={false}
+                    dataTableDefaultView={<DataTableDefaultView icon={ShareMeIcon} />} />;
+            }
+
+            handleContextMenu = (event: React.MouseEvent<HTMLElement>, resourceUuid: string) => {
+                const resource = getResource<GroupResource>(resourceUuid)(this.props.resources);
+                if (resource) {
+                    this.props.dispatch<any>(openContextMenu(event, {
+                        name: '',
+                        uuid: resource.uuid,
+                        ownerUuid: resource.ownerUuid,
+                        isTrashed: resource.isTrashed,
+                        kind: resource.kind,
+                        menuKind: ContextMenuKind.PROJECT,
+                    }));
+                }
+            }
+
+            handleRowDoubleClick = (uuid: string) => {
+                this.props.dispatch<any>(navigateTo(uuid));
+            }
+
+            handleRowClick = (uuid: string) => {
+                this.props.dispatch(loadDetailsPanel(uuid));
+            }
+        }
+    )
+);
index 95f4683414d702159526696dbe4d74fdf131a305..1d7d47d09ee89f8085312cf2b0a1b804f823e07c 100644 (file)
@@ -42,6 +42,7 @@ import { PartialCopyCollectionDialog } from '~/views-components/dialog-forms/par
 import { TrashPanel } from "~/views/trash-panel/trash-panel";
 import { MainContentBar } from '~/views-components/main-content-bar/main-content-bar';
 import { Grid } from '@material-ui/core';
+import { SharedWithMePanel } from '../shared-with-me-panel/shared-with-me-panel';
 import { ProcessCommandDialog } from '~/views-components/process-command-dialog/process-command-dialog';
 import SplitterLayout from 'react-splitter-layout';
 
@@ -137,6 +138,7 @@ export const Workbench = withStyles(styles)(
                                                     <Route path={Routes.PROCESSES} component={ProcessPanel} />
                                                     <Route path={Routes.TRASH} component={TrashPanel} />
                                                     <Route path={Routes.PROCESS_LOGS} component={ProcessLogPanel} />
+                                                    <Route path={Routes.SHARED_WITH_ME} component={SharedWithMePanel} />
                                                 </Switch>
                                             </Grid>
                                         </Grid>