Skip to content

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

Set rowNum as optional, fix styles

Krzysztof Bialoglowicz445ae81c6c32
diff --git a/saleor/static/dashboard-next/components/RowNumberSelect/RowNumberSelect.tsx b/saleor/static/dashboard-next/components/RowNumberSelect/RowNumberSelect.tsx
index 249191f24b..429d924576 100644
--- a/saleor/static/dashboard-next/components/RowNumberSelect/RowNumberSelect.tsx
+++ b/saleor/static/dashboard-next/components/RowNumberSelect/RowNumberSelect.tsx
@@ -16,8 +16,12 @@ const styles = (theme: Theme) =>
label: {
fontSize: "14px"
},
+ root: {},
select: {
"& div": {
+ "&:focus": {
+ background: "none"
+ },
color: theme.palette.primary.main,
padding: "0 10px 0 5px"
},
@@ -32,9 +36,8 @@ const styles = (theme: Theme) =>
interface RowNumberSelectProps extends WithStyles<typeof styles> {
choices: number[];
- className: string;
+ className?: string;
currentRowNum: number;
- name: string;
onChange(event: any);
}
diff --git a/saleor/static/dashboard-next/components/TablePagination/TablePagination.tsx b/saleor/static/dashboard-next/components/TablePagination/TablePagination.tsx
index 3102a53ff7..3629413d94 100644
--- a/saleor/static/dashboard-next/components/TablePagination/TablePagination.tsx
+++ b/saleor/static/dashboard-next/components/TablePagination/TablePagination.tsx
@@ -61,13 +61,13 @@ interface TablePaginationProps extends WithStyles<typeof styles> {
backIconButtonProps?: Partial<IconButtonProps>;
colSpan: number;
component?: string | typeof TableCell;
- currentRowNum: number;
+ currentRowNum?: number;
hasNextPage: boolean;
hasPreviousPage: boolean;
nextIconButtonProps?: Partial<IconButtonProps>;
onNextPage(event);
onPreviousPage(event);
- onRowNumChange(event);
+ onRowNumChange?(event);
}
const TablePagination = withStyles(styles, { name: "TablePagination" })(
@@ -96,11 +96,13 @@ const TablePagination = withStyles(styles, { name: "TablePagination" })(
<Component className={classes.root} colSpan={colSpan} {...other}>
<Toolbar className={classes.toolbar}>
<div className={classes.spacer}>
- <RowNumberSelect
- choices={[20, 30, 50, 100]}
- currentRowNum={currentRowNum}
- onChange={onRowNumChange}
- />
+ {currentRowNum && (
+ <RowNumberSelect
+ choices={[20, 30, 50, 100]}
+ currentRowNum={currentRowNum}
+ onChange={onRowNumChange}
+ />
+ )}
</div>
<Actions
backIconButtonProps={backIconButtonProps}
diff --git a/saleor/static/dashboard-next/fixtures.ts b/saleor/static/dashboard-next/fixtures.ts
index ef1d1aeec9..18e1e301a5 100644
--- a/saleor/static/dashboard-next/fixtures.ts
+++ b/saleor/static/dashboard-next/fixtures.ts
@@ -7,6 +7,7 @@ const pageInfo = {
};
export const pageListProps: { [key: string]: PageListProps } = {
default: {
+ currentRowNum: 20,
disabled: false,
onAdd: undefined,
onNextPage: undefined,
@@ -15,6 +16,7 @@ export const pageListProps: { [key: string]: PageListProps } = {
pageInfo
},
loading: {
+ currentRowNum: undefined,
disabled: true,
onAdd: undefined,
onNextPage: undefined,
diff --git a/saleor/static/dashboard-next/products/components/ProductListCard/ProductListCard.tsx b/saleor/static/dashboard-next/products/components/ProductListCard/ProductListCard.tsx
index 0d25fa9b54..d381ae343f 100644
--- a/saleor/static/dashboard-next/products/components/ProductListCard/ProductListCard.tsx
+++ b/saleor/static/dashboard-next/products/components/ProductListCard/ProductListCard.tsx
@@ -16,7 +16,7 @@ export interface ProductListCardProps
extends PageListProps,
ListActions,
FilterPageProps<ProductListUrlFilters> {
- currentRowNum: number;
+ currentRowNum?: number;
currencySymbol: string;
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 67d2feaac5..294cd547a9 100644
--- a/saleor/static/dashboard-next/products/views/ProductList/ProductList.tsx
+++ b/saleor/static/dashboard-next/products/views/ProductList/ProductList.tsx
@@ -18,7 +18,6 @@ import usePaginator, {
} from "@saleor/hooks/usePaginator";
import useRowChange from "@saleor/hooks/useRowChange";
import useShop from "@saleor/hooks/useShop";
-import { PAGINATE_BY } from "../../../config";
import i18n from "../../../i18n";
import { getMutationState, maybe } from "../../../misc";
import ProductListCard from "../../components/ProductListCard";
diff --git a/saleor/static/dashboard-next/types.ts b/saleor/static/dashboard-next/types.ts
index a332416a27..4740e5dd35 100644
--- a/saleor/static/dashboard-next/types.ts
+++ b/saleor/static/dashboard-next/types.ts
@@ -10,7 +10,7 @@ export interface UserError {
}
export interface ListProps {
- currentRowNum: number;
+ currentRowNum?: number;
disabled: boolean;
pageInfo?: {
hasNextPage: boolean;
@@ -19,7 +19,7 @@ export interface ListProps {
onNextPage: () => void;
onPreviousPage: () => void;
onRowClick: (id: string) => () => void;
- onRowNumChange: (event: React.ChangeEvent<any>) => void;
+ onRowNumChange?: (event: React.ChangeEvent<any>) => void;
}
export interface ListActionsWithoutToolbar {
toggle: (id: string) => void;