Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
wip
Lukasz Szewczyk8da355ea8afa
diff --git a/saleor/static/dashboard-next/categories/components/CategoryBackground/CategoryBackground.tsx b/saleor/static/dashboard-next/categories/components/CategoryBackground/CategoryBackground.tsxindex ef7c0340ce..4cc51bbea4 100644--- a/saleor/static/dashboard-next/categories/components/CategoryBackground/CategoryBackground.tsx+++ b/saleor/static/dashboard-next/categories/components/CategoryBackground/CategoryBackground.tsx@@ -1,36 +1,23 @@import { withStyles, WithStyles } from "@material-ui/core/styles";import * as React from "react";-import Card from "@material-ui/core/Card";import Button from "@material-ui/core/Button";+import Card from "@material-ui/core/Card";import CardContent from "@material-ui/core/CardContent";import AddPhotoIcon from "@material-ui/icons/AddAPhoto";-import DeleteIcon from "@material-ui/icons/Delete";-import IconButton from "@material-ui/core/IconButton";-import Toggle from "../../../components/Toggle";-import CardTitle from "../../../components/CardTitle";-import ActionDialog from "../../../components/ActionDialog";-import DialogContentText from "@material-ui/core/DialogContentText";+import BackgroundImage from "./CategoryBackgroundImage";+import CardTitle from "../../../components/CardTitle";import i18n from "../../../i18n";interface CategoryBackgroundProps {- onImageUpload?(event: React.ChangeEvent<any>);onImageDelete?: (id: string) => () => void;placeholderImage: string;backgroundImage?: {- id?: string;- url?: string;- };-}--interface BackgroundImageProps {- onImageDelete?: (id: string) => () => void;- backgroundImage?: {- id?: string;url?: string;};+ onImageUpload?(event: React.ChangeEvent<any>);}const decorate = withStyles(theme => ({@@ -46,10 +33,6 @@ const decorate = withStyles(theme => ({fileField: {display: "none"},- root: {- display: "grid" as "grid",- gridTemplateColumns: "repeat(4, 1fr)"- },image: {height: "100%",objectFit: "contain" as "contain",@@ -62,72 +45,18 @@ const decorate = withStyles(theme => ({display: "block" as "block"}},- justifySelf: "start",- height: 148,- width: 148,background: "#ffffff",border: "1px solid #eaeaea",borderRadius: theme.spacing.unit,- overflow: "hidden" as "hidden",- padding: theme.spacing.unit * 2,- position: "relative" as "relative"- },- imageOverlay: {- background: "rgba(0, 0, 0, 0.6)",- cursor: "pointer",- display: "none" as "none",height: 148,- left: 0,+ justifySelf: "start",+ overflow: "hidden" as "hidden",padding: theme.spacing.unit * 2,- position: "absolute" as "absolute",- top: 0,- width: 148- },- imageOverlayToolbar: {- display: "flex" as "flex",- justifyContent: "flex-end",position: "relative" as "relative",- top: "-10px"+ width: 148}}));-const BackgroundImage = decorate<BackgroundImageProps>(- ({ classes, onImageDelete, backgroundImage }) => (- <Toggle>- {(opened, { toggle }) => (- <>- <div className={classes.root}>- <div className={classes.imageContainer}>- <div className={classes.imageOverlay}>- <div className={classes.imageOverlayToolbar}>- <IconButton color="secondary" onClick={toggle}>- <DeleteIcon />- </IconButton>- </div>- </div>- <img className={classes.image} src={backgroundImage.url} />- </div>- </div>- <ActionDialog- open={opened}- onClose={toggle}- onConfirm={() => {- onImageDelete(backgroundImage.url)();- toggle();- }}- variant="delete"- title={i18n.t("Remove category image")}- >- <DialogContentText>- {i18n.t("Are you sure you want to delete this image?")}- </DialogContentText>- </ActionDialog>- </>- )}- </Toggle>- )-);-export const CategoryBackground = decorate(class CategoryBackgroundClass extends React.Component<CategoryBackgroundProps &@@ -138,8 +67,6 @@ export const CategoryBackground = decorate(| "root"| "image"| "imageContainer"- | "imageOverlay"- | "imageOverlayToolbar">,{}> {@@ -180,7 +107,7 @@ export const CategoryBackground = decorate(/><CardContent>{backgroundImage === undefined ? (- <div className={classes.root}>+ <div><div className={classes.imageContainer}><img className={classes.image} src={placeholderImage} /></div>diff --git a/saleor/static/dashboard-next/categories/components/CategoryBackground/CategoryBackgroundImage.tsx b/saleor/static/dashboard-next/categories/components/CategoryBackground/CategoryBackgroundImage.tsxnew file mode 100644index 0000000000..c57ff649a2--- /dev/null+++ b/saleor/static/dashboard-next/categories/components/CategoryBackground/CategoryBackgroundImage.tsx@@ -0,0 +1,39 @@+import { withStyles } from "@material-ui/core/styles";+import * as React from "react";++import Image from "../../../components/Image";+import Toggle from "../../../components/Toggle";+import CategoryDelete from "../CategoryDelete";++const decorate = withStyles({});++interface BackgroundImageProps {+ onImageDelete?: (id: string) => () => void;+ backgroundImage?: {+ url?: string;+ };+}++const BackgroundImage = decorate<BackgroundImageProps>(+ ({ onImageDelete, backgroundImage }) => (+ <Toggle>+ {(opened, { toggle }) => (+ <>+ <Image tile={backgroundImage} onImageDelete={toggle} />+ <CategoryDelete+ open={opened}+ onClose={toggle}+ onConfirm={() => {+ onImageDelete(backgroundImage.url)();+ toggle();+ }}+ title={"Remove category background"}+ dialogText={"Are you sure you want to delete this image?"}+ />+ </>+ )}+ </Toggle>+ )+);++export default BackgroundImage;diff --git a/saleor/static/dashboard-next/categories/components/CategoryCreatePage/CategoryCreatePage.tsx b/saleor/static/dashboard-next/categories/components/CategoryCreatePage/CategoryCreatePage.tsxindex b91731818b..f008305645 100644--- a/saleor/static/dashboard-next/categories/components/CategoryCreatePage/CategoryCreatePage.tsx+++ b/saleor/static/dashboard-next/categories/components/CategoryCreatePage/CategoryCreatePage.tsx@@ -1,14 +1,14 @@import { withStyles } from "@material-ui/core/styles";import * as React from "react";+import { UserError } from "../../../";import { CardSpacer } from "../../../components/CardSpacer";-import Form from "../../../components/Form";import Container from "../../../components/Container";+import Form from "../../../components/Form";import PageHeader from "../../../components/PageHeader";-import { UserError } from "../../../";+import SeoForm from "../../../components/SeoForm";import i18n from "../../../i18n";import CategoryDetailsForm from "../../components/CategoryDetailsForm";-import SeoForm from "../../../components/SeoForm";import SaveButtonBar, {SaveButtonBarState@@ -21,43 +21,30 @@ interface FormData {seoDescription: string;}+const initialData: FormData = {+ description: "",+ name: "",+ seoDescription: "",+ seoTitle: ""+};+export interface CategoryCreatePageProps {errors: UserError[];- header: string;disabled: boolean;+ saveButtonBarState?: SaveButtonBarState;onSubmit(data: FormData);onBack();- saveButtonBarState?: SaveButtonBarState;}-const decorate = withStyles(theme => ({- root: {- display: "grid",- marginTop: theme.spacing.unit * 2,- gridGap: theme.spacing.unit * 4 + "px"- }-}));+const decorate = withStyles({});export const CategoryCreatePage = decorate<CategoryCreatePageProps>(- ({- header,- disabled,- onSubmit,- onBack,- errors: userErrors,- saveButtonBarState- }) => {- const initialData: FormData = {- name: "",- description: "",- seoTitle: "",- seoDescription: ""- };+ ({ disabled, onSubmit, onBack, errors: userErrors, saveButtonBarState }) => {return (<Form onSubmit={onSubmit} initial={initialData} errors={userErrors}>{({ data, change, errors, submit, hasChanged }) => (<>- <Container width="lg">- <PageHeader title={header} />+ <Container width="md">+ <PageHeader title={i18n.t("Add Category")} onBack={onBack} /><div><CategoryDetailsFormdisabled={disabled}@@ -66,7 +53,6 @@ export const CategoryCreatePage = decorate<CategoryCreatePageProps>(errors={errors}/><CardSpacer />- <CardSpacer /><SeoFormhelperText={i18n.t("Add search engine title and description to make this product easier to find"@@ -78,7 +64,7 @@ export const CategoryCreatePage = decorate<CategoryCreatePageProps>(loading={disabled}onChange={change}disabled={disabled}- />{" "}+ /><SaveButtonBaronCancel={onBack}onSave={submit}diff --git a/saleor/static/dashboard-next/categories/components/CategoryCreateSubcategories/CategoryCreateSubcategories.tsx b/saleor/static/dashboard-next/categories/components/CategoryCreateSubcategories/CategoryCreateSubcategories.tsxindex a87df08b3a..a6a7b052c5 100644--- a/saleor/static/dashboard-next/categories/components/CategoryCreateSubcategories/CategoryCreateSubcategories.tsx+++ b/saleor/static/dashboard-next/categories/components/CategoryCreateSubcategories/CategoryCreateSubcategories.tsx@@ -1,21 +1,19 @@import { withStyles } from "@material-ui/core/styles";-import * as React from "react";import * as classNames from "classnames";+import * as React from "react";-import Card from "@material-ui/core/Card";import Button from "@material-ui/core/Button";+import Card from "@material-ui/core/Card";import CardContent from "@material-ui/core/CardContent";-import Typography from "@material-ui/core/Typography";-import TextField from "@material-ui/core/TextField";-import DeleteIcon from "@material-ui/icons/Delete";import IconButton from "@material-ui/core/IconButton";+import TextField from "@material-ui/core/TextField";+import Typography from "@material-ui/core/Typography";import AddIcon from "@material-ui/icons/Add";-// import CardActions from "@material-ui/core/CardActions";+import DeleteIcon from "@material-ui/icons/Delete";import Hr from "../../../components/Hr";import CardTitle from "../../../components/CardTitle";import Toggle from "../../../components/Toggle";-// import FormSpacer from "../../../components/FormSpacer";import i18n from "../../../i18n";diff --git a/saleor/static/dashboard-next/categories/components/CategoryDelete/CategoryDelete.tsx b/saleor/static/dashboard-next/categories/components/CategoryDelete/CategoryDelete.tsxnew file mode 100644index 0000000000..4207c78fb4--- /dev/null+++ b/saleor/static/dashboard-next/categories/components/CategoryDelete/CategoryDelete.tsx@@ -0,0 +1,32 @@+import { withStyles } from "@material-ui/core/styles";+import * as React from "react";++import DialogContentText from "@material-ui/core/DialogContentText";+import ActionDialog from "../../../components/ActionDialog";+import i18n from "../../../i18n";++const decorate = withStyles({});++interface CategoryDeleteProps {+ open: boolean;+ title: string;+ dialogText: string;+ onClose: () => any;+ onConfirm?(event: React.FormEvent<any>);+}++const CategoryDelete = decorate<CategoryDeleteProps>(+ ({ open, onClose, onConfirm, title, dialogText }) => (+ <ActionDialog+ open={open}+ onClose={onClose}+ onConfirm={onConfirm}+ variant="delete"+ title={i18n.t(title)}+ >+ <DialogContentText>{i18n.t(dialogText)}</DialogContentText>+ </ActionDialog>+ )+);++export default CategoryDelete;diff --git a/saleor/static/dashboard-next/categories/components/CategoryDelete/index.ts b/saleor/static/dashboard-next/categories/components/CategoryDelete/index.tsnew file mode 100644index 0000000000..39766830a4--- /dev/null+++ b/saleor/static/dashboard-next/categories/components/CategoryDelete/index.ts@@ -0,0 +1,2 @@+export { default } from "./CategoryDelete";+export * from "./CategoryDelete";diff --git a/saleor/static/dashboard-next/categories/components/CategoryDetailsForm/CategoryDetailsForm.tsx b/saleor/static/dashboard-next/categories/components/CategoryDetailsForm/CategoryDetailsForm.tsxindex 03243e9c57..861933d30a 100644--- a/saleor/static/dashboard-next/categories/components/CategoryDetailsForm/CategoryDetailsForm.tsx+++ b/saleor/static/dashboard-next/categories/components/CategoryDetailsForm/CategoryDetailsForm.tsx@@ -18,7 +18,7 @@ interface CategoryDetailsFormProps {};disabled: boolean;errors: { [key: string]: string };- onChange(event: any);+ onChange: (event: React.ChangeEvent<any>) => void;}const decorate = withStyles(theme => ({@@ -41,7 +41,7 @@ export const CategoryDetailsForm = decorate<CategoryDetailsFormProps>(label={i18n.t("Name")}name="name"disabled={disabled}- value={data.name}+ value={data && data.name}onChange={onChange}error={!!errors.name}helperText={errors.name}diff --git a/saleor/static/dashboard-next/categories/components/CategoryProducts/CategoryProducts.tsx b/saleor/static/dashboard-next/categories/components/CategoryProducts/CategoryProducts.tsxindex 4f9e1de0a1..4bde646ae8 100644--- a/saleor/static/dashboard-next/categories/components/CategoryProducts/CategoryProducts.tsx+++ b/saleor/static/dashboard-next/categories/components/CategoryProducts/CategoryProducts.tsx@@ -56,7 +56,7 @@ export const ProductList = decorate<ProductListProps>(}) => (<Card><CardTitle- title={i18n.t(`Products in`)}+ title={i18n.t("Products")}toolbar={<Button variant="flat" color="secondary" onClick={onAddProduct}>{i18n.t("Add product")}diff --git a/saleor/static/dashboard-next/categories/components/CategoryProductsCard/CategoryProductsCard.tsx b/saleor/static/dashboard-next/categories/components/CategoryProductsCard/CategoryProductsCard.tsxindex 83bd2de4a0..2806ed5874 100644--- a/saleor/static/dashboard-next/categories/components/CategoryProductsCard/CategoryProductsCard.tsx+++ b/saleor/static/dashboard-next/categories/components/CategoryProductsCard/CategoryProductsCard.tsx@@ -2,14 +2,14 @@ import Button from "@material-ui/core/Button";import Card from "@material-ui/core/Card";import * as React from "react";-import { MoneyType } from "../../../products";import { PageListProps } from "../../..";import CardTitle from "../../../components/CardTitle";import ProductList from "../../../components/ProductList";import i18n from "../../../i18n";+import { MoneyType } from "../../../products";interface CategoryProductsCardProps extends PageListProps {- products?: Array<{+ products: Array<{id: string;name: string;productType: {@@ -21,6 +21,7 @@ interface CategoryProductsCardProps extends PageListProps {};price: MoneyType;}>;+ categoryName: string;onAddProduct?();}@@ -33,11 +34,12 @@ export const CategoryProductsCard: React.StatelessComponent<onAddProduct,onNextPage,onPreviousPage,- onRowClick+ onRowClick,+ categoryName}) => (<Card><CardTitle- title={i18n.t("Products")}+ title={i18n.t("Products in {{ categoryName }}", { categoryName })}toolbar={<Button color="secondary" variant="flat" onClick={onAddProduct}>{i18n.t("Add product")}diff --git a/saleor/static/dashboard-next/categories/components/CategoryTable/CategoryTable.tsx b/saleor/static/dashboard-next/categories/components/CategoryTable/CategoryTable.tsxnew file mode 100644index 0000000000..bf42d13e3c--- /dev/null+++ b/saleor/static/dashboard-next/categories/components/CategoryTable/CategoryTable.tsx@@ -0,0 +1,52 @@+import Button from "@material-ui/core/Button";+import { withStyles } from "@material-ui/core/styles";+import AddIcon from "@material-ui/icons/Add";+import * as React from "react";+import Container from "../../../components/Container";+import PageHeader from "../../../components/PageHeader";+import CategoryList from "../../components/CategoryList";+import i18n from "../../../i18n";++export interface CategoryTableProps {+ categories: Array<{+ id: string;+ name: string;+ children: {+ totalCount: number;+ };+ products: {+ totalCount: number;+ };+ }>;+ onAddCategory();+ onCategoryClick(id: string): () => void;+}++const decorate = withStyles({});++export const CategoryTable = decorate<CategoryTableProps>(+ ({ categories, onAddCategory, onCategoryClick }) => {+ return (+ <>+ <Container width="md">+ <PageHeader title={i18n.t("Category")}>+ <Button+ color="secondary"+ variant="contained"+ onClick={onAddCategory}+ >+ {i18n.t("Add category")} <AddIcon />+ </Button>+ </PageHeader>++ <CategoryList+ categories={categories}+ onAdd={onAddCategory}+ onRowClick={onCategoryClick}+ />+ </Container>+ </>+ );+ }+);+export default CategoryTable;diff --git a/saleor/static/dashboard-next/categories/components/CategoryTable/index.ts b/saleor/static/dashboard-next/categories/components/CategoryTable/index.tsnew file mode 100644index 0000000000..6023b704af--- /dev/null+++ b/saleor/static/dashboard-next/categories/components/CategoryTable/index.ts@@ -0,0 +1,2 @@+export { default } from "./CategoryTable";+export * from "./CategoryTable";diff --git a/saleor/static/dashboard-next/categories/components/CategoryUpdatePage/CategoryUpdatePage.tsx b/saleor/static/dashboard-next/categories/components/CategoryUpdatePage/CategoryUpdatePage.tsxindex d009726f2d..8fd13811be 100644--- a/saleor/static/dashboard-next/categories/components/CategoryUpdatePage/CategoryUpdatePage.tsx+++ b/saleor/static/dashboard-next/categories/components/CategoryUpdatePage/CategoryUpdatePage.tsx@@ -1,28 +1,28 @@-import { withStyles } from "@material-ui/core/styles";-import * as React from "react";-import AddIcon from "@material-ui/icons/Add";import Button from "@material-ui/core/Button";import DialogContentText from "@material-ui/core/DialogContentText";+import { withStyles } from "@material-ui/core/styles";+import AddIcon from "@material-ui/icons/Add";+import * as React from "react";-import CategoryBackground from "../CategoryBackground";+import { UserError } from "../../../";+import ActionDialog from "../../../components/ActionDialog";import Container from "../../../components/Container";-import PageHeader from "../../../components/PageHeader";-import CategoryList from "../../components/CategoryList";-import CategoryDetailsForm from "../../components/CategoryDetailsForm";-import SeoForm from "../../../components/SeoForm";import Form from "../../../components/Form";-import CategoryProductsCard from "../CategoryProductsCard";-import ActionDialog from "../../../components/ActionDialog";-import { MoneyType } from "../../../products";-import Toggle from "../../../components/Toggle";+import PageHeader from "../../../components/PageHeader";import SaveButtonBar, {SaveButtonBarState} from "../../../components/SaveButtonBar/SaveButtonBar";+import SeoForm from "../../../components/SeoForm";import Tabs, { SingleTab } from "../../../components/Tab";-import { UserError } from "../../../";+import Toggle from "../../../components/Toggle";+import { MoneyType } from "../../../products";+import CategoryDetailsForm from "../../components/CategoryDetailsForm";+import CategoryList from "../../components/CategoryList";+import CategoryBackground from "../CategoryBackground";+import CategoryProductsCard from "../CategoryProductsCard";-import i18n from "../../../i18n";import { CardSpacer } from "../../../components/CardSpacer";+import i18n from "../../../i18n";interface FormData {description: string;@@ -72,28 +72,24 @@ export interface CategoryUpdatePageProps {};loading: boolean;saveButtonBarState?: SaveButtonBarState;+ onImageDelete: (id: string) => () => void;onSubmit(data: FormData);- onImageUpload?(event: React.ChangeEvent<any>);+ onImageUpload(event: React.ChangeEvent<any>);onNextPage();onPreviousPage();onProductClick(id: string): () => void;onAddProduct();onBack();onDelete();- onImageDelete: (id: string) => () => void;onAddCategory();onCategoryClick(id: string): () => void;}-const decorate = withStyles(theme => ({- root: {- marginTop: theme.spacing.unit * 2,- gridGap: theme.spacing.unit * 4 + "px"- },+const decorate = withStyles({tabsBorder: {borderBottom: "1px solid #eeeeee"}-}));+});export const CategoryUpdatePage = decorate<CategoryUpdatePageProps>(({@@ -161,7 +157,7 @@ export const CategoryUpdatePage = decorate<CategoryUpdatePageProps>()}</PageHeader>- <div className={classes.root}>+ <div>{!isRoot && (<><CategoryDetailsForm@@ -221,8 +217,8 @@ export const CategoryUpdatePage = decorate<CategoryUpdatePageProps>(>Products</SingleTab>- <CardSpacer /></div>+ <CardSpacer />{currentTab === 0 && (<CategoryListcategories={subcategories}@@ -233,6 +229,7 @@ export const CategoryUpdatePage = decorate<CategoryUpdatePageProps>()}{currentTab === 1 && (<CategoryProductsCard+ categoryName={category.name}products={products}disabled={disabled}pageInfo={pageInfo}@@ -251,8 +248,8 @@ export const CategoryUpdatePage = decorate<CategoryUpdatePageProps>(onDelete={toggleDeleteDialog}onSave={submit}labels={{- save: i18n.t("Save category"),- delete: i18n.t("Delete category")+ delete: i18n.t("Delete category"),+ save: i18n.t("Save category")}}state={saveButtonBarState}disabled={disabled || !hasChanged}diff --git a/saleor/static/dashboard-next/components/ActionDialog/ActionDialog.tsx b/saleor/static/dashboard-next/components/ActionDialog/ActionDialog.tsxindex 5b1ce392b7..d3a74e0045 100644--- a/saleor/static/dashboard-next/components/ActionDialog/ActionDialog.tsx+++ b/saleor/static/dashboard-next/components/ActionDialog/ActionDialog.tsx@@ -12,7 +12,7 @@ import i18n from "../../i18n";interface ActionDialogProps {open: boolean;title: string;- variant?: "default" | "delete";+ variant?: string;onClose?();onConfirm?(event: React.FormEvent<any>);}diff --git a/saleor/static/dashboard-next/components/Image/Image.tsx b/saleor/static/dashboard-next/components/Image/Image.tsxnew file mode 100644index 0000000000..980500d4bc--- /dev/null+++ b/saleor/static/dashboard-next/components/Image/Image.tsx@@ -0,0 +1,86 @@+import { withStyles } from "@material-ui/core/styles";+import * as React from "react";++import IconButton from "@material-ui/core/IconButton";+import DeleteIcon from "@material-ui/icons/Delete";+import EditIcon from "@material-ui/icons/Edit";+import { SortableElement } from "react-sortable-hoc";++const decorate = withStyles(theme => ({+ image: {+ height: "100%",+ objectFit: "contain" as "contain",+ userSelect: "none" as "none",+ width: "100%"+ },+ imageContainer: {+ "&:hover, &.dragged": {+ "& $imageOverlay": {+ display: "block" as "block"+ }+ },+ background: "#ffffff",+ border: "1px solid #eaeaea",+ borderRadius: theme.spacing.unit,+ height: 140,+ margin: "auto",+ overflow: "hidden" as "hidden",+ padding: theme.spacing.unit * 2,+ position: "relative" as "relative",+ width: 140+ },+ imageOverlay: {+ background: "rgba(0, 0, 0, 0.6)",+ cursor: "move",+ display: "none" as "none",+ height: 140,+ left: 0,+ padding: theme.spacing.unit * 2,+ position: "absolute" as "absolute",+ top: 0,+ width: 140+ },+ imageOverlayToolbar: {+ alignContent: "flex-end",+ display: "flex" as "flex",+ position: "relative" as "relative",+ right: -theme.spacing.unit * 3,+ top: -theme.spacing.unit * 2+ }+}));++interface ImageProps {+ tile?: {+ id?: string;+ alt?: string;+ sortOrder?: number;+ url?: string;+ };+ onImageDelete?: () => void;+ onImageEdit?: (event: React.ChangeEvent<any>) => void;+ index?: string;+}++const Image = SortableElement(+ decorate<ImageProps>(({ classes, onImageDelete, onImageEdit, tile }) => (+ <div className={classes.imageContainer}>+ <div className={classes.imageOverlay}>+ <div className={classes.imageOverlayToolbar}>+ {onImageEdit !== undefined ? (+ <IconButton color="secondary" onClick={onImageEdit}>+ <EditIcon />+ </IconButton>+ ) : null}+ {onImageDelete !== undefined ? (+ <IconButton color="secondary" onClick={onImageDelete}>+ <DeleteIcon />+ </IconButton>+ ) : null}+ </div>+ </div>+ <img className={classes.image} src={tile.url} alt={tile.alt} />+ </div>+ ))+);++export default Image;diff --git a/saleor/static/dashboard-next/components/Image/index.ts b/saleor/static/dashboard-next/components/Image/index.tsnew file mode 100644index 0000000000..6baa126180--- /dev/null+++ b/saleor/static/dashboard-next/components/Image/index.ts@@ -0,0 +1,2 @@+export { default } from "./Image";+export * from "./Image";diff --git a/saleor/static/dashboard-next/products/components/ProductImages/ProductImages.tsx b/saleor/static/dashboard-next/products/components/ProductImages/ProductImages.tsxindex cadd8830e6..a88a40fcc6 100644--- a/saleor/static/dashboard-next/products/components/ProductImages/ProductImages.tsx+++ b/saleor/static/dashboard-next/products/components/ProductImages/ProductImages.tsx@@ -2,17 +2,15 @@ import Button from "@material-ui/core/Button";import Card from "@material-ui/core/Card";import CardContent from "@material-ui/core/CardContent";import DialogContentText from "@material-ui/core/DialogContentText";-import IconButton from "@material-ui/core/IconButton";+import { withStyles } from "@material-ui/core/styles";import Typography from "@material-ui/core/Typography";import AddPhotoIcon from "@material-ui/icons/AddAPhoto";-import DeleteIcon from "@material-ui/icons/Delete";-import EditIcon from "@material-ui/icons/Edit";import * as React from "react";-import { SortableContainer, SortableElement } from "react-sortable-hoc";-+import { SortableContainer } from "react-sortable-hoc";import ActionDialog from "../../../components/ActionDialog";import CardTitle from "../../../components/CardTitle";+import Image from "../../../components/Image";import Toggle from "../../../components/Toggle";import i18n from "../../../i18n";@@ -31,17 +29,6 @@ interface ProductImagesProps {onImageReorder?(event: { oldIndex: number; newIndex: number });}-interface ImageListElementProps {- tile: {- id: string;- alt?: string;- sortOrder: number;- url: string;- };- onImageDelete: () => void;- onImageEdit: (event: React.ChangeEvent<any>) => void;-}-interface ImageListContainerProps {items: any;onImageDelete: (id: string) => () => void;@@ -129,26 +116,6 @@ const decorate = withStyles(theme => ({}}));-const ImageListElement = SortableElement(- decorate<ImageListElementProps>(- ({ classes, onImageDelete, onImageEdit, tile }) => (- <div className={classes.imageContainer}>- <div className={classes.imageOverlay}>- <div className={classes.imageOverlayToolbar}>- <IconButton color="secondary" onClick={onImageEdit}>- <EditIcon />- </IconButton>- <IconButton color="secondary" onClick={onImageDelete}>- <DeleteIcon />- </IconButton>- </div>- </div>- <img className={classes.image} src={tile.url} alt={tile.alt} />- </div>- )- )-);-const ImageListContainer = SortableContainer(decorate<ImageListContainerProps>(({ classes, items, onImageDelete, onImageEdit, ...props }) => {@@ -158,7 +125,7 @@ const ImageListContainer = SortableContainer(<Toggle key={index}>{(opened, { toggle }) => (<>- <ImageListElement+ <Imagekey={`item-${index}`}index={index}tile={image}diff --git a/saleor/static/dashboard-next/storybook/config.js b/saleor/static/dashboard-next/storybook/config.jsindex a6bcdc7d8d..c29d95715b 100644--- a/saleor/static/dashboard-next/storybook/config.js+++ b/saleor/static/dashboard-next/storybook/config.js@@ -34,11 +34,13 @@ function loadStories() {// Categoriesrequire("./stories/categories/CategoryDeleteDialog");+ require("./stories/categories/CategoryDelete");require("./stories/categories/CategoryDetailsPage");require("./stories/categories/CategoryEditPage");require("./stories/categories/CategoryProducts");require("./stories/categories/CategoryCreatePage");require("./stories/categories/CategoryUpdatePage");+ require("./stories/categories/CategoryTable");// Collectionsrequire("./stories/collections/CollectionDetailsPage");diff --git a/saleor/static/dashboard-next/storybook/stories/categories/CategoryCreatePage.tsx b/saleor/static/dashboard-next/storybook/stories/categories/CategoryCreatePage.tsxindex bfd562f963..bc3caf5a8a 100644--- a/saleor/static/dashboard-next/storybook/stories/categories/CategoryCreatePage.tsx+++ b/saleor/static/dashboard-next/storybook/stories/categories/CategoryCreatePage.tsx@@ -7,12 +7,10 @@ import CategoryCreatePage, {import Decorator from "../../Decorator";const createProps: CategoryCreatePageProps = {- header: "Add category",disabled: false,errors: [],onBack: () => undefined,- onSubmit: () => undefined,- onDelete: () => undefined+ onSubmit: () => undefined};storiesOf("Views / Categories / Create category", module)diff --git a/saleor/static/dashboard-next/storybook/stories/categories/CategoryDelete.tsx b/saleor/static/dashboard-next/storybook/stories/categories/CategoryDelete.tsxnew file mode 100644index 0000000000..c24c77e27b--- /dev/null+++ b/saleor/static/dashboard-next/storybook/stories/categories/CategoryDelete.tsx@@ -0,0 +1,17 @@+import { storiesOf } from "@storybook/react";+import * as React from "react";++import CategoryDelete from "../../../categories/components/CategoryDelete";+import Decorator from "../../Decorator";++storiesOf("Categories / Remove image dialog", module)+ .addDecorator(Decorator)+ .add("default", () => (+ <CategoryDelete+ open={true}+ onClose={undefined}+ onConfirm={undefined}+ title={"Remove"}+ dialogText={"Do you want to remove this"}+ />+ ));diff --git a/saleor/static/dashboard-next/storybook/stories/categories/CategoryTable.tsx b/saleor/static/dashboard-next/storybook/stories/categories/CategoryTable.tsxnew file mode 100644index 0000000000..b091bc2527--- /dev/null+++ b/saleor/static/dashboard-next/storybook/stories/categories/CategoryTable.tsx@@ -0,0 +1,17 @@+import { storiesOf } from "@storybook/react";+import * as React from "react";++import { categories } from "../../../categories/fixtures";++import CategoryTable from "../../../categories/components/CategoryTable";+import Decorator from "../../Decorator";++storiesOf("Views / Categories / Category Table", module)+ .addDecorator(Decorator)+ .add("default", () => (+ <CategoryTable+ categories={categories}+ onAddCategory={undefined}+ onCategoryClick={() => undefined}+ />+ ));diff --git a/saleor/static/dashboard-next/storybook/stories/categories/CategoryUpdatePage.tsx b/saleor/static/dashboard-next/storybook/stories/categories/CategoryUpdatePage.tsxindex a2febb1106..394b52319b 100644--- a/saleor/static/dashboard-next/storybook/stories/categories/CategoryUpdatePage.tsx+++ b/saleor/static/dashboard-next/storybook/stories/categories/CategoryUpdatePage.tsx@@ -13,13 +13,13 @@ const category = categoryFixture(placeholderImage);const updateProps: CategoryUpdatePageProps = {category: category,- subcategories: category.children,backgroundImage: category.backgroundImage,- placeholderImage: placeholderImage,+ subcategories: category.children,disabled: false,errors: [],products: category.products,loading: false,+ placeholderImage: placeholderImage,pageInfo: {hasNextPage: true,hasPreviousPage: true