Skip to content

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

Fix commented issues

Krzysztof Bialoglowicza07ede300580
diff --git a/saleor/static/dashboard-next/categories/components/CategoryList/CategoryList.tsx b/saleor/static/dashboard-next/categories/components/CategoryList/CategoryList.tsx
index 1875f6a5cd..e89b6c7994 100644
--- a/saleor/static/dashboard-next/categories/components/CategoryList/CategoryList.tsx
+++ b/saleor/static/dashboard-next/categories/components/CategoryList/CategoryList.tsx
@@ -72,7 +72,7 @@ const CategoryList = withStyles(styles, { name: "CategoryList" })(
categories,
classes,
disabled,
- listSettings,
+ settings,
isRoot,
pageInfo,
isChecked,
@@ -119,7 +119,7 @@ const CategoryList = withStyles(styles, { name: "CategoryList" })(
<TableRow>
<TablePagination
colSpan={4}
- listSettings={listSettings}
+ settings={settings}
hasNextPage={pageInfo && !disabled ? pageInfo.hasNextPage : false}
onNextPage={onNextPage}
onUpdateListSettings={onUpdateListSettings}
diff --git a/saleor/static/dashboard-next/categories/components/CategoryListPage/CategoryListPage.tsx b/saleor/static/dashboard-next/categories/components/CategoryListPage/CategoryListPage.tsx
index e0d77304ad..c3829c4bde 100644
--- a/saleor/static/dashboard-next/categories/components/CategoryListPage/CategoryListPage.tsx
+++ b/saleor/static/dashboard-next/categories/components/CategoryListPage/CategoryListPage.tsx
@@ -24,7 +24,7 @@ export interface CategoryTableProps extends PageListProps, ListActions {
export const CategoryListPage: React.StatelessComponent<CategoryTableProps> = ({
categories,
disabled,
- listSettings,
+ settings,
onAdd,
onNextPage,
onPreviousPage,
@@ -48,7 +48,7 @@ export const CategoryListPage: React.StatelessComponent<CategoryTableProps> = ({
onAdd={onAdd}
onRowClick={onRowClick}
disabled={disabled}
- listSettings={listSettings}
+ settings={settings}
isRoot={true}
onNextPage={onNextPage}
onPreviousPage={onPreviousPage}
diff --git a/saleor/static/dashboard-next/categories/views/CategoryList.tsx b/saleor/static/dashboard-next/categories/views/CategoryList.tsx
index 21592e802d..a9520ceb51 100644
--- a/saleor/static/dashboard-next/categories/views/CategoryList.tsx
+++ b/saleor/static/dashboard-next/categories/views/CategoryList.tsx
@@ -12,7 +12,7 @@ import usePaginator, {
} from "@saleor/hooks/usePaginator";
import i18n from "@saleor/i18n";
import { getMutationState, maybe } from "@saleor/misc";
-import { Lists } from "@saleor/types";
+import { ListViews } from "@saleor/types";
import { CategoryListPage } from "../components/CategoryListPage/CategoryListPage";
import { TypedCategoryBulkDeleteMutation } from "../mutations";
import { TypedRootCategoriesQuery } from "../queries";
@@ -36,13 +36,10 @@ export const CategoryList: React.StatelessComponent<CategoryListProps> = ({
const { isSelected, listElements, toggle, toggleAll, reset } = useBulkActions(
params.ids
);
- const { updateListSettings, listSettings } = useListSettings(
- Lists.CATEGORY_LIST
- );
- const paginationState = createPaginationState(
- listSettings.CATEGORY_LIST.rowNumber,
- params
+ const { updateListSettings, settings } = useListSettings(
+ ListViews.CATEGORY_LIST
);
+ const paginationState = createPaginationState(settings.rowNumber, params);
return (
<TypedRootCategoriesQuery displayLoader variables={paginationState}>
{({ data, loading, refetch }) => {
@@ -79,7 +76,7 @@ export const CategoryList: React.StatelessComponent<CategoryListProps> = ({
() => data.categories.edges.map(edge => edge.node),
[]
)}
- listSettings={listSettings.CATEGORY_LIST}
+ settings={settings}
onAdd={() => navigate(categoryAddUrl())}
onRowClick={id => () => navigate(categoryUrl(id))}
disabled={loading}
diff --git a/saleor/static/dashboard-next/collections/components/CollectionList/CollectionList.tsx b/saleor/static/dashboard-next/collections/components/CollectionList/CollectionList.tsx
index b067aad245..d0394b5932 100644
--- a/saleor/static/dashboard-next/collections/components/CollectionList/CollectionList.tsx
+++ b/saleor/static/dashboard-next/collections/components/CollectionList/CollectionList.tsx
@@ -55,7 +55,7 @@ const CollectionList = withStyles(styles, { name: "CollectionList" })(
classes,
collections,
disabled,
- listSettings,
+ settings,
onNextPage,
onPreviousPage,
onUpdateListSettings,
@@ -92,7 +92,7 @@ const CollectionList = withStyles(styles, { name: "CollectionList" })(
<TableRow>
<TablePagination
colSpan={5}
- listSettings={listSettings}
+ settings={settings}
hasNextPage={pageInfo && !disabled ? pageInfo.hasNextPage : false}
onNextPage={onNextPage}
onUpdateListSettings={onUpdateListSettings}
diff --git a/saleor/static/dashboard-next/collections/views/CollectionList.tsx b/saleor/static/dashboard-next/collections/views/CollectionList.tsx
index e1aff0f8e4..90a3f6686d 100644
--- a/saleor/static/dashboard-next/collections/views/CollectionList.tsx
+++ b/saleor/static/dashboard-next/collections/views/CollectionList.tsx
@@ -14,7 +14,7 @@ import usePaginator, {
} from "@saleor/hooks/usePaginator";
import i18n from "@saleor/i18n";
import { getMutationState, maybe } from "@saleor/misc";
-import { Lists } from "@saleor/types";
+import { ListViews } from "@saleor/types";
import CollectionListPage from "../components/CollectionListPage/CollectionListPage";
import {
TypedCollectionBulkDelete,
@@ -44,8 +44,8 @@ export const CollectionList: React.StatelessComponent<CollectionListProps> = ({
const { isSelected, listElements, reset, toggle, toggleAll } = useBulkActions(
params.ids
);
- const { updateListSettings, listSettings } = useListSettings(
- Lists.COLLECTION_LIST
+ const { updateListSettings, settings } = useListSettings(
+ ListViews.COLLECTION_LIST
);
const closeModal = () =>
@@ -66,10 +66,7 @@ export const CollectionList: React.StatelessComponent<CollectionListProps> = ({
})
);
- const paginationState = createPaginationState(
- listSettings.COLLECTION_LIST.rowNumber,
- params
- );
+ const paginationState = createPaginationState(settings.rowNumber, params);
return (
<TypedCollectionListQuery displayLoader variables={paginationState}>
{({ data, loading, refetch }) => {
@@ -136,7 +133,7 @@ export const CollectionList: React.StatelessComponent<CollectionListProps> = ({
collections={maybe(() =>
data.collections.edges.map(edge => edge.node)
)}
- listSettings={listSettings.COLLECTION_LIST}
+ settings={settings}
onNextPage={loadNextPage}
onPreviousPage={loadPreviousPage}
onUpdateListSettings={updateListSettings}
diff --git a/saleor/static/dashboard-next/components/ProductList/ProductList.tsx b/saleor/static/dashboard-next/components/ProductList/ProductList.tsx
index d3f2edaf89..09fa0c286b 100644
--- a/saleor/static/dashboard-next/components/ProductList/ProductList.tsx
+++ b/saleor/static/dashboard-next/components/ProductList/ProductList.tsx
@@ -71,7 +71,7 @@ interface ProductListProps
export const ProductList = withStyles(styles, { name: "ProductList" })(
({
classes,
- listSettings,
+ settings,
disabled,
isChecked,
pageInfo,
@@ -111,7 +111,7 @@ export const ProductList = withStyles(styles, { name: "ProductList" })(
<TableRow>
<TablePagination
colSpan={6}
- listSettings={listSettings}
+ settings={settings}
hasNextPage={pageInfo && !disabled ? pageInfo.hasNextPage : false}
onNextPage={onNextPage}
onUpdateListSettings={onUpdateListSettings}
diff --git a/saleor/static/dashboard-next/components/RowNumberSelect/RowNumberSelect.tsx b/saleor/static/dashboard-next/components/RowNumberSelect/RowNumberSelect.tsx
index dba862d92a..2a670e7ae5 100644
--- a/saleor/static/dashboard-next/components/RowNumberSelect/RowNumberSelect.tsx
+++ b/saleor/static/dashboard-next/components/RowNumberSelect/RowNumberSelect.tsx
@@ -37,14 +37,14 @@ const useStyles = makeStyles(
interface RowNumberSelectProps {
choices: number[];
className?: string;
- listSettings: ListSettings;
+ settings: ListSettings;
onChange(key: keyof ListSettings, value: any);
}
const RowNumberSelect: React.FC<RowNumberSelectProps> = ({
className,
choices,
- listSettings,
+ settings,
onChange
}) => {
const theme = useTheme();
@@ -54,7 +54,7 @@ const RowNumberSelect: React.FC<RowNumberSelectProps> = ({
<span className={classes.label}>{i18n.t("No of Rows:")}</span>
<Select
className={classes.select}
- value={listSettings.rowNumber}
+ value={settings.rowNumber}
onChange={event => onChange("rowNumber", event.target.value)}
>
{choices.length > 0 &&
diff --git a/saleor/static/dashboard-next/components/TablePagination/TablePagination.tsx b/saleor/static/dashboard-next/components/TablePagination/TablePagination.tsx
index bb8100a4d1..8d5e9207e6 100644
--- a/saleor/static/dashboard-next/components/TablePagination/TablePagination.tsx
+++ b/saleor/static/dashboard-next/components/TablePagination/TablePagination.tsx
@@ -62,7 +62,7 @@ interface TablePaginationProps extends WithStyles<typeof styles> {
backIconButtonProps?: Partial<IconButtonProps>;
colSpan: number;
component?: string | typeof TableCell;
- listSettings?: ListSettings;
+ settings?: ListSettings;
hasNextPage: boolean;
hasPreviousPage: boolean;
nextIconButtonProps?: Partial<IconButtonProps>;
@@ -78,7 +78,7 @@ const TablePagination = withStyles(styles, { name: "TablePagination" })(
classes,
colSpan: colSpanProp,
component: Component,
- listSettings,
+ settings,
hasNextPage,
hasPreviousPage,
nextIconButtonProps,
@@ -97,10 +97,10 @@ const TablePagination = withStyles(styles, { name: "TablePagination" })(
<Component className={classes.root} colSpan={colSpan} {...other}>
<Toolbar className={classes.toolbar}>
<div className={classes.spacer}>
- {listSettings && (
+ {settings && (
<RowNumberSelect
choices={[20, 30, 50, 100]}
- listSettings={listSettings}
+ settings={settings}
onChange={onUpdateListSettings}
/>
)}
diff --git a/saleor/static/dashboard-next/config.ts b/saleor/static/dashboard-next/config.ts
index 0efb4b6ab8..00ebd89500 100644
--- a/saleor/static/dashboard-next/config.ts
+++ b/saleor/static/dashboard-next/config.ts
@@ -13,51 +13,39 @@ export const PAGINATE_BY = 20;
export const defaultListSettings = {
CATEGORY_LIST: {
- name: "CATEGORY_LIST",
rowNumber: PAGINATE_BY
},
COLLECTION_LIST: {
- name: "COLLECTION_LIST",
rowNumber: PAGINATE_BY
},
CUSTOMER_LIST: {
- name: "CUSTOMER_LIST",
rowNumber: PAGINATE_BY
},
DRAFT_LIST: {
- name: "DRAFT_LIST",
rowNumber: PAGINATE_BY
},
NAVIGATION_LIST: {
- name: "NAVIGATION_LIST",
rowNumber: PAGINATE_BY
},
ORDER_LIST: {
- name: "ORDER_LIST",
rowNumber: PAGINATE_BY
},
PAGES_LIST: {
- name: "PAGES_LIST",
rowNumber: PAGINATE_BY
},
PRODUCT_LIST: {
- name: "PRODUCT_LIST",
rowNumber: PAGINATE_BY
},
SALES_LIST: {
- name: "SALES_LIST",
rowNumber: PAGINATE_BY
},
SHIPPING_METHODS_LIST: {
- name: "SHIPPING_METHODS_LIST",
rowNumber: PAGINATE_BY
},
STAFF_MEMBERS_LIST: {
- name: "COLLECTIOSTAFF_MEMBERS_LIST",
rowNumber: PAGINATE_BY
},
VOUCHER_LIST: {
- name: "VOUCHER_LIST",
rowNumber: PAGINATE_BY
}
};
diff --git a/saleor/static/dashboard-next/customers/components/CustomerList/CustomerList.tsx b/saleor/static/dashboard-next/customers/components/CustomerList/CustomerList.tsx
index 528ede82ce..cdde7640ba 100644
--- a/saleor/static/dashboard-next/customers/components/CustomerList/CustomerList.tsx
+++ b/saleor/static/dashboard-next/customers/components/CustomerList/CustomerList.tsx
@@ -50,7 +50,7 @@ export interface CustomerListProps
const CustomerList = withStyles(styles, { name: "CustomerList" })(
({
classes,
- listSettings,
+ settings,
disabled,
customers,
pageInfo,
@@ -87,7 +87,7 @@ const CustomerList = withStyles(styles, { name: "CustomerList" })(
<TableRow>
<TablePagination
colSpan={4}
- listSettings={listSettings}
+ settings={settings}
hasNextPage={pageInfo && !disabled ? pageInfo.hasNextPage : false}
onNextPage={onNextPage}
onUpdateListSettings={onUpdateListSettings}
diff --git a/saleor/static/dashboard-next/customers/views/CustomerList.tsx b/saleor/static/dashboard-next/customers/views/CustomerList.tsx
index a6c85e1451..b36ed9e2a4 100644
--- a/saleor/static/dashboard-next/customers/views/CustomerList.tsx
+++ b/saleor/static/dashboard-next/customers/views/CustomerList.tsx
@@ -13,7 +13,7 @@ import usePaginator, {
} from "@saleor/hooks/usePaginator";
import i18n from "@saleor/i18n";
import { getMutationState, maybe } from "@saleor/misc";
-import { Lists } from "@saleor/types";
+import { ListViews } from "@saleor/types";
import CustomerListPage from "../components/CustomerListPage";
import { TypedBulkRemoveCustomers } from "../mutations";
import { TypedCustomerListQuery } from "../queries";
@@ -38,8 +38,8 @@ export const CustomerList: React.StatelessComponent<CustomerListProps> = ({
const { isSelected, listElements, reset, toggle, toggleAll } = useBulkActions(
params.ids
);
- const { updateListSettings, listSettings } = useListSettings(
- Lists.CUSTOMER_LIST
+ const { updateListSettings, settings } = useListSettings(
+ ListViews.CUSTOMER_LIST
);
const closeModal = () =>
@@ -52,10 +52,7 @@ export const CustomerList: React.StatelessComponent<CustomerListProps> = ({
true
);
- const paginationState = createPaginationState(
- listSettings.CUSTOMER_LIST.rowNumber,
- params
- );
+ const paginationState = createPaginationState(settings.rowNumber, params);
return (
<TypedCustomerListQuery displayLoader variables={paginationState}>
@@ -94,7 +91,7 @@ export const CustomerList: React.StatelessComponent<CustomerListProps> = ({
customers={maybe(() =>
data.customers.edges.map(edge => edge.node)
)}
- listSettings={listSettings.CUSTOMER_LIST}
+ settings={settings}
disabled={loading}
pageInfo={pageInfo}
onAdd={() => navigate(customerAddUrl)}
diff --git a/saleor/static/dashboard-next/discounts/components/SaleList/SaleList.tsx b/saleor/static/dashboard-next/discounts/components/SaleList/SaleList.tsx
index 9494343d7a..39efbc4955 100644
--- a/saleor/static/dashboard-next/discounts/components/SaleList/SaleList.tsx
+++ b/saleor/static/dashboard-next/discounts/components/SaleList/SaleList.tsx
@@ -64,7 +64,7 @@ const SaleList = withStyles(styles, {
})(
({
classes,
- listSettings,
+ settings,
defaultCurrency,
disabled,
onNextPage,
@@ -113,7 +113,7 @@ const SaleList = withStyles(styles, {
<TableRow>
<TablePagination
colSpan={5}
- listSettings={listSettings}
+ settings={settings}
hasNextPage={pageInfo && !disabled ? pageInfo.hasNextPage : false}
onNextPage={onNextPage}
onUpdateListSettings={onUpdateListSettings}
diff --git a/saleor/static/dashboard-next/discounts/components/VoucherList/VoucherList.tsx b/saleor/static/dashboard-next/discounts/components/VoucherList/VoucherList.tsx
index 7dc2e6b93d..af20b6eb95 100644
--- a/saleor/static/dashboard-next/discounts/components/VoucherList/VoucherList.tsx
+++ b/saleor/static/dashboard-next/discounts/components/VoucherList/VoucherList.tsx
@@ -79,7 +79,7 @@ const VoucherList = withStyles(styles, {
})(
({
classes,
- listSettings,
+ settings,
defaultCurrency,
disabled,
onNextPage,
@@ -138,7 +138,7 @@ const VoucherList = withStyles(styles, {
<TableRow>
<TablePagination
colSpan={7}
- listSettings={listSettings}
+ settings={settings}
hasNextPage={pageInfo && !disabled ? pageInfo.hasNextPage : false}
onNextPage={onNextPage}
onUpdateListSettings={onUpdateListSettings}
diff --git a/saleor/static/dashboard-next/discounts/components/VoucherListPage/VoucherListPage.tsx b/saleor/static/dashboard-next/discounts/components/VoucherListPage/VoucherListPage.tsx
index 698b88d2dd..f8b75c59a8 100644
--- a/saleor/static/dashboard-next/discounts/components/VoucherListPage/VoucherListPage.tsx
+++ b/saleor/static/dashboard-next/discounts/components/VoucherListPage/VoucherListPage.tsx
@@ -17,7 +17,7 @@ export interface VoucherListPageProps extends PageListProps, ListActions {
const VoucherListPage: React.StatelessComponent<VoucherListPageProps> = ({
defaultCurrency,
disabled,
- listSettings,
+ settings,
onAdd,
onNextPage,
onPreviousPage,
@@ -40,7 +40,7 @@ const VoucherListPage: React.StatelessComponent<VoucherListPageProps> = ({
</PageHeader>
<VoucherList
defaultCurrency={defaultCurrency}
- listSettings={listSettings}
+ settings={settings}
disabled={disabled}
onNextPage={onNextPage}
onPreviousPage={onPreviousPage}
diff --git a/saleor/static/dashboard-next/discounts/views/SaleList.tsx b/saleor/static/dashboard-next/discounts/views/SaleList.tsx
index a5b06a39de..c159bf5020 100644
--- a/saleor/static/dashboard-next/discounts/views/SaleList.tsx
+++ b/saleor/static/dashboard-next/discounts/views/SaleList.tsx
@@ -15,7 +15,7 @@ import usePaginator, {
import useShop from "@saleor/hooks/useShop";
import i18n from "@saleor/i18n";
import { getMutationState, maybe } from "@saleor/misc";
-import { Lists } from "@saleor/types";
+import { ListViews } from "@saleor/types";
import SaleListPage from "../components/SaleListPage";
import { TypedSaleBulkDelete } from "../mutations";
import { TypedSaleList } from "../queries";
@@ -41,16 +41,13 @@ export const SaleList: React.StatelessComponent<SaleListProps> = ({
const { isSelected, listElements, reset, toggle, toggleAll } = useBulkActions(
params.ids
);
- const { updateListSettings, listSettings } = useListSettings(
- Lists.SALES_LIST
+ const { updateListSettings, settings } = useListSettings(
+ ListViews.SALES_LIST
);
const closeModal = () => navigate(saleListUrl(), true);
- const paginationState = createPaginationState(
- listSettings.SALES_LIST.rowNumber,
- params
- );
+ const paginationState = createPaginationState(settings.rowNumber, params);
return (
<TypedSaleList displayLoader variables={paginationState}>
@@ -93,7 +90,7 @@ export const SaleList: React.StatelessComponent<SaleListProps> = ({
<SaleListPage
defaultCurrency={maybe(() => shop.defaultCurrency)}
sales={maybe(() => data.sales.edges.map(edge => edge.node))}
- listSettings={listSettings.SALES_LIST}
+ settings={settings}
disabled={loading}
pageInfo={pageInfo}
onAdd={() => navigate(saleAddUrl)}
diff --git a/saleor/static/dashboard-next/discounts/views/VoucherList.tsx b/saleor/static/dashboard-next/discounts/views/VoucherList.tsx
index 62497cacf3..fe47592a29 100644
--- a/saleor/static/dashboard-next/discounts/views/VoucherList.tsx
+++ b/saleor/static/dashboard-next/discounts/views/VoucherList.tsx
@@ -15,7 +15,7 @@ import usePaginator, {
import useShop from "@saleor/hooks/useShop";
import i18n from "@saleor/i18n";
import { getMutationState, maybe } from "@saleor/misc";
-import { Lists } from "@saleor/types";
+import { ListViews } from "@saleor/types";
import VoucherListPage from "../components/VoucherListPage";
import { TypedVoucherBulkDelete } from "../mutations";
import { TypedVoucherList } from "../queries";
@@ -41,16 +41,13 @@ export const VoucherList: React.StatelessComponent<VoucherListProps> = ({
const { isSelected, listElements, reset, toggle, toggleAll } = useBulkActions(
params.ids
);
- const { updateListSettings, listSettings } = useListSettings(
- Lists.VOUCHER_LIST
+ const { updateListSettings, settings } = useListSettings(
+ ListViews.VOUCHER_LIST
);
const closeModal = () => navigate(voucherListUrl(), true);
- const paginationState = createPaginationState(
- listSettings.VOUCHER_LIST.rowNumber,
- params
- );
+ const paginationState = createPaginationState(settings.rowNumber, params);
return (
<TypedVoucherList displayLoader variables={paginationState}>
@@ -91,7 +88,7 @@ export const VoucherList: React.StatelessComponent<VoucherListProps> = ({
<WindowTitle title={i18n.t("Vouchers")} />
<VoucherListPage
defaultCurrency={maybe(() => shop.defaultCurrency)}
- listSettings={listSettings.VOUCHER_LIST}
+ settings={settings}
vouchers={maybe(() =>
data.vouchers.edges.map(edge => edge.node)
)}
diff --git a/saleor/static/dashboard-next/fixtures.ts b/saleor/static/dashboard-next/fixtures.ts
index 0f467bbda8..adbb177d87 100644
--- a/saleor/static/dashboard-next/fixtures.ts
+++ b/saleor/static/dashboard-next/fixtures.ts
@@ -8,21 +8,21 @@ const pageInfo = {
export const pageListProps: { [key: string]: PageListProps } = {
default: {
disabled: false,
- listSettings: { name: undefined, rowNumber: 20 },
onAdd: undefined,
onNextPage: undefined,
onPreviousPage: undefined,
onRowClick: () => undefined,
- pageInfo
+ pageInfo,
+ settings: { rowNumber: 20 }
},
loading: {
disabled: true,
- listSettings: undefined,
onAdd: undefined,
onNextPage: undefined,
onPreviousPage: undefined,
onRowClick: () => undefined,
- pageInfo
+ pageInfo,
+ settings: undefined
}
};
export const listActionsProps: ListActions = {
diff --git a/saleor/static/dashboard-next/hooks/useListSettings.ts b/saleor/static/dashboard-next/hooks/useListSettings.ts
index 6038c2677a..cb2a93c40d 100644
--- a/saleor/static/dashboard-next/hooks/useListSettings.ts
+++ b/saleor/static/dashboard-next/hooks/useListSettings.ts
@@ -1,9 +1,9 @@
import useLocalStorage from "@saleor/hooks/useLocalStorage";
import { defaultListSettings } from "./../config";
-import { Lists, ListSettings } from "./../types";
+import { ListSettings, ListViews } from "./../types";
-export default function useListSettings(listName: Lists) {
- const [listSettings, setListSettings] = useLocalStorage(
+export default function useListSettings(listName: ListViews) {
+ const [settings, setListSettings] = useLocalStorage(
"listConfig",
defaultListSettings
);
@@ -18,7 +18,7 @@ export default function useListSettings(listName: Lists) {
};
return {
- listSettings,
+ settings: settings[listName],
updateListSettings
};
}
diff --git a/saleor/static/dashboard-next/hooks/useRowChange.ts b/saleor/static/dashboard-next/hooks/useRowChange.ts
deleted file mode 100644
index ae20ba75e2..0000000000
--- a/saleor/static/dashboard-next/hooks/useRowChange.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-import { useState } from "react";
-
-import { PAGINATE_BY } from "../config";
-
-function useRowChange() {
- const [rowNumber, setRowNumber] = useState(PAGINATE_BY);
-
- function onRowChange(event: React.ChangeEvent<any>) {
- setRowNumber(event.target.value);
- }
-
- return {
- onRowChange,
- rowNumber
- };
-}
-
-export default useRowChange;
diff --git a/saleor/static/dashboard-next/navigation/components/MenuList/MenuList.tsx b/saleor/static/dashboard-next/navigation/components/MenuList/MenuList.tsx
index 8f609fb800..350c5cb5fe 100644
--- a/saleor/static/dashboard-next/navigation/components/MenuList/MenuList.tsx
+++ b/saleor/static/dashboard-next/navigation/components/MenuList/MenuList.tsx
@@ -47,7 +47,7 @@ const styles = (theme: Theme) =>
const MenuList = withStyles(styles, { name: "MenuList" })(
({
classes,
- listSettings,
+ settings,
disabled,
isChecked,
menus,
@@ -82,7 +82,7 @@ const MenuList = withStyles(styles, { name: "MenuList" })(
<TableRow>
<TablePagination
colSpan={4}
- listSettings={listSettings}
+ settings={settings}
hasNextPage={pageInfo && !disabled ? pageInfo.hasNextPage : false}
onNextPage={onNextPage}
onUpdateListSettings={onUpdateListSettings}
diff --git a/saleor/static/dashboard-next/navigation/views/MenuList.tsx b/saleor/static/dashboard-next/navigation/views/MenuList.tsx
index 12530df6b6..fbde8d36f1 100644
--- a/saleor/static/dashboard-next/navigation/views/MenuList.tsx
+++ b/saleor/static/dashboard-next/navigation/views/MenuList.tsx
@@ -13,7 +13,7 @@ import usePaginator, {
} from "@saleor/hooks/usePaginator";
import i18n from "@saleor/i18n";
import { getMutationState, maybe } from "@saleor/misc";
-import { Lists } from "@saleor/types";
+import { ListViews } from "@saleor/types";
import MenuCreateDialog from "../components/MenuCreateDialog";
import MenuListPage from "../components/MenuListPage";
import {
@@ -37,8 +37,8 @@ const MenuList: React.FC<MenuListProps> = ({ params }) => {
const { isSelected, listElements, reset, toggle, toggleAll } = useBulkActions(
params.ids
);
- const { updateListSettings, listSettings } = useListSettings(
- Lists.NAVIGATION_LIST
+ const { updateListSettings, settings } = useListSettings(
+ ListViews.NAVIGATION_LIST
);
const closeModal = () =>
@@ -52,10 +52,7 @@ const MenuList: React.FC<MenuListProps> = ({ params }) => {
true
);
- const paginationState = createPaginationState(
- listSettings.NAVIGATION_LIST.rowNumber,
- params
- );
+ const paginationState = createPaginationState(settings.rowNumber, params);
return (
<MenuListQuery variables={paginationState}>
@@ -136,7 +133,7 @@ const MenuList: React.FC<MenuListProps> = ({ params }) => {
menus={maybe(() =>
data.menus.edges.map(edge => edge.node)
)}
- listSettings={listSettings.NAVIGATION_LIST}
+ settings={settings}
onAdd={() =>
navigate(
menuListUrl({
diff --git a/saleor/static/dashboard-next/orders/components/OrderDraftList/OrderDraftList.tsx b/saleor/static/dashboard-next/orders/components/OrderDraftList/OrderDraftList.tsx
index 2daab269fc..e384a946cc 100644
--- a/saleor/static/dashboard-next/orders/components/OrderDraftList/OrderDraftList.tsx
+++ b/saleor/static/dashboard-next/orders/components/OrderDraftList/OrderDraftList.tsx
@@ -63,7 +63,7 @@ export const OrderDraftList = withStyles(styles, { name: "OrderDraftList" })(
({
classes,
disabled,
- listSettings,
+ settings,
orders,
pageInfo,
onPreviousPage,
@@ -109,7 +109,7 @@ export const OrderDraftList = withStyles(styles, { name: "OrderDraftList" })(
<TableRow>
<TablePagination
colSpan={5}
- listSettings={listSettings}
+ settings={settings}
hasNextPage={pageInfo && !disabled ? pageInfo.hasNextPage : false}
onNextPage={onNextPage}
onUpdateListSettings={onUpdateListSettings}
diff --git a/saleor/static/dashboard-next/orders/components/OrderList/OrderList.tsx b/saleor/static/dashboard-next/orders/components/OrderList/OrderList.tsx
index bcc15cadc8..8ed5bda21a 100644
--- a/saleor/static/dashboard-next/orders/components/OrderList/OrderList.tsx
+++ b/saleor/static/dashboard-next/orders/components/OrderList/OrderList.tsx
@@ -70,7 +70,7 @@ export const OrderList = withStyles(styles, { name: "OrderList" })(
({
classes,
disabled,
- listSettings,
+ settings,
orders,
pageInfo,
onPreviousPage,
@@ -122,7 +122,7 @@ export const OrderList = withStyles(styles, { name: "OrderList" })(
<TableRow>
<TablePagination
colSpan={7}
- listSettings={listSettings}
+ settings={settings}
hasNextPage={pageInfo && !disabled ? pageInfo.hasNextPage : false}
onNextPage={onNextPage}
onUpdateListSettings={onUpdateListSettings}
diff --git a/saleor/static/dashboard-next/orders/views/OrderDraftList.tsx b/saleor/static/dashboard-next/orders/views/OrderDraftList.tsx
index 9ac874fe75..129ba3fcf1 100644
--- a/saleor/static/dashboard-next/orders/views/OrderDraftList.tsx
+++ b/saleor/static/dashboard-next/orders/views/OrderDraftList.tsx
@@ -13,7 +13,7 @@ import usePaginator, {
} from "@saleor/hooks/usePaginator";
import i18n from "@saleor/i18n";
import { getMutationState, maybe } from "@saleor/misc";
-import { Lists } from "@saleor/types";
+import { ListViews } from "@saleor/types";
import OrderDraftListPage from "../components/OrderDraftListPage";
import {
TypedOrderDraftBulkCancelMutation,
@@ -41,8 +41,8 @@ export const OrderDraftList: React.StatelessComponent<OrderDraftListProps> = ({
const { isSelected, listElements, reset, toggle, toggleAll } = useBulkActions(
params.ids
);
- const { updateListSettings, listSettings } = useListSettings(
- Lists.DRAFT_LIST
+ const { updateListSettings, settings } = useListSettings(
+ ListViews.DRAFT_LIST
);
const closeModal = () =>
@@ -61,10 +61,7 @@ export const OrderDraftList: React.StatelessComponent<OrderDraftListProps> = ({
navigate(orderUrl(data.draftOrderCreate.order.id));
};
- const paginationState = createPaginationState(
- listSettings.DRAFT_LIST.rowNumber,
- params
- );
+ const paginationState = createPaginationState(settings.rowNumber, params);
return (
<TypedOrderDraftCreateMutation onCompleted={handleCreateOrderCreateSuccess}>
@@ -113,7 +110,7 @@ export const OrderDraftList: React.StatelessComponent<OrderDraftListProps> = ({
<>
<OrderDraftListPage
disabled={loading}
- listSettings={listSettings.DRAFT_LIST}
+ settings={settings}
orders={maybe(() =>
data.draftOrders.edges.map(edge => edge.node)
)}
diff --git a/saleor/static/dashboard-next/orders/views/OrderList/OrderList.tsx b/saleor/static/dashboard-next/orders/views/OrderList/OrderList.tsx
index 4b7e1449f2..c099b68154 100644
--- a/saleor/static/dashboard-next/orders/views/OrderList/OrderList.tsx
+++ b/saleor/static/dashboard-next/orders/views/OrderList/OrderList.tsx
@@ -16,7 +16,7 @@ import usePaginator, {
import useShop from "@saleor/hooks/useShop";
import i18n from "@saleor/i18n";
import { getMutationState, maybe } from "@saleor/misc";
-import { Lists } from "@saleor/types";
+import { ListViews } from "@saleor/types";
import OrderBulkCancelDialog from "../../components/OrderBulkCancelDialog";
import OrderListPage from "../../components/OrderListPage/OrderListPage";
import {
@@ -59,8 +59,8 @@ export const OrderList: React.StatelessComponent<OrderListProps> = ({
const { isSelected, listElements, reset, toggle, toggleAll } = useBulkActions(
params.ids
);
- const { updateListSettings, listSettings } = useListSettings(
- Lists.ORDER_LIST
+ const { updateListSettings, settings } = useListSettings(
+ ListViews.ORDER_LIST
);
const tabs = getFilterTabs();
@@ -128,10 +128,7 @@ export const OrderList: React.StatelessComponent<OrderListProps> = ({
handleTabChange(tabs.length + 1);
};
- const paginationState = createPaginationState(
- listSettings.ORDER_LIST.rowNumber,
- params
- );
+ const paginationState = createPaginationState(settings.rowNumber, params);
const currencySymbol = maybe(() => shop.defaultCurrency, "USD");
const handleCreateOrderCreateSuccess = (data: OrderDraftCreate) => {
@@ -146,7 +143,7 @@ export const OrderList: React.StatelessComponent<OrderListProps> = ({
...paginationState,
filter: getFilterVariables(params)
}),
- [params, listSettings.ORDER_LIST.rowNumber]
+ [params, settings.rowNumber]
);
return (
@@ -193,7 +190,7 @@ export const OrderList: React.StatelessComponent<OrderListProps> = ({
<>
<OrderListPage
currencySymbol={currencySymbol}
- listSettings={listSettings.ORDER_LIST}
+ settings={settings}
filtersList={createFilterChips(
params,
{
diff --git a/saleor/static/dashboard-next/pages/components/PageList/PageList.tsx b/saleor/static/dashboard-next/pages/components/PageList/PageList.tsx
index 0df72c9552..6c8dbee457 100644
--- a/saleor/static/dashboard-next/pages/components/PageList/PageList.tsx
+++ b/saleor/static/dashboard-next/pages/components/PageList/PageList.tsx
@@ -47,7 +47,7 @@ const styles = (theme: Theme) =>
const PageList = withStyles(styles, { name: "PageList" })(
({
classes,
- listSettings,
+ settings,
pages,
disabled,
onNextPage,
@@ -84,7 +84,7 @@ const PageList = withStyles(styles, { name: "PageList" })(
<TableRow>
<TablePagination
colSpan={4}
- listSettings={listSettings}
+ settings={settings}
hasNextPage={pageInfo && !disabled ? pageInfo.hasNextPage : false}
onNextPage={onNextPage}
onUpdateListSettings={onUpdateListSettings}
diff --git a/saleor/static/dashboard-next/pages/components/PageListPage/PageListPage.tsx b/saleor/static/dashboard-next/pages/components/PageListPage/PageListPage.tsx
index ffd27cd242..282058a50b 100644
--- a/saleor/static/dashboard-next/pages/components/PageListPage/PageListPage.tsx
+++ b/saleor/static/dashboard-next/pages/components/PageListPage/PageListPage.tsx
@@ -17,7 +17,7 @@ export interface PageListPageProps extends PageListProps, ListActions {
const PageListPage: React.StatelessComponent<PageListPageProps> = ({
disabled,
- listSettings,
+ settings,
onAdd,
onBack,
onNextPage,
@@ -47,7 +47,7 @@ const PageListPage: React.StatelessComponent<PageListPageProps> = ({
</PageHeader>
<PageList
disabled={disabled}
- listSettings={listSettings}
+ settings={settings}
pages={pages}
onNextPage={onNextPage}
onPreviousPage={onPreviousPage}
diff --git a/saleor/static/dashboard-next/pages/views/PageList.tsx b/saleor/static/dashboard-next/pages/views/PageList.tsx
index 39004dcbfc..7bc199c22a 100644
--- a/saleor/static/dashboard-next/pages/views/PageList.tsx
+++ b/saleor/static/dashboard-next/pages/views/PageList.tsx
@@ -15,7 +15,7 @@ import usePaginator, {
} from "@saleor/hooks/usePaginator";
import i18n from "@saleor/i18n";
import { getMutationState, maybe } from "@saleor/misc";
-import { Lists } from "@saleor/types";
+import { ListViews } from "@saleor/types";
import PageListPage from "../components/PageListPage/PageListPage";
import { TypedPageBulkPublish, TypedPageBulkRemove } from "../mutations";
import { TypedPageListQuery } from "../queries";
@@ -42,13 +42,10 @@ export const PageList: React.StatelessComponent<PageListProps> = ({
const { isSelected, listElements, reset, toggle, toggleAll } = useBulkActions(
params.ids
);
- const { updateListSettings, listSettings } = useListSettings(
- Lists.PAGES_LIST
- );
- const paginationState = createPaginationState(
- listSettings.PAGES_LIST.rowNumber,
- params
+ const { updateListSettings, settings } = useListSettings(
+ ListViews.PAGES_LIST
);
+ const paginationState = createPaginationState(settings.rowNumber, params);
return (
<TypedPageListQuery displayLoader variables={paginationState}>
@@ -121,7 +118,7 @@ export const PageList: React.StatelessComponent<PageListProps> = ({
<>
<PageListPage
disabled={loading}
- listSettings={listSettings.PAGES_LIST}
+ settings={settings}
pages={maybe(() =>
data.pages.edges.map(edge => edge.node)
)}
diff --git a/saleor/static/dashboard-next/products/components/ProductListCard/ProductListCard.tsx b/saleor/static/dashboard-next/products/components/ProductListCard/ProductListCard.tsx
index ca53623e9c..687bdff9b8 100644
--- a/saleor/static/dashboard-next/products/components/ProductListCard/ProductListCard.tsx
+++ b/saleor/static/dashboard-next/products/components/ProductListCard/ProductListCard.tsx
@@ -22,7 +22,7 @@ export interface ProductListCardProps
ListActions,
FilterPageProps<ProductListUrlFilters> {
currencySymbol: string;
- listSettings?: ListSettings;
+ settings?: ListSettings;
products: CategoryDetails_category_products_edges_node[];
}
diff --git a/saleor/static/dashboard-next/products/views/ProductList/ProductList.tsx b/saleor/static/dashboard-next/products/views/ProductList/ProductList.tsx
index 9482dea9c2..85cdf7d417 100644
--- a/saleor/static/dashboard-next/products/views/ProductList/ProductList.tsx
+++ b/saleor/static/dashboard-next/products/views/ProductList/ProductList.tsx
@@ -20,7 +20,7 @@ import usePaginator, {
import useShop from "@saleor/hooks/useShop";
import i18n from "@saleor/i18n";
import { getMutationState, maybe } from "@saleor/misc";
-import { Lists } from "@saleor/types";
+import { ListViews } from "@saleor/types";
import ProductListCard from "../../components/ProductListCard";
import {
TypedProductBulkDeleteMutation,
@@ -63,8 +63,8 @@ export const ProductList: React.StatelessComponent<ProductListProps> = ({
const { isSelected, listElements, reset, toggle, toggleAll } = useBulkActions(
params.ids
);
- const { updateListSettings, listSettings } = useListSettings(
- Lists.PRODUCT_LIST
+ const { updateListSettings, settings } = useListSettings(
+ ListViews.PRODUCT_LIST
);
const tabs = getFilterTabs();
@@ -131,17 +131,14 @@ export const ProductList: React.StatelessComponent<ProductListProps> = ({
handleTabChange(tabs.length + 1);
};
- const paginationState = createPaginationState(
- listSettings.PRODUCT_LIST.rowNumber,
- params
- );
+ const paginationState = createPaginationState(settings.rowNumber, params);
const currencySymbol = maybe(() => shop.defaultCurrency, "USD");
const queryVariables = React.useMemo(
() => ({
...paginationState,
filter: getFilterVariables(params)
}),
- [params, listSettings.PRODUCT_LIST.rowNumber]
+ [params, settings.rowNumber]
);
return (
@@ -202,7 +199,7 @@ export const ProductList: React.StatelessComponent<ProductListProps> = ({
<ProductListCard
currencySymbol={currencySymbol}
currentTab={currentTab}
- listSettings={listSettings.PRODUCT_LIST}
+ settings={settings}
filtersList={createFilterChips(
params,
{
diff --git a/saleor/static/dashboard-next/shipping/components/ShippingZonesList/ShippingZonesList.tsx b/saleor/static/dashboard-next/shipping/components/ShippingZonesList/ShippingZonesList.tsx
index 5fbe7fc668..bc69e169ff 100644
--- a/saleor/static/dashboard-next/shipping/components/ShippingZonesList/ShippingZonesList.tsx
+++ b/saleor/static/dashboard-next/shipping/components/ShippingZonesList/ShippingZonesList.tsx
@@ -54,7 +54,7 @@ const ShippingZonesList = withStyles(styles, { name: "ShippingZonesList" })(
({
classes,
disabled,
- listSettings,
+ settings,
onAdd,
onNextPage,
onPreviousPage,
@@ -100,7 +100,7 @@ const ShippingZonesList = withStyles(styles, { name: "ShippingZonesList" })(
<TableRow>
<TablePagination
colSpan={4}
- listSettings={listSettings}
+ settings={settings}
hasNextPage={pageInfo && !disabled ? pageInfo.hasNextPage : false}
onNextPage={onNextPage}
onUpdateListSettings={onUpdateListSettings}
diff --git a/saleor/static/dashboard-next/shipping/views/ShippingZonesList.tsx b/saleor/static/dashboard-next/shipping/views/ShippingZonesList.tsx
index 1bab775bfd..501ec532aa 100644
--- a/saleor/static/dashboard-next/shipping/views/ShippingZonesList.tsx
+++ b/saleor/static/dashboard-next/shipping/views/ShippingZonesList.tsx
@@ -15,7 +15,7 @@ import usePaginator, {
import useShop from "@saleor/hooks/useShop";
import i18n from "@saleor/i18n";
import { getMutationState, maybe } from "@saleor/misc";
-import { Lists } from "@saleor/types";
+import { ListViews } from "@saleor/types";
import ShippingZonesListPage from "../components/ShippingZonesListPage";
import {
TypedBulkDeleteShippingZone,
@@ -47,14 +47,11 @@ export const ShippingZonesList: React.StatelessComponent<
const { isSelected, listElements, reset, toggle, toggleAll } = useBulkActions(
params.ids
);
- const { updateListSettings, listSettings } = useListSettings(
- Lists.SHIPPING_METHODS_LIST
+ const { updateListSettings, settings } = useListSettings(
+ ListViews.SHIPPING_METHODS_LIST
);
- const paginationState = createPaginationState(
- listSettings.SHIPPING_METHODS_LIST.rowNumber,
- params
- );
+ const paginationState = createPaginationState(settings.rowNumber, params);
return (
<TypedShippingZones displayLoader variables={paginationState}>
@@ -152,7 +149,7 @@ export const ShippingZonesList: React.StatelessComponent<
defaultWeightUnit={maybe(
() => shop.defaultWeightUnit
)}
- listSettings={listSettings.SHIPPING_METHODS_LIST}
+ settings={settings}
disabled={
loading ||
deleteShippingZoneOpts.loading ||
diff --git a/saleor/static/dashboard-next/staff/components/StaffList/StaffList.tsx b/saleor/static/dashboard-next/staff/components/StaffList/StaffList.tsx
index 614be9da88..a3c67c56a0 100644
--- a/saleor/static/dashboard-next/staff/components/StaffList/StaffList.tsx
+++ b/saleor/static/dashboard-next/staff/components/StaffList/StaffList.tsx
@@ -72,7 +72,7 @@ interface StaffListProps extends ListProps, WithStyles<typeof styles> {
const StaffList = withStyles(styles, { name: "StaffList" })(
({
classes,
- listSettings,
+ settings,
disabled,
onNextPage,
onPreviousPage,
@@ -97,7 +97,7 @@ const StaffList = withStyles(styles, { name: "StaffList" })(
<TableRow>
<TablePagination
colSpan={3}
- listSettings={listSettings}
+ settings={settings}
hasNextPage={
pageInfo && !disabled ? pageInfo.hasNextPage : undefined
}
diff --git a/saleor/static/dashboard-next/staff/views/StaffList.tsx b/saleor/static/dashboard-next/staff/views/StaffList.tsx
index 16c99affd4..a730d86953 100644
--- a/saleor/static/dashboard-next/staff/views/StaffList.tsx
+++ b/saleor/static/dashboard-next/staff/views/StaffList.tsx
@@ -10,7 +10,7 @@ import usePaginator, {
import { configurationMenuUrl } from "@saleor/configuration";
import i18n from "@saleor/i18n";
import { getMutationState, maybe } from "@saleor/misc";
-import { Lists } from "@saleor/types";
+import { ListViews } from "@saleor/types";
import StaffAddMemberDialog, {
FormData as AddStaffMemberForm
} from "../components/StaffAddMemberDialog";
@@ -34,8 +34,8 @@ export const StaffList: React.StatelessComponent<StaffListProps> = ({
const navigate = useNavigator();
const notify = useNotifier();
const paginate = usePaginator();
- const { updateListSettings, listSettings } = useListSettings(
- Lists.STAFF_MEMBERS_LIST
+ const { updateListSettings, settings } = useListSettings(
+ ListViews.STAFF_MEMBERS_LIST
);
const closeModal = () =>
@@ -48,10 +48,7 @@ export const StaffList: React.StatelessComponent<StaffListProps> = ({
true
);
- const paginationState = createPaginationState(
- listSettings.STAFF_MEMBERS_LIST.rowNumber,
- params
- );
+ const paginationState = createPaginationState(settings.rowNumber, params);
return (
<TypedStaffListQuery displayLoader variables={paginationState}>
{({ data, loading }) => {
@@ -99,7 +96,7 @@ export const StaffList: React.StatelessComponent<StaffListProps> = ({
<>
<StaffListPage
disabled={loading || addStaffMemberData.loading}
- listSettings={listSettings.STAFF_MEMBERS_LIST}
+ settings={settings}
pageInfo={pageInfo}
staffMembers={maybe(() =>
data.staffUsers.edges.map(edge => edge.node)
diff --git a/saleor/static/dashboard-next/types.ts b/saleor/static/dashboard-next/types.ts
index 64099f36f4..16f830d83a 100644
--- a/saleor/static/dashboard-next/types.ts
+++ b/saleor/static/dashboard-next/types.ts
@@ -10,11 +10,10 @@ export interface UserError {
}
export interface ListSettings {
- name: string;
rowNumber: number;
}
-export enum Lists {
+export enum ListViews {
CATEGORY_LIST = "CATEGORY_LIST",
COLLECTION_LIST = "COLLECTION_LIST",
CUSTOMER_LIST = "CUSTOMER_LIST",
@@ -35,7 +34,7 @@ export interface ListProps {
hasNextPage: boolean;
hasPreviousPage: boolean;
};
- listSettings?: ListSettings;
+ settings?: ListSettings;
onNextPage: () => void;
onPreviousPage: () => void;
onRowClick: (id: string) => () => void;