[ARVADOS-WORKBENCH2] updated: 1.1.4-185-g3816fac
Git user
git at public.curoverse.com
Wed Jul 4 06:27:34 EDT 2018
Summary of changes:
src/store/navigation/navigation-action.ts | 12 +----
src/store/store.ts | 4 +-
src/views/project-panel/project-panel-item.ts | 17 +++----
.../project-panel/project-panel-middleware.ts | 55 ++++++++++++++++++++++
4 files changed, 69 insertions(+), 19 deletions(-)
create mode 100644 src/views/project-panel/project-panel-middleware.ts
via 3816facfe98d5ee9c0b825880188214e336b0506 (commit)
from 2767521c504e5a43cfdcf86781f94ce2bcfc81e4 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 3816facfe98d5ee9c0b825880188214e336b0506
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date: Wed Jul 4 12:27:20 2018 +0200
Create project panel middleware
Feature #13703
Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
diff --git a/src/store/navigation/navigation-action.ts b/src/store/navigation/navigation-action.ts
index daeb26f..ec6e9bb 100644
--- a/src/store/navigation/navigation-action.ts
+++ b/src/store/navigation/navigation-action.ts
@@ -61,17 +61,9 @@ export const setProjectItem = (itemId: string, itemMode: ItemMode) =>
: dispatch<any>(getProjectList(itemId));
promise
- .then(() => dispatch<any>(getCollectionList(itemId)))
.then(() => dispatch<any>(() => {
- const { projects, collections } = getState();
- dispatch(dataExplorerActions.SET_ITEMS({
- id: PROJECT_PANEL_ID,
- items: projectPanelItems(
- projects.items,
- treeItem.data.uuid,
- collections
- )
- }));
+ dispatch(dataExplorerActions.RESET_PAGINATION({id: PROJECT_PANEL_ID}));
+ dispatch(dataExplorerActions.REQUEST_ITEMS({id: PROJECT_PANEL_ID}));
}));
}
diff --git a/src/store/store.ts b/src/store/store.ts
index 68c5d82..0c32e65 100644
--- a/src/store/store.ts
+++ b/src/store/store.ts
@@ -12,6 +12,7 @@ import sidePanelReducer, { SidePanelState } from './side-panel/side-panel-reduce
import authReducer, { AuthState } from "./auth/auth-reducer";
import dataExplorerReducer, { DataExplorerState } from './data-explorer/data-explorer-reducer';
import collectionsReducer, { CollectionState } from "./collection/collection-reducer";
+import { projectPanelMiddleware } from '../views/project-panel/project-panel-middleware';
const composeEnhancers =
(process.env.NODE_ENV === 'development' &&
@@ -40,7 +41,8 @@ const rootReducer = combineReducers({
export default function configureStore(history: History) {
const middlewares: Middleware[] = [
routerMiddleware(history),
- thunkMiddleware
+ thunkMiddleware,
+ projectPanelMiddleware
];
const enhancer = composeEnhancers(applyMiddleware(...middlewares));
return createStore(rootReducer, enhancer);
diff --git a/src/views/project-panel/project-panel-item.ts b/src/views/project-panel/project-panel-item.ts
index e0eb84f..cf77aaf 100644
--- a/src/views/project-panel/project-panel-item.ts
+++ b/src/views/project-panel/project-panel-item.ts
@@ -2,14 +2,13 @@
//
// SPDX-License-Identifier: AGPL-3.0
-import { TreeItem } from "../../components/tree/tree";
-import { Project } from "../../models/project";
-import { getResourceKind, Resource, ResourceKind } from "../../models/resource";
+import { Resource } from "../../common/api/common-resource-service";
+import { DataItem } from "../../components/data-table/data-table";
-export interface ProjectPanelItem {
+export interface ProjectPanelItem extends DataItem {
uuid: string;
name: string;
- kind: ResourceKind;
+ kind: string;
url: string;
owner: string;
lastModified: string;
@@ -17,11 +16,13 @@ export interface ProjectPanelItem {
status?: string;
}
-function resourceToDataItem(r: Resource, kind?: ResourceKind) {
+export function resourceToDataItem(r: Resource): ProjectPanelItem {
return {
+ key: r.uuid,
uuid: r.uuid,
- name: r.name,
- kind: kind ? kind : getResourceKind(r.kind),
+ name: r.uuid,
+ kind: r.kind,
+ url: "",
owner: r.ownerUuid,
lastModified: r.modifiedAt
};
diff --git a/src/views/project-panel/project-panel-middleware.ts b/src/views/project-panel/project-panel-middleware.ts
new file mode 100644
index 0000000..9be5981
--- /dev/null
+++ b/src/views/project-panel/project-panel-middleware.ts
@@ -0,0 +1,55 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { Middleware } from "redux";
+import actions from "../../store/data-explorer/data-explorer-action";
+import { PROJECT_PANEL_ID, columns } from "./project-panel";
+import { groupsService } from "../../services/services";
+import { RootState } from "../../store/store";
+import { getDataExplorer } from "../../store/data-explorer/data-explorer-reducer";
+import { resourceToDataItem } from "./project-panel-item";
+
+export const projectPanelMiddleware: Middleware = store => next => {
+ next(actions.SET_COLUMNS({ id: PROJECT_PANEL_ID, columns }));
+
+ return action => {
+
+ const handleProjectPanelAction = <T extends { id: string }>(handler: (data: T) => void) =>
+ (data: T) => {
+ next(action);
+ if (data.id === PROJECT_PANEL_ID) {
+ handler(data);
+ }
+ };
+
+ actions.match(action, {
+ SET_PAGE: handleProjectPanelAction(() => {
+ store.dispatch(actions.REQUEST_ITEMS({ id: PROJECT_PANEL_ID }));
+ }),
+ SET_ROWS_PER_PAGE: handleProjectPanelAction(() => {
+ store.dispatch(actions.REQUEST_ITEMS({ id: PROJECT_PANEL_ID }));
+ }),
+ REQUEST_ITEMS: handleProjectPanelAction(() => {
+ const state = store.getState() as RootState;
+ const dataExplorer = getDataExplorer(state.dataExplorer, PROJECT_PANEL_ID);
+ groupsService
+ .contents(state.projects.currentItemId, {
+ limit: dataExplorer.rowsPerPage,
+ offset: dataExplorer.page * dataExplorer.rowsPerPage,
+ })
+ .then(response => {
+ store.dispatch(actions.SET_ITEMS({
+ id: PROJECT_PANEL_ID,
+ items: response.items.map(resourceToDataItem),
+ itemsAvailable: response.itemsAvailable,
+ page: Math.floor(response.offset / response.limit),
+ rowsPerPage: response.limit
+ }));
+ });
+
+ }),
+ default: () => next(action)
+ });
+ };
+};
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list