Skip to content

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

Revert product list changes

dominik-zeglen250a90a4f254
diff --git a/saleor/static/dashboard-next/components/ProductList/ProductList.tsx b/saleor/static/dashboard-next/components/ProductList/ProductList.tsx
index 23d4dfd3c8..a4fff5a154 100644
--- a/saleor/static/dashboard-next/components/ProductList/ProductList.tsx
+++ b/saleor/static/dashboard-next/components/ProductList/ProductList.tsx
@@ -1,3 +1,5 @@
+import Avatar from "@material-ui/core/Avatar";
+import blue from "@material-ui/core/colors/blue";
import { withStyles } from "@material-ui/core/styles";
import Table from "@material-ui/core/Table";
import TableBody from "@material-ui/core/TableBody";
@@ -5,15 +7,12 @@ import TableCell from "@material-ui/core/TableCell";
import TableFooter from "@material-ui/core/TableFooter";
import TableHead from "@material-ui/core/TableHead";
import TableRow from "@material-ui/core/TableRow";
+import Cached from "@material-ui/icons/Cached";
import * as React from "react";
import { ListProps } from "../..";
-import TableCellAvatar from "../../components/TableCellAvatar";
import i18n from "../../i18n";
-import { MoneyType } from "../../products";
-import Money from "../Money";
import Skeleton from "../Skeleton";
-import StatusLabel from "../StatusLabel";
import TablePagination from "../TablePagination";
const decorate = withStyles(theme => ({
@@ -23,10 +22,8 @@ const decorate = withStyles(theme => ({
width: theme.spacing.unit * 5
},
link: {
- cursor: "pointer" as "pointer"
- },
- textLeft: {
- textAlign: "left" as "left"
+ color: blue[500],
+ cursor: "pointer"
}
}));
@@ -38,10 +35,6 @@ interface ProductListProps extends ListProps {
name: string;
};
thumbnailUrl: string;
- availability: {
- available: boolean;
- };
- price: MoneyType;
}>;
}
@@ -58,19 +51,15 @@ export const ProductList = decorate<ProductListProps>(
<Table>
<TableHead>
<TableRow>
- <TableCell />
- <TableCell className={classes.textLeft}>
- {i18n.t("Name", { context: "object" })}
- </TableCell>
+ <TableCell className={classes.avatarCell} />
+ <TableCell>{i18n.t("Name", { context: "object" })}</TableCell>
<TableCell>{i18n.t("Type", { context: "object" })}</TableCell>
- <TableCell>{i18n.t("Published", { context: "object" })}</TableCell>
- <TableCell>{i18n.t("Price", { context: "object" })}</TableCell>
</TableRow>
</TableHead>
<TableFooter>
<TableRow>
<TablePagination
- colSpan={5}
+ colSpan={3}
hasNextPage={pageInfo && !disabled ? pageInfo.hasNextPage : false}
onNextPage={onNextPage}
hasPreviousPage={
@@ -81,14 +70,12 @@ export const ProductList = decorate<ProductListProps>(
</TableRow>
</TableFooter>
<TableBody>
- {products === undefined ? (
+ {products === undefined || products === null ? (
<TableRow>
- <TableCellAvatar />
- <TableCell>
- <Skeleton />
- </TableCell>
- <TableCell>
- <Skeleton />
+ <TableCell className={classes.avatarCell}>
+ <Avatar>
+ <Cached />
+ </Avatar>
</TableCell>
<TableCell>
<Skeleton />
@@ -97,11 +84,13 @@ export const ProductList = decorate<ProductListProps>(
<Skeleton />
</TableCell>
</TableRow>
- ) : products !== null && products.length > 0 ? (
+ ) : products.length > 0 ? (
products.map(product => (
<TableRow key={product.id}>
- <TableCellAvatar thumbnail={product.thumbnailUrl} />
- <TableCell className={classes.textLeft}>
+ <TableCell className={classes.avatarCell}>
+ <Avatar src={product.thumbnailUrl} />
+ </TableCell>
+ <TableCell>
<span
onClick={onRowClick ? onRowClick(product.id) : undefined}
className={onRowClick ? classes.link : ""}
@@ -110,40 +99,12 @@ export const ProductList = decorate<ProductListProps>(
</span>
</TableCell>
<TableCell>{product.productType.name}</TableCell>
- <TableCell>
- {product.availability &&
- product.availability.available !== undefined ? (
- <StatusLabel
- label={
- product.availability.available
- ? i18n.t("Published")
- : i18n.t("Not published")
- }
- status={
- product.availability.available ? "success" : "error"
- }
- />
- ) : (
- <Skeleton />
- )}
- </TableCell>
- <TableCell>
- {product.price &&
- product.price.amount !== undefined &&
- product.price.currency ? (
- <Money
- amount={product.price.amount}
- currency={product.price.currency}
- />
- ) : (
- <Skeleton />
- )}
- </TableCell>
</TableRow>
))
) : (
<TableRow>
- <TableCell colSpan={5}>{i18n.t("No products found")}</TableCell>
+ <TableCell className={classes.avatarCell} />
+ <TableCell colSpan={2}>{i18n.t("No products found")}</TableCell>
</TableRow>
)}
</TableBody>