Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Add row number to collection list

Krzysztof Bialoglowicz07d38791f271
diff --git a/saleor/static/dashboard-next/collections/components/CollectionList/CollectionList.tsx b/saleor/static/dashboard-next/collections/components/CollectionList/CollectionList.tsx
index 6a4b24d9ca..14b6f0260c 100644
--- a/saleor/static/dashboard-next/collections/components/CollectionList/CollectionList.tsx
+++ b/saleor/static/dashboard-next/collections/components/CollectionList/CollectionList.tsx
@@ -55,8 +55,10 @@ const CollectionList = withStyles(styles, { name: "CollectionList" })(
classes,
collections,
disabled,
+ listSettings,
onNextPage,
onPreviousPage,
+ onUpdateListSettings,
onRowClick,
pageInfo,
isChecked,
@@ -90,8 +92,10 @@ const CollectionList = withStyles(styles, { name: "CollectionList" })(
<TableRow>
<TablePagination
colSpan={5}
+ listSettings={listSettings}
hasNextPage={pageInfo && !disabled ? pageInfo.hasNextPage : false}
onNextPage={onNextPage}
+ onUpdateListSettings={onUpdateListSettings}
hasPreviousPage={
pageInfo && !disabled ? pageInfo.hasPreviousPage : false
}
diff --git a/saleor/static/dashboard-next/collections/views/CollectionList.tsx b/saleor/static/dashboard-next/collections/views/CollectionList.tsx
index 008fcfb4dd..7f34a38bf2 100644
--- a/saleor/static/dashboard-next/collections/views/CollectionList.tsx
+++ b/saleor/static/dashboard-next/collections/views/CollectionList.tsx
@@ -6,14 +6,15 @@ import React from "react";
import ActionDialog from "@saleor/components/ActionDialog";
import useBulkActions from "@saleor/hooks/useBulkActions";
+import useListSettings from "@saleor/hooks/useListSettings";
import useNavigator from "@saleor/hooks/useNavigator";
import useNotifier from "@saleor/hooks/useNotifier";
import usePaginator, {
createPaginationState
} from "@saleor/hooks/usePaginator";
-import { PAGINATE_BY } from "../../config";
import i18n from "../../i18n";
import { getMutationState, maybe } from "../../misc";
+import { Lists } from "../../types";
import CollectionListPage from "../components/CollectionListPage/CollectionListPage";
import {
TypedCollectionBulkDelete,
@@ -44,6 +45,10 @@ export const CollectionList: React.StatelessComponent<CollectionListProps> = ({
params.ids
);
+ const { updateListSettings, listSettings } = useListSettings(
+ Lists.COLLECTION_LIST
+ );
+
const closeModal = () =>
navigate(
collectionListUrl({
@@ -62,7 +67,10 @@ export const CollectionList: React.StatelessComponent<CollectionListProps> = ({
})
);
- const paginationState = createPaginationState(PAGINATE_BY, params);
+ const paginationState = createPaginationState(
+ listSettings.COLLECTION_LIST.rowNumber,
+ params
+ );
return (
<TypedCollectionListQuery displayLoader variables={paginationState}>
{({ data, loading, refetch }) => {
@@ -129,8 +137,10 @@ export const CollectionList: React.StatelessComponent<CollectionListProps> = ({
collections={maybe(() =>
data.collections.edges.map(edge => edge.node)
)}
+ listSettings={listSettings.COLLECTION_LIST}
onNextPage={loadNextPage}
onPreviousPage={loadPreviousPage}
+ onUpdateListSettings={updateListSettings}
pageInfo={pageInfo}
onRowClick={id => () => navigate(collectionUrl(id))}
toolbar={
diff --git a/saleor/static/dashboard-next/types.ts b/saleor/static/dashboard-next/types.ts
index b50109d7a4..abf87aa3ea 100644
--- a/saleor/static/dashboard-next/types.ts
+++ b/saleor/static/dashboard-next/types.ts
@@ -16,7 +16,7 @@ export interface ListSettings {
export enum Lists {
CATEGORY_LIST = "CATEGORY_LIST",
- COLLECTION_PAGE = "COLLECTION_PAGE",
+ COLLECTION_LIST = "COLLECTION_LIST",
PRODUCT_LIST = "PRODUCT_LIST"
}