X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/b22b921c05816744f83e2a726d93705b3b8f0599..47e0dc87fa82bac593c53518e556ba7c55410288:/src/store/project-panel/project-panel-middleware.ts diff --git a/src/store/project-panel/project-panel-middleware.ts b/src/store/project-panel/project-panel-middleware.ts index e72b6c1b..fbed1783 100644 --- a/src/store/project-panel/project-panel-middleware.ts +++ b/src/store/project-panel/project-panel-middleware.ts @@ -3,22 +3,21 @@ // SPDX-License-Identifier: AGPL-3.0 import { Middleware } from "redux"; -import actions from "../../store/data-explorer/data-explorer-action"; +import { dataExplorerActions } from "../data-explorer/data-explorer-action"; import { PROJECT_PANEL_ID, columns, ProjectPanelFilter, ProjectPanelColumnNames } from "../../views/project-panel/project-panel"; import { groupsService } from "../../services/services"; -import { RootState } from "../../store/store"; -import { getDataExplorer, DataExplorerState } from "../../store/data-explorer/data-explorer-reducer"; +import { RootState } from "../store"; +import { getDataExplorer } from "../data-explorer/data-explorer-reducer"; import { resourceToDataItem, ProjectPanelItem } from "../../views/project-panel/project-panel-item"; -import FilterBuilder from "../../common/api/filter-builder"; +import { FilterBuilder } from "../../common/api/filter-builder"; import { DataColumns } from "../../components/data-table/data-table"; import { ProcessResource } from "../../models/process"; -import { CollectionResource } from "../../models/collection"; -import OrderBuilder from "../../common/api/order-builder"; +import { OrderBuilder } from "../../common/api/order-builder"; import { GroupContentsResource, GroupContentsResourcePrefix } from "../../services/groups-service/groups-service"; import { SortDirection } from "../../components/data-table/data-column"; export const projectPanelMiddleware: Middleware = store => next => { - next(actions.SET_COLUMNS({ id: PROJECT_PANEL_ID, columns })); + next(dataExplorerActions.SET_COLUMNS({ id: PROJECT_PANEL_ID, columns })); return action => { @@ -30,30 +29,30 @@ export const projectPanelMiddleware: Middleware = store => next => { } }; - actions.match(action, { + dataExplorerActions.match(action, { SET_PAGE: handleProjectPanelAction(() => { - store.dispatch(actions.REQUEST_ITEMS({ id: PROJECT_PANEL_ID })); + store.dispatch(dataExplorerActions.REQUEST_ITEMS({ id: PROJECT_PANEL_ID })); }), SET_ROWS_PER_PAGE: handleProjectPanelAction(() => { - store.dispatch(actions.REQUEST_ITEMS({ id: PROJECT_PANEL_ID })); + store.dispatch(dataExplorerActions.REQUEST_ITEMS({ id: PROJECT_PANEL_ID })); }), SET_FILTERS: handleProjectPanelAction(() => { - store.dispatch(actions.RESET_PAGINATION({ id: PROJECT_PANEL_ID })); - store.dispatch(actions.REQUEST_ITEMS({ id: PROJECT_PANEL_ID })); + store.dispatch(dataExplorerActions.RESET_PAGINATION({ id: PROJECT_PANEL_ID })); + store.dispatch(dataExplorerActions.REQUEST_ITEMS({ id: PROJECT_PANEL_ID })); }), TOGGLE_SORT: handleProjectPanelAction(() => { - store.dispatch(actions.REQUEST_ITEMS({ id: PROJECT_PANEL_ID })); + store.dispatch(dataExplorerActions.REQUEST_ITEMS({ id: PROJECT_PANEL_ID })); }), SET_SEARCH_VALUE: handleProjectPanelAction(() => { - store.dispatch(actions.RESET_PAGINATION({ id: PROJECT_PANEL_ID })); - store.dispatch(actions.REQUEST_ITEMS({ id: PROJECT_PANEL_ID })); + store.dispatch(dataExplorerActions.RESET_PAGINATION({ id: PROJECT_PANEL_ID })); + store.dispatch(dataExplorerActions.REQUEST_ITEMS({ id: PROJECT_PANEL_ID })); }), REQUEST_ITEMS: handleProjectPanelAction(() => { const state = store.getState() as RootState; const dataExplorer = getDataExplorer(state.dataExplorer, PROJECT_PANEL_ID); const columns = dataExplorer.columns as DataColumns; - const typeFilters = getColumnFilters(columns, ProjectPanelColumnNames.Type); - const statusFilters = getColumnFilters(columns, ProjectPanelColumnNames.Status); + const typeFilters = getColumnFilters(columns, ProjectPanelColumnNames.TYPE); + const statusFilters = getColumnFilters(columns, ProjectPanelColumnNames.STATUS); const sortColumn = dataExplorer.columns.find(({ sortDirection }) => Boolean(sortDirection && sortDirection !== "none")); const sortDirection = sortColumn && sortColumn.sortDirection === SortDirection.Asc ? SortDirection.Asc : SortDirection.Desc; if (typeFilters.length > 0) { @@ -62,7 +61,7 @@ export const projectPanelMiddleware: Middleware = store => next => { limit: dataExplorer.rowsPerPage, offset: dataExplorer.page * dataExplorer.rowsPerPage, order: sortColumn - ? sortColumn.name === ProjectPanelColumnNames.Name + ? sortColumn.name === ProjectPanelColumnNames.NAME ? getOrder("name", sortDirection) : getOrder("createdAt", sortDirection) : OrderBuilder.create(), @@ -77,7 +76,7 @@ export const projectPanelMiddleware: Middleware = store => next => { .concat(getSearchFilter(dataExplorer.searchValue)) }) .then(response => { - store.dispatch(actions.SET_ITEMS({ + store.dispatch(dataExplorerActions.SET_ITEMS({ id: PROJECT_PANEL_ID, items: response.items.map(resourceToDataItem), itemsAvailable: response.itemsAvailable, @@ -86,7 +85,7 @@ export const projectPanelMiddleware: Middleware = store => next => { })); }); } else { - store.dispatch(actions.SET_ITEMS({ + store.dispatch(dataExplorerActions.SET_ITEMS({ id: PROJECT_PANEL_ID, items: [], itemsAvailable: 0,