Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fix bugs, remove unnecessary components
Lukasz Szewczyk285c07cf8f90
diff --git a/saleor/static/dashboard-next/categories/components/CategoryBackground/CategoryBackground.tsx b/saleor/static/dashboard-next/categories/components/CategoryBackground/CategoryBackground.tsxindex 4cc51bbea4..4bbba5da30 100644--- a/saleor/static/dashboard-next/categories/components/CategoryBackground/CategoryBackground.tsx+++ b/saleor/static/dashboard-next/categories/components/CategoryBackground/CategoryBackground.tsx@@ -6,25 +6,25 @@ import Card from "@material-ui/core/Card";import CardContent from "@material-ui/core/CardContent";import AddPhotoIcon from "@material-ui/icons/AddAPhoto";-import BackgroundImage from "./CategoryBackgroundImage";+import CategoryBackgroundImage from "./CategoryBackgroundImage";import CardTitle from "../../../components/CardTitle";import i18n from "../../../i18n";interface CategoryBackgroundProps {- onImageDelete?: (id: string) => () => void;+ onImageDelete: (id: string) => () => void;placeholderImage: string;backgroundImage?: {url?: string;};- onImageUpload?(event: React.ChangeEvent<any>);+ onImageUpload(event: React.ChangeEvent<any>);}const decorate = withStyles(theme => ({PhotosIcon: {- height: theme.spacing.unit * 8,+ height: "64px",margin: "0 auto",- width: theme.spacing.unit * 8+ width: "64px"},PhotosIconContainer: {margin: `${theme.spacing.unit * 5}px 0`,@@ -53,6 +53,7 @@ const decorate = withStyles(theme => ({overflow: "hidden" as "hidden",padding: theme.spacing.unit * 2,position: "relative" as "relative",+ margin: "auto",width: 148}}));@@ -64,7 +65,6 @@ export const CategoryBackground = decorate(| "PhotosIcon"| "PhotosIconContainer"| "fileField"- | "root"| "image"| "imageContainer">,@@ -113,7 +113,7 @@ export const CategoryBackground = decorate(</div></div>) : backgroundImage.url ? (- <BackgroundImage+ <CategoryBackgroundImageonImageDelete={onImageDelete}backgroundImage={backgroundImage}/>diff --git a/saleor/static/dashboard-next/categories/components/CategoryBackground/CategoryBackgroundImage.tsx b/saleor/static/dashboard-next/categories/components/CategoryBackground/CategoryBackgroundImage.tsxindex c57ff649a2..31f9e888e5 100644--- a/saleor/static/dashboard-next/categories/components/CategoryBackground/CategoryBackgroundImage.tsx+++ b/saleor/static/dashboard-next/categories/components/CategoryBackground/CategoryBackgroundImage.tsx@@ -3,24 +3,29 @@ import * as React from "react";import Image from "../../../components/Image";import Toggle from "../../../components/Toggle";-import CategoryDelete from "../CategoryDelete";+import CategoryDeleteImage from "../CategoryDeleteImage";const decorate = withStyles({});-interface BackgroundImageProps {+interface CategoryBackgroundImageProps {onImageDelete?: (id: string) => () => void;backgroundImage?: {url?: string;};}-const BackgroundImage = decorate<BackgroundImageProps>(+const CategoryBackgroundImage = decorate<CategoryBackgroundImageProps>(({ onImageDelete, backgroundImage }) => (<Toggle>{(opened, { toggle }) => (<>- <Image tile={backgroundImage} onImageDelete={toggle} />- <CategoryDelete+ <Image+ tile={backgroundImage}+ onImageDelete={toggle}+ deleteIcon={true}+ editIcon={false}+ />+ <CategoryDeleteImageopen={opened}onClose={toggle}onConfirm={() => {@@ -36,4 +41,4 @@ const BackgroundImage = decorate<BackgroundImageProps>());-export default BackgroundImage;+export default CategoryBackgroundImage;diff --git a/saleor/static/dashboard-next/categories/components/CategoryBackground/index.ts b/saleor/static/dashboard-next/categories/components/CategoryBackground/index.tsindex f5a59d0a36..46667f78a5 100644--- a/saleor/static/dashboard-next/categories/components/CategoryBackground/index.ts+++ b/saleor/static/dashboard-next/categories/components/CategoryBackground/index.ts@@ -1,2 +1,4 @@export { default } from "./CategoryBackground";+export * from "./CategoryBackground";+export * from "./CategoryBackgroundImage";diff --git a/saleor/static/dashboard-next/categories/components/CategoryCreateSubcategories/CategoryCreateSubcategories.tsx b/saleor/static/dashboard-next/categories/components/CategoryCreateSubcategories/CategoryCreateSubcategories.tsxindex a6a7b052c5..575119bbe4 100644--- a/saleor/static/dashboard-next/categories/components/CategoryCreateSubcategories/CategoryCreateSubcategories.tsx+++ b/saleor/static/dashboard-next/categories/components/CategoryCreateSubcategories/CategoryCreateSubcategories.tsx@@ -22,28 +22,28 @@ interface CategoryCreateSubcategoriesProps {}const decorate = withStyles(theme => ({+ addSubCat: {+ marginTop: ".5rem",+ padding: "0"+ },+ deleteIcon: {+ alignSelf: "end",+ justifySelf: "center"+ },+ helperText: {+ marginBottom: theme.spacing.unit * 4+ },inputGrid: {display: "grid",gridColumnGap: theme.spacing.unit * 2 + "px",gridTemplateColumns: "5fr 8fr 30px",marginBottom: "1rem"},- helperText: {- marginBottom: theme.spacing.unit * 4- },- deleteIcon: {- justifySelf: "center",- alignSelf: "end"- },- addSubCat: {- padding: "0",- marginTop: ".5rem"- },root: {- paddingBottom: "0px","&:last-child": {paddingBottom: ".5rem"- }+ },+ paddingBottom: "0px"}}));diff --git a/saleor/static/dashboard-next/categories/components/CategoryDelete/index.ts b/saleor/static/dashboard-next/categories/components/CategoryDelete/index.tsdeleted file mode 100644index 39766830a4..0000000000--- a/saleor/static/dashboard-next/categories/components/CategoryDelete/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export { default } from "./CategoryDelete";-export * from "./CategoryDelete";diff --git a/saleor/static/dashboard-next/categories/components/CategoryDeleteDialog/CategoryDeleteDialog.tsx b/saleor/static/dashboard-next/categories/components/CategoryDeleteDialog/CategoryDeleteDialog.tsxindex 02a77e1d8b..9fdef17126 100644--- a/saleor/static/dashboard-next/categories/components/CategoryDeleteDialog/CategoryDeleteDialog.tsx+++ b/saleor/static/dashboard-next/categories/components/CategoryDeleteDialog/CategoryDeleteDialog.tsx@@ -25,8 +25,8 @@ const decorate = withStyles(export interface CategoryDeleteDialogProps {open: boolean;name: string;- onClose?();- onConfirm?();+ onClose();+ onConfirm();}const CategoryDeleteDialog = decorate<CategoryDeleteDialogProps>(props => {diff --git a/saleor/static/dashboard-next/categories/components/CategoryDelete/CategoryDelete.tsx b/saleor/static/dashboard-next/categories/components/CategoryDeleteImage/CategoryDeleteImage.tsxsimilarity index 83%rename from saleor/static/dashboard-next/categories/components/CategoryDelete/CategoryDelete.tsxrename to saleor/static/dashboard-next/categories/components/CategoryDeleteImage/CategoryDeleteImage.tsxindex 4207c78fb4..749815f40d 100644--- a/saleor/static/dashboard-next/categories/components/CategoryDelete/CategoryDelete.tsx+++ b/saleor/static/dashboard-next/categories/components/CategoryDeleteImage/CategoryDeleteImage.tsx@@ -7,7 +7,7 @@ import i18n from "../../../i18n";const decorate = withStyles({});-interface CategoryDeleteProps {+interface CategoryDeleteImageProps {open: boolean;title: string;dialogText: string;@@ -15,7 +15,7 @@ interface CategoryDeleteProps {onConfirm?(event: React.FormEvent<any>);}-const CategoryDelete = decorate<CategoryDeleteProps>(+const CategoryDeleteImage = decorate<CategoryDeleteImageProps>(({ open, onClose, onConfirm, title, dialogText }) => (<ActionDialogopen={open}@@ -29,4 +29,4 @@ const CategoryDelete = decorate<CategoryDeleteProps>());-export default CategoryDelete;+export default CategoryDeleteImage;diff --git a/saleor/static/dashboard-next/categories/components/CategoryDeleteImage/index.ts b/saleor/static/dashboard-next/categories/components/CategoryDeleteImage/index.tsnew file mode 100644index 0000000000..7113ccae86--- /dev/null+++ b/saleor/static/dashboard-next/categories/components/CategoryDeleteImage/index.ts@@ -0,0 +1,2 @@+export { default } from "./CategoryDeleteImage";+export * from "./CategoryDeleteImage";diff --git a/saleor/static/dashboard-next/categories/components/CategoryDetailsForm/CategoryDetailsForm.tsx b/saleor/static/dashboard-next/categories/components/CategoryDetailsForm/CategoryDetailsForm.tsxindex 861933d30a..092f435b84 100644--- a/saleor/static/dashboard-next/categories/components/CategoryDetailsForm/CategoryDetailsForm.tsx+++ b/saleor/static/dashboard-next/categories/components/CategoryDetailsForm/CategoryDetailsForm.tsx@@ -21,13 +21,11 @@ interface CategoryDetailsFormProps {onChange: (event: React.ChangeEvent<any>) => void;}-const decorate = withStyles(theme => ({+const decorate = withStyles({root: {- display: "grid",- gridColumnGap: theme.spacing.unit * 2 + "px",- gridTemplateColumns: `1fr 1fr`+ width: "50%"}-}));+});export const CategoryDetailsForm = decorate<CategoryDetailsFormProps>(({ classes, disabled, data, onChange, errors }) => {@@ -36,8 +34,9 @@ export const CategoryDetailsForm = decorate<CategoryDetailsFormProps>(<CardTitle title={i18n.t("General information")} /><CardContent><>- <div className={classes.root}>+ <div><TextField+ classes={{ root: classes.root }}label={i18n.t("Name")}name="name"disabled={disabled}diff --git a/saleor/static/dashboard-next/categories/components/CategoryDetailsPage/CategoryDetailsPage.tsx b/saleor/static/dashboard-next/categories/components/CategoryDetailsPage/CategoryDetailsPage.tsxdeleted file mode 100644index 3d4f4ed97f..0000000000--- a/saleor/static/dashboard-next/categories/components/CategoryDetailsPage/CategoryDetailsPage.tsx+++ /dev/null@@ -1,185 +0,0 @@-import Button from "@material-ui/core/Button";-import gray from "@material-ui/core/colors/grey";-import { withStyles } from "@material-ui/core/styles";-import AddIcon from "@material-ui/icons/Add";-import * as classNames from "classnames";-import * as React from "react";--import { Container } from "../../../components/Container";-import PageHeader from "../../../components/PageHeader";-import Toggle from "../../../components/Toggle";-import i18n from "../../../i18n";-import CategoryDeleteDialog from "../../components/CategoryDeleteDialog";-import CategoryList from "../../components/CategoryList";-import CategoryProperties from "../../components/CategoryProperties";-import CategoryProducts from "../CategoryProducts";--interface CategoryDetailsPageProps {- category?: {- id: string;- description?: string;- name?: string;- };- subcategories?: Array<{- id: string;- name: string;- children: {- totalCount: number;- };- products: {- totalCount: number;- };- }>;- products?: Array<{- id: string;- name: string;- thumbnailUrl: string;- productType: {- name: string;- };- }>;- pageInfo?: {- hasNextPage: boolean;- hasPreviousPage: boolean;- };- loading?: boolean;- onAddCategory?();- onAddProduct?();- onBack?();- onCategoryClick?(id: string): () => void;- onDelete?();- onEdit?();- onNextPage?();- onPreviousPage?();- onProductClick?(id: string): () => void;-}--const decorate = withStyles(theme => ({- actions: {- borderTop: `1px ${gray[300]} solid`,- display: "flex",- marginBottom: theme.spacing.unit * 2,- marginTop: theme.spacing.unit * 2,- paddingTop: theme.spacing.unit * 2,- [theme.breakpoints.down("sm")]: {- marginTop: theme.spacing.unit- }- },- cardContainer: {- marginTop: theme.spacing.unit * 2,- [theme.breakpoints.down("md")]: {- marginTop: theme.spacing.unit- }- },- deleteButton: {- "&:hover": {- backgroundColor: theme.palette.error.dark- },- backgroundColor: theme.palette.error.main,- color: theme.palette.error.contrastText- }-}));-const CategoryDetailsPage = decorate<CategoryDetailsPageProps>(- ({- category,- classes,- loading,- pageInfo,- products,- subcategories,- onAddCategory,- onAddProduct,- onBack,- onCategoryClick,- onDelete,- onEdit,- onNextPage,- onPreviousPage,- onProductClick- }) => {- const isRoot = !loading && !products && !category;- return (- <Toggle>- {(opened, { toggle: toggleDialog }) => (- <>- <Container width="md">- <PageHeader- onBack={isRoot ? undefined : onBack}- title={- isRoot- ? i18n.t("Categories")- : category- ? category.name- : undefined- }- >- {isRoot && (- <Button- color="secondary"- variant="contained"- onClick={onAddCategory}- >- {i18n.t("Add category")} <AddIcon />- </Button>- )}- </PageHeader>- <div>- {!isRoot && (- <CategoryProperties- description={category ? category.description : undefined}- onEdit={onEdit}- />- )}- <div- className={classNames({ [classes.cardContainer]: !isRoot })}- >- <CategoryList- categories={subcategories}- isRoot={isRoot}- onAdd={onAddCategory}- onRowClick={onCategoryClick}- />- </div>- {!isRoot && (- <div className={classes.cardContainer}>- <CategoryProducts- products={products}- hasNextPage={pageInfo ? pageInfo.hasNextPage : false}- hasPreviousPage={- pageInfo ? pageInfo.hasPreviousPage : false- }- onAddProduct={onAddProduct}- onNextPage={onNextPage}- onPreviousPage={onPreviousPage}- onRowClick={onProductClick}- />- </div>- )}- </div>- {!isRoot && (- <div className={classes.actions}>- <Button- variant="contained"- onClick={toggleDialog}- className={classes.deleteButton}- >- {i18n.t("Remove category")}- </Button>- </div>- )}- </Container>- {category && (- <CategoryDeleteDialog- name={category.name}- open={opened}- onClose={toggleDialog}- onConfirm={onDelete}- />- )}- </>- )}- </Toggle>- );- }-);-export default CategoryDetailsPage;diff --git a/saleor/static/dashboard-next/categories/components/CategoryDetailsPage/index.ts b/saleor/static/dashboard-next/categories/components/CategoryDetailsPage/index.tsdeleted file mode 100644index 6cfdd43df5..0000000000--- a/saleor/static/dashboard-next/categories/components/CategoryDetailsPage/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export { default } from "./CategoryDetailsPage";-export * from "./CategoryDetailsPage";diff --git a/saleor/static/dashboard-next/categories/components/CategoryEditPage/CategoryEditPage.tsx b/saleor/static/dashboard-next/categories/components/CategoryEditPage/CategoryEditPage.tsxdeleted file mode 100644index 371704b79f..0000000000--- a/saleor/static/dashboard-next/categories/components/CategoryEditPage/CategoryEditPage.tsx+++ /dev/null@@ -1,108 +0,0 @@-import Card from "@material-ui/core/Card";-import CardContent from "@material-ui/core/CardContent";-import TextField from "@material-ui/core/TextField";-import * as React from "react";--import Container from "../../../components/Container";-import Form from "../../../components/Form";-import FormSpacer from "../../../components/FormSpacer";-import PageHeader from "../../../components/PageHeader";-import SaveButtonBar, {- SaveButtonBarState-} from "../../../components/SaveButtonBar";-import i18n from "../../../i18n";--interface CategoryForm {- description: string;- name: string;-}-interface CategoryEditPageProps {- category?: CategoryForm;- errors?: Array<{- field: string;- message: string;- }>;- disabled?: boolean;- variant?: "add" | "edit";- saveButtonBarState?: SaveButtonBarState;- onBack?: () => void;- onSubmit?: (data: CategoryForm) => void;-}--const CategoryEditPage: React.StatelessComponent<CategoryEditPageProps> = ({- category,- errors,- disabled,- variant,- saveButtonBarState,- onBack,- onSubmit-}) => {- const errorList: { [key: string]: string } = errors- ? errors.reduce((acc, curr) => {- acc[curr.field] = curr.message;- return acc;- }, {})- : {};- return (- <Form- initial={{- description: category ? category.description : "",- name: category ? category.name : ""- }}- onSubmit={onSubmit}- key={category === undefined ? "loading" : "ready"}- >- {({ change, data, hasChanged, submit }) => (- <Container width="md">- <PageHeader- onBack={onBack}- title={- variant === "add"- ? i18n.t("Add category")- : i18n.t("Edit category")- }- />- <Card>- <CardContent>- <TextField- autoFocus- fullWidth- disabled={disabled}- value={data && data.name}- error={!!errorList.name}- helperText={errorList.name}- label={i18n.t("Name", { context: "category" })}- name="name"- onChange={change}- />- <FormSpacer />- <TextField- fullWidth- multiline- rows={10}- disabled={disabled}- value={data && data.description}- error={!!errorList.description}- helperText={- errorList.description ||- i18n.t("Optional", { context: "field" })- }- label={i18n.t("Description")}- name="description"- onChange={change}- />- </CardContent>- </Card>- <SaveButtonBar- disabled={disabled || !onSubmit || !hasChanged}- state={saveButtonBarState}- onCancel={onBack}- onSave={submit}- />- </Container>- )}- </Form>- );-};-export default CategoryEditPage;diff --git a/saleor/static/dashboard-next/categories/components/CategoryEditPage/index.ts b/saleor/static/dashboard-next/categories/components/CategoryEditPage/index.tsdeleted file mode 100644index c1bc43cc8c..0000000000--- a/saleor/static/dashboard-next/categories/components/CategoryEditPage/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export { default } from "./CategoryEditPage";-export * from "./CategoryEditPage";diff --git a/saleor/static/dashboard-next/categories/components/CategoryList/CategoryList.tsx b/saleor/static/dashboard-next/categories/components/CategoryList/CategoryList.tsxindex e596420026..19bd87350b 100644--- a/saleor/static/dashboard-next/categories/components/CategoryList/CategoryList.tsx+++ b/saleor/static/dashboard-next/categories/components/CategoryList/CategoryList.tsx@@ -24,7 +24,7 @@ interface CategoryListProps {totalCount: number;};}>;- isRoot?: boolean;+ isRoot: boolean;onAdd?();onRowClick?(id: string): () => void;}diff --git a/saleor/static/dashboard-next/categories/components/CategoryProperties/CategoryProperties.tsx b/saleor/static/dashboard-next/categories/components/CategoryProperties/CategoryProperties.tsxdeleted file mode 100644index f278b279d2..0000000000--- a/saleor/static/dashboard-next/categories/components/CategoryProperties/CategoryProperties.tsx+++ /dev/null@@ -1,42 +0,0 @@-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 * as React from "react";--import CardTitle from "../../../components/CardTitle";-import Skeleton from "../../../components/Skeleton";-import i18n from "../../../i18n";--interface CategoryPropertiesProps {- description?: string;- onEdit?();-}--const CategoryProperties: React.StatelessComponent<CategoryPropertiesProps> = ({- description,- onEdit-}) => (- <Card>- <CardTitle- title={i18n.t("Details")}- toolbar={- <Button variant="flat" color="secondary" onClick={onEdit}>- {i18n.t("Edit category")}- </Button>- }- />- <CardContent>- {description === undefined ? (- <Skeleton />- ) : description ? (- <Typography>{description}</Typography>- ) : (- <Typography color={"textSecondary"}>- {i18n.t("No description")}- </Typography>- )}- </CardContent>- </Card>-);-export default CategoryProperties;diff --git a/saleor/static/dashboard-next/categories/components/CategoryProperties/index.ts b/saleor/static/dashboard-next/categories/components/CategoryProperties/index.tsdeleted file mode 100644index 33e7170525..0000000000--- a/saleor/static/dashboard-next/categories/components/CategoryProperties/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export { default } from "./CategoryProperties";-export * from "./CategoryProperties";diff --git a/saleor/static/dashboard-next/categories/components/CategoryTable/CategoryTable.tsx b/saleor/static/dashboard-next/categories/components/CategoryTable/CategoryTable.tsxindex bf42d13e3c..bb2a320c30 100644--- a/saleor/static/dashboard-next/categories/components/CategoryTable/CategoryTable.tsx+++ b/saleor/static/dashboard-next/categories/components/CategoryTable/CategoryTable.tsx@@ -4,8 +4,8 @@ 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";+import CategoryList from "../../components/CategoryList";export interface CategoryTableProps {categories: Array<{@@ -38,11 +38,11 @@ export const CategoryTable = decorate<CategoryTableProps>({i18n.t("Add category")} <AddIcon /></Button></PageHeader>-<CategoryListcategories={categories}onAdd={onAddCategory}onRowClick={onCategoryClick}+ isRoot={true}/></Container></>diff --git a/saleor/static/dashboard-next/categories/components/CategoryUpdatePage/CategoryUpdatePage.tsx b/saleor/static/dashboard-next/categories/components/CategoryUpdatePage/CategoryUpdatePage.tsxindex 8fd13811be..65f4e9eec3 100644--- a/saleor/static/dashboard-next/categories/components/CategoryUpdatePage/CategoryUpdatePage.tsx+++ b/saleor/static/dashboard-next/categories/components/CategoryUpdatePage/CategoryUpdatePage.tsx@@ -1,11 +1,7 @@-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 { UserError } from "../../../";-import ActionDialog from "../../../components/ActionDialog";import Container from "../../../components/Container";import Form from "../../../components/Form";import PageHeader from "../../../components/PageHeader";@@ -13,8 +9,7 @@ import SaveButtonBar, {SaveButtonBarState} from "../../../components/SaveButtonBar/SaveButtonBar";import SeoForm from "../../../components/SeoForm";-import Tabs, { SingleTab } from "../../../components/Tab";-import Toggle from "../../../components/Toggle";+import Tabs, { Tab } from "../../../components/Tab";import { MoneyType } from "../../../products";import CategoryDetailsForm from "../../components/CategoryDetailsForm";import CategoryList from "../../components/CategoryList";@@ -41,7 +36,7 @@ export interface CategoryUpdatePageProps {name: string;description: string;};- backgroundImage: {+ backgroundImage?: {url?: string;};products: Array<{@@ -118,168 +113,106 @@ export const CategoryUpdatePage = decorate<CategoryUpdatePageProps>(}) => {const initialData = category? {- name: category.name,description: category.description,- seoTitle: category.SeoTitle,- seoDescription: category.SeoDescription+ name: category.name,+ seoDescription: category.SeoDescription,+ seoTitle: category.SeoTitle}: {- name: "",description: "",- seoTitle: "",- seoDescription: ""+ name: "",+ seoDescription: "",+ seoTitle: ""};- const isRoot = !loading && !products && !category;return (- <Toggle>- {(openedDeleteDialog, { toggle: toggleDeleteDialog }) => (- <Form onSubmit={onSubmit} initial={initialData} errors={userErrors}>- {({ data, change, errors, submit, hasChanged }) => (- <>- <Container width="md">- <PageHeader- title={- isRoot- ? i18n.t("Category")- : category- ? category.name- : undefined- }- >- {isRoot && (- <Button- color="secondary"- variant="contained"- onClick={onAddCategory}- >- {i18n.t("Add category")} <AddIcon />- </Button>- )}- </PageHeader>-- <div>- {!isRoot && (- <>- <CategoryDetailsForm- data={data}- disabled={disabled}- errors={errors}- onChange={change}- />- <CardSpacer />- <CategoryBackground- onImageUpload={onImageUpload}- onImageDelete={onImageDelete}- backgroundImage={backgroundImage}- placeholderImage={placeholderImage}- />- <CardSpacer />- <SeoForm- helperText={i18n.t(- "Add search engine title and description to make this product easier to find"- )}- title={data.seoTitle}- titlePlaceholder={data.name}- description={data.seoDescription}- descriptionPlaceholder={data.description}- loading={loading}- onChange={change}- disabled={disabled}- />- <CardSpacer />- </>- )}- {isRoot && (- <CategoryList- categories={subcategories}- isRoot={isRoot}- onAdd={onAddCategory}- onRowClick={onCategoryClick}- />- )}- {!isRoot && (- <>- <Tabs>- {({ changeTab, currentTab }) => (- <>- <div className={classes.tabsBorder}>- <SingleTab- isActive={currentTab === 0}- value={0}- changeTab={changeTab}- >- Subcategories- </SingleTab>- <SingleTab- isActive={currentTab === 1}- value={1}- changeTab={changeTab}- >- Products- </SingleTab>- </div>- <CardSpacer />- {currentTab === 0 && (- <CategoryList- categories={subcategories}- isRoot={isRoot}- onAdd={onAddCategory}- onRowClick={onCategoryClick}- />- )}- {currentTab === 1 && (- <CategoryProductsCard- categoryName={category.name}- products={products}- disabled={disabled}- pageInfo={pageInfo}- onNextPage={onNextPage}- onPreviousPage={onPreviousPage}- onRowClick={onProductClick}- onAdd={onAddProduct}- />- )}- </>- )}- </Tabs>-- <SaveButtonBar- onCancel={onBack}- onDelete={toggleDeleteDialog}- onSave={submit}- labels={{- delete: i18n.t("Delete category"),- save: i18n.t("Save category")- }}- state={saveButtonBarState}- disabled={disabled || !hasChanged}- />- </>- )}+ <Form onSubmit={onSubmit} initial={initialData} errors={userErrors}>+ {({ data, change, errors, submit, hasChanged }) => (+ <Container width="md">+ <PageHeader title={category ? category.name : undefined} />+ <CategoryDetailsForm+ data={data}+ disabled={disabled}+ errors={errors}+ onChange={change}+ />+ <CardSpacer />+ <CategoryBackground+ onImageUpload={onImageUpload}+ onImageDelete={onImageDelete}+ backgroundImage={backgroundImage}+ placeholderImage={placeholderImage}+ />+ <CardSpacer />+ <SeoForm+ helperText={i18n.t(+ "Add search engine title and description to make this product easier to find"+ )}+ title={data.seoTitle}+ titlePlaceholder={data.name}+ description={data.seoDescription}+ descriptionPlaceholder={data.description}+ loading={loading}+ onChange={change}+ disabled={disabled}+ />+ <CardSpacer />+ <Tabs>+ {({ changeTab, currentTab }) => (+ <>+ <div className={classes.tabsBorder}>+ <Tab+ isActive={currentTab === 0}+ value={0}+ changeTab={changeTab}+ >+ Subcategories+ </Tab>+ <Tab+ isActive={currentTab === 1}+ value={1}+ changeTab={changeTab}+ >+ Products+ </Tab></div>- </Container>- {!isRoot && (- <ActionDialog- title={i18n.t("Remove category")}- open={openedDeleteDialog}- onClose={toggleDeleteDialog}- onConfirm={onDelete}- variant={"delete"}- >- <DialogContentText- dangerouslySetInnerHTML={{- __html: i18n.t(- "Are you sure you want to remove this category"- )- }}+ <CardSpacer />+ {currentTab === 0 && (+ <CategoryList+ isRoot={false}+ categories={subcategories}+ onAdd={onAddCategory}+ onRowClick={onCategoryClick}+ />+ )}+ {currentTab === 1 && (+ <CategoryProductsCard+ categoryName={category.name}+ products={products}+ disabled={disabled}+ pageInfo={pageInfo}+ onNextPage={onNextPage}+ onPreviousPage={onPreviousPage}+ onRowClick={onProductClick}+ onAdd={onAddProduct}/>- </ActionDialog>- )}- </>- )}- </Form>+ )}+ </>+ )}+ </Tabs>+ <SaveButtonBar+ onCancel={onBack}+ onDelete={onDelete}+ onSave={submit}+ labels={{+ delete: i18n.t("Delete category"),+ save: i18n.t("Save category")+ }}+ state={saveButtonBarState}+ disabled={disabled || !hasChanged}+ />+ </Container>)}- </Toggle>+ </Form>);});diff --git a/saleor/static/dashboard-next/categories/fixtures.ts b/saleor/static/dashboard-next/categories/fixtures.tsindex 2d714d6489..404aea367c 100644--- a/saleor/static/dashboard-next/categories/fixtures.ts+++ b/saleor/static/dashboard-next/categories/fixtures.ts@@ -1,5 +1,5 @@-import { products } from "../products/fixtures";import * as block1 from "../../images/block1.jpg";+import { products } from "../products/fixtures";export const categories = [{@@ -67,14 +67,14 @@ export const category = (placeholderImage: string) => ({SeoDescription:"Across pressure PM food discover recognize. Send letter reach listen. Quickly work plan rule.\nTell lose part purpose do when. Whatever drug contain particularly defense.",SeoTitle: "Apparel",+ backgroundImage: {+ url: block1+ },children: categories,description:"Across pressure PM food discover recognize. Send letter reach listen. Quickly work plan rule.\nTell lose part purpose do when. Whatever drug contain particularly defense.",id: "c1",name: "Apparel",- backgroundImage: {- url: block1- },products: products(placeholderImage)});export const errors = [diff --git a/saleor/static/dashboard-next/categories/index.tsx b/saleor/static/dashboard-next/categories/index.tsxindex 0a5a9d0fdb..f358c2f2bb 100644--- a/saleor/static/dashboard-next/categories/index.tsx+++ b/saleor/static/dashboard-next/categories/index.tsx@@ -1,48 +1,40 @@-import { parse as parseQs } from "qs";+// import { parse as parseQs } from "qs";import * as React from "react";-import { Route, RouteComponentProps, Switch } from "react-router-dom";+import { Route, Switch } from "react-router-dom";-import { CategoryCreateForm } from "./views/CategoryCreate";-import CategoryDetails from "./views/CategoryDetails";-import { CategoryUpdateForm } from "./views/CategoryUpdate";+// import { CategoryCreateForm } from "./views/CategoryCreate";+// import CategoryDetails from "./views/CategoryDetails";+// import { CategoryUpdateForm } from "./views/CategoryUpdate";-const CategoryPaginator: React.StatelessComponent<RouteComponentProps<any>> = ({- location,- match-}) => {- const qs = parseQs(location.search.substr(1));- const params = {- after: qs.after,- before: qs.before- };- return <CategoryDetails id={match.params.id} params={params} />;-};-const SubcategoryCreateForm: React.StatelessComponent<- RouteComponentProps<any>-> = ({ match }) => {- return <CategoryCreateForm parentId={match.params.id} />;-};-const SubcategoryUpdateForm: React.StatelessComponent<- RouteComponentProps<any>-> = ({ match }) => {- return <CategoryUpdateForm id={match.params.id} />;-};+// const CategoryPaginator: React.StatelessComponent<RouteComponentProps<any>> = ({+// location,+// match+// }) => {+// const qs = parseQs(location.search.substr(1));+// const params = {+// after: qs.after,+// before: qs.before+// };+// return <CategoryDetails id={match.params.id} params={params} />;+// };+// const SubcategoryCreateForm: React.StatelessComponent<+// RouteComponentProps<any>+// > = ({ match }) => {+// return <CategoryCreateForm parentId={match.params.id} />;+// };+// const SubcategoryUpdateForm: React.StatelessComponent<+// RouteComponentProps<any>+// > = ({ match }) => {+// return <CategoryUpdateForm id={match.params.id} />;+// };const Component = ({ match }) => (<Switch>- <Route exact path={match.url} component={CategoryPaginator} />- <Route exact path={`${match.url}/add/`} component={CategoryCreateForm} />- <Route- exact- path={`${match.url}/:id/edit/`}- component={SubcategoryUpdateForm}- />- <Route- exact- path={`${match.url}/:id/add/`}- component={SubcategoryCreateForm}- />- <Route exact path={`${match.url}/:id/`} component={CategoryPaginator} />+ <Route exact path={match.url} component={null} />+ <Route exact path={`${match.url}/add/`} component={null} />+ <Route exact path={`${match.url}/:id/edit/`} component={null} />+ <Route exact path={`${match.url}/:id/add/`} component={null} />+ <Route exact path={`${match.url}/:id/`} component={null} /></Switch>);diff --git a/saleor/static/dashboard-next/components/Image/Image.tsx b/saleor/static/dashboard-next/components/Image/Image.tsxindex 980500d4bc..259cdad773 100644--- a/saleor/static/dashboard-next/components/Image/Image.tsx+++ b/saleor/static/dashboard-next/components/Image/Image.tsx@@ -4,7 +4,6 @@ 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: {@@ -22,29 +21,29 @@ const decorate = withStyles(theme => ({background: "#ffffff",border: "1px solid #eaeaea",borderRadius: theme.spacing.unit,- height: 140,margin: "auto",+ height: 148,overflow: "hidden" as "hidden",padding: theme.spacing.unit * 2,position: "relative" as "relative",- width: 140+ width: 148},imageOverlay: {background: "rgba(0, 0, 0, 0.6)",cursor: "move",display: "none" as "none",- height: 140,+ height: 148,left: 0,padding: theme.spacing.unit * 2,position: "absolute" as "absolute",top: 0,- width: 140+ width: 148},imageOverlayToolbar: {alignContent: "flex-end",display: "flex" as "flex",position: "relative" as "relative",- right: -theme.spacing.unit * 3,+ right: -theme.spacing.unit * 4,top: -theme.spacing.unit * 2}}));@@ -56,22 +55,24 @@ interface ImageProps {sortOrder?: number;url?: string;};+ deleteIcon: boolean;+ editIcon: boolean;onImageDelete?: () => void;onImageEdit?: (event: React.ChangeEvent<any>) => void;index?: string;}-const Image = SortableElement(- decorate<ImageProps>(({ classes, onImageDelete, onImageEdit, tile }) => (+const Image = decorate<ImageProps>(+ ({ classes, onImageDelete, onImageEdit, tile, editIcon, deleteIcon }) => (<div className={classes.imageContainer}><div className={classes.imageOverlay}><div className={classes.imageOverlayToolbar}>- {onImageEdit !== undefined ? (+ {editIcon ? (<IconButton color="secondary" onClick={onImageEdit}><EditIcon /></IconButton>) : null}- {onImageDelete !== undefined ? (+ {deleteIcon ? (<IconButton color="secondary" onClick={onImageDelete}><DeleteIcon /></IconButton>@@ -80,7 +81,7 @@ const Image = SortableElement(</div><img className={classes.image} src={tile.url} alt={tile.alt} /></div>- ))+ ));export default Image;diff --git a/saleor/static/dashboard-next/components/Tab/SingleTab.tsx b/saleor/static/dashboard-next/components/Tab/Tab.tsxsimilarity index 75%rename from saleor/static/dashboard-next/components/Tab/SingleTab.tsxrename to saleor/static/dashboard-next/components/Tab/Tab.tsxindex c86559b8e0..c9b008b92f 100644--- a/saleor/static/dashboard-next/components/Tab/SingleTab.tsx+++ b/saleor/static/dashboard-next/components/Tab/Tab.tsx@@ -15,21 +15,14 @@ const decorate = withStyles(theme => ({"&$active": {borderBottomColor: theme.palette.primary.main},- borderBottomWidth: 1,- borderBottomStyle: "solid" as "solid",- borderBottomColor: "transparent",+ borderBottom: "1px solid transparent",display: "inline-block" as "inline-block",minWidth: 40,fontWeight: theme.typography.fontWeightRegular,marginRight: theme.spacing.unit * 4,cursor: "pointer","&:hover": {- color: "#5AB378",- opacity: 1- },- "&$tabSelected": {- color: "#5AB378",- fontWeight: theme.typography.fontWeightMedium+ color: "#5AB378"},"&:focus": {color: "#5AB378"@@ -37,7 +30,7 @@ const decorate = withStyles(theme => ({}}));-export const SingleTab = decorate<TabProps>(+export const Tab = decorate<TabProps>(({ classes, children, isActive, value, changeTab }) => (<Typographycomponent="span"@@ -52,4 +45,4 @@ export const SingleTab = decorate<TabProps>());-export default SingleTab;+export default Tab;diff --git a/saleor/static/dashboard-next/components/Tab/index.ts b/saleor/static/dashboard-next/components/Tab/index.tsindex 6fad2c4fcb..8e3168e5cf 100644--- a/saleor/static/dashboard-next/components/Tab/index.ts+++ b/saleor/static/dashboard-next/components/Tab/index.ts@@ -1,3 +1,3 @@export { default } from "./Tabs";export * from "./Tabs";-export * from "./SingleTab";+export * from "./Tab";diff --git a/saleor/static/dashboard-next/products/components/ProductImages/ProductImages.tsx b/saleor/static/dashboard-next/products/components/ProductImages/ProductImages.tsxindex a88a40fcc6..1fee3a5105 100644--- a/saleor/static/dashboard-next/products/components/ProductImages/ProductImages.tsx+++ b/saleor/static/dashboard-next/products/components/ProductImages/ProductImages.tsx@@ -7,7 +7,7 @@ import { withStyles } from "@material-ui/core/styles";import Typography from "@material-ui/core/Typography";import AddPhotoIcon from "@material-ui/icons/AddAPhoto";import * as React from "react";-import { SortableContainer } from "react-sortable-hoc";+import { SortableContainer, SortableElement } from "react-sortable-hoc";import ActionDialog from "../../../components/ActionDialog";import CardTitle from "../../../components/CardTitle";import Image from "../../../components/Image";@@ -116,6 +116,18 @@ const decorate = withStyles(theme => ({}}));+const SortableImage = SortableElement(+ ({ image, onImageEdit, toggle, tile }) => (+ <Image+ tile={tile}+ deleteIcon={true}+ editIcon={true}+ onImageEdit={onImageEdit ? onImageEdit(image.id) : null}+ onImageDelete={toggle}+ />+ )+);+const ImageListContainer = SortableContainer(decorate<ImageListContainerProps>(({ classes, items, onImageDelete, onImageEdit, ...props }) => {@@ -125,7 +137,7 @@ const ImageListContainer = SortableContainer(<Toggle key={index}>{(opened, { toggle }) => (<>- <Image+ <SortableImagekey={`item-${index}`}index={index}tile={image}diff --git a/saleor/static/dashboard-next/storybook/config.js b/saleor/static/dashboard-next/storybook/config.jsindex c29d95715b..ac8652f3c2 100644--- a/saleor/static/dashboard-next/storybook/config.js+++ b/saleor/static/dashboard-next/storybook/config.js@@ -34,9 +34,7 @@ function loadStories() {// Categoriesrequire("./stories/categories/CategoryDeleteDialog");- require("./stories/categories/CategoryDelete");- require("./stories/categories/CategoryDetailsPage");- require("./stories/categories/CategoryEditPage");+ require("./stories/categories/CategoryDeleteImage");require("./stories/categories/CategoryProducts");require("./stories/categories/CategoryCreatePage");require("./stories/categories/CategoryUpdatePage");diff --git a/saleor/static/dashboard-next/storybook/stories/categories/CategoryDeleteDialog.tsx b/saleor/static/dashboard-next/storybook/stories/categories/CategoryDeleteDialog.tsxindex 8c19f21fd4..f1bea78281 100644--- a/saleor/static/dashboard-next/storybook/stories/categories/CategoryDeleteDialog.tsx+++ b/saleor/static/dashboard-next/storybook/stories/categories/CategoryDeleteDialog.tsx@@ -7,7 +7,7 @@ import Decorator from "../../Decorator";const category = categoryFixture("");-storiesOf("Categories / CategoryDeleteDialog", module)+storiesOf("Views / Categories / Category Delete Dialog", module).addDecorator(Decorator).add("default", () => (<CategoryDeleteDialogdiff --git a/saleor/static/dashboard-next/storybook/stories/categories/CategoryDelete.tsx b/saleor/static/dashboard-next/storybook/stories/categories/CategoryDeleteImage.tsxsimilarity index 55%rename from saleor/static/dashboard-next/storybook/stories/categories/CategoryDelete.tsxrename to saleor/static/dashboard-next/storybook/stories/categories/CategoryDeleteImage.tsxindex c24c77e27b..a85aa6b916 100644--- a/saleor/static/dashboard-next/storybook/stories/categories/CategoryDelete.tsx+++ b/saleor/static/dashboard-next/storybook/stories/categories/CategoryDeleteImage.tsx@@ -1,17 +1,17 @@import { storiesOf } from "@storybook/react";import * as React from "react";-import CategoryDelete from "../../../categories/components/CategoryDelete";+import CategoryDeleteImage from "../../../categories/components/CategoryDeleteImage";import Decorator from "../../Decorator";-storiesOf("Categories / Remove image dialog", module)+storiesOf("Views / Categories / Remove image dialog", module).addDecorator(Decorator).add("default", () => (- <CategoryDelete+ <CategoryDeleteImageopen={true}onClose={undefined}onConfirm={undefined}title={"Remove"}- dialogText={"Do you want to remove this"}+ dialogText={"Do you want to remove this image"}/>));diff --git a/saleor/static/dashboard-next/storybook/stories/categories/CategoryDetailsPage.tsx b/saleor/static/dashboard-next/storybook/stories/categories/CategoryDetailsPage.tsxdeleted file mode 100644index 1de7098772..0000000000--- a/saleor/static/dashboard-next/storybook/stories/categories/CategoryDetailsPage.tsx+++ /dev/null@@ -1,49 +0,0 @@-import { storiesOf } from "@storybook/react";-import * as React from "react";--import * as placeholderImage from "../../../../images/placeholder60x60.png";-import CategoryDetailsPage from "../../../categories/components/CategoryDetailsPage";-import { category as categoryFixture } from "../../../categories/fixtures";-import Decorator from "../../Decorator";--const category = categoryFixture(placeholderImage);--storiesOf("Views / Categories / Category details", module)- .addDecorator(Decorator)- .add("default", () => (- <CategoryDetailsPage- category={category}- subcategories={category.children}- products={category.products}- pageInfo={{- hasNextPage: true,- hasPreviousPage: true- }}- loading={false}- onAddCategory={undefined}- onAddProduct={undefined}- onBack={() => undefined}- onCategoryClick={() => undefined}- onDelete={undefined}- onEdit={undefined}- onNextPage={undefined}- onPreviousPage={undefined}- onProductClick={() => undefined}- />- ))- .add("when in root", () => (- <CategoryDetailsPage- subcategories={category.children}- loading={false}- onAddCategory={undefined}- onAddProduct={undefined}- onBack={() => undefined}- onCategoryClick={() => undefined}- onDelete={undefined}- onEdit={undefined}- onNextPage={undefined}- onPreviousPage={undefined}- onProductClick={() => undefined}- />- ))- .add("when loading", () => <CategoryDetailsPage loading={true} />);diff --git a/saleor/static/dashboard-next/storybook/stories/categories/CategoryEditPage.tsx b/saleor/static/dashboard-next/storybook/stories/categories/CategoryEditPage.tsxdeleted file mode 100644index 4ef45b1388..0000000000--- a/saleor/static/dashboard-next/storybook/stories/categories/CategoryEditPage.tsx+++ /dev/null@@ -1,37 +0,0 @@-import { storiesOf } from "@storybook/react";-import * as React from "react";--import CategoryEditPage from "../../../categories/components/CategoryEditPage";-import {- category as categoryFixture,- errors-} from "../../../categories/fixtures";-import Decorator from "../../Decorator";--const category = categoryFixture("");--storiesOf("Views / Categories / Category edit", module)- .addDecorator(Decorator)- .add("default", () => (- <CategoryEditPage- category={category}- onBack={() => undefined}- onSubmit={() => undefined}- />- ))- .add("when loading", () => (- <CategoryEditPage- category={category}- disabled={true}- onBack={() => undefined}- onSubmit={() => undefined}- />- ))- .add("with errors", () => (- <CategoryEditPage- category={category}- errors={errors}- onBack={() => undefined}- onSubmit={() => undefined}- />- ));diff --git a/saleor/static/dashboard-next/storybook/stories/categories/CategoryTable.tsx b/saleor/static/dashboard-next/storybook/stories/categories/CategoryTable.tsxindex b091bc2527..36bfbc0a37 100644--- a/saleor/static/dashboard-next/storybook/stories/categories/CategoryTable.tsx+++ b/saleor/static/dashboard-next/storybook/stories/categories/CategoryTable.tsx@@ -6,12 +6,18 @@ import { categories } from "../../../categories/fixtures";import CategoryTable from "../../../categories/components/CategoryTable";import Decorator from "../../Decorator";+const categoryTableProps = {+ categories: categories,+ onAddCategory: undefined,+ onCategoryClick: () => undefined+};+storiesOf("Views / Categories / Category Table", module).addDecorator(Decorator)- .add("default", () => (- <CategoryTable- categories={categories}- onAddCategory={undefined}- onCategoryClick={() => undefined}- />+ .add("default", () => <CategoryTable {...categoryTableProps} />)+ .add("loading", () => (+ <CategoryTable {...categoryTableProps} categories={undefined} />+ ))+ .add("No data", () => (+ <CategoryTable {...categoryTableProps} categories={[]} />));diff --git a/saleor/static/dashboard-next/storybook/stories/categories/CategoryUpdatePage.tsx b/saleor/static/dashboard-next/storybook/stories/categories/CategoryUpdatePage.tsxindex 394b52319b..1598bf3d25 100644--- a/saleor/static/dashboard-next/storybook/stories/categories/CategoryUpdatePage.tsx+++ b/saleor/static/dashboard-next/storybook/stories/categories/CategoryUpdatePage.tsx@@ -12,28 +12,29 @@ import Decorator from "../../Decorator";const category = categoryFixture(placeholderImage);const updateProps: CategoryUpdatePageProps = {- category: category,backgroundImage: category.backgroundImage,- subcategories: category.children,+ category,disabled: false,errors: [],- products: category.products,loading: false,- placeholderImage: placeholderImage,+ onAddCategory: undefined,+ onAddProduct: undefined,+ onBack: undefined,+ onCategoryClick: () => undefined,+ onDelete: () => undefined,+ onImageDelete: () => undefined,+ onImageUpload: () => undefined,+ onNextPage: undefined,+ onPreviousPage: undefined,+ onProductClick: () => undefined,+ onSubmit: () => undefined,pageInfo: {hasNextPage: true,hasPreviousPage: true},- onNextPage: undefined,- onSubmit: () => undefined,- onPreviousPage: undefined,- onImageDelete: () => undefined,- onProductClick: () => undefined,- onAddProduct: undefined,- onCategoryClick: () => undefined,- onAddCategory: undefined,- onBack: undefined,- onDelete: undefined+ placeholderImage,+ products: category.products,+ subcategories: category.children};storiesOf("Views / Categories / Update category", module)diff --git a/saleor/static/dashboard-next/storybook/stories/products/ProductListCard.tsx b/saleor/static/dashboard-next/storybook/stories/products/ProductListCard.tsxindex a44ffe1cab..3febf86ee3 100644--- a/saleor/static/dashboard-next/storybook/stories/products/ProductListCard.tsx+++ b/saleor/static/dashboard-next/storybook/stories/products/ProductListCard.tsx@@ -9,6 +9,13 @@ import Decorator from "../../Decorator";const products = productFixture(placeholderImage);+// disabled: false,+// onAdd: undefined,+// onNextPage: undefined,+// onPreviousPage: undefined,+// onRowClick: () => undefined,+// pageInfo+storiesOf("Views / Products / Product list", module).addDecorator(Decorator).add("default", () => (