Merge branch 'main' into 19482-wf-panel refs #19482
[arvados-workbench2.git] / src / store / collections-content-address-panel / collections-content-address-middleware-service.ts
index 983b309aa4543f1edf0c8d5a903ffc48b552411b..18023affdb4f449202336a8b28c53addb81b34fa 100644 (file)
@@ -4,18 +4,13 @@
 
 import { ServiceRepository } from 'services/services';
 import { MiddlewareAPI, Dispatch } from 'redux';
-import { DataExplorerMiddlewareService } from 'store/data-explorer/data-explorer-middleware-service';
+import { DataExplorerMiddlewareService, getOrder } from 'store/data-explorer/data-explorer-middleware-service';
 import { RootState } from 'store/store';
 import { getUserUuid } from "common/getuser";
 import { snackbarActions, SnackbarKind } from 'store/snackbar/snackbar-actions';
 import { getDataExplorer } from 'store/data-explorer/data-explorer-reducer';
 import { resourcesActions } from 'store/resources/resources-actions';
 import { FilterBuilder } from 'services/api/filter-builder';
-import { SortDirection } from 'components/data-table/data-column';
-import { OrderDirection, OrderBuilder } from 'services/api/order-builder';
-import { getSortColumn } from "store/data-explorer/data-explorer-reducer";
-import { FavoritePanelColumnNames } from 'views/favorite-panel/favorite-panel';
-import { GroupContentsResource, GroupContentsResourcePrefix } from 'services/groups-service/groups-service';
 import { progressIndicatorActions } from 'store/progress-indicator/progress-indicator-actions';
 import { collectionsContentAddressActions } from './collections-content-address-panel-actions';
 import { navigateTo } from 'store/navigation/navigation-action';
@@ -25,6 +20,7 @@ import { setBreadcrumbs } from '../breadcrumbs/breadcrumbs-actions';
 import { ResourceKind, extractUuidKind } from 'models/resource';
 import { ownerNameActions } from 'store/owner-name/owner-name-actions';
 import { getUserDisplayName } from 'models/user';
+import { CollectionResource } from 'models/collection';
 
 export class CollectionsWithSameContentAddressMiddlewareService extends DataExplorerMiddlewareService {
     constructor(private services: ServiceRepository, id: string) {
@@ -36,18 +32,6 @@ export class CollectionsWithSameContentAddressMiddlewareService extends DataExpl
         if (!dataExplorer) {
             api.dispatch(collectionPanelDataExplorerIsNotSet());
         } else {
-            const sortColumn = getSortColumn(dataExplorer);
-
-            const contentOrder = new OrderBuilder<GroupContentsResource>();
-
-            if (sortColumn && sortColumn.name === FavoritePanelColumnNames.NAME) {
-                const direction = sortColumn.sortDirection === SortDirection.ASC
-                    ? OrderDirection.ASC
-                    : OrderDirection.DESC;
-
-                contentOrder
-                    .addOrder(direction, "name", GroupContentsResourcePrefix.COLLECTION);
-            }
             try {
                 api.dispatch(progressIndicatorActions.START_WORKING(this.getId()));
                 const userUuid = getUserUuid(api.getState());
@@ -60,7 +44,8 @@ export class CollectionsWithSameContentAddressMiddlewareService extends DataExpl
                         .addEqual('portable_data_hash', contentAddress)
                         .addILike("name", dataExplorer.searchValue)
                         .getFilters(),
-                    includeOldVersions: true
+                    includeOldVersions: true,
+                    order: getOrder<CollectionResource>(dataExplorer)
                 });
                 const userUuids = response.items.map(it => {
                     if (extractUuidKind(it.ownerUuid) === ResourceKind.USER) {