X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/7792c5200c3144fcc75e102f2aeaf4862252ec8e..59100a72caedbc8f3c9872de1153bf3d4129122a:/src/store/trash-panel/trash-panel-middleware-service.ts diff --git a/src/store/trash-panel/trash-panel-middleware-service.ts b/src/store/trash-panel/trash-panel-middleware-service.ts index 90a8b19a..90838b20 100644 --- a/src/store/trash-panel/trash-panel-middleware-service.ts +++ b/src/store/trash-panel/trash-panel-middleware-service.ts @@ -10,18 +10,18 @@ import { RootState } from "../store"; import { DataColumns } from "~/components/data-table/data-table"; import { ServiceRepository } from "~/services/services"; import { SortDirection } from "~/components/data-table/data-column"; -import { FilterBuilder } from "~/common/api/filter-builder"; +import { FilterBuilder } from "~/services/api/filter-builder"; import { trashPanelActions } from "./trash-panel-action"; import { Dispatch, MiddlewareAPI } from "redux"; -import { OrderBuilder, OrderDirection } from "~/common/api/order-builder"; +import { OrderBuilder, OrderDirection } from "~/services/api/order-builder"; import { GroupContentsResourcePrefix } from "~/services/groups-service/groups-service"; import { TrashPanelColumnNames, TrashPanelFilter } from "~/views/trash-panel/trash-panel"; import { ProjectResource } from "~/models/project"; import { ProjectPanelColumnNames } from "~/views/project-panel/project-panel"; import { updateFavorites } from "~/store/favorites/favorites-actions"; -import { TrashResource } from "~/models/resource"; -import { snackbarActions } from "~/store/snackbar/snackbar-actions"; +import { snackbarActions, SnackbarKind } from "~/store/snackbar/snackbar-actions"; import { updateResources } from "~/store/resources/resources-actions"; +import { progressIndicatorActions } from "~/store/progress-indicator/progress-indicator-actions"; export class TrashPanelMiddlewareService extends DataExplorerMiddlewareService { constructor(private services: ServiceRepository, id: string) { @@ -48,6 +48,7 @@ export class TrashPanelMiddlewareService extends DataExplorerMiddlewareService { } try { + api.dispatch(progressIndicatorActions.START_WORKING(this.getId())); const userUuid = this.services.authService.getUuid()!; const listResults = await this.services.groupsService .contents(userUuid, { @@ -57,14 +58,14 @@ export class TrashPanelMiddlewareService extends DataExplorerMiddlewareService { .addIsA("uuid", typeFilters.map(f => f.type)) .addILike("name", dataExplorer.searchValue, GroupContentsResourcePrefix.COLLECTION) .addILike("name", dataExplorer.searchValue, GroupContentsResourcePrefix.PROJECT) + .addEqual("is_trashed", true) .getFilters(), recursive: true, includeTrash: true }); + api.dispatch(progressIndicatorActions.PERSIST_STOP_WORKING(this.getId())); - const items = listResults.items - .filter(it => (it as TrashResource).isTrashed) - .map(it => it.uuid); + const items = listResults.items.map(it => it.uuid); api.dispatch(trashPanelActions.SET_ITEMS({ ...listResultsToDataExplorerItemsMeta(listResults), @@ -73,6 +74,13 @@ export class TrashPanelMiddlewareService extends DataExplorerMiddlewareService { api.dispatch(updateFavorites(items)); api.dispatch(updateResources(listResults.items)); } catch (e) { + api.dispatch(progressIndicatorActions.PERSIST_STOP_WORKING(this.getId())); + api.dispatch(trashPanelActions.SET_ITEMS({ + items: [], + itemsAvailable: 0, + page: 0, + rowsPerPage: dataExplorer.rowsPerPage + })); api.dispatch(couldNotFetchTrashContents()); } } @@ -80,5 +88,7 @@ export class TrashPanelMiddlewareService extends DataExplorerMiddlewareService { const couldNotFetchTrashContents = () => snackbarActions.OPEN_SNACKBAR({ - message: 'Could not fetch trash contents.' + message: 'Could not fetch trash contents.', + kind: SnackbarKind.ERROR }); +