Skip to content

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

Show category pages in storybook (#2250)

Dominik Żegleń6093276c02d9
diff --git a/saleor/static/dashboard-next/components/CategoryDeleteDialog/CategoryDeleteDialog.tsx b/saleor/static/dashboard-next/categories/components/CategoryDeleteDialog/CategoryDeleteDialog.tsx
similarity index 98%
rename from saleor/static/dashboard-next/components/CategoryDeleteDialog/CategoryDeleteDialog.tsx
rename to saleor/static/dashboard-next/categories/components/CategoryDeleteDialog/CategoryDeleteDialog.tsx
index edfb860b75..aa9faa54d5 100644
--- a/saleor/static/dashboard-next/components/CategoryDeleteDialog/CategoryDeleteDialog.tsx
+++ b/saleor/static/dashboard-next/categories/components/CategoryDeleteDialog/CategoryDeleteDialog.tsx
@@ -9,7 +9,7 @@ import Dialog, {
import { withStyles } from "material-ui/styles";
import * as React from "react";
-import i18n from "../../i18n";
+import i18n from "../../../i18n";
const decorate = withStyles(theme => ({
deleteButton: {
diff --git a/saleor/static/dashboard-next/components/CategoryDeleteDialog/index.ts b/saleor/static/dashboard-next/categories/components/CategoryDeleteDialog/index.ts
similarity index 100%
rename from saleor/static/dashboard-next/components/CategoryDeleteDialog/index.ts
rename to saleor/static/dashboard-next/categories/components/CategoryDeleteDialog/index.ts
diff --git a/saleor/static/dashboard-next/categories/components/CategoryDetailsPage/CategoryDetailsPage.tsx b/saleor/static/dashboard-next/categories/components/CategoryDetailsPage/CategoryDetailsPage.tsx
new file mode 100644
index 0000000000..d6dc914ee6
--- /dev/null
+++ b/saleor/static/dashboard-next/categories/components/CategoryDetailsPage/CategoryDetailsPage.tsx
@@ -0,0 +1,146 @@
+import AddIcon from "@material-ui/icons/Add";
+import IconButton from "material-ui/IconButton";
+import { withStyles } from "material-ui/styles";
+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;
+ }>;
+ products?: Array<{
+ id: string;
+ name: string;
+ thumbnailUrl: string;
+ productType: {
+ name: string;
+ };
+ }>;
+ pageInfo?: {
+ hasNextPage: boolean;
+ hasPreviousPage: boolean;
+ };
+ productCount?: number;
+ loading?: boolean;
+ onAddCategory?();
+ onAddProduct?();
+ onBack?();
+ onCategoryClick?(id: string): () => void;
+ onDelete?();
+ onEdit?();
+ onNextPage?();
+ onPreviousPage?();
+ onProductClick?(id: string): () => void;
+}
+
+const decorate = withStyles(theme => ({
+ root: {
+ "& > *": {
+ marginBottom: theme.spacing.unit * 2,
+ [theme.breakpoints.down("md")]: {
+ marginBottom: theme.spacing.unit
+ }
+ }
+ }
+}));
+const CategoryDetailsPage = decorate<CategoryDetailsPageProps>(
+ ({
+ category,
+ classes,
+ loading,
+ pageInfo,
+ productCount,
+ 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 ? onBack : undefined}
+ title={
+ !isRoot
+ ? category
+ ? category.name
+ : undefined
+ : i18n.t("Categories")
+ }
+ >
+ {!!onAddProduct &&
+ isRoot && (
+ <IconButton onClick={onAddProduct}>
+ <AddIcon />
+ </IconButton>
+ )}
+ </PageHeader>
+ <div className={classes.root}>
+ {!isRoot && (
+ <CategoryProperties
+ description={category ? category.description : undefined}
+ onEdit={onEdit}
+ onDelete={toggleDialog}
+ />
+ )}
+ <CategoryList
+ categories={subcategories}
+ displayTitle={!isRoot}
+ onAdd={onAddCategory}
+ onRowClick={onCategoryClick}
+ />
+ {!isRoot && (
+ <CategoryProducts
+ products={products}
+ hasNextPage={pageInfo ? pageInfo.hasNextPage : false}
+ hasPreviousPage={
+ pageInfo ? pageInfo.hasPreviousPage : false
+ }
+ onAddProduct={onAddProduct}
+ onNextPage={onNextPage}
+ onPreviousPage={onPreviousPage}
+ onRowClick={onProductClick}
+ />
+ )}
+ </div>
+ </Container>
+ {category && (
+ <CategoryDeleteDialog
+ name={category.name}
+ open={opened}
+ productCount={productCount}
+ 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.ts
new file mode 100644
index 0000000000..6cfdd43df5
--- /dev/null
+++ b/saleor/static/dashboard-next/categories/components/CategoryDetailsPage/index.ts
@@ -0,0 +1,2 @@
+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.tsx
new file mode 100644
index 0000000000..ea5aea6f80
--- /dev/null
+++ b/saleor/static/dashboard-next/categories/components/CategoryEditPage/CategoryEditPage.tsx
@@ -0,0 +1,96 @@
+import Card, { CardContent } from "material-ui/Card";
+import * as React from "react";
+
+import TextField from "material-ui/TextField";
+import { Container } from "../../../components/Container";
+import Form from "../../../components/Form";
+import { FormSpacer } from "../../../components/FormSpacer";
+import PageHeader from "../../../components/PageHeader";
+import SaveButtonBar from "../../../components/SaveButtonBar";
+import i18n from "../../../i18n";
+
+interface CategoryEditPageProps {
+ category?: {
+ description: string;
+ name: string;
+ };
+ errors?: Array<{
+ field: string;
+ message: string;
+ }>;
+ disabled?: boolean;
+ variant?: "add" | "edit";
+ onBack?();
+ onSubmit(data: any);
+}
+
+const CategoryEditPage: React.StatelessComponent<CategoryEditPageProps> = ({
+ category,
+ errors,
+ disabled,
+ variant,
+ 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, 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
+ 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} onBack={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.ts
new file mode 100644
index 0000000000..c1bc43cc8c
--- /dev/null
+++ b/saleor/static/dashboard-next/categories/components/CategoryEditPage/index.ts
@@ -0,0 +1,2 @@
+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.tsx
new file mode 100644
index 0000000000..7e3f6f51e7
--- /dev/null
+++ b/saleor/static/dashboard-next/categories/components/CategoryList/CategoryList.tsx
@@ -0,0 +1,73 @@
+import AddIcon from "@material-ui/icons/Add";
+import Folder from "@material-ui/icons/Folder";
+import Card from "material-ui/Card";
+import IconButton from "material-ui/IconButton";
+import List, {
+ ListItem,
+ ListItemIcon,
+ ListItemText,
+ ListSubheader
+} from "material-ui/List";
+import { withStyles } from "material-ui/styles";
+import * as React from "react";
+
+import PageHeader from "../../../components/PageHeader";
+import Skeleton from "../../../components/Skeleton";
+import i18n from "../../../i18n";
+
+interface CategoryListProps {
+ categories?: Array<{
+ id: string;
+ name: string;
+ }>;
+ displayTitle?: boolean;
+ onAdd?();
+ onRowClick?(id: string): () => void;
+}
+
+const CategoryList: React.StatelessComponent<CategoryListProps> = ({
+ categories,
+ displayTitle,
+ onAdd,
+ onRowClick
+}) => (
+ <Card>
+ {displayTitle && (
+ <PageHeader title={i18n.t("Categories")}>
+ {!!onAdd && (
+ <IconButton onClick={onAdd}>
+ <AddIcon />
+ </IconButton>
+ )}
+ </PageHeader>
+ )}
+ <List>
+ {categories === undefined || categories === null ? (
+ <ListItem>
+ <ListItemIcon>
+ <Folder />
+ </ListItemIcon>
+ <ListItemText>
+ <Skeleton />
+ </ListItemText>
+ </ListItem>
+ ) : categories.length > 0 ? (
+ categories.map(category => (
+ <ListItem
+ button={!!onRowClick}
+ key={category.id}
+ onClick={!!onRowClick ? onRowClick(category.id) : undefined}
+ >
+ <ListItemIcon>
+ <Folder />
+ </ListItemIcon>
+ <ListItemText primary={category.name} />
+ </ListItem>
+ ))
+ ) : (
+ <ListSubheader>{i18n.t("No categories found")}</ListSubheader>
+ )}
+ </List>
+ </Card>
+);
+export default CategoryList;
diff --git a/saleor/static/dashboard-next/components/CategoryList/index.ts b/saleor/static/dashboard-next/categories/components/CategoryList/index.ts
similarity index 56%
rename from saleor/static/dashboard-next/components/CategoryList/index.ts
rename to saleor/static/dashboard-next/categories/components/CategoryList/index.ts
index 9bf9d53a27..52c4017ff3 100644
--- a/saleor/static/dashboard-next/components/CategoryList/index.ts
+++ b/saleor/static/dashboard-next/categories/components/CategoryList/index.ts
@@ -1 +1,2 @@
export { default } from "./CategoryList";
+export * from "./CategoryList";
diff --git a/saleor/static/dashboard-next/categories/components/CategoryProducts/CategoryProducts.tsx b/saleor/static/dashboard-next/categories/components/CategoryProducts/CategoryProducts.tsx
new file mode 100644
index 0000000000..b67c3bcd73
--- /dev/null
+++ b/saleor/static/dashboard-next/categories/components/CategoryProducts/CategoryProducts.tsx
@@ -0,0 +1,133 @@
+import AddIcon from "@material-ui/icons/Add";
+import Cached from "@material-ui/icons/Cached";
+import Avatar from "material-ui/Avatar";
+import Card from "material-ui/Card";
+import blue from "material-ui/colors/blue";
+import IconButton from "material-ui/IconButton";
+import { withStyles } from "material-ui/styles";
+import Table, {
+ TableBody,
+ TableCell,
+ TableFooter,
+ TableHead,
+ TableRow
+} from "material-ui/Table";
+import * as React from "react";
+
+import PageHeader from "../../../components/PageHeader";
+import Skeleton from "../../../components/Skeleton";
+import TablePagination from "../../../components/TablePagination";
+import i18n from "../../../i18n";
+
+const decorate = withStyles(theme => ({
+ avatarCell: {
+ paddingLeft: theme.spacing.unit * 2,
+ paddingRight: 0,
+ width: theme.spacing.unit * 5
+ },
+ link: {
+ color: blue[500],
+ cursor: "pointer"
+ }
+}));
+
+interface ProductListProps {
+ hasNextPage?: boolean;
+ hasPreviousPage?: boolean;
+ products?: Array<{
+ id: string;
+ name: string;
+ productType: {
+ name: string;
+ };
+ thumbnailUrl: string;
+ }>;
+ onAddProduct?();
+ onNextPage?();
+ onPreviousPage?();
+ onRowClick?(id: string): () => void;
+}
+
+export const ProductList = decorate<ProductListProps>(
+ ({
+ classes,
+ hasNextPage,
+ hasPreviousPage,
+ products,
+ onAddProduct,
+ onNextPage,
+ onPreviousPage,
+ onRowClick
+ }) => (
+ <Card>
+ <PageHeader title={i18n.t("Products")}>
+ {!!onAddProduct && (
+ <IconButton onClick={onAddProduct}>
+ <AddIcon />
+ </IconButton>
+ )}
+ </PageHeader>
+ <Table>
+ <TableHead>
+ <TableRow>
+ <TableCell className={classes.avatarCell} />
+ <TableCell>{i18n.t("Name", { context: "object" })}</TableCell>
+ <TableCell>{i18n.t("Type", { context: "object" })}</TableCell>
+ </TableRow>
+ </TableHead>
+ <TableFooter>
+ <TableRow>
+ <TablePagination
+ colSpan={3}
+ hasNextPage={hasNextPage}
+ onNextPage={onNextPage}
+ hasPreviousPage={hasPreviousPage}
+ onPreviousPage={onPreviousPage}
+ />
+ </TableRow>
+ </TableFooter>
+ <TableBody>
+ {products === undefined || products === null ? (
+ <TableRow>
+ <TableCell className={classes.avatarCell}>
+ <Avatar>
+ <Cached />
+ </Avatar>
+ </TableCell>
+ <TableCell>
+ <Skeleton />
+ </TableCell>
+ <TableCell>
+ <Skeleton />
+ </TableCell>
+ </TableRow>
+ ) : products.length > 0 ? (
+ products.map(product => (
+ <TableRow key={product.id}>
+ <TableCell className={classes.avatarCell}>
+ <Avatar src={product.thumbnailUrl} />
+ </TableCell>
+ <TableCell>
+ <span
+ onClick={onRowClick ? onRowClick(product.id) : () => {}}
+ className={onRowClick ? classes.link : ""}
+ >
+ {product.name}
+ </span>
+ </TableCell>
+ <TableCell>{product.productType.name}</TableCell>
+ </TableRow>
+ ))
+ ) : (
+ <TableRow>
+ <TableCell className={classes.avatarCell} />
+ <TableCell colSpan={2}>{i18n.t("No products found")}</TableCell>
+ </TableRow>
+ )}
+ </TableBody>
+ </Table>
+ </Card>
+ )
+);
+
+export default ProductList;
diff --git a/saleor/static/dashboard-next/category/components/CategoryProducts/index.ts b/saleor/static/dashboard-next/categories/components/CategoryProducts/index.ts
similarity index 100%
rename from saleor/static/dashboard-next/category/components/CategoryProducts/index.ts
rename to saleor/static/dashboard-next/categories/components/CategoryProducts/index.ts
diff --git a/saleor/static/dashboard-next/categories/components/CategoryProperties/CategoryProperties.tsx b/saleor/static/dashboard-next/categories/components/CategoryProperties/CategoryProperties.tsx
new file mode 100644
index 0000000000..14fc58ddf0
--- /dev/null
+++ b/saleor/static/dashboard-next/categories/components/CategoryProperties/CategoryProperties.tsx
@@ -0,0 +1,49 @@
+import DeleteIcon from "@material-ui/icons/Delete";
+import EditIcon from "@material-ui/icons/Edit";
+import Card, { CardContent } from "material-ui/Card";
+import IconButton from "material-ui/IconButton";
+import { withStyles } from "material-ui/styles";
+import Typography from "material-ui/Typography";
+import * as React from "react";
+
+import PageHeader from "../../../components/PageHeader";
+import Skeleton from "../../../components/Skeleton";
+import i18n from "../../../i18n";
+
+interface CategoryPropertiesProps {
+ description?: string;
+ onEdit?();
+ onDelete?();
+}
+
+const decorate = withStyles(theme => ({ root: {} }));
+const CategoryProperties: React.StatelessComponent<CategoryPropertiesProps> = ({
+ description,
+ onDelete,
+ onEdit
+}) => (
+ <Card>
+ <PageHeader title={i18n.t("Details")}>
+ {!!onEdit && (
+ <IconButton onClick={onEdit}>
+ <EditIcon />
+ </IconButton>
+ )}
+ {!!onDelete && (
+ <IconButton onClick={onDelete}>
+ <DeleteIcon />
+ </IconButton>
+ )}
+ </PageHeader>
+ <CardContent>
+ {description === undefined ? (
+ <Skeleton />
+ ) : (
+ <Typography color={description === "" ? "textSecondary" : "default"}>
+ {description === "" ? i18n.t("No description") : 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.ts
new file mode 100644
index 0000000000..33e7170525
--- /dev/null
+++ b/saleor/static/dashboard-next/categories/components/CategoryProperties/index.ts
@@ -0,0 +1,2 @@
+export { default } from "./CategoryProperties";
+export * from "./CategoryProperties";
diff --git a/saleor/static/dashboard-next/categories/fixtures.ts b/saleor/static/dashboard-next/categories/fixtures.ts
new file mode 100644
index 0000000000..16a0105eab
--- /dev/null
+++ b/saleor/static/dashboard-next/categories/fixtures.ts
@@ -0,0 +1,29 @@
+import { products } from "../products/fixtures";
+
+export const categories = [
+ {
+ id: "123123",
+ name: "Lorem ipsum dolor"
+ },
+ {
+ id: "876752",
+ name: "Mauris vehicula tortor vulputate"
+ }
+];
+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",
+ 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",
+ products: products(placeholderImage)
+});
+export const errors = [
+ {
+ field: "name",
+ message: "To pole jest wymagane."
+ }
+];
diff --git a/saleor/static/dashboard-next/category/index.tsx b/saleor/static/dashboard-next/categories/index.tsx
similarity index 89%
rename from saleor/static/dashboard-next/category/index.tsx
rename to saleor/static/dashboard-next/categories/index.tsx
index 8c3eba41aa..c4bd014749 100644
--- a/saleor/static/dashboard-next/category/index.tsx
+++ b/saleor/static/dashboard-next/categories/index.tsx
@@ -2,9 +2,9 @@ import { parse as parseQs } from "qs";
import * as React from "react";
import { Route, RouteComponentProps, Switch } from "react-router-dom";
-import { CategoryCreateForm } from "./views/CategoryCreateForm";
-import { CategoryUpdateForm } from "./views/CategoryUpdateForm";
-import CategoryDetails from "./views/details";
+import { CategoryCreateForm } from "./views/CategoryCreate";
+import CategoryDetails from "./views/CategoryDetails";
+import { CategoryUpdateForm } from "./views/CategoryUpdate";
const CategoryPaginator: React.StatelessComponent<RouteComponentProps<any>> = ({
location,
diff --git a/saleor/static/dashboard-next/category/mutations.ts b/saleor/static/dashboard-next/categories/mutations.ts
similarity index 100%
rename from saleor/static/dashboard-next/category/mutations.ts
rename to saleor/static/dashboard-next/categories/mutations.ts
diff --git a/saleor/static/dashboard-next/category/queries.ts b/saleor/static/dashboard-next/categories/queries.ts
similarity index 100%
rename from saleor/static/dashboard-next/category/queries.ts
rename to saleor/static/dashboard-next/categories/queries.ts
diff --git a/saleor/static/dashboard-next/categories/views/CategoryCreate.tsx b/saleor/static/dashboard-next/categories/views/CategoryCreate.tsx
new file mode 100644
index 0000000000..d9f308da49
--- /dev/null
+++ b/saleor/static/dashboard-next/categories/views/CategoryCreate.tsx
@@ -0,0 +1,56 @@
+import Card from "material-ui/Card";
+import * as React from "react";
+import { Redirect } from "react-router-dom";
+
+import { NavigatorLink } from "../../components/Navigator";
+import PageHeader from "../../components/PageHeader";
+import CategoryEditPage from "../components/CategoryEditPage";
+import { categoryShowUrl } from "../index";
+import {
+ categoryCreateMutation,
+ TypedCategoryCreateMutation
+} from "../mutations";
+
+interface CategoryCreateFormProps {
+ parentId: string;
+}
+
+export const CategoryCreateForm: React.StatelessComponent<
+ CategoryCreateFormProps
+> = ({ parentId }) => (
+ <TypedCategoryCreateMutation mutation={categoryCreateMutation}>
+ {(mutate, { called, data: createResult, loading: createInProgress }) => {
+ if (
+ called &&
+ !createInProgress &&
+ createResult &&
+ createResult.categoryCreate.errors.length === 0
+ ) {
+ return (
+ <Redirect
+ to={categoryShowUrl(createResult.categoryCreate.category.id)}
+ push={false}
+ />
+ );
+ }
+ const errors =
+ called && !createInProgress && createResult
+ ? createResult.categoryCreate.errors
+ : [];
+ return (
+ <NavigatorLink to={categoryShowUrl(parentId)}>
+ {handleCancel => (
+ <CategoryEditPage
+ category={{ description: "", name: "" }}
+ errors={errors}
+ disabled={createInProgress}
+ variant="add"
+ onBack={handleCancel}
+ onSubmit={data => mutate({ variables: { ...data, parentId } })}
+ />
+ )}
+ </NavigatorLink>
+ );
+ }}
+ </TypedCategoryCreateMutation>
+);
diff --git a/saleor/static/dashboard-next/categories/views/CategoryDetails.tsx b/saleor/static/dashboard-next/categories/views/CategoryDetails.tsx
new file mode 100644
index 0000000000..8f859eb6f1
--- /dev/null
+++ b/saleor/static/dashboard-next/categories/views/CategoryDetails.tsx
@@ -0,0 +1,252 @@
+import { stringify as stringifyQs } from "qs";
+import * as React from "react";
+import { Redirect } from "react-router-dom";
+
+import CategoryDetailsPage from "../../categories/components/CategoryDetailsPage";
+import ErrorMessageCard from "../../components/ErrorMessageCard";
+import Navigator, { NavigatorLink } from "../../components/Navigator";
+import { CategoryPropertiesQuery } from "../../gql-types";
+import i18n from "../../i18n";
+import { productAddUrl, productShowUrl } from "../../products";
+import { categoryAddUrl, categoryEditUrl, categoryShowUrl } from "../index";
+import {
+ categoryDeleteMutation,
+ TypedCategoryDeleteMutation
+} from "../mutations";
+import {
+ categoryPropertiesQuery,
+ rootCategoryChildrenQuery,
+ TypedCategoryPropertiesQuery,
+ TypedRootCategoryChildrenQuery
+} from "../queries";
+
+interface CategoryDeleteProviderProps {
+ category?: CategoryPropertiesQuery["category"];
+ children:
+ | ((deleteCategory: () => void) => React.ReactElement<any>)
+ | React.ReactNode;
+}
+
+const CategoryDeleteProvider: React.StatelessComponent<
+ CategoryDeleteProviderProps
+> = ({ category, children }) => (
+ <TypedCategoryDeleteMutation
+ mutation={categoryDeleteMutation}
+ variables={{
+ id: (category && category.id) || ""
+ }}
+ >
+ {(deleteCategory, { called, loading, error: deleteError }) => {
+ if (called && !loading) {
+ return (
+ <Redirect
+ to={categoryShowUrl(category.parent ? category.parent.id : null)}
+ push={false}
+ />
+ );
+ }
+ if (deleteError) {
+ return <ErrorMessageCard message={deleteError.message} />;
+ }
+
+ if (typeof children === "function") {
+ return children(() => deleteCategory());
+ }
+ if (React.Children.count(children) > 0) {
+ return React.Children.only(children);
+ }
+ return null;
+ }}
+ </TypedCategoryDeleteMutation>
+);
+
+interface CategoryPaginationProviderProps {
+ children:
+ | ((
+ props: {
+ data: CategoryPropertiesQuery;
+ loading: boolean;
+ fetchNextPage();
+ fetchPreviousPage();
+ }
+ ) => React.ReactElement<any>)
+ | React.ReactNode;
+ id?: string;
+}
+
+const CategoryPaginationProvider: React.StatelessComponent<
+ CategoryPaginationProviderProps
+> = ({ children, id }) => (
+ <TypedCategoryPropertiesQuery
+ query={categoryPropertiesQuery}
+ variables={{ id, first: 12 }}
+ fetchPolicy="network-only"
+ >
+ {({ loading, error, data, fetchMore }) => {
+ if (error) {
+ return (
+ <ErrorMessageCard
+ message={i18n.t("Unable to find a matching category.")}
+ />
+ );
+ }
+ const { category } = data;
+ const updatePageInfo = (
+ results: CategoryPropertiesQuery,
+ overrides: Partial<
+ CategoryPropertiesQuery["category"]["products"]["pageInfo"]
+ >
+ ) => ({
+ ...results,
+ category: {
+ ...results.category,
+ products: {
+ ...results.category.products,
+ pageInfo: {
+ ...results.category.products.pageInfo,
+ ...overrides
+ }
+ }
+ }
+ });
+ const fetchNextPage = () => {
+ return fetchMore({
+ updateQuery: (previousResult, { fetchMoreResult }) =>
+ updatePageInfo(fetchMoreResult, {
+ hasPreviousPage: true
+ }),
+ variables: {
+ after: category.products.pageInfo.endCursor,
+ first: 12
+ }
+ });
+ };
+ const fetchPreviousPage = () => {
+ return fetchMore({
+ updateQuery: (previousResult, { fetchMoreResult }) =>
+ updatePageInfo(fetchMoreResult, {
+ hasNextPage: true
+ }),
+ variables: {
+ before: category.products.pageInfo.startCursor,
+ first: undefined,
+ last: 12
+ }
+ });
+ };
+ if (typeof children === "function") {
+ return children({ data, loading, fetchNextPage, fetchPreviousPage });
+ }
+ if (React.Children.count(children) > 0) {
+ return React.Children.only(children);
+ }
+ return null;
+ }}
+ </TypedCategoryPropertiesQuery>
+);
+
+interface CategoryDetailsProps {
+ filters: any;
+ id: string;
+}
+
+const CategoryDetails: React.StatelessComponent<CategoryDetailsProps> = ({
+ filters,
+ id
+}) => {
+ if (id) {
+ return (
+ <Navigator>
+ {navigate => {
+ const applyFilters = data => {
+ navigate(`?${stringifyQs({ ...filters, ...data.formData })}`, true);
+ };
+ const clearFilters = () => navigate("?");
+ return (
+ <CategoryPaginationProvider id={id}>
+ {({ data, loading, fetchNextPage, fetchPreviousPage }) => {
+ const dataHasProducts =
+ data && data.category && data.category.products;
+ return (
+ <CategoryDeleteProvider category={data.category}>
+ {deleteCategory => (
+ <CategoryDetailsPage
+ category={data ? data.category : undefined}
+ products={
+ data && data.category && data.category.products
+ ? data.category.products.edges.map(
+ edge => edge.node
+ )
+ : undefined
+ }
+ subcategories={
+ data && data.category && data.category.children
+ ? data.category.children.edges.map(
+ edge => edge.node
+ )
+ : undefined
+ }
+ loading={loading}
+ onAddCategory={() => navigate(categoryAddUrl(id))}
+ onAddProduct={() => navigate(productAddUrl)}
+ onBack={() => window.history.back()}
+ onCategoryClick={(id: string) => () =>
+ navigate(categoryShowUrl(id))}
+ onDelete={deleteCategory}
+ onEdit={() => navigate(categoryEditUrl(id))}
+ onProductClick={(id: string) => () =>
+ navigate(productShowUrl(id))}
+ pageInfo={
+ data && data.category && data.category.products
+ ? data.category.products.pageInfo
+ : undefined
+ }
+ onNextPage={fetchNextPage}
+ onPreviousPage={fetchPreviousPage}
+ />
+ )}
+ </CategoryDeleteProvider>
+ );
+ }}
+ </CategoryPaginationProvider>
+ );
+ }}
+ </Navigator>
+ );
+ }
+ return (
+ <TypedRootCategoryChildrenQuery
+ query={rootCategoryChildrenQuery}
+ fetchPolicy="network-only"
+ >
+ {({ error, loading, data }) => {
+ if (error) {
+ return <ErrorMessageCard message={error.message} />;
+ }
+ return (
+ <Navigator>
+ {navigate => (
+ <CategoryDetailsPage
+ subcategories={
+ data && data.categories
+ ? data.categories.edges.map(edge => edge.node)
+ : undefined
+ }
+ loading={loading}
+ onAddCategory={() => navigate(categoryAddUrl())}
+ onAddProduct={() => navigate(productAddUrl)}
+ onBack={() => window.history.back()}
+ onCategoryClick={(id: string) => () =>
+ navigate(categoryShowUrl(id))}
+ onProductClick={(id: string) => () =>
+ navigate(productShowUrl(id))}
+ />
+ )}
+ </Navigator>
+ );
+ }}
+ </TypedRootCategoryChildrenQuery>
+ );
+};
+
+export default CategoryDetails;
diff --git a/saleor/static/dashboard-next/categories/views/CategoryUpdate.tsx b/saleor/static/dashboard-next/categories/views/CategoryUpdate.tsx
new file mode 100644
index 0000000000..defcebcbd4
--- /dev/null
+++ b/saleor/static/dashboard-next/categories/views/CategoryUpdate.tsx
@@ -0,0 +1,72 @@
+import * as React from "react";
+import { Redirect } from "react-router-dom";
+
+import ErrorMessageCard from "../../components/ErrorMessageCard";
+import { NavigatorLink } from "../../components/Navigator";
+import CategoryEditPage from "../components/CategoryEditPage";
+import { categoryShowUrl } from "../index";
+import {
+ categoryUpdateMutation,
+ TypedCategoryUpdateMutation
+} from "../mutations";
+import { categoryDetailsQuery, TypedCategoryDetailsQuery } from "../queries";
+
+interface CategoryUpdateFormProps {
+ id: string;
+}
+
+export const CategoryUpdateForm: React.StatelessComponent<
+ CategoryUpdateFormProps
+> = ({ id }) => (
+ <TypedCategoryDetailsQuery query={categoryDetailsQuery} variables={{ id }}>
+ {({ data, loading, error }) => {
+ if (error) {
+ return <ErrorMessageCard message={error.message} />;
+ }
+
+ return (
+ <TypedCategoryUpdateMutation mutation={categoryUpdateMutation}>
+ {(
+ mutate,
+ { called, data: updateResult, loading: updateInProgress }
+ ) => {
+ if (
+ called &&
+ !updateInProgress &&
+ updateResult &&
+ updateResult.categoryUpdate.errors.length === 0
+ ) {
+ return (
+ <Redirect
+ to={categoryShowUrl(updateResult.categoryUpdate.category.id)}
+ />
+ );
+ }
+ const errors =
+ called && !updateInProgress && updateResult
+ ? updateResult.categoryUpdate.errors
+ : [];
+ return (
+ <NavigatorLink to={categoryShowUrl(id)}>
+ {handleCancel => (
+ <CategoryEditPage
+ category={data ? data.category : undefined}
+ errors={errors}
+ disabled={updateInProgress || loading}
+ variant="edit"
+ onBack={handleCancel}
+ onSubmit={data =>
+ mutate({
+ variables: { ...data, id }
+ })
+ }
+ />
+ )}
+ </NavigatorLink>
+ );
+ }}
+ </TypedCategoryUpdateMutation>
+ );
+ }}
+ </TypedCategoryDetailsQuery>
+);
diff --git a/saleor/static/dashboard-next/category/components/CategoryBaseForm/CategoryBaseForm.tsx b/saleor/static/dashboard-next/category/components/CategoryBaseForm/CategoryBaseForm.tsx
deleted file mode 100644
index 77552fce6e..0000000000
--- a/saleor/static/dashboard-next/category/components/CategoryBaseForm/CategoryBaseForm.tsx
+++ /dev/null
@@ -1,67 +0,0 @@
-import { CardContent } from "material-ui/Card";
-import { withStyles } from "material-ui/styles";
-import * as React from "react";
-
-import TextField from "material-ui/TextField";
-import i18n from "../../../i18n";
-
-const { Component } = React;
-
-const decorate = withStyles(theme => ({
- cardActions: {
- flexDirection: "row-reverse" as "row-reverse"
- },
- textField: {
- marginBottom: "2rem"
- }
-}));
-
-interface BaseCategoryFormProps {
- description?: string;
- errors?: Array<{
- field: string;
- message: string;
- }>;
- name?: string;
- onChange?(event: React.ChangeEvent<any>);
-}
-
-export const CategoryBaseForm = decorate<BaseCategoryFormProps>(
- ({ classes, description, errors, name, onChange }) => {
- const errorList: { [key: string]: string } = errors
- ? errors.reduce((acc, curr) => {
- acc[curr.field] = curr.message;
- return acc;
- }, {})
- : {};
- return (
- <CardContent>
- <TextField
- autoFocus
- fullWidth
- className={classes.textField}
- value={name || ""}
- error={!!errorList.name}
- helperText={errorList.name}
- label={i18n.t("Name", { context: "category" })}
- name="name"
- onChange={onChange}
- />
- <TextField
- fullWidth
- multiline
- value={description || ""}
- error={!!errorList.description}
- helperText={
- errorList.description || i18n.t("Optional", { context: "field" })
- }
- label={i18n.t("Description")}
- name="description"
- onChange={onChange}
- />
- </CardContent>
- );
- }
-);
-
-export default CategoryBaseForm;
diff --git a/saleor/static/dashboard-next/category/components/CategoryBaseForm/index.ts b/saleor/static/dashboard-next/category/components/CategoryBaseForm/index.ts
deleted file mode 100644
index 64589221ca..0000000000
--- a/saleor/static/dashboard-next/category/components/CategoryBaseForm/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export { default } from "./CategoryBaseForm";
diff --git a/saleor/static/dashboard-next/category/components/CategoryProducts/CategoryProducts.tsx b/saleor/static/dashboard-next/category/components/CategoryProducts/CategoryProducts.tsx
deleted file mode 100644
index e8e3e03600..0000000000
--- a/saleor/static/dashboard-next/category/components/CategoryProducts/CategoryProducts.tsx
+++ /dev/null
@@ -1,67 +0,0 @@
-import AddIcon from "@material-ui/icons/Add";
-import FilterListIcon from "@material-ui/icons/FilterList";
-import Card from "material-ui/Card";
-import Hidden from "material-ui/Hidden";
-import IconButton from "material-ui/IconButton";
-import * as React from "react";
-
-import PageHeader from "../../../components/PageHeader";
-import ProductList from "../../../components/ProductList";
-import i18n from "../../../i18n";
-
-interface CategoryProductsProps {
- hasPreviousPage: boolean;
- hasNextPage: boolean;
- products?: Array<{
- id: string;
- name: string;
- thumbnailUrl: string;
- productType: {
- id: string;
- name: string;
- };
- }>;
- onCreate?();
- onFilter?();
- onNextPage?();
- onPreviousPage?();
- onRowClick?(id: string);
-}
-
-const CategoryProducts: React.StatelessComponent<CategoryProductsProps> = ({
- hasNextPage,
- hasPreviousPage,
- onCreate,
- onFilter,
- onNextPage,
- onPreviousPage,
- onRowClick,
- products
-}) => (
- <Card>
- <PageHeader
- title={i18n.t("Products", {
- context: "title"
- })}
- >
- <IconButton onClick={onCreate}>
- <AddIcon />
- </IconButton>
- <Hidden mdUp>
- <IconButton onClick={onFilter}>
- <FilterListIcon />
- </IconButton>
- </Hidden>
- </PageHeader>
- <ProductList
- hasNextPage={hasNextPage}
- hasPreviousPage={hasPreviousPage}
- onNextPage={onNextPage}
- onPreviousPage={onPreviousPage}
- products={products}
- onRowClick={onRowClick}
- />
- </Card>
-);
-
-export default CategoryProducts;
diff --git a/saleor/static/dashboard-next/category/components/CategorySubcategories/CategorySubcategories.tsx b/saleor/static/dashboard-next/category/components/CategorySubcategories/CategorySubcategories.tsx
deleted file mode 100644
index 2e6b4ed9ed..0000000000
--- a/saleor/static/dashboard-next/category/components/CategorySubcategories/CategorySubcategories.tsx
+++ /dev/null
@@ -1,37 +0,0 @@
-import AddIcon from "@material-ui/icons/Add";
-import Card from "material-ui/Card";
-import IconButton from "material-ui/IconButton";
-import * as React from "react";
-
-import CategoryList from "../../../components/CategoryList";
-import PageHeader from "../../../components/PageHeader";
-import { CategoryPropertiesQuery } from "../../../gql-types";
-import i18n from "../../../i18n";
-
-interface CategorySubcategoriesProps {
- subcategories?: Array<{
- id: string;
- name: string;
- }>;
- onClickSubcategory?(id: string);
- onCreate?();
-}
-
-const CategorySubcategories: React.StatelessComponent<
- CategorySubcategoriesProps
-> = ({ subcategories, onClickSubcategory, onCreate }) => (
- <Card>
- <PageHeader
- title={i18n.t("Subcategories", {
- context: "title"
- })}
- >
- <IconButton onClick={onCreate}>
- <AddIcon />
- </IconButton>
- </PageHeader>
- <CategoryList categories={subcategories} onClick={onClickSubcategory} />
- </Card>
-);
-
-export default CategorySubcategories;
diff --git a/saleor/static/dashboard-next/category/components/CategorySubcategories/index.ts b/saleor/static/dashboard-next/category/components/CategorySubcategories/index.ts
deleted file mode 100644
index b4aea88215..0000000000
--- a/saleor/static/dashboard-next/category/components/CategorySubcategories/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export { default } from "./CategorySubcategories";
-export * from "./CategorySubcategories";
diff --git a/saleor/static/dashboard-next/category/components/ProductFilters/ProductFilters.tsx b/saleor/static/dashboard-next/category/components/ProductFilters/ProductFilters.tsx
deleted file mode 100644
index 1a5bcc31d7..0000000000
--- a/saleor/static/dashboard-next/category/components/ProductFilters/ProductFilters.tsx
+++ /dev/null
@@ -1,176 +0,0 @@
-import TextField from "material-ui/TextField";
-import * as React from "react";
-
-import FilterCard from "../../../components/FilterCard";
-import FormSpacer from "../../../components/FormSpacer";
-import MultiSelectField from "../../../components/MultiSelectField";
-import { PriceRangeField } from "../../../components/PriceField";
-import SingleSelectField from "../../../components/SingleSelectField";
-import i18n from "../../../i18n";
-
-const { Component } = React;
-
-interface ProductFiltersState {
- debounceTimeout?: any;
- highlighted: string;
- name: string;
- price_min: string;
- price_max: string;
- productTypes: string[];
- published: string;
-}
-interface ProductFiltersProps {
- productTypes: Array<{
- id: string;
- name: string;
- }>;
- formState?: {
- highlighted: string;
- name: string;
- price_min: string;
- price_max: string;
- productTypes: string[];
- published: string;
- };
- handleSubmit(formState: any);
- handleClear();
-}
-
-export class ProductFilters extends Component<
- ProductFiltersProps,
- ProductFiltersState
-> {
- static defaultState = {
- highlighted: "",
- name: "",
- price_max: "",
- price_min: "",
- productTypes: [],
- published: ""
- };
- constructor(props) {
- super(props);
- this.state = { ...ProductFilters.defaultState, ...props.formState };
- }
-
- render() {
- const { handleSubmit, productTypes, handleClear } = this.props;
- const publishingStatuses = [
- {
- label: i18n.t("Published", { context: "Product publishing status" }),
- value: "1"
- },
- {
- label: i18n.t("Not published", {
- context: "Product publishing status"
- }),
- value: "0"
- },
- {
- label: i18n.t("All", {
- context: "Product publishing status"
- }),
- value: ""
- }
- ];
- const highlightingStatuses = [
- {
- label: i18n.t("Highlighted", {
- context: "Product highlighting status"
- }),
- value: "1"
- },
- {
- label: i18n.t("Not highlighted", {
- context: "Product highlighting status"
- }),
- value: "0"
- },
- {
- label: i18n.t("All", {
- context: "Product highlighting status"
- }),
- value: ""
- }
- ];
-
- const handleInputChange = event => {
- const { name, value } = event.target;
- const debounceTimeout = setTimeout(() => {
- handleSubmit({
- formData: { [name]: value }
- });
- }, 500);
- clearTimeout(this.state.debounceTimeout);
- this.setState({
- [name]: value,
- debounceTimeout
- });
- };
-
- const handleClearButtonClick = () => {
- this.setState(ProductFilters.defaultState);
- handleClear();
- };
-
- return (
- <FilterCard handleClear={handleClearButtonClick}>
- <TextField
- fullWidth
- name="name"
- label={i18n.t("Name", {
- context: "Product filter field label"
- })}
- onChange={handleInputChange}
- value={this.state.name || ""}
- />
- <FormSpacer />
- <MultiSelectField
- label={i18n.t("Product type", {
- context: "Product filter field label"
- })}
- choices={productTypes.map(type => ({
- label: type.name,
- value: type.id
- }))}
- name="productTypes"
- onChange={handleInputChange}
- value={this.state.productTypes || []}
- />
- <FormSpacer />
- <PriceRangeField
- currencySymbol="USD"
- label={i18n.t("Price")}
- name="price"
- onChange={handleInputChange}
- value={{
- max: this.state.price_max || "",
- min: this.state.price_min
- }}
- />
- <FormSpacer />
- <SingleSelectField
- label={i18n.t("Published", {
- context: "Product filter field label"
- })}
- choices={publishingStatuses}
- name="published"
- onChange={handleInputChange}
- value={this.state.published || ""}
- />
- <FormSpacer />
- <SingleSelectField
- label={i18n.t("Highlighted", {
- context: "Product filter field label"
- })}
- choices={highlightingStatuses}
- name="highlighted"
- onChange={handleInputChange}
- value={this.state.highlighted || ""}
- />
- </FilterCard>
- );
- }
-}
-
-export default ProductFilters;
diff --git a/saleor/static/dashboard-next/category/components/ProductFilters/index.ts b/saleor/static/dashboard-next/category/components/ProductFilters/index.ts
deleted file mode 100644
index 053048c577..0000000000
--- a/saleor/static/dashboard-next/category/components/ProductFilters/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export { default } from "./ProductFilters";
-export * from "./ProductFilters";
diff --git a/saleor/static/dashboard-next/category/components/RootCategoryList/RootCategoryList.tsx b/saleor/static/dashboard-next/category/components/RootCategoryList/RootCategoryList.tsx
deleted file mode 100644
index cce76ea3f1..0000000000
--- a/saleor/static/dashboard-next/category/components/RootCategoryList/RootCategoryList.tsx
+++ /dev/null
@@ -1,35 +0,0 @@
-import AddIcon from "@material-ui/icons/Add";
-import Card from "material-ui/Card";
-import IconButton from "material-ui/IconButton";
-import * as React from "react";
-
-import CategoryList from "../../../components/CategoryList";
-import PageHeader from "../../../components/PageHeader";
-import { RootCategoryChildrenQuery } from "../../../gql-types";
-import i18n from "../../../i18n";
-
-interface RootCategoryListProps {
- categories?: Array<{
- id: string;
- name: string;
- }>;
- onClick?(id: string);
- onCreate?();
-}
-
-const RootCategoryList: React.StatelessComponent<RootCategoryListProps> = ({
- categories,
- onClick,
- onCreate
-}) => (
- <Card>
- <PageHeader title={i18n.t("Categories", { context: "title" })}>
- <IconButton onClick={onCreate}>
- <AddIcon />
- </IconButton>
- </PageHeader>
- <CategoryList categories={categories} onClick={onClick} />
- </Card>
-);
-
-export default RootCategoryList;
diff --git a/saleor/static/dashboard-next/category/components/RootCategoryList/index.ts b/saleor/static/dashboard-next/category/components/RootCategoryList/index.ts
deleted file mode 100644
index 7a2a819935..0000000000
--- a/saleor/static/dashboard-next/category/components/RootCategoryList/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export { default } from "./RootCategoryList";
-export * from "./RootCategoryList";
diff --git a/saleor/static/dashboard-next/category/views/CategoryCreateForm.tsx b/saleor/static/dashboard-next/category/views/CategoryCreateForm.tsx
deleted file mode 100644
index ddf6464e4d..0000000000
--- a/saleor/static/dashboard-next/category/views/CategoryCreateForm.tsx
+++ /dev/null
@@ -1,86 +0,0 @@
-import Card from "material-ui/Card";
-import * as React from "react";
-import { Redirect } from "react-router-dom";
-
-import Form, { FormActions, FormProps } from "../../components/Form";
-import { NavigatorLink } from "../../components/Navigator";
-import PageHeader from "../../components/PageHeader";
-import { CategoryCreateMutationVariables } from "../../gql-types";
-import i18n from "../../i18n";
-import CategoryBaseForm from "../components/CategoryBaseForm";
-import { categoryShowUrl } from "../index";
-import {
- categoryCreateMutation,
- TypedCategoryCreateMutation
-} from "../mutations";
-
-const CategoryForm: React.ComponentType<
- FormProps<CategoryCreateMutationVariables>
-> = Form;
-
-interface CategoryCreateFormProps {
- parentId: string;
-}
-
-export const CategoryCreateForm: React.StatelessComponent<
- CategoryCreateFormProps
-> = ({ parentId }) => (
- <TypedCategoryCreateMutation mutation={categoryCreateMutation}>
- {(mutate, { called, data: createResult, loading: createInProgress }) => {
- if (
- called &&
- !createInProgress &&
- createResult.categoryCreate.errors.length === 0
- ) {
- return (
- <Redirect
- to={categoryShowUrl(createResult.categoryCreate.category.id)}
- push={false}
- />
- );
- }
- const errors =
- called && !createInProgress ? createResult.categoryCreate.errors : [];
- return (
- <NavigatorLink to={categoryShowUrl(parentId)}>
- {handleCancel => (
- <CategoryForm
- initial={{
- description: "",
- name: "",
- parentId
- }}
- onSubmit={data =>
- mutate({
- variables: data
- })
- }
- >
- {({ change, data, submit: handleSubmit }) => (
- <Card style={{ maxWidth: 750 }}>
- <PageHeader
- onBack={handleCancel}
- title={i18n.t("Add category", { context: "title" })}
- />
- <CategoryBaseForm
- description={data.description}
- errors={errors}
- name={data.name}
- onChange={change}
- />
- <FormActions
- onCancel={handleCancel}
- onSubmit={handleSubmit}
- submitLabel={i18n.t("Save", {
- context: "button"
- })}
- />
- </Card>
- )}
- </CategoryForm>
- )}
- </NavigatorLink>
- );
- }}
- </TypedCategoryCreateMutation>
-);
diff --git a/saleor/static/dashboard-next/category/views/CategoryUpdateForm.tsx b/saleor/static/dashboard-next/category/views/CategoryUpdateForm.tsx
deleted file mode 100644
index 1d3beb05ec..0000000000
--- a/saleor/static/dashboard-next/category/views/CategoryUpdateForm.tsx
+++ /dev/null
@@ -1,125 +0,0 @@
-import Card from "material-ui/Card";
-import { CircularProgress } from "material-ui/Progress";
-import { withStyles } from "material-ui/styles";
-import * as React from "react";
-import { Redirect } from "react-router-dom";
-
-import ErrorMessageCard from "../../components/ErrorMessageCard";
-import Form, { FormActions, FormProps } from "../../components/Form";
-import { NavigatorLink } from "../../components/Navigator";
-import PageHeader from "../../components/PageHeader";
-import { CategoryUpdateMutationVariables } from "../../gql-types";
-import i18n from "../../i18n";
-import CategoryBaseForm from "../components/CategoryBaseForm";
-import { categoryShowUrl } from "../index";
-import {
- categoryUpdateMutation,
- TypedCategoryUpdateMutation
-} from "../mutations";
-import { categoryDetailsQuery, TypedCategoryDetailsQuery } from "../queries";
-
-const CategoryForm: React.ComponentType<
- FormProps<CategoryUpdateMutationVariables>
-> = Form;
-
-const decorate = withStyles(theme => ({
- root: {
- marginBottom: theme.spacing.unit * 2,
- [theme.breakpoints.up("sm")]: {
- marginLeft: "auto",
- marginRight: "auto",
- maxWidth: theme.breakpoints.width("sm")
- }
- }
-}));
-
-interface CategoryUpdateFormProps {
- id: string;
-}
-
-export const CategoryUpdateForm = decorate<CategoryUpdateFormProps>(
- ({ classes, id }) => (
- <TypedCategoryDetailsQuery query={categoryDetailsQuery} variables={{ id }}>
- {({ data, loading, error }) => {
- if (error) {
- console.error(error.message);
- return <ErrorMessageCard message={error.message} />;
- }
- const { category } = data;
-
- return (
- <TypedCategoryUpdateMutation mutation={categoryUpdateMutation}>
- {(
- mutate,
- { called, data: updateResult, loading: updateInProgress }
- ) => {
- if (
- called &&
- !updateInProgress &&
- updateResult.categoryUpdate.errors.length === 0
- ) {
- return (
- <Redirect
- to={categoryShowUrl(
- updateResult.categoryUpdate.category.id
- )}
- />
- );
- }
- const errors =
- called && !updateInProgress
- ? updateResult.categoryUpdate.errors
- : [];
- return (
- <NavigatorLink to={categoryShowUrl(id)}>
- {handleCancel =>
- loading ? (
- <CircularProgress />
- ) : (
- <CategoryForm
- initial={{
- description: category.description,
- id: category.id,
- name: category.name
- }}
- onSubmit={data =>
- mutate({
- variables: data
- })
- }
- >
- {({ change, data, submit: handleSubmit }) => (
- <Card className={classes.root}>
- <PageHeader
- onBack={handleCancel}
- title={i18n.t("Category details", {
- context: "title"
- })}
- />
- <CategoryBaseForm
- description={data.description}
- errors={errors}
- name={data.name}
- onChange={change}
- />
- <FormActions
- onCancel={handleCancel}
- onSubmit={handleSubmit}
- submitLabel={i18n.t("Save", {
- context: "button"
- })}
- />
- </Card>
- )}
- </CategoryForm>
- )
- }
- </NavigatorLink>
- );
- }}
- </TypedCategoryUpdateMutation>
- );
- }}
- </TypedCategoryDetailsQuery>
- )
-);
diff --git a/saleor/static/dashboard-next/category/views/details.tsx b/saleor/static/dashboard-next/category/views/details.tsx
deleted file mode 100644
index 31a99da46e..0000000000
--- a/saleor/static/dashboard-next/category/views/details.tsx
+++ /dev/null
@@ -1,392 +0,0 @@
-import Drawer from "material-ui/Drawer";
-import Grid from "material-ui/Grid";
-import Hidden from "material-ui/Hidden";
-import { withStyles } from "material-ui/styles";
-import { stringify as stringifyQs } from "qs";
-import * as React from "react";
-import { Redirect } from "react-router-dom";
-
-import CategoryDeleteDialog from "../../components/CategoryDeleteDialog";
-import CategoryPropertiesCard from "../../components/CategoryPropertiesCard";
-import ErrorMessageCard from "../../components/ErrorMessageCard";
-import Navigator, { NavigatorLink } from "../../components/Navigator";
-import Toggle from "../../components/Toggle";
-import { CategoryPropertiesQuery } from "../../gql-types";
-import { productShowUrl } from "../../products";
-import CategoryProducts from "../components/CategoryProducts";
-import CategorySubcategories from "../components/CategorySubcategories";
-import ProductFilters from "../components/ProductFilters";
-import RootCategoryList from "../components/RootCategoryList";
-import { categoryAddUrl, categoryEditUrl, categoryShowUrl } from "../index";
-import {
- categoryDeleteMutation,
- TypedCategoryDeleteMutation
-} from "../mutations";
-import {
- categoryPropertiesQuery,
- rootCategoryChildrenQuery,
- TypedCategoryPropertiesQuery,
- TypedRootCategoryChildrenQuery
-} from "../queries";
-
-const decorate = withStyles(theme => ({
- root: {
- display: "grid",
- gridGap: theme.spacing.unit + "px",
- gridTemplateColumns: "100%",
- [theme.breakpoints.up("md")]: {
- gridGap: theme.spacing.unit * 2 + "px",
- gridTemplateColumns: "3fr 1fr"
- }
- }
-}));
-
-interface CategoryDeleteProviderProps {
- category?: CategoryPropertiesQuery["category"];
- children:
- | ((deleteCategory: () => void) => React.ReactElement<any>)
- | React.ReactNode;
-}
-
-const CategoryDeleteProvider: React.StatelessComponent<
- CategoryDeleteProviderProps
-> = ({ category, children }) => (
- <TypedCategoryDeleteMutation
- mutation={categoryDeleteMutation}
- variables={{
- id: (category && category.id) || ""
- }}
- >
- {(deleteCategory, { called, loading }) => {
- if (called && !loading) {
- return (
- <Redirect
- to={categoryShowUrl(category.parent ? category.parent.id : null)}
- push={false}
- />
- );
- }
-
- if (typeof children === "function") {
- return children(() => deleteCategory());
- }
- if (React.Children.count(children) > 0) {
- return React.Children.only(children);
- }
- return null;
- }}
- </TypedCategoryDeleteMutation>
-);
-
-interface CategoryPaginationProviderProps {
- children:
- | ((
- props: {
- data: CategoryPropertiesQuery;
- loading: boolean;
- fetchNextPage();
- fetchPreviousPage();
- }
- ) => React.ReactElement<any>)
- | React.ReactNode;
- id?: string;
-}
-
-const CategoryPaginationProvider: React.StatelessComponent<
- CategoryPaginationProviderProps
-> = ({ children, id }) => (
- <TypedCategoryPropertiesQuery
- query={categoryPropertiesQuery}
- variables={{ id, first: 12 }}
- fetchPolicy="network-only"
- >
- {({ loading, error, data, fetchMore }) => {
- if (error) {
- return (
- <Grid container spacing={16}>
- <Grid item xs={12} md={9}>
- <ErrorMessageCard message="Unable to find a matching category." />
- </Grid>
- </Grid>
- );
- }
- const { category } = data;
- const updatePageInfo = (
- results: CategoryPropertiesQuery,
- overrides: Partial<
- CategoryPropertiesQuery["category"]["products"]["pageInfo"]
- >
- ) => ({
- ...results,
- category: {
- ...results.category,
- products: {
- ...results.category.products,
- pageInfo: {
- ...results.category.products.pageInfo,
- ...overrides
- }
- }
- }
- });
- const fetchNextPage = () => {
- return fetchMore({
- updateQuery: (previousResult, { fetchMoreResult }) =>
- updatePageInfo(fetchMoreResult, {
- hasPreviousPage: true
- }),
- variables: {
- after: category.products.pageInfo.endCursor,
- first: 12
- }
- });
- };
- const fetchPreviousPage = () => {
- return fetchMore({
- updateQuery: (previousResult, { fetchMoreResult }) =>
- updatePageInfo(fetchMoreResult, {
- hasNextPage: true
- }),
- variables: {
- before: category.products.pageInfo.startCursor,
- first: undefined,
- last: 12
- }
- });
- };
- if (typeof children === "function") {
- return children({ data, loading, fetchNextPage, fetchPreviousPage });
- }
- if (React.Children.count(children) > 0) {
- return React.Children.only(children);
- }
- return null;
- }}
- </TypedCategoryPropertiesQuery>
-);
-
-interface CategoryDetailsProps {
- filters: any;
- id: string;
-}
-
-// TODO: Replace when API is ready
-const dummyProductTypes = [
- { id: "123123123", name: "Type 1" },
- { id: "123123124", name: "Type 2" },
- { id: "123123125", name: "Type 3" },
- { id: "123123126", name: "Type 4" }
-];
-
-const CategoryDetails = decorate<CategoryDetailsProps>(
- ({ classes, filters, id }) => {
- if (id) {
- return (
- <Navigator>
- {navigate => {
- const applyFilters = data => {
- navigate(
- `?${stringifyQs({ ...filters, ...data.formData })}`,
- true
- );
- };
- const clearFilters = () => navigate("?");
- return (
- <CategoryPaginationProvider id={id}>
- {({ data, loading, fetchNextPage, fetchPreviousPage }) => {
- const dataHasProducts =
- data && data.category && data.category.products;
- return (
- <CategoryDeleteProvider category={data.category}>
- {deleteCategory => (
- <Toggle>
- {(
- filtersVisible,
- { disable: hideFilters, enable: showFilters }
- ) => (
- <div className={classes.root}>
- <Toggle>
- {(
- deleteVisible,
- { disable: hideDelete, enable: showDelete }
- ) => (
- <NavigatorLink
- to={
- (data.category &&
- categoryShowUrl(
- data.category.parent &&
- data.category.parent.id
- )) ||
- "#"
- }
- >
- {handleBack => (
- <NavigatorLink
- to={
- data.category &&
- categoryEditUrl(data.category.id)
- }
- >
- {handleEdit => (
- <>
- <CategoryPropertiesCard
- description={
- data.category &&
- data.category.description
- }
- onBack={handleBack}
- onDelete={showDelete}
- onEdit={handleEdit}
- title={
- data.category &&
- data.category.name
- }
- />
- <CategoryDeleteDialog
- name={
- data.category &&
- data.category.name
- }
- onClose={hideDelete}
- onConfirm={deleteCategory}
- open={deleteVisible}
- productCount={
- dataHasProducts &&
- data.category.products
- .totalCount
- }
- />
- </>
- )}
- </NavigatorLink>
- )}
- </NavigatorLink>
- )}
- </Toggle>
- <Hidden smDown implementation="css" />
- <NavigatorLink
- to={
- data.category
- ? categoryAddUrl(data.category.id)
- : "#"
- }
- >
- {handleCreate => (
- <CategorySubcategories
- subcategories={
- data && data.category
- ? data.category.children.edges.map(
- edge => edge.node
- )
- : []
- }
- onClickSubcategory={id =>
- navigate(categoryShowUrl(id))
- }
- onCreate={handleCreate}
- />
- )}
- </NavigatorLink>
- <Hidden smDown implementation="css" />
- <div>
- {/* CSS grid will make this full height */}
- <CategoryProducts
- products={
- dataHasProducts
- ? data.category.products.edges.map(
- edge => edge.node
- )
- : []
- }
- hasPreviousPage={
- dataHasProducts
- ? data.category.products.pageInfo
- .hasPreviousPage
- : false
- }
- hasNextPage={
- dataHasProducts
- ? data.category.products.pageInfo
- .hasNextPage
- : false
- }
- onCreate={() => undefined}
- onFilter={showFilters}
- onNextPage={fetchNextPage}
- onPreviousPage={fetchPreviousPage}
- />
- </div>
- <Hidden smDown implementation="css">
- <ProductFilters
- handleSubmit={applyFilters}
- handleClear={clearFilters}
- productTypes={dummyProductTypes}
- formState={filters}
- />
- </Hidden>
- <Hidden mdUp implementation="css">
- <Drawer
- open={filtersVisible}
- onClose={hideFilters}
- anchor="bottom"
- >
- <ProductFilters
- handleSubmit={applyFilters}
- handleClear={clearFilters}
- productTypes={dummyProductTypes}
- formState={filters}
- />
- </Drawer>
- </Hidden>
- </div>
- )}
- </Toggle>
- )}
- </CategoryDeleteProvider>
- );
- }}
- </CategoryPaginationProvider>
- );
- }}
- </Navigator>
- );
- }
- return (
- <TypedRootCategoryChildrenQuery
- query={rootCategoryChildrenQuery}
- fetchPolicy="network-only"
- >
- {({ error, loading, data }) => {
- if (error) {
- return <span>not ok</span>;
- }
- return (
- <Grid container spacing={16}>
- <Grid item xs={12} md={9}>
- <Navigator>
- {navigate => (
- <NavigatorLink to={categoryAddUrl()}>
- {handleCreate => (
- <RootCategoryList
- categories={
- data && data.categories
- ? data.categories.edges.map(edge => edge.node)
- : []
- }
- onClick={id => navigate(categoryShowUrl(id))}
- onCreate={handleCreate}
- />
- )}
- </NavigatorLink>
- )}
- </Navigator>
- </Grid>
- </Grid>
- );
- }}
- </TypedRootCategoryChildrenQuery>
- );
- }
-);
-
-export default CategoryDetails;
diff --git a/saleor/static/dashboard-next/components/CategoryList/CategoryList.tsx b/saleor/static/dashboard-next/components/CategoryList/CategoryList.tsx
deleted file mode 100644
index 2277f14ceb..0000000000
--- a/saleor/static/dashboard-next/components/CategoryList/CategoryList.tsx
+++ /dev/null
@@ -1,56 +0,0 @@
-import Folder from "@material-ui/icons/Folder";
-import List, {
- ListItem,
- ListItemIcon,
- ListItemText,
- ListSubheader
-} from "material-ui/List";
-import * as React from "react";
-
-import { CategoryPropertiesQuery } from "../../gql-types";
-import i18n from "../../i18n";
-import Skeleton from "../Skeleton";
-
-interface CategoryListProps {
- categories?: Array<{
- id: string;
- name: string;
- }>;
- onClick?(id: string);
-}
-export const CategoryList: React.StatelessComponent<CategoryListProps> = ({
- categories,
- onClick
-}) => (
- <List>
- {categories === undefined || categories === null ? (
- <ListItem>
- <ListItemIcon>
- <Folder />
- </ListItemIcon>
- <ListItemText>
- <Skeleton />
- </ListItemText>
- </ListItem>
- ) : categories.length > 0 ? (
- categories.map(category => (
- <ListItem
- button={!!onClick}
- key={category.id}
- onClick={
- onClick !== undefined ? () => onClick(category.id) : undefined
- }
- >
- <ListItemIcon>
- <Folder />
- </ListItemIcon>
- <ListItemText primary={category.name} />
- </ListItem>
- ))
- ) : (
- <ListSubheader>{i18n.t("No categories found")}</ListSubheader>
- )}
- </List>
-);
-
-export default CategoryList;
diff --git a/saleor/static/dashboard-next/components/CategoryPropertiesCard/CategoryPropertiesCard.tsx b/saleor/static/dashboard-next/components/CategoryPropertiesCard/CategoryPropertiesCard.tsx
deleted file mode 100644
index 2ed15b5c4e..0000000000
--- a/saleor/static/dashboard-next/components/CategoryPropertiesCard/CategoryPropertiesCard.tsx
+++ /dev/null
@@ -1,45 +0,0 @@
-import DeleteIcon from "@material-ui/icons/Delete";
-import ModeEditIcon from "@material-ui/icons/ModeEdit";
-import Card, { CardContent } from "material-ui/Card";
-import IconButton from "material-ui/IconButton";
-import Typography from "material-ui/Typography";
-import * as React from "react";
-
-import PageHeader from "../../components/PageHeader";
-import Skeleton from "../../components/Skeleton";
-
-interface CategoryPropertiesProps {
- description?: string;
- title?: string;
- onBack?();
- onDelete?();
- onEdit?();
-}
-
-export const CategoryProperties: React.StatelessComponent<
- CategoryPropertiesProps
-> = ({ description, onBack, onDelete, onEdit, title }) => (
- <Card>
- <PageHeader onBack={onBack} title={title}>
- <IconButton onClick={onDelete}>
- <DeleteIcon />
- </IconButton>
- <IconButton onClick={onEdit}>
- <ModeEditIcon />
- </IconButton>
- </PageHeader>
- <CardContent>
- <Typography variant="body1">
- {description !== undefined
- ? description
- : [
- <Skeleton key="skel-1" style={{ width: "80%" }} />,
- <Skeleton key="skel-2" style={{ width: "75%" }} />,
- <Skeleton key="skel-3" style={{ width: "60%" }} />
- ]}
- </Typography>
- </CardContent>
- </Card>
-);
-
-export default CategoryProperties;
diff --git a/saleor/static/dashboard-next/components/CategoryPropertiesCard/index.ts b/saleor/static/dashboard-next/components/CategoryPropertiesCard/index.ts
deleted file mode 100644
index eea396de7b..0000000000
--- a/saleor/static/dashboard-next/components/CategoryPropertiesCard/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export { default } from "./CategoryPropertiesCard";
diff --git a/saleor/static/dashboard-next/components/PointOfInterestField/PointOfInterestField.tsx b/saleor/static/dashboard-next/components/PointOfInterestField/PointOfInterestField.tsx
new file mode 100644
index 0000000000..c6df436577
--- /dev/null
+++ b/saleor/static/dashboard-next/components/PointOfInterestField/PointOfInterestField.tsx
@@ -0,0 +1,56 @@
+import { withStyles } from "material-ui/styles";
+import * as React from "react";
+
+interface PointOfInterestFieldProps {
+ disabled?: boolean;
+ src: string;
+ value: string;
+ onChange(event: any);
+}
+
+function hexToRgb(hex) {
+ // Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF")
+ const shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
+ hex = hex.replace(shorthandRegex, (m, r, g, b) => {
+ return r + r + g + g + b + b;
+ });
+
+ const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
+ return result
+ ? {
+ b: parseInt(result[3], 16),
+ g: parseInt(result[2], 16),
+ r: parseInt(result[1], 16)
+ }
+ : null;
+}
+
+const decorate = withStyles(theme => {
+ const color = hexToRgb(theme.palette.secondary.light);
+ return {
+ indicator: {
+ backgroundColor: `rgba(${color.r}, ${color.g}, ${color.b}, .45)`,
+ borderColor: theme.palette.secondary.main,
+ borderRadius: "100%",
+ borderStyle: "solid",
+ borderWidth: 1,
+ height: theme.spacing.unit * 4,
+ position: "absolute" as "absolute",
+ width: theme.spacing.unit * 4
+ },
+ root: {
+ position: "relative" as "relative"
+ }
+ };
+});
+const PointOfInterestField = decorate<PointOfInterestFieldProps>(
+ ({ classes, src, value, onChange, disabled }) => {
+ return (
+ <div className={classes.root}>
+ <img src={src} />
+ <div className={classes.indicator} />
+ </div>
+ );
+ }
+);
+export default PointOfInterestField;
diff --git a/saleor/static/dashboard-next/components/PointOfInterestField/index.ts b/saleor/static/dashboard-next/components/PointOfInterestField/index.ts
new file mode 100644
index 0000000000..b49a60e961
--- /dev/null
+++ b/saleor/static/dashboard-next/components/PointOfInterestField/index.ts
@@ -0,0 +1,2 @@
+export { default } from "./PointOfInterestField";
+export * from "./PointOfInterestField";
diff --git a/saleor/static/dashboard-next/index.tsx b/saleor/static/dashboard-next/index.tsx
index 3a91cf5d12..0f1e3a23b9 100644
--- a/saleor/static/dashboard-next/index.tsx
+++ b/saleor/static/dashboard-next/index.tsx
@@ -12,7 +12,7 @@ import { createStore } from "redux";
import * as Cookies from "universal-cookie";
import AppRoot from "./AppRoot";
-import CategorySection from "./category";
+import CategorySection from "./categories";
import "./i18n";
import PageSection from "./pages";
import ProductSection from "./products";
diff --git a/saleor/static/dashboard-next/products/fixtures.ts b/saleor/static/dashboard-next/products/fixtures.ts
index dde93437fa..2537236925 100644
--- a/saleor/static/dashboard-next/products/fixtures.ts
+++ b/saleor/static/dashboard-next/products/fixtures.ts
@@ -157,12 +157,11 @@ export const product = {
},
url: "/pl/products/stewart-barrera-28/"
};
-export const products = [
+export const products = (placeholderImage: string) => [
{
id: "UHJvZHVjdDox",
name: "Gardner, Graham and King",
- thumbnailUrl:
- "/media/__sized__/products/saleor/static/placeholders/t-shirts/6_tdo7a5D-crop-c0-5__0-5-255x255-70.jpg",
+ thumbnailUrl: placeholderImage,
productType: {
id: "1",
name: "T-Shirt"
@@ -171,8 +170,7 @@ export const products = [
{
id: "UHJvZHVjdDoy",
name: "Gardner, Graham and King",
- thumbnailUrl:
- "/media/__sized__/products/saleor/static/placeholders/t-shirts/6_tdo7a5D-crop-c0-5__0-5-255x255-70.jpg",
+ thumbnailUrl: placeholderImage,
productType: {
id: "1",
name: "T-Shirt"
@@ -181,8 +179,7 @@ export const products = [
{
id: "UHJvZHVjdDoz",
name: "Gardner, Graham and King",
- thumbnailUrl:
- "/media/__sized__/products/saleor/static/placeholders/t-shirts/6_tdo7a5D-crop-c0-5__0-5-255x255-70.jpg",
+ thumbnailUrl: placeholderImage,
productType: {
id: "1",
name: "T-Shirt"
@@ -191,8 +188,7 @@ export const products = [
{
id: "UHJvZHVjdDoa",
name: "Gardner, Graham and King",
- thumbnailUrl:
- "/media/__sized__/products/saleor/static/placeholders/t-shirts/6_tdo7a5D-crop-c0-5__0-5-255x255-70.jpg",
+ thumbnailUrl: placeholderImage,
productType: {
id: "1",
name: "T-Shirt"
diff --git a/saleor/static/dashboard-next/products/views/ProductList.tsx b/saleor/static/dashboard-next/products/views/ProductList.tsx
index 9519267fc3..bed292758e 100644
--- a/saleor/static/dashboard-next/products/views/ProductList.tsx
+++ b/saleor/static/dashboard-next/products/views/ProductList.tsx
@@ -6,7 +6,6 @@ import { stringify as stringifyQs } from "qs";
import * as React from "react";
import { productShowUrl } from "..";
-import { ProductFilters } from "../../category/components/ProductFilters";
import ErrorMessageCard from "../../components/ErrorMessageCard";
import Navigator from "../../components/Navigator";
import Toggle from "../../components/Toggle";
@@ -141,30 +140,6 @@ export const ProductList = decorate<ProductListProps>(
navigate(productShowUrl(id))}
/>
</div>
- <div>
- <Hidden smDown>
- <ProductFilters
- handleSubmit={applyFilters}
- handleClear={clearFilters}
- productTypes={dummyProductTypes}
- formState={filters}
- />
- </Hidden>
- <Hidden mdUp>
- <Drawer
- open={filtersVisible}
- onClose={hideFilters}
- anchor="bottom"
- >
- <ProductFilters
- handleSubmit={applyFilters}
- handleClear={clearFilters}
- productTypes={dummyProductTypes}
- formState={filters}
- />
- </Drawer>
- </Hidden>
- </div>
</>
);
}}
diff --git a/saleor/static/dashboard-next/storybook/__snapshots__/Stories.test.ts.snap b/saleor/static/dashboard-next/storybook/__snapshots__/Stories.test.ts.snap
index 46ccc5a8a0..172de0b680 100644
--- a/saleor/static/dashboard-next/storybook/__snapshots__/Stories.test.ts.snap
+++ b/saleor/static/dashboard-next/storybook/__snapshots__/Stories.test.ts.snap
@@ -1,625 +1,178 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`Storyshots Categories / CategoryBaseForm with 'errors' property 1`] = `
+exports[`Storyshots Categories / CategoryDeleteDialog default 1`] = `
<Component
classes={
Object {
- "cardActions": "Component-cardActions-21",
- "textField": "Component-textField-22",
+ "deleteButton": "Component-deleteButton-21",
}
}
- description="Across pressure PM food discover recognize. Send letter reach listen. Quickly work plan rule.
-Tell lose part purpose do when. Whatever drug contain particularly defense."
- errors={
- Array [
- Object {
- "field": "name",
- "message": "To pole jest wymagane.",
- },
- ]
- }
name="Apparel"
+ onClose={[Function]}
+ onConfirm={[Function]}
+ open={true}
/>
`;
-exports[`Storyshots Categories / CategoryBaseForm with initial data 1`] = `
+exports[`Storyshots Categories / CategoryDeleteDialog with products 1`] = `
<Component
classes={
Object {
- "cardActions": "Component-cardActions-21",
- "textField": "Component-textField-22",
+ "deleteButton": "Component-deleteButton-21",
}
}
- description="Across pressure PM food discover recognize. Send letter reach listen. Quickly work plan rule.
-Tell lose part purpose do when. Whatever drug contain particularly defense."
name="Apparel"
+ onClose={[Function]}
+ onConfirm={[Function]}
+ open={true}
+ productCount={100}
/>
`;
-exports[`Storyshots Categories / CategoryBaseForm without initial data 1`] = `
+exports[`Storyshots Categories / CategoryProducts when loading data 1`] = `
<Component
classes={
Object {
- "cardActions": "Component-cardActions-21",
- "textField": "Component-textField-22",
+ "avatarCell": "Component-avatarCell-23",
+ "link": "Component-link-24",
}
}
+ hasNextPage={true}
+ hasPreviousPage={false}
+ onAddProduct={[Function]}
+ onNextPage={[Function]}
+ onPreviousPage={[Function]}
/>
`;
-exports[`Storyshots Categories / CategoryProducts when loading data 1`] = `
-<WithStyles(Card)>
- <WithStyles(Component)
- title="Products"
- >
- <WithStyles(IconButton)
- onClick={[Function]}
- >
- <pure(Add) />
- </WithStyles(IconButton)>
- <Hidden
- implementation="js"
- lgDown={false}
- lgUp={false}
- mdDown={false}
- mdUp={true}
- smDown={false}
- smUp={false}
- xlDown={false}
- xlUp={false}
- xsDown={false}
- xsUp={false}
- >
- <WithStyles(IconButton)
- onClick={[Function]}
- >
- <pure(FilterList) />
- </WithStyles(IconButton)>
- </Hidden>
- </WithStyles(Component)>
- <WithStyles(Component)
- hasNextPage={true}
- hasPreviousPage={false}
- onNextPage={[Function]}
- onPreviousPage={[Function]}
- />
-</WithStyles(Card)>
-`;
-
exports[`Storyshots Categories / CategoryProducts with clickable rows 1`] = `
-<WithStyles(Card)>
- <WithStyles(Component)
- title="Products"
- >
- <WithStyles(IconButton)
- onClick={[Function]}
- >
- <pure(Add) />
- </WithStyles(IconButton)>
- <Hidden
- implementation="js"
- lgDown={false}
- lgUp={false}
- mdDown={false}
- mdUp={true}
- smDown={false}
- smUp={false}
- xlDown={false}
- xlUp={false}
- xsDown={false}
- xsUp={false}
- >
- <WithStyles(IconButton)
- onClick={[Function]}
- >
- <pure(FilterList) />
- </WithStyles(IconButton)>
- </Hidden>
- </WithStyles(Component)>
- <WithStyles(Component)
- hasNextPage={true}
- hasPreviousPage={false}
- onNextPage={[Function]}
- onPreviousPage={[Function]}
- onRowClick={[Function]}
- products={
- Array [
- Object {
- "id": "UHJvZHVjdDox",
- "name": "Gardner, Graham and King",
- "productType": Object {
- "id": "1",
- "name": "T-Shirt",
- },
- "thumbnailUrl": "placeholder60x60.png",
- },
- Object {
- "id": "UHJvZHVjdDoy",
- "name": "Gardner, Graham and King",
- "productType": Object {
- "id": "1",
- "name": "T-Shirt",
- },
- "thumbnailUrl": "placeholder60x60.png",
- },
- Object {
- "id": "UHJvZHVjdDoz",
- "name": "Gardner, Graham and King",
- "productType": Object {
- "id": "1",
- "name": "T-Shirt",
- },
- "thumbnailUrl": "placeholder60x60.png",
- },
- Object {
- "id": "UHJvZHVjdDoa",
- "name": "Gardner, Graham and King",
- "productType": Object {
- "id": "1",
- "name": "T-Shirt",
- },
- "thumbnailUrl": "placeholder60x60.png",
- },
- ]
- }
- />
-</WithStyles(Card)>
-`;
-
-exports[`Storyshots Categories / CategoryProducts with initial data 1`] = `
-<WithStyles(Card)>
- <WithStyles(Component)
- title="Products"
- >
- <WithStyles(IconButton)
- onClick={[Function]}
- >
- <pure(Add) />
- </WithStyles(IconButton)>
- <Hidden
- implementation="js"
- lgDown={false}
- lgUp={false}
- mdDown={false}
- mdUp={true}
- smDown={false}
- smUp={false}
- xlDown={false}
- xlUp={false}
- xsDown={false}
- xsUp={false}
- >
- <WithStyles(IconButton)
- onClick={[Function]}
- >
- <pure(FilterList) />
- </WithStyles(IconButton)>
- </Hidden>
- </WithStyles(Component)>
- <WithStyles(Component)
- hasNextPage={true}
- hasPreviousPage={false}
- onNextPage={[Function]}
- onPreviousPage={[Function]}
- products={
- Array [
- Object {
- "id": "UHJvZHVjdDox",
- "name": "Gardner, Graham and King",
- "productType": Object {
- "id": "1",
- "name": "T-Shirt",
- },
- "thumbnailUrl": "placeholder60x60.png",
- },
- Object {
- "id": "UHJvZHVjdDoy",
- "name": "Gardner, Graham and King",
- "productType": Object {
- "id": "1",
- "name": "T-Shirt",
- },
- "thumbnailUrl": "placeholder60x60.png",
- },
- Object {
- "id": "UHJvZHVjdDoz",
- "name": "Gardner, Graham and King",
- "productType": Object {
- "id": "1",
- "name": "T-Shirt",
- },
- "thumbnailUrl": "placeholder60x60.png",
- },
- Object {
- "id": "UHJvZHVjdDoa",
- "name": "Gardner, Graham and King",
- "productType": Object {
- "id": "1",
- "name": "T-Shirt",
- },
- "thumbnailUrl": "placeholder60x60.png",
- },
- ]
- }
- />
-</WithStyles(Card)>
-`;
-
-exports[`Storyshots Categories / CategoryProducts without initial data 1`] = `
-<WithStyles(Card)>
- <WithStyles(Component)
- title="Products"
- >
- <WithStyles(IconButton)
- onClick={[Function]}
- >
- <pure(Add) />
- </WithStyles(IconButton)>
- <Hidden
- implementation="js"
- lgDown={false}
- lgUp={false}
- mdDown={false}
- mdUp={true}
- smDown={false}
- smUp={false}
- xlDown={false}
- xlUp={false}
- xsDown={false}
- xsUp={false}
- >
- <WithStyles(IconButton)
- onClick={[Function]}
- >
- <pure(FilterList) />
- </WithStyles(IconButton)>
- </Hidden>
- </WithStyles(Component)>
- <WithStyles(Component)
- hasNextPage={true}
- hasPreviousPage={false}
- onNextPage={[Function]}
- onPreviousPage={[Function]}
- products={Array []}
- />
-</WithStyles(Card)>
-`;
-
-exports[`Storyshots Categories / CategorySubcategories when loading data 1`] = `
-<WithStyles(Card)>
- <WithStyles(Component)
- title="Subcategories"
- >
- <WithStyles(IconButton)
- onClick={[Function]}
- >
- <pure(Add) />
- </WithStyles(IconButton)>
- </WithStyles(Component)>
- <Component
- onClick={[Function]}
- />
-</WithStyles(Card)>
-`;
-
-exports[`Storyshots Categories / CategorySubcategories with initial data 1`] = `
-<WithStyles(Card)>
- <WithStyles(Component)
- title="Subcategories"
- >
- <WithStyles(IconButton)
- onClick={[Function]}
- >
- <pure(Add) />
- </WithStyles(IconButton)>
- </WithStyles(Component)>
- <Component
- categories={
- Array [
- Object {
- "id": "123123",
- "name": "Lorem ipsum dolor",
- },
- Object {
- "id": "876752",
- "name": "Mauris vehicula tortor vulputate",
- },
- ]
- }
- onClick={[Function]}
- />
-</WithStyles(Card)>
-`;
-
-exports[`Storyshots Categories / CategorySubcategories without initial data 1`] = `
-<WithStyles(Card)>
- <WithStyles(Component)
- title="Subcategories"
- >
- <WithStyles(IconButton)
- onClick={[Function]}
- >
- <pure(Add) />
- </WithStyles(IconButton)>
- </WithStyles(Component)>
- <Component
- categories={Array []}
- onClick={[Function]}
- />
-</WithStyles(Card)>
-`;
-
-exports[`Storyshots Categories / ProductFilters with initial data 1`] = `
-<FilterCard
- handleClear={[Function]}
->
- <TextField
- fullWidth={true}
- label="Name"
- name="name"
- onChange={[Function]}
- required={false}
- select={false}
- value="Lorem ipsum"
- />
- <WithStyles(Component) />
- <WithStyles(Component)
- choices={
- Array [
- Object {
- "label": "Type 1",
- "value": "123123123",
- },
- Object {
- "label": "Type 2",
- "value": "123123124",
- },
- Object {
- "label": "Type 3",
- "value": "123123125",
- },
- Object {
- "label": "Type 4",
- "value": "123123126",
- },
- ]
- }
- label="Product type"
- name="productTypes"
- onChange={[Function]}
- value={
- Array [
- "123123123",
- "123123126",
- ]
+<Component
+ classes={
+ Object {
+ "avatarCell": "Component-avatarCell-23",
+ "link": "Component-link-24",
}
- />
- <WithStyles(Component) />
- <WithStyles(Component)
- currencySymbol="USD"
- label="Price"
- name="price"
- onChange={[Function]}
- value={
+ }
+ hasNextPage={true}
+ hasPreviousPage={false}
+ onAddProduct={[Function]}
+ onNextPage={[Function]}
+ onPreviousPage={[Function]}
+ onRowClick={[Function]}
+ products={
+ Array [
Object {
- "max": "50",
- "min": "30",
- }
- }
- />
- <WithStyles(Component) />
- <WithStyles(Component)
- choices={
- Array [
- Object {
- "label": "Published",
- "value": "1",
- },
- Object {
- "label": "Not published",
- "value": "0",
- },
- Object {
- "label": "All",
- "value": "",
- },
- ]
- }
- label="Published"
- name="published"
- onChange={[Function]}
- value="true"
- />
- <WithStyles(Component) />
- <WithStyles(Component)
- choices={
- Array [
- Object {
- "label": "Highlighted",
- "value": "1",
- },
- Object {
- "label": "Not highlighted",
- "value": "0",
- },
- Object {
- "label": "All",
- "value": "",
- },
- ]
- }
- label="Highlighted"
- name="highlighted"
- onChange={[Function]}
- value="false"
- />
-</FilterCard>
-`;
-
-exports[`Storyshots Categories / ProductFilters without initial data 1`] = `
-<FilterCard
- handleClear={[Function]}
->
- <TextField
- fullWidth={true}
- label="Name"
- name="name"
- onChange={[Function]}
- required={false}
- select={false}
- value=""
- />
- <WithStyles(Component) />
- <WithStyles(Component)
- choices={
- Array [
- Object {
- "label": "Type 1",
- "value": "123123123",
- },
- Object {
- "label": "Type 2",
- "value": "123123124",
- },
- Object {
- "label": "Type 3",
- "value": "123123125",
+ "id": "UHJvZHVjdDox",
+ "name": "Gardner, Graham and King",
+ "productType": Object {
+ "id": "1",
+ "name": "T-Shirt",
},
- Object {
- "label": "Type 4",
- "value": "123123126",
- },
- ]
- }
- label="Product type"
- name="productTypes"
- onChange={[Function]}
- value={Array []}
- />
- <WithStyles(Component) />
- <WithStyles(Component)
- currencySymbol="USD"
- label="Price"
- name="price"
- onChange={[Function]}
- value={
+ "thumbnailUrl": "placeholder60x60.png",
+ },
Object {
- "max": "",
- "min": "",
- }
- }
- />
- <WithStyles(Component) />
- <WithStyles(Component)
- choices={
- Array [
- Object {
- "label": "Published",
- "value": "1",
- },
- Object {
- "label": "Not published",
- "value": "0",
- },
- Object {
- "label": "All",
- "value": "",
- },
- ]
- }
- label="Published"
- name="published"
- onChange={[Function]}
- value=""
- />
- <WithStyles(Component) />
- <WithStyles(Component)
- choices={
- Array [
- Object {
- "label": "Highlighted",
- "value": "1",
- },
- Object {
- "label": "Not highlighted",
- "value": "0",
- },
- Object {
- "label": "All",
- "value": "",
- },
- ]
- }
- label="Highlighted"
- name="highlighted"
- onChange={[Function]}
- value=""
- />
-</FilterCard>
-`;
-
-exports[`Storyshots Categories / RootCategoryList when loading data 1`] = `
-<WithStyles(Card)>
- <WithStyles(Component)
- title="Categories"
- >
- <WithStyles(IconButton)
- onClick={[Function]}
- >
- <pure(Add) />
- </WithStyles(IconButton)>
- </WithStyles(Component)>
- <Component
- onClick={[Function]}
- />
-</WithStyles(Card)>
+ "id": "UHJvZHVjdDoy",
+ "name": "Gardner, Graham and King",
+ "productType": Object {
+ "id": "1",
+ "name": "T-Shirt",
+ },
+ "thumbnailUrl": "placeholder60x60.png",
+ },
+ Object {
+ "id": "UHJvZHVjdDoz",
+ "name": "Gardner, Graham and King",
+ "productType": Object {
+ "id": "1",
+ "name": "T-Shirt",
+ },
+ "thumbnailUrl": "placeholder60x60.png",
+ },
+ Object {
+ "id": "UHJvZHVjdDoa",
+ "name": "Gardner, Graham and King",
+ "productType": Object {
+ "id": "1",
+ "name": "T-Shirt",
+ },
+ "thumbnailUrl": "placeholder60x60.png",
+ },
+ ]
+ }
+/>
`;
-exports[`Storyshots Categories / RootCategoryList with initial data 1`] = `
-<WithStyles(Card)>
- <WithStyles(Component)
- title="Categories"
- >
- <WithStyles(IconButton)
- onClick={[Function]}
- >
- <pure(Add) />
- </WithStyles(IconButton)>
- </WithStyles(Component)>
- <Component
- categories={
- Array [
- Object {
- "id": "123123",
- "name": "Lorem ipsum dolor",
+exports[`Storyshots Categories / CategoryProducts with initial data 1`] = `
+<Component
+ classes={
+ Object {
+ "avatarCell": "Component-avatarCell-23",
+ "link": "Component-link-24",
+ }
+ }
+ hasNextPage={true}
+ hasPreviousPage={false}
+ onAddProduct={[Function]}
+ onNextPage={[Function]}
+ onPreviousPage={[Function]}
+ products={
+ Array [
+ Object {
+ "id": "UHJvZHVjdDox",
+ "name": "Gardner, Graham and King",
+ "productType": Object {
+ "id": "1",
+ "name": "T-Shirt",
},
- Object {
- "id": "876752",
- "name": "Mauris vehicula tortor vulputate",
+ "thumbnailUrl": "placeholder60x60.png",
+ },
+ Object {
+ "id": "UHJvZHVjdDoy",
+ "name": "Gardner, Graham and King",
+ "productType": Object {
+ "id": "1",
+ "name": "T-Shirt",
},
- ]
- }
- onClick={[Function]}
- />
-</WithStyles(Card)>
+ "thumbnailUrl": "placeholder60x60.png",
+ },
+ Object {
+ "id": "UHJvZHVjdDoz",
+ "name": "Gardner, Graham and King",
+ "productType": Object {
+ "id": "1",
+ "name": "T-Shirt",
+ },
+ "thumbnailUrl": "placeholder60x60.png",
+ },
+ Object {
+ "id": "UHJvZHVjdDoa",
+ "name": "Gardner, Graham and King",
+ "productType": Object {
+ "id": "1",
+ "name": "T-Shirt",
+ },
+ "thumbnailUrl": "placeholder60x60.png",
+ },
+ ]
+ }
+/>
`;
-exports[`Storyshots Categories / RootCategoryList without initial data 1`] = `
-<WithStyles(Card)>
- <WithStyles(Component)
- title="Categories"
- >
- <WithStyles(IconButton)
- onClick={[Function]}
- >
- <pure(Add) />
- </WithStyles(IconButton)>
- </WithStyles(Component)>
- <Component
- categories={Array []}
- onClick={[Function]}
- />
-</WithStyles(Card)>
+exports[`Storyshots Categories / CategoryProducts without initial data 1`] = `
+<Component
+ classes={
+ Object {
+ "avatarCell": "Component-avatarCell-23",
+ "link": "Component-link-24",
+ }
+ }
+ hasNextPage={true}
+ hasPreviousPage={false}
+ onAddProduct={[Function]}
+ onNextPage={[Function]}
+ onPreviousPage={[Function]}
+ products={Array []}
+/>
`;
exports[`Storyshots Generics / DateFormatter default 1`] = `
@@ -3912,7 +3465,7 @@ exports[`Storyshots Pages / PageContent when loaded 1`] = `
availableOn="2018-03-20T16:39:08.850105+00:00"
classes={
Object {
- "addHelperTextPadding": "Component-addHelperTextPadding-23",
+ "addHelperTextPadding": "Component-addHelperTextPadding-25",
}
}
content="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin bibendum et justo sit amet viverra. Maecenas euismod auctor nisi et tincidunt. Maecenas ante urna, aliquet at odio sed, gravida efficitur purus. Morbi ut dapibus ante. Nulla eu neque sit amet odio tincidunt porttitor eu quis purus. Aliquam at diam sit amet turpis varius semper vitae non lectus. Vivamus lectus ligula, molestie eu augue eu, cursus tincidunt sem. Nam ornare egestas tincidunt."
@@ -3927,7 +3480,7 @@ exports[`Storyshots Pages / PageContent when loading 1`] = `
<Component
classes={
Object {
- "addHelperTextPadding": "Component-addHelperTextPadding-23",
+ "addHelperTextPadding": "Component-addHelperTextPadding-25",
}
}
content=""
@@ -3940,7 +3493,7 @@ exports[`Storyshots Pages / PageDeleteDialog default 1`] = `
<Component
classes={
Object {
- "deleteButton": "Component-deleteButton-24",
+ "deleteButton": "Component-deleteButton-26",
}
}
onClose={[Function]}
@@ -3954,8 +3507,8 @@ exports[`Storyshots Pages / PageList when loading data 1`] = `
<Component
classes={
Object {
- "link": "Component-link-26",
- "textRight": "Component-textRight-27",
+ "link": "Component-link-28",
+ "textRight": "Component-textRight-29",
}
}
onEditClick={[Function]}
@@ -3975,8 +3528,8 @@ exports[`Storyshots Pages / PageList with data 1`] = `
<Component
classes={
Object {
- "link": "Component-link-26",
- "textRight": "Component-textRight-27",
+ "link": "Component-link-28",
+ "textRight": "Component-textRight-29",
}
}
onEditClick={[Function]}
@@ -4012,8 +3565,8 @@ exports[`Storyshots Pages / PageList without data 1`] = `
<Component
classes={
Object {
- "link": "Component-link-26",
- "textRight": "Component-textRight-27",
+ "link": "Component-link-28",
+ "textRight": "Component-textRight-29",
}
}
onEditClick={[Function]}
@@ -4035,7 +3588,7 @@ exports[`Storyshots Pages / PageProperties when loaded 1`] = `
availableOn="2018-03-20T16:39:08.850105+00:00"
classes={
Object {
- "root": "Component-root-29",
+ "root": "Component-root-31",
}
}
content="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin bibendum et justo sit amet viverra. Maecenas euismod auctor nisi et tincidunt. Maecenas ante urna, aliquet at odio sed, gravida efficitur purus. Morbi ut dapibus ante. Nulla eu neque sit amet odio tincidunt porttitor eu quis purus. Aliquam at diam sit amet turpis varius semper vitae non lectus. Vivamus lectus ligula, molestie eu augue eu, cursus tincidunt sem. Nam ornare egestas tincidunt."
@@ -4051,7 +3604,7 @@ exports[`Storyshots Pages / PageProperties when loading 1`] = `
availableOn=""
classes={
Object {
- "root": "Component-root-29",
+ "root": "Component-root-31",
}
}
isVisible={false}
@@ -4164,7 +3717,7 @@ exports[`Storyshots Products / ProductAvailabilityForm when loading data 1`] = `
<Component
classes={
Object {
- "root": "Component-root-30",
+ "root": "Component-root-32",
}
}
onChange={[Function]}
@@ -4177,7 +3730,7 @@ exports[`Storyshots Products / ProductAvailabilityForm with loaded data 1`] = `
availableOn="04-10-2010"
classes={
Object {
- "root": "Component-root-30",
+ "root": "Component-root-32",
}
}
onChange={[Function]}
@@ -4233,8 +3786,8 @@ exports[`Storyshots Products / ProductCollections when loading data 1`] = `
<Component
classes={
Object {
- "card": "Component-card-31",
- "link": "Component-link-32",
+ "card": "Component-card-33",
+ "link": "Component-link-34",
}
}
onRowClick={[Function]}
@@ -4245,8 +3798,8 @@ exports[`Storyshots Products / ProductCollections with collections 1`] = `
<Component
classes={
Object {
- "card": "Component-card-31",
- "link": "Component-link-32",
+ "card": "Component-card-33",
+ "link": "Component-link-34",
}
}
collections={
@@ -4269,8 +3822,8 @@ exports[`Storyshots Products / ProductCollections with no collections 1`] = `
<Component
classes={
Object {
- "card": "Component-card-31",
- "link": "Component-link-32",
+ "card": "Component-card-33",
+ "link": "Component-link-34",
}
}
collections={Array []}
@@ -4382,7 +3935,7 @@ exports[`Storyshots Products / ProductDetailsForm when loading data 1`] = `
<Component
classes={
Object {
- "root": "Component-root-33",
+ "root": "Component-root-35",
}
}
loading={true}
@@ -4395,7 +3948,7 @@ exports[`Storyshots Products / ProductDetailsForm with initial data 1`] = `
<Component
classes={
Object {
- "root": "Component-root-33",
+ "root": "Component-root-35",
}
}
currencySymbol="USD"
@@ -4411,7 +3964,7 @@ exports[`Storyshots Products / ProductDetailsForm with no initial data 1`] = `
<Component
classes={
Object {
- "root": "Component-root-33",
+ "root": "Component-root-35",
}
}
onBack={[Function]}
@@ -4423,8 +3976,8 @@ exports[`Storyshots Products / ProductImagePage data loaded 1`] = `
<Component
classes={
Object {
- "image": "Component-image-36",
- "root": "Component-root-35",
+ "image": "Component-image-38",
+ "root": "Component-root-37",
}
}
image="placeholder255x255.png"
@@ -4437,8 +3990,8 @@ exports[`Storyshots Products / ProductImagePage loading 1`] = `
<Component
classes={
Object {
- "image": "Component-image-36",
- "root": "Component-root-35",
+ "image": "Component-image-38",
+ "root": "Component-root-37",
}
}
loading={true}
@@ -4451,11 +4004,11 @@ exports[`Storyshots Products / ProductImages when loading data 1`] = `
<Component
classes={
Object {
- "card": "Component-card-38",
- "fileField": "Component-fileField-41",
- "gridElement": "Component-gridElement-39",
- "icon": "Component-icon-40",
- "root": "Component-root-37",
+ "card": "Component-card-40",
+ "fileField": "Component-fileField-43",
+ "gridElement": "Component-gridElement-41",
+ "icon": "Component-icon-42",
+ "root": "Component-root-39",
}
}
onImageReorder={[Function]}
@@ -4468,11 +4021,11 @@ exports[`Storyshots Products / ProductImages with data 1`] = `
<Component
classes={
Object {
- "card": "Component-card-38",
- "fileField": "Component-fileField-41",
- "gridElement": "Component-gridElement-39",
- "icon": "Component-icon-40",
- "root": "Component-root-37",
+ "card": "Component-card-40",
+ "fileField": "Component-fileField-43",
+ "gridElement": "Component-gridElement-41",
+ "icon": "Component-icon-42",
+ "root": "Component-root-39",
}
}
images={
@@ -4506,11 +4059,11 @@ exports[`Storyshots Products / ProductImages without data 1`] = `
<Component
classes={
Object {
- "card": "Component-card-38",
- "fileField": "Component-fileField-41",
- "gridElement": "Component-gridElement-39",
- "icon": "Component-icon-40",
- "root": "Component-root-37",
+ "card": "Component-card-40",
+ "fileField": "Component-fileField-43",
+ "gridElement": "Component-gridElement-41",
+ "icon": "Component-icon-42",
+ "root": "Component-root-39",
}
}
images={Array []}
@@ -4523,10 +4076,10 @@ exports[`Storyshots Products / ProductPriceAndAvailability when loading data 1`]
<Component
classes={
Object {
- "greenText": "Component-greenText-42",
- "leftCell": "Component-leftCell-43",
- "redText": "Component-redText-44",
- "rightCell": "Component-rightCell-45",
+ "greenText": "Component-greenText-44",
+ "leftCell": "Component-leftCell-45",
+ "redText": "Component-redText-46",
+ "rightCell": "Component-rightCell-47",
}
}
onPublish={[Function]}
@@ -4537,10 +4090,10 @@ exports[`Storyshots Products / ProductPriceAndAvailability when product is avail
<Component
classes={
Object {
- "greenText": "Component-greenText-42",
- "leftCell": "Component-leftCell-43",
- "redText": "Component-redText-44",
- "rightCell": "Component-rightCell-45",
+ "greenText": "Component-greenText-44",
+ "leftCell": "Component-leftCell-45",
+ "redText": "Component-redText-46",
+ "rightCell": "Component-rightCell-47",
}
}
grossMargin={
@@ -4570,10 +4123,10 @@ exports[`Storyshots Products / ProductPriceAndAvailability when product is not a
<Component
classes={
Object {
- "greenText": "Component-greenText-42",
- "leftCell": "Component-leftCell-43",
- "redText": "Component-redText-44",
- "rightCell": "Component-rightCell-45",
+ "greenText": "Component-greenText-44",
+ "leftCell": "Component-leftCell-45",
+ "redText": "Component-redText-46",
+ "rightCell": "Component-rightCell-47",
}
}
grossMargin={
@@ -4629,7 +4182,7 @@ exports[`Storyshots Products / ProductVariantAttributes when loaded data 1`] = `
}
classes={
Object {
- "grid": "Component-grid-49",
+ "grid": "Component-grid-51",
}
}
onChange={[Function]}
@@ -4640,7 +4193,7 @@ exports[`Storyshots Products / ProductVariantAttributes when loading data 1`] =
<Component
classes={
Object {
- "grid": "Component-grid-49",
+ "grid": "Component-grid-51",
}
}
loading={true}
@@ -4652,7 +4205,7 @@ exports[`Storyshots Products / ProductVariantDeleteDialog default 1`] = `
<Component
classes={
Object {
- "deleteButton": "Component-deleteButton-50",
+ "deleteButton": "Component-deleteButton-52",
}
}
name="Extended Hard"
@@ -4664,10 +4217,10 @@ exports[`Storyshots Products / ProductVariantImageSelectDialog default 1`] = `
<ProductVariantImageSelectDialogComponent
classes={
Object {
- "gridElement": "ProductVariantImageSelectDialogComponent-gridElement-52",
- "icon": "ProductVariantImageSelectDialogComponent-icon-53",
- "iconChecked": "ProductVariantImageSelectDialogComponent-iconChecked-54",
- "root": "ProductVariantImageSelectDialogComponent-root-51",
+ "gridElement": "ProductVariantImageSelectDialogComponent-gridElement-54",
+ "icon": "ProductVariantImageSelectDialogComponent-icon-55",
+ "iconChecked": "ProductVariantImageSelectDialogComponent-iconChecked-56",
+ "root": "ProductVariantImageSelectDialogComponent-root-53",
}
}
images={
@@ -4752,9 +4305,9 @@ exports[`Storyshots Products / ProductVariantImages when loaded data 1`] = `
<Component
classes={
Object {
- "card": "Component-card-56",
- "gridElement": "Component-gridElement-57",
- "root": "Component-root-55",
+ "card": "Component-card-58",
+ "gridElement": "Component-gridElement-59",
+ "root": "Component-root-57",
}
}
images={
@@ -4824,9 +4377,9 @@ exports[`Storyshots Products / ProductVariantImages when loading data 1`] = `
<Component
classes={
Object {
- "card": "Component-card-56",
- "gridElement": "Component-gridElement-57",
- "root": "Component-root-55",
+ "card": "Component-card-58",
+ "gridElement": "Component-gridElement-59",
+ "root": "Component-root-57",
}
}
loading={true}
@@ -4839,8 +4392,8 @@ exports[`Storyshots Products / ProductVariantNavigation when loaded data 1`] = `
<Component
classes={
Object {
- "card": "Component-card-58",
- "link": "Component-link-59",
+ "card": "Component-card-60",
+ "link": "Component-link-61",
}
}
variants={
@@ -4866,8 +4419,8 @@ exports[`Storyshots Products / ProductVariantNavigation when loading data 1`] =
<Component
classes={
Object {
- "card": "Component-card-58",
- "link": "Component-link-59",
+ "card": "Component-card-60",
+ "link": "Component-link-61",
}
}
loading={true}
@@ -4878,8 +4431,8 @@ exports[`Storyshots Products / ProductVariantNavigation with clickable rows 1`]
<Component
classes={
Object {
- "card": "Component-card-58",
- "link": "Component-link-59",
+ "card": "Component-card-60",
+ "link": "Component-link-61",
}
}
onRowClick={[Function]}
@@ -4906,8 +4459,8 @@ exports[`Storyshots Products / ProductVariantPrice when loaded data 1`] = `
<Component
classes={
Object {
- "grid": "Component-grid-62",
- "root": "Component-root-61",
+ "grid": "Component-grid-64",
+ "root": "Component-root-63",
}
}
costPrice={100}
@@ -4921,8 +4474,8 @@ exports[`Storyshots Products / ProductVariantPrice when loading data 1`] = `
<Component
classes={
Object {
- "grid": "Component-grid-62",
- "root": "Component-root-61",
+ "grid": "Component-grid-64",
+ "root": "Component-root-63",
}
}
loading={true}
@@ -4934,7 +4487,7 @@ exports[`Storyshots Products / ProductVariantProduct when loaded data 1`] = `
<Component
classes={
Object {
- "root": "Component-root-63",
+ "root": "Component-root-65",
}
}
product={
@@ -5050,7 +4603,7 @@ exports[`Storyshots Products / ProductVariantProduct when loading data 1`] = `
<Component
classes={
Object {
- "root": "Component-root-63",
+ "root": "Component-root-65",
}
}
loading={true}
@@ -5062,8 +4615,8 @@ exports[`Storyshots Products / ProductVariantStock when loaded data 1`] = `
<Component
classes={
Object {
- "grid": "Component-grid-65",
- "root": "Component-root-64",
+ "grid": "Component-grid-67",
+ "root": "Component-root-66",
}
}
onChange={[Function]}
@@ -5077,8 +4630,8 @@ exports[`Storyshots Products / ProductVariantStock when loading data 1`] = `
<Component
classes={
Object {
- "grid": "Component-grid-65",
- "root": "Component-root-64",
+ "grid": "Component-grid-67",
+ "root": "Component-root-66",
}
}
loading={true}
@@ -5090,10 +4643,10 @@ exports[`Storyshots Products / ProductVariants when loading data 1`] = `
<Component
classes={
Object {
- "alignRightText": "Component-alignRightText-66",
- "greenDot": "Component-greenDot-67",
- "link": "Component-link-68",
- "redDot": "Component-redDot-69",
+ "alignRightText": "Component-alignRightText-68",
+ "greenDot": "Component-greenDot-69",
+ "link": "Component-link-70",
+ "redDot": "Component-redDot-71",
}
}
/>
@@ -5103,10 +4656,10 @@ exports[`Storyshots Products / ProductVariants when product has no variants 1`]
<Component
classes={
Object {
- "alignRightText": "Component-alignRightText-66",
- "greenDot": "Component-greenDot-67",
- "link": "Component-link-68",
- "redDot": "Component-redDot-69",
+ "alignRightText": "Component-alignRightText-68",
+ "greenDot": "Component-greenDot-69",
+ "link": "Component-link-70",
+ "redDot": "Component-redDot-71",
}
}
variants={Array []}
@@ -5117,10 +4670,10 @@ exports[`Storyshots Products / ProductVariants when product has variants 1`] = `
<Component
classes={
Object {
- "alignRightText": "Component-alignRightText-66",
- "greenDot": "Component-greenDot-67",
- "link": "Component-link-68",
- "redDot": "Component-redDot-69",
+ "alignRightText": "Component-alignRightText-68",
+ "greenDot": "Component-greenDot-69",
+ "link": "Component-link-70",
+ "redDot": "Component-redDot-71",
}
}
fallbackGross="80%"
@@ -5184,10 +4737,10 @@ exports[`Storyshots Products / ProductVariants with clickable rows 1`] = `
<Component
classes={
Object {
- "alignRightText": "Component-alignRightText-66",
- "greenDot": "Component-greenDot-67",
- "link": "Component-link-68",
- "redDot": "Component-redDot-69",
+ "alignRightText": "Component-alignRightText-68",
+ "greenDot": "Component-greenDot-69",
+ "link": "Component-link-70",
+ "redDot": "Component-redDot-71",
}
}
fallbackGross="80%"
@@ -5248,6 +4801,228 @@ exports[`Storyshots Products / ProductVariants with clickable rows 1`] = `
/>
`;
+exports[`Storyshots Views / Categories / Category details default 1`] = `
+<Component
+ category={
+ Object {
+ "SeoDescription": "Across pressure PM food discover recognize. Send letter reach listen. Quickly work plan rule.
+Tell lose part purpose do when. Whatever drug contain particularly defense.",
+ "SeoTitle": "Apparel",
+ "children": Array [
+ Object {
+ "id": "123123",
+ "name": "Lorem ipsum dolor",
+ },
+ Object {
+ "id": "876752",
+ "name": "Mauris vehicula tortor vulputate",
+ },
+ ],
+ "description": "Across pressure PM food discover recognize. Send letter reach listen. Quickly work plan rule.
+Tell lose part purpose do when. Whatever drug contain particularly defense.",
+ "id": "c1",
+ "name": "Apparel",
+ "products": Array [
+ Object {
+ "id": "UHJvZHVjdDox",
+ "name": "Gardner, Graham and King",
+ "productType": Object {
+ "id": "1",
+ "name": "T-Shirt",
+ },
+ "thumbnailUrl": "placeholder60x60.png",
+ },
+ Object {
+ "id": "UHJvZHVjdDoy",
+ "name": "Gardner, Graham and King",
+ "productType": Object {
+ "id": "1",
+ "name": "T-Shirt",
+ },
+ "thumbnailUrl": "placeholder60x60.png",
+ },
+ Object {
+ "id": "UHJvZHVjdDoz",
+ "name": "Gardner, Graham and King",
+ "productType": Object {
+ "id": "1",
+ "name": "T-Shirt",
+ },
+ "thumbnailUrl": "placeholder60x60.png",
+ },
+ Object {
+ "id": "UHJvZHVjdDoa",
+ "name": "Gardner, Graham and King",
+ "productType": Object {
+ "id": "1",
+ "name": "T-Shirt",
+ },
+ "thumbnailUrl": "placeholder60x60.png",
+ },
+ ],
+ }
+ }
+ classes={
+ Object {
+ "root": "Component-root-22",
+ }
+ }
+ loading={false}
+ onAddCategory={[Function]}
+ onAddProduct={[Function]}
+ onBack={[Function]}
+ onCategoryClick={[Function]}
+ onDelete={[Function]}
+ onEdit={[Function]}
+ onNextPage={[Function]}
+ onPreviousPage={[Function]}
+ onProductClick={[Function]}
+ pageInfo={
+ Object {
+ "hasNextPage": true,
+ "hasPreviousPage": true,
+ }
+ }
+ products={
+ Array [
+ Object {
+ "id": "UHJvZHVjdDox",
+ "name": "Gardner, Graham and King",
+ "productType": Object {
+ "id": "1",
+ "name": "T-Shirt",
+ },
+ "thumbnailUrl": "placeholder60x60.png",
+ },
+ Object {
+ "id": "UHJvZHVjdDoy",
+ "name": "Gardner, Graham and King",
+ "productType": Object {
+ "id": "1",
+ "name": "T-Shirt",
+ },
+ "thumbnailUrl": "placeholder60x60.png",
+ },
+ Object {
+ "id": "UHJvZHVjdDoz",
+ "name": "Gardner, Graham and King",
+ "productType": Object {
+ "id": "1",
+ "name": "T-Shirt",
+ },
+ "thumbnailUrl": "placeholder60x60.png",
+ },
+ Object {
+ "id": "UHJvZHVjdDoa",
+ "name": "Gardner, Graham and King",
+ "productType": Object {
+ "id": "1",
+ "name": "T-Shirt",
+ },
+ "thumbnailUrl": "placeholder60x60.png",
+ },
+ ]
+ }
+ subcategories={
+ Array [
+ Object {
+ "id": "123123",
+ "name": "Lorem ipsum dolor",
+ },
+ Object {
+ "id": "876752",
+ "name": "Mauris vehicula tortor vulputate",
+ },
+ ]
+ }
+/>
+`;
+
+exports[`Storyshots Views / Categories / Category details when in root 1`] = `
+<Component
+ classes={
+ Object {
+ "root": "Component-root-22",
+ }
+ }
+ loading={false}
+ onAddCategory={[Function]}
+ onAddProduct={[Function]}
+ onBack={[Function]}
+ onCategoryClick={[Function]}
+ onDelete={[Function]}
+ onEdit={[Function]}
+ onNextPage={[Function]}
+ onPreviousPage={[Function]}
+ onProductClick={[Function]}
+ subcategories={
+ Array [
+ Object {
+ "id": "123123",
+ "name": "Lorem ipsum dolor",
+ },
+ Object {
+ "id": "876752",
+ "name": "Mauris vehicula tortor vulputate",
+ },
+ ]
+ }
+/>
+`;
+
+exports[`Storyshots Views / Categories / Category details when loading 1`] = `
+<Component
+ classes={
+ Object {
+ "root": "Component-root-22",
+ }
+ }
+ loading={true}
+/>
+`;
+
+exports[`Storyshots Views / Categories / Category edit default 1`] = `
+<Form
+ initial={
+ Object {
+ "description": "Across pressure PM food discover recognize. Send letter reach listen. Quickly work plan rule.
+Tell lose part purpose do when. Whatever drug contain particularly defense.",
+ "name": "Apparel",
+ }
+ }
+ key="ready"
+ onSubmit={[Function]}
+/>
+`;
+
+exports[`Storyshots Views / Categories / Category edit when loading 1`] = `
+<Form
+ initial={
+ Object {
+ "description": "Across pressure PM food discover recognize. Send letter reach listen. Quickly work plan rule.
+Tell lose part purpose do when. Whatever drug contain particularly defense.",
+ "name": "Apparel",
+ }
+ }
+ key="ready"
+ onSubmit={[Function]}
+/>
+`;
+
+exports[`Storyshots Views / Categories / Category edit with errors 1`] = `
+<Form
+ initial={
+ Object {
+ "description": "Across pressure PM food discover recognize. Send letter reach listen. Quickly work plan rule.
+Tell lose part purpose do when. Whatever drug contain particularly defense.",
+ "name": "Apparel",
+ }
+ }
+ key="ready"
+ onSubmit={[Function]}
+/>
+`;
+
exports[`Storyshots Views / Orders / Order details as a draft 1`] = `
Array [
<WithStyles(CssBaseline) />,
@@ -6435,7 +6210,7 @@ exports[`Storyshots Views / Pages / Page details when loading 1`] = `
<Component
classes={
Object {
- "root": "Component-root-25",
+ "root": "Component-root-27",
}
}
disabled={true}
@@ -6448,7 +6223,7 @@ exports[`Storyshots Views / Pages / Page details with delete button 1`] = `
<Component
classes={
Object {
- "root": "Component-root-25",
+ "root": "Component-root-27",
}
}
onBack={[Function]}
@@ -6471,7 +6246,7 @@ exports[`Storyshots Views / Pages / Page details with initial data 1`] = `
<Component
classes={
Object {
- "root": "Component-root-25",
+ "root": "Component-root-27",
}
}
onBack={[Function]}
@@ -6493,7 +6268,7 @@ exports[`Storyshots Views / Pages / Page list when loading data 1`] = `
<Component
classes={
Object {
- "root": "Component-root-28",
+ "root": "Component-root-30",
}
}
onBack={[Function]}
@@ -6514,7 +6289,7 @@ exports[`Storyshots Views / Pages / Page list with data 1`] = `
<Component
classes={
Object {
- "root": "Component-root-28",
+ "root": "Component-root-30",
}
}
onBack={[Function]}
@@ -6551,7 +6326,7 @@ exports[`Storyshots Views / Pages / Page list without data 1`] = `
<Component
classes={
Object {
- "root": "Component-root-28",
+ "root": "Component-root-30",
}
}
onBack={[Function]}
@@ -6573,7 +6348,7 @@ exports[`Storyshots Views / Products / Product details when loaded data 1`] = `
<Component
classes={
Object {
- "root": "Component-root-34",
+ "root": "Component-root-36",
}
}
onBack={[Function]}
@@ -6759,7 +6534,7 @@ exports[`Storyshots Views / Products / Product details when loading data 1`] = `
<Component
classes={
Object {
- "root": "Component-root-34",
+ "root": "Component-root-36",
}
}
onBack={[Function]}
@@ -6792,9 +6567,9 @@ exports[`Storyshots Views / Products / Product edit when data is fully loaded 1`
}
classes={
Object {
- "cardContainer": "Component-cardContainer-48",
- "grid": "Component-grid-47",
- "root": "Component-root-46",
+ "cardContainer": "Component-cardContainer-50",
+ "grid": "Component-grid-49",
+ "root": "Component-root-48",
}
}
collections={
@@ -6942,9 +6717,9 @@ exports[`Storyshots Views / Products / Product edit when loading data 1`] = `
<Component
classes={
Object {
- "cardContainer": "Component-cardContainer-48",
- "grid": "Component-grid-47",
- "root": "Component-root-46",
+ "cardContainer": "Component-cardContainer-50",
+ "grid": "Component-grid-49",
+ "root": "Component-root-48",
}
}
loading={true}
@@ -7191,7 +6966,7 @@ exports[`Storyshots Views / Products / Product variant details when loaded data
<Component
classes={
Object {
- "root": "Component-root-60",
+ "root": "Component-root-62",
}
}
onBack={[Function]}
@@ -7369,7 +7144,7 @@ exports[`Storyshots Views / Products / Product variant details when loading data
<Component
classes={
Object {
- "root": "Component-root-60",
+ "root": "Component-root-62",
}
}
loading={true}
diff --git a/saleor/static/dashboard-next/storybook/config.js b/saleor/static/dashboard-next/storybook/config.js
index b6ca5273a2..78e1cf9b67 100644
--- a/saleor/static/dashboard-next/storybook/config.js
+++ b/saleor/static/dashboard-next/storybook/config.js
@@ -19,11 +19,10 @@ function loadStories() {
require("./stories/components/Timeline");
// Categories
- require("./stories/categories/CategoryBaseForm");
+ require("./stories/categories/CategoryDeleteDialog");
+ require("./stories/categories/CategoryDetailsPage");
+ require("./stories/categories/CategoryEditPage");
require("./stories/categories/CategoryProducts");
- require("./stories/categories/CategorySubcategories");
- require("./stories/categories/ProductFilters");
- require("./stories/categories/RootCategoryList");
// Pages
require("./stories/pages/PageContent");
diff --git a/saleor/static/dashboard-next/storybook/stories/categories/CategoryBaseForm.tsx b/saleor/static/dashboard-next/storybook/stories/categories/CategoryBaseForm.tsx
deleted file mode 100644
index 731091edf7..0000000000
--- a/saleor/static/dashboard-next/storybook/stories/categories/CategoryBaseForm.tsx
+++ /dev/null
@@ -1,24 +0,0 @@
-import { storiesOf } from "@storybook/react";
-import { DialogContentText } from "material-ui/Dialog";
-import * as React from "react";
-
-import CategoryBaseForm from "../../../category/components/CategoryBaseForm";
-
-const category = {
- 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.",
- name: "Apparel"
-};
-
-storiesOf("Categories / CategoryBaseForm", module)
- .add("with initial data", () => <CategoryBaseForm {...category} />)
- .add("without initial data", () => <CategoryBaseForm />)
- .add("with 'errors' property", () => {
- const errors = [
- {
- field: "name",
- message: "To pole jest wymagane."
- }
- ];
- return <CategoryBaseForm {...category} errors={errors} />;
- });
diff --git a/saleor/static/dashboard-next/storybook/stories/categories/CategoryDeleteDialog.tsx b/saleor/static/dashboard-next/storybook/stories/categories/CategoryDeleteDialog.tsx
new file mode 100644
index 0000000000..84917842e8
--- /dev/null
+++ b/saleor/static/dashboard-next/storybook/stories/categories/CategoryDeleteDialog.tsx
@@ -0,0 +1,28 @@
+import { storiesOf } from "@storybook/react";
+import * as React from "react";
+
+import CategoryDeleteDialog from "../../../categories/components/CategoryDeleteDialog";
+import { category as categoryFixture } from "../../../categories/fixtures";
+// import Decorator from "../../Decorator";
+
+const category = categoryFixture("");
+
+storiesOf("Categories / CategoryDeleteDialog", module)
+ // .addDecorator(Decorator)
+ .add("default", () => (
+ <CategoryDeleteDialog
+ name={category.name}
+ open={true}
+ onClose={() => {}}
+ onConfirm={() => {}}
+ />
+ ))
+ .add("with products", () => (
+ <CategoryDeleteDialog
+ name={category.name}
+ open={true}
+ productCount={100}
+ onClose={() => {}}
+ onConfirm={() => {}}
+ />
+ ));
diff --git a/saleor/static/dashboard-next/storybook/stories/categories/CategoryDetailsPage.tsx b/saleor/static/dashboard-next/storybook/stories/categories/CategoryDetailsPage.tsx
new file mode 100644
index 0000000000..83a5e4d5dc
--- /dev/null
+++ b/saleor/static/dashboard-next/storybook/stories/categories/CategoryDetailsPage.tsx
@@ -0,0 +1,49 @@
+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={() => {}}
+ onAddProduct={() => {}}
+ onBack={() => {}}
+ onCategoryClick={() => () => {}}
+ onDelete={() => {}}
+ onEdit={() => {}}
+ onNextPage={() => {}}
+ onPreviousPage={() => {}}
+ onProductClick={() => () => {}}
+ />
+ ))
+ .add("when in root", () => (
+ <CategoryDetailsPage
+ subcategories={category.children}
+ loading={false}
+ onAddCategory={() => {}}
+ onAddProduct={() => {}}
+ onBack={() => {}}
+ onCategoryClick={() => () => {}}
+ onDelete={() => {}}
+ onEdit={() => {}}
+ onNextPage={() => {}}
+ onPreviousPage={() => {}}
+ onProductClick={() => () => {}}
+ />
+ ))
+ .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.tsx
new file mode 100644
index 0000000000..d374bcfc89
--- /dev/null
+++ b/saleor/static/dashboard-next/storybook/stories/categories/CategoryEditPage.tsx
@@ -0,0 +1,37 @@
+import { storiesOf } from "@storybook/react";
+import * as React from "react";
+
+import CategoryEditPage from "../../../categories/components/CategoryEditPage";
+// import Decorator from "../../Decorator";
+import {
+ category as categoryFixture,
+ errors
+} from "../../../categories/fixtures";
+
+const category = categoryFixture("");
+
+storiesOf("Views / Categories / Category edit", module)
+ // .addDecorator(Decorator)
+ .add("default", () => (
+ <CategoryEditPage
+ category={category}
+ onBack={() => {}}
+ onSubmit={() => {}}
+ />
+ ))
+ .add("when loading", () => (
+ <CategoryEditPage
+ category={category}
+ disabled={true}
+ onBack={() => {}}
+ onSubmit={() => {}}
+ />
+ ))
+ .add("with errors", () => (
+ <CategoryEditPage
+ category={category}
+ errors={errors}
+ onBack={() => {}}
+ onSubmit={() => {}}
+ />
+ ));
diff --git a/saleor/static/dashboard-next/storybook/stories/categories/CategoryList.tsx b/saleor/static/dashboard-next/storybook/stories/categories/CategoryList.tsx
new file mode 100644
index 0000000000..27b59d2e1a
--- /dev/null
+++ b/saleor/static/dashboard-next/storybook/stories/categories/CategoryList.tsx
@@ -0,0 +1,10 @@
+import { storiesOf } from "@storybook/react";
+import * as React from "react";
+
+import CategoryList from "../../../categories/components/CategoryList";
+import Decorator from "../../Decorator";
+
+storiesOf("Categories / CategoryList", module)
+ .addDecorator(Decorator)
+ .add("default", () => <CategoryList />)
+ .add("other", () => <CategoryList />);
diff --git a/saleor/static/dashboard-next/storybook/stories/categories/CategoryProducts.tsx b/saleor/static/dashboard-next/storybook/stories/categories/CategoryProducts.tsx
index 2da8a53c16..3961d11db2 100644
--- a/saleor/static/dashboard-next/storybook/stories/categories/CategoryProducts.tsx
+++ b/saleor/static/dashboard-next/storybook/stories/categories/CategoryProducts.tsx
@@ -2,7 +2,7 @@ import { storiesOf } from "@storybook/react";
import { DialogContentText } from "material-ui/Dialog";
import * as React from "react";
-import CategoryProducts from "../../../category/components/CategoryProducts";
+import CategoryProducts from "../../../categories/components/CategoryProducts";
import * as placeholder from "../../../../images/placeholder60x60.png";
const products = [
@@ -50,8 +50,7 @@ storiesOf("Categories / CategoryProducts", module)
hasNextPage={true}
hasPreviousPage={false}
products={[]}
- onCreate={() => {}}
- onFilter={() => {}}
+ onAddProduct={() => {}}
onNextPage={() => {}}
onPreviousPage={() => {}}
/>
@@ -61,8 +60,7 @@ storiesOf("Categories / CategoryProducts", module)
hasNextPage={true}
hasPreviousPage={false}
products={products}
- onCreate={() => {}}
- onFilter={() => {}}
+ onAddProduct={() => {}}
onNextPage={() => {}}
onPreviousPage={() => {}}
/>
@@ -72,19 +70,17 @@ storiesOf("Categories / CategoryProducts", module)
hasNextPage={true}
hasPreviousPage={false}
products={products}
- onCreate={() => {}}
- onFilter={() => {}}
+ onAddProduct={() => {}}
onNextPage={() => {}}
onPreviousPage={() => {}}
- onRowClick={() => {}}
+ onRowClick={() => () => {}}
/>
))
.add("when loading data", () => (
<CategoryProducts
hasNextPage={true}
hasPreviousPage={false}
- onCreate={() => {}}
- onFilter={() => {}}
+ onAddProduct={() => {}}
onNextPage={() => {}}
onPreviousPage={() => {}}
/>
diff --git a/saleor/static/dashboard-next/storybook/stories/categories/CategoryProperties.tsx b/saleor/static/dashboard-next/storybook/stories/categories/CategoryProperties.tsx
new file mode 100644
index 0000000000..dd502f6515
--- /dev/null
+++ b/saleor/static/dashboard-next/storybook/stories/categories/CategoryProperties.tsx
@@ -0,0 +1,10 @@
+import { storiesOf } from "@storybook/react";
+import * as React from "react";
+
+import CategoryProperties from "../../../categories/components/CategoryProperties";
+import Decorator from "../../Decorator";
+
+storiesOf("Categories / CategoryProperties", module)
+ .addDecorator(Decorator)
+ .add("default", () => <CategoryProperties />)
+ .add("other", () => <CategoryProperties />);
diff --git a/saleor/static/dashboard-next/storybook/stories/categories/CategorySubcategories.tsx b/saleor/static/dashboard-next/storybook/stories/categories/CategorySubcategories.tsx
deleted file mode 100644
index c2a4c421cc..0000000000
--- a/saleor/static/dashboard-next/storybook/stories/categories/CategorySubcategories.tsx
+++ /dev/null
@@ -1,35 +0,0 @@
-import { storiesOf } from "@storybook/react";
-import { DialogContentText } from "material-ui/Dialog";
-import * as React from "react";
-
-import CategorySubcategories from "../../../category/components/CategorySubcategories";
-
-const categories = [
- {
- id: "123123",
- name: "Lorem ipsum dolor"
- },
- {
- id: "876752",
- name: "Mauris vehicula tortor vulputate"
- }
-];
-
-storiesOf("Categories / CategorySubcategories", module)
- .add("with initial data", () => (
- <CategorySubcategories
- subcategories={categories}
- onClickSubcategory={() => {}}
- onCreate={() => {}}
- />
- ))
- .add("without initial data", () => (
- <CategorySubcategories
- subcategories={[]}
- onClickSubcategory={() => {}}
- onCreate={() => {}}
- />
- ))
- .add("when loading data", () => (
- <CategorySubcategories onClickSubcategory={() => {}} onCreate={() => {}} />
- ));
diff --git a/saleor/static/dashboard-next/storybook/stories/categories/ProductFilters.tsx b/saleor/static/dashboard-next/storybook/stories/categories/ProductFilters.tsx
deleted file mode 100644
index b3a0ceb10e..0000000000
--- a/saleor/static/dashboard-next/storybook/stories/categories/ProductFilters.tsx
+++ /dev/null
@@ -1,36 +0,0 @@
-import { storiesOf } from "@storybook/react";
-import * as React from "react";
-
-import ProductFilters from "../../../category/components/ProductFilters";
-
-const productTypes = [
- { id: "123123123", name: "Type 1" },
- { id: "123123124", name: "Type 2" },
- { id: "123123125", name: "Type 3" },
- { id: "123123126", name: "Type 4" }
-];
-const productFilters = {
- highlighted: "false",
- name: "Lorem ipsum",
- price_max: "50",
- price_min: "30",
- productTypes: ["123123123", "123123126"],
- published: "true"
-};
-
-storiesOf("Categories / ProductFilters", module)
- .add("with initial data", () => (
- <ProductFilters
- formState={productFilters}
- handleClear={() => {}}
- handleSubmit={() => {}}
- productTypes={productTypes}
- />
- ))
- .add("without initial data", () => (
- <ProductFilters
- handleClear={() => {}}
- handleSubmit={() => {}}
- productTypes={productTypes}
- />
- ));
diff --git a/saleor/static/dashboard-next/storybook/stories/categories/RootCategoryList.tsx b/saleor/static/dashboard-next/storybook/stories/categories/RootCategoryList.tsx
deleted file mode 100644
index 5d76e7c67e..0000000000
--- a/saleor/static/dashboard-next/storybook/stories/categories/RootCategoryList.tsx
+++ /dev/null
@@ -1,31 +0,0 @@
-import { storiesOf } from "@storybook/react";
-import { DialogContentText } from "material-ui/Dialog";
-import * as React from "react";
-
-import RootCategoryList from "../../../category/components/RootCategoryList";
-
-const categories = [
- {
- id: "123123",
- name: "Lorem ipsum dolor"
- },
- {
- id: "876752",
- name: "Mauris vehicula tortor vulputate"
- }
-];
-
-storiesOf("Categories / RootCategoryList", module)
- .add("with initial data", () => (
- <RootCategoryList
- categories={categories}
- onClick={() => {}}
- onCreate={() => {}}
- />
- ))
- .add("without initial data", () => (
- <RootCategoryList categories={[]} onClick={() => {}} onCreate={() => {}} />
- ))
- .add("when loading data", () => (
- <RootCategoryList onClick={() => {}} onCreate={() => {}} />
- ));