Skip to content

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

Fix rowNumberSelect small issues

Krzysztof Bialoglowiczca0b8e3c65af
diff --git a/saleor/static/dashboard-next/components/ProductList/ProductList.tsx b/saleor/static/dashboard-next/components/ProductList/ProductList.tsx
index 005d7ae4ab..d3f2edaf89 100644
--- a/saleor/static/dashboard-next/components/ProductList/ProductList.tsx
+++ b/saleor/static/dashboard-next/components/ProductList/ProductList.tsx
@@ -84,118 +84,115 @@ export const ProductList = withStyles(styles, { name: "ProductList" })(
onPreviousPage,
onUpdateListSettings,
onRowClick
- }: ProductListProps) => {
- return (
- <Table>
- <TableHead
- selected={selected}
- disabled={disabled}
- items={products}
- toggleAll={toggleAll}
- toolbar={toolbar}
- >
- <TableCell />
- <TableCell className={classes.colName}>
- {i18n.t("Name", { context: "object" })}
- </TableCell>
- <TableCell className={classes.colType}>
- {i18n.t("Type", { context: "object" })}
- </TableCell>
- <TableCell className={classes.colPublished}>
- {i18n.t("Published", { context: "object" })}
- </TableCell>
- <TableCell className={classes.colPrice}>
- {i18n.t("Price", { context: "object" })}
- </TableCell>
- </TableHead>
- <TableFooter>
- <TableRow>
- <TablePagination
- colSpan={6}
- listSettings={listSettings}
- hasNextPage={pageInfo && !disabled ? pageInfo.hasNextPage : false}
- onNextPage={onNextPage}
- onUpdateListSettings={onUpdateListSettings}
- hasPreviousPage={
- pageInfo && !disabled ? pageInfo.hasPreviousPage : false
- }
- onPreviousPage={onPreviousPage}
- />
- </TableRow>
- </TableFooter>
- <TableBody>
- {renderCollection(
- products,
- product => {
- const isSelected = product ? isChecked(product.id) : false;
+ }: ProductListProps) => (
+ <Table>
+ <TableHead
+ selected={selected}
+ disabled={disabled}
+ items={products}
+ toggleAll={toggleAll}
+ toolbar={toolbar}
+ >
+ <TableCell />
+ <TableCell className={classes.colName}>
+ {i18n.t("Name", { context: "object" })}
+ </TableCell>
+ <TableCell className={classes.colType}>
+ {i18n.t("Type", { context: "object" })}
+ </TableCell>
+ <TableCell className={classes.colPublished}>
+ {i18n.t("Published", { context: "object" })}
+ </TableCell>
+ <TableCell className={classes.colPrice}>
+ {i18n.t("Price", { context: "object" })}
+ </TableCell>
+ </TableHead>
+ <TableFooter>
+ <TableRow>
+ <TablePagination
+ colSpan={6}
+ listSettings={listSettings}
+ hasNextPage={pageInfo && !disabled ? pageInfo.hasNextPage : false}
+ onNextPage={onNextPage}
+ onUpdateListSettings={onUpdateListSettings}
+ hasPreviousPage={
+ pageInfo && !disabled ? pageInfo.hasPreviousPage : false
+ }
+ onPreviousPage={onPreviousPage}
+ />
+ </TableRow>
+ </TableFooter>
+ <TableBody>
+ {renderCollection(
+ products,
+ product => {
+ const isSelected = product ? isChecked(product.id) : false;
- return (
- <TableRow
- selected={isSelected}
- hover={!!product}
- key={product ? product.id : "skeleton"}
- onClick={product && onRowClick(product.id)}
- className={classes.link}
- >
- <TableCell padding="checkbox">
- <Checkbox
- checked={isSelected}
- disabled={disabled}
- onChange={() => toggle(product.id)}
- />
- </TableCell>
- <TableCellAvatar
- thumbnail={maybe(() => product.thumbnail.url)}
+ return (
+ <TableRow
+ selected={isSelected}
+ hover={!!product}
+ key={product ? product.id : "skeleton"}
+ onClick={product && onRowClick(product.id)}
+ className={classes.link}
+ >
+ <TableCell padding="checkbox">
+ <Checkbox
+ checked={isSelected}
+ disabled={disabled}
+ onChange={() => toggle(product.id)}
/>
- <TableCell className={classes.colName}>
- {product ? product.name : <Skeleton />}
- </TableCell>
- <TableCell className={classes.colType}>
- {product && product.productType ? (
- product.productType.name
- ) : (
- <Skeleton />
- )}
- </TableCell>
- <TableCell className={classes.colPublished}>
- {product &&
- maybe(() => product.isAvailable !== undefined) ? (
- <StatusLabel
- label={
- product.isAvailable
- ? i18n.t("Published", { context: "product status" })
- : i18n.t("Not published", {
- context: "product status"
- })
- }
- status={product.isAvailable ? "success" : "error"}
- />
- ) : (
- <Skeleton />
- )}
- </TableCell>
- <TableCell className={classes.colPrice}>
- {maybe(() => product.basePrice) &&
- maybe(() => product.basePrice.amount) !== undefined &&
- maybe(() => product.basePrice.currency) !== undefined ? (
- <Money money={product.basePrice} />
- ) : (
- <Skeleton />
- )}
- </TableCell>
- </TableRow>
- );
- },
- () => (
- <TableRow>
- <TableCell colSpan={6}>{i18n.t("No products found")}</TableCell>
+ </TableCell>
+ <TableCellAvatar
+ thumbnail={maybe(() => product.thumbnail.url)}
+ />
+ <TableCell className={classes.colName}>
+ {product ? product.name : <Skeleton />}
+ </TableCell>
+ <TableCell className={classes.colType}>
+ {product && product.productType ? (
+ product.productType.name
+ ) : (
+ <Skeleton />
+ )}
+ </TableCell>
+ <TableCell className={classes.colPublished}>
+ {product && maybe(() => product.isAvailable !== undefined) ? (
+ <StatusLabel
+ label={
+ product.isAvailable
+ ? i18n.t("Published", { context: "product status" })
+ : i18n.t("Not published", {
+ context: "product status"
+ })
+ }
+ status={product.isAvailable ? "success" : "error"}
+ />
+ ) : (
+ <Skeleton />
+ )}
+ </TableCell>
+ <TableCell className={classes.colPrice}>
+ {maybe(() => product.basePrice) &&
+ maybe(() => product.basePrice.amount) !== undefined &&
+ maybe(() => product.basePrice.currency) !== undefined ? (
+ <Money money={product.basePrice} />
+ ) : (
+ <Skeleton />
+ )}
+ </TableCell>
</TableRow>
- )
- )}
- </TableBody>
- </Table>
- );
- }
+ );
+ },
+ () => (
+ <TableRow>
+ <TableCell colSpan={6}>{i18n.t("No products found")}</TableCell>
+ </TableRow>
+ )
+ )}
+ </TableBody>
+ </Table>
+ )
);
ProductList.displayName = "ProductList";
export default ProductList;
diff --git a/saleor/static/dashboard-next/components/RowNumberSelect/RowNumberSelect.tsx b/saleor/static/dashboard-next/components/RowNumberSelect/RowNumberSelect.tsx
index 2ca84d4689..dba862d92a 100644
--- a/saleor/static/dashboard-next/components/RowNumberSelect/RowNumberSelect.tsx
+++ b/saleor/static/dashboard-next/components/RowNumberSelect/RowNumberSelect.tsx
@@ -1,74 +1,71 @@
import MenuItem from "@material-ui/core/MenuItem";
import Select from "@material-ui/core/Select";
-import {
- createStyles,
- Theme,
- withStyles,
- WithStyles
-} from "@material-ui/core/styles";
-import classNames from "classnames";
+import { Theme } from "@material-ui/core/styles";
+import { createStyles, makeStyles, useTheme } from "@material-ui/styles";
import React from "react";
import i18n from "../../i18n";
import { ListSettings } from "../../types";
-const styles = (theme: Theme) =>
- createStyles({
- label: {
- fontSize: "14px"
- },
- root: {},
- select: {
- "& div": {
- "&:focus": {
- background: "none"
- },
- color: theme.palette.primary.main,
- padding: "0 10px 0 5px"
- },
- "& svg": {
- color: theme.palette.primary.main
+const useStyles = makeStyles(
+ (theme: Theme) =>
+ createStyles({
+ label: {
+ fontSize: 14
},
- "&:after, &:before, &:hover": {
- border: "none !important"
+ select: {
+ "& div": {
+ "&:focus": {
+ background: "none"
+ },
+ color: theme.palette.primary.main,
+ padding: "0 10px 0 5px"
+ },
+ "& svg": {
+ color: theme.palette.primary.main
+ },
+ "&:after, &:before, &:hover": {
+ border: "none !important"
+ }
}
- }
- });
+ }),
+ {
+ name: "RowNumberSelect"
+ }
+);
-interface RowNumberSelectProps extends WithStyles<typeof styles> {
+interface RowNumberSelectProps {
choices: number[];
className?: string;
listSettings: ListSettings;
onChange(key: keyof ListSettings, value: any);
}
-const RowNumberSelect = withStyles(styles, { name: "RowNumberSelect" })(
- ({
- classes,
- className,
- choices,
- listSettings,
- onChange
- }: RowNumberSelectProps) => {
- return (
- <div className={classNames(classes.root, className)}>
- <span className={classes.label}>{i18n.t("No of Rows:")}</span>
- <Select
- className={classes.select}
- value={listSettings.rowNumber}
- onChange={event => onChange("rowNumber", event.target.value)}
- >
- {choices.length > 0 &&
- choices.map(choice => (
- <MenuItem value={choice} key={choice}>
- {choice}
- </MenuItem>
- ))}
- </Select>
- </div>
- );
- }
-);
+const RowNumberSelect: React.FC<RowNumberSelectProps> = ({
+ className,
+ choices,
+ listSettings,
+ onChange
+}) => {
+ const theme = useTheme();
+ const classes = useStyles({ theme });
+ return (
+ <div className={className}>
+ <span className={classes.label}>{i18n.t("No of Rows:")}</span>
+ <Select
+ className={classes.select}
+ value={listSettings.rowNumber}
+ onChange={event => onChange("rowNumber", event.target.value)}
+ >
+ {choices.length > 0 &&
+ choices.map(choice => (
+ <MenuItem value={choice} key={choice}>
+ {choice}
+ </MenuItem>
+ ))}
+ </Select>
+ </div>
+ );
+};
-RowNumberSelect.displayName = "RowNumberSelect";
export default RowNumberSelect;