Merge branch 'master' into 14466-handling-an-error-which-occurs-when-trying-to-upload...
[arvados.git] / src / store / data-explorer / data-explorer-reducer.ts
index 141d1a9f20657e1a4a462dbe32b8dd583f817341..1657ab70ed7bc1fbe13bc4c691f38d41084f45c2 100644 (file)
@@ -2,7 +2,7 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import { DataColumn, toggleSortDirection, resetSortDirection } from "~/components/data-table/data-column";
+import { DataColumn, toggleSortDirection, resetSortDirection, SortDirection } from "~/components/data-table/data-column";
 import { dataExplorerActions, DataExplorerAction } from "./data-explorer-action";
 import { DataTableFilterItem } from "~/components/data-table-filters/data-table-filters";
 import { DataColumns } from "~/components/data-table/data-table";
@@ -65,6 +65,9 @@ export const dataExplorerReducer = (state: DataExplorerState = {}, action: DataE
 export const getDataExplorer = (state: DataExplorerState, id: string) =>
     state[id] || initialDataExplorer;
 
+export const getSortColumn = (dataExplorer: DataExplorer) => dataExplorer.columns.find((c: any) =>
+    !!c.sortDirection && c.sortDirection !== SortDirection.NONE);
+
 const update = (state: DataExplorerState, id: string, updateFn: (dataExplorer: DataExplorer) => DataExplorer) =>
     ({ ...state, [id]: updateFn(getDataExplorer(state, id)) });