[ARVADOS-WORKBENCH2] updated: 1.1.4-451-gae85f32
Git user
git at public.curoverse.com
Mon Jul 30 05:27:05 EDT 2018
Summary of changes:
.../data-explorer-middleware-service.ts | 8 ++---
.../data-explorer/data-explorer-middleware.test.ts | 41 ++++------------------
.../data-explorer/data-explorer-middleware.ts | 27 +++++++-------
.../favorite-panel-middleware-service.ts | 13 +++----
.../project-panel-middleware-service.ts | 13 +++----
5 files changed, 37 insertions(+), 65 deletions(-)
via ae85f32b449562726c0fd3d30447c799069a0bbb (commit)
via d6044c2155e8a59a09de9f581b34573f94f1827a (commit)
from 6d13a683ff5ce887bfd4c20b0bdbd18298dd86b2 (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 ae85f32b449562726c0fd3d30447c799069a0bbb
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date: Mon Jul 30 11:26:48 2018 +0200
Use bindDataExplorerActions in middleware, remove api field from service class, update tests
Feature #13887
Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
diff --git a/src/store/data-explorer/data-explorer-middleware-service.ts b/src/store/data-explorer/data-explorer-middleware-service.ts
index fa85664..4606307 100644
--- a/src/store/data-explorer/data-explorer-middleware-service.ts
+++ b/src/store/data-explorer/data-explorer-middleware-service.ts
@@ -7,7 +7,6 @@ import { MiddlewareAPI } from "redux";
import { DataColumns } from "../../components/data-table/data-table";
export abstract class DataExplorerMiddlewareService {
- protected api: MiddlewareAPI;
protected readonly id: string;
protected constructor(id: string) {
@@ -21,10 +20,7 @@ export abstract class DataExplorerMiddlewareService {
abstract getColumns(): DataColumns<any>;
abstract requestItems(api: MiddlewareAPI): void;
- setApi(api: MiddlewareAPI) {
- this.api = api;
- }
- getDataExplorer() {
- return getDataExplorer(this.api.getState().dataExplorer, this.id);
+ getDataExplorer(api: MiddlewareAPI) {
+ return getDataExplorer(api.getState().dataExplorer, this.id);
}
}
diff --git a/src/store/data-explorer/data-explorer-middleware.test.ts b/src/store/data-explorer/data-explorer-middleware.test.ts
index f66819f..65ff8a5 100644
--- a/src/store/data-explorer/data-explorer-middleware.test.ts
+++ b/src/store/data-explorer/data-explorer-middleware.test.ts
@@ -1,30 +1,15 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
import { DataExplorerMiddlewareService } from "./data-explorer-middleware-service";
import { dataExplorerMiddleware } from "./data-explorer-middleware";
import { MiddlewareAPI } from "../../../node_modules/redux";
-import { columns } from "../../views/project-panel/project-panel";
import { DataColumns } from "../../components/data-table/data-table";
import { dataExplorerActions } from "./data-explorer-action";
-// Copyright (C) The Arvados Authors. All rights reserved.
-//
-// SPDX-License-Identifier: AGPL-3.0
describe("DataExplorerMiddleware", () => {
- it("initializes service with middleware api", () => {
- const config = {
- id: "",
- columns: [],
- requestItems: jest.fn(),
- setApi: jest.fn()
- };
- const service = new ServiceMock(config);
- const api = {
- getState: jest.fn(),
- dispatch: jest.fn()
- };
- dataExplorerMiddleware(service)(api)(jest.fn());
- expect(config.setApi).toHaveBeenCalled();
- });
it("initializes columns in the store", () => {
const config = {
@@ -163,15 +148,8 @@ describe("DataExplorerMiddleware", () => {
};
const next = jest.fn();
const middleware = dataExplorerMiddleware(service)(api)(next);
- middleware(dataExplorerActions.SET_PAGE({ id: service.getId(), page: 0 }));
middleware(dataExplorerActions.SET_ROWS_PER_PAGE({ id: service.getId(), rowsPerPage: 0 }));
- middleware(dataExplorerActions.SET_FILTERS({ id: service.getId(), columnName: "", filters: [] }));
- middleware(dataExplorerActions.TOGGLE_SORT({ id: service.getId(), columnName: "" }));
- middleware(dataExplorerActions.TOGGLE_COLUMN({ id: service.getId(), columnName: "" }));
- middleware(dataExplorerActions.REQUEST_ITEMS({ id: service.getId() }));
- middleware(dataExplorerActions.SET_SEARCH_VALUE({ id: service.getId(), searchValue: "" }));
- middleware(dataExplorerActions.RESET_PAGINATION({ id: service.getId() }));
- expect(api.dispatch).toHaveBeenCalledTimes(7);
+ expect(api.dispatch).toHaveBeenCalledTimes(1);
});
it("handles TOGGLE_SORT action", () => {
@@ -247,12 +225,7 @@ class ServiceMock extends DataExplorerMiddlewareService {
return this.config.columns;
}
- requestItems() {
- this.config.requestItems(this.api);
- }
-
- setApi(api: MiddlewareAPI) {
- this.config.setApi();
- this.api = api;
+ requestItems(api: MiddlewareAPI) {
+ this.config.requestItems(api);
}
}
diff --git a/src/store/data-explorer/data-explorer-middleware.ts b/src/store/data-explorer/data-explorer-middleware.ts
index f299ea1..71825e8 100644
--- a/src/store/data-explorer/data-explorer-middleware.ts
+++ b/src/store/data-explorer/data-explorer-middleware.ts
@@ -4,40 +4,41 @@
// SPDX-License-Identifier: AGPL-3.0
import { Middleware } from "../../../node_modules/redux";
-import { dataExplorerActions } from "./data-explorer-action";
+import { dataExplorerActions, bindDataExplorerActions } from "./data-explorer-action";
import { DataExplorerMiddlewareService } from "./data-explorer-middleware-service";
-export const dataExplorerMiddleware = (dataExplorerService: DataExplorerMiddlewareService): Middleware => api => next => {
- dataExplorerService.setApi(api);
- next(dataExplorerActions.SET_COLUMNS({ id: dataExplorerService.getId(), columns: dataExplorerService.getColumns() }));
+export const dataExplorerMiddleware = (service: DataExplorerMiddlewareService): Middleware => api => next => {
+ const actions = bindDataExplorerActions(service.getId());
+ next(actions.SET_COLUMNS({ columns: service.getColumns() }));
+
return action => {
const handleAction = <T extends { id: string }>(handler: (data: T) => void) =>
(data: T) => {
next(action);
- if (data.id === dataExplorerService.getId()) {
+ if (data.id === service.getId()) {
handler(data);
}
};
dataExplorerActions.match(action, {
SET_PAGE: handleAction(() => {
- api.dispatch(dataExplorerActions.REQUEST_ITEMS({ id: dataExplorerService.getId() }));
+ api.dispatch(actions.REQUEST_ITEMS());
}),
SET_ROWS_PER_PAGE: handleAction(() => {
- api.dispatch(dataExplorerActions.REQUEST_ITEMS({ id: dataExplorerService.getId() }));
+ api.dispatch(actions.REQUEST_ITEMS());
}),
SET_FILTERS: handleAction(() => {
- api.dispatch(dataExplorerActions.RESET_PAGINATION({ id: dataExplorerService.getId() }));
- api.dispatch(dataExplorerActions.REQUEST_ITEMS({ id: dataExplorerService.getId() }));
+ api.dispatch(actions.RESET_PAGINATION());
+ api.dispatch(actions.REQUEST_ITEMS());
}),
TOGGLE_SORT: handleAction(() => {
- api.dispatch(dataExplorerActions.REQUEST_ITEMS({ id: dataExplorerService.getId() }));
+ api.dispatch(actions.REQUEST_ITEMS());
}),
SET_SEARCH_VALUE: handleAction(() => {
- api.dispatch(dataExplorerActions.RESET_PAGINATION({ id: dataExplorerService.getId() }));
- api.dispatch(dataExplorerActions.REQUEST_ITEMS({ id: dataExplorerService.getId() }));
+ api.dispatch(actions.RESET_PAGINATION());
+ api.dispatch(actions.REQUEST_ITEMS());
}),
REQUEST_ITEMS: handleAction(() => {
- dataExplorerService.requestItems(api);
+ service.requestItems(api);
}),
default: () => next(action)
});
diff --git a/src/store/favorite-panel/favorite-panel-middleware-service.ts b/src/store/favorite-panel/favorite-panel-middleware-service.ts
index f688d41..dfbcfd2 100644
--- a/src/store/favorite-panel/favorite-panel-middleware-service.ts
+++ b/src/store/favorite-panel/favorite-panel-middleware-service.ts
@@ -14,6 +14,7 @@ import { FilterBuilder } from "../../common/api/filter-builder";
import { LinkResource } from "../../models/link";
import { checkPresenceInFavorites } from "../favorites/favorites-actions";
import { favoritePanelActions } from "./favorite-panel-action";
+import { MiddlewareAPI } from "../../../node_modules/redux";
export class FavoritePanelMiddlewareService extends DataExplorerMiddlewareService {
constructor(id: string) {
@@ -24,9 +25,9 @@ export class FavoritePanelMiddlewareService extends DataExplorerMiddlewareServic
return columns;
}
- requestItems() {
- const state = this.api.getState() as RootState;
- const dataExplorer = this.getDataExplorer();
+ requestItems(api: MiddlewareAPI) {
+ const state = api.getState() as RootState;
+ const dataExplorer = this.getDataExplorer(api);
const columns = dataExplorer.columns as DataColumns<FavoritePanelItem, FavoritePanelFilter>;
const sortColumn = dataExplorer.columns.find(({ sortDirection }) => Boolean(sortDirection && sortDirection !== "none"));
const typeFilters = getColumnFilters(columns, FavoritePanelColumnNames.TYPE);
@@ -47,16 +48,16 @@ export class FavoritePanelMiddlewareService extends DataExplorerMiddlewareServic
.addILike("name", dataExplorer.searchValue)
})
.then(response => {
- this.api.dispatch(favoritePanelActions.SET_ITEMS({
+ api.dispatch(favoritePanelActions.SET_ITEMS({
items: response.items.map(resourceToDataItem),
itemsAvailable: response.itemsAvailable,
page: Math.floor(response.offset / response.limit),
rowsPerPage: response.limit
}));
- this.api.dispatch<any>(checkPresenceInFavorites(response.items.map(item => item.uuid)));
+ api.dispatch<any>(checkPresenceInFavorites(response.items.map(item => item.uuid)));
});
} else {
- this.api.dispatch(favoritePanelActions.SET_ITEMS({
+ api.dispatch(favoritePanelActions.SET_ITEMS({
items: [],
itemsAvailable: 0,
page: 0,
diff --git a/src/store/project-panel/project-panel-middleware-service.ts b/src/store/project-panel/project-panel-middleware-service.ts
index fd3009e..95a548a 100644
--- a/src/store/project-panel/project-panel-middleware-service.ts
+++ b/src/store/project-panel/project-panel-middleware-service.ts
@@ -15,6 +15,7 @@ import { ProcessResource } from "../../models/process";
import { GroupContentsResourcePrefix, GroupContentsResource } from "../../services/groups-service/groups-service";
import { checkPresenceInFavorites } from "../favorites/favorites-actions";
import { projectPanelActions } from "./project-panel-action";
+import { MiddlewareAPI } from "../../../node_modules/redux";
export class ProjectPanelMiddlewareService extends DataExplorerMiddlewareService {
constructor(id: string) {
@@ -25,9 +26,9 @@ export class ProjectPanelMiddlewareService extends DataExplorerMiddlewareService
return columns;
}
- requestItems() {
- const state = this.api.getState() as RootState;
- const dataExplorer = this.getDataExplorer();
+ requestItems(api: MiddlewareAPI) {
+ const state = api.getState() as RootState;
+ const dataExplorer = this.getDataExplorer(api);
const columns = dataExplorer.columns as DataColumns<ProjectPanelItem, ProjectPanelFilter>;
const typeFilters = getColumnFilters(columns, ProjectPanelColumnNames.TYPE);
const statusFilters = getColumnFilters(columns, ProjectPanelColumnNames.STATUS);
@@ -54,16 +55,16 @@ export class ProjectPanelMiddlewareService extends DataExplorerMiddlewareService
.concat(getSearchFilter(dataExplorer.searchValue))
})
.then(response => {
- this.api.dispatch(projectPanelActions.SET_ITEMS({
+ api.dispatch(projectPanelActions.SET_ITEMS({
items: response.items.map(resourceToDataItem),
itemsAvailable: response.itemsAvailable,
page: Math.floor(response.offset / response.limit),
rowsPerPage: response.limit
}));
- this.api.dispatch<any>(checkPresenceInFavorites(response.items.map(item => item.uuid)));
+ api.dispatch<any>(checkPresenceInFavorites(response.items.map(item => item.uuid)));
});
} else {
- this.api.dispatch(projectPanelActions.SET_ITEMS({
+ api.dispatch(projectPanelActions.SET_ITEMS({
items: [],
itemsAvailable: 0,
page: 0,
commit d6044c2155e8a59a09de9f581b34573f94f1827a
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date: Mon Jul 30 11:04:45 2018 +0200
Fix getDataExplorer method
Feature #13887
Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
diff --git a/src/store/data-explorer/data-explorer-middleware-service.ts b/src/store/data-explorer/data-explorer-middleware-service.ts
index 18091f0..fa85664 100644
--- a/src/store/data-explorer/data-explorer-middleware-service.ts
+++ b/src/store/data-explorer/data-explorer-middleware-service.ts
@@ -25,6 +25,6 @@ export abstract class DataExplorerMiddlewareService {
this.api = api;
}
getDataExplorer() {
- return getDataExplorer(this.api.getState(), this.id);
+ return getDataExplorer(this.api.getState().dataExplorer, this.id);
}
}
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list