Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Update stories
dominik-zeglen4f35cc5288e0
diff --git a/saleor/static/dashboard-next/categories/components/CategoryBackground/CategoryBackground.tsx b/saleor/static/dashboard-next/categories/components/CategoryBackground/CategoryBackground.tsxindex f4b4b78d5d..1b46be3b99 100644--- a/saleor/static/dashboard-next/categories/components/CategoryBackground/CategoryBackground.tsx+++ b/saleor/static/dashboard-next/categories/components/CategoryBackground/CategoryBackground.tsx@@ -12,10 +12,10 @@ import CardTitle from "../../../components/CardTitle";import i18n from "../../../i18n";interface CategoryBackgroundProps {- onImageDelete: (id: string) => () => void;+ onImageDelete: () => void;placeholderImage: string;- backgroundImage?: {- url?: string;+ backgroundImage: {+ url: string;};onImageUpload(event: React.ChangeEvent<any>);}diff --git a/saleor/static/dashboard-next/categories/components/CategoryBackground/CategoryBackgroundImage.tsx b/saleor/static/dashboard-next/categories/components/CategoryBackground/CategoryBackgroundImage.tsxindex b817368ca0..92f9cc6b5f 100644--- a/saleor/static/dashboard-next/categories/components/CategoryBackground/CategoryBackgroundImage.tsx+++ b/saleor/static/dashboard-next/categories/components/CategoryBackground/CategoryBackgroundImage.tsx@@ -2,42 +2,24 @@ import { withStyles } from "@material-ui/core/styles";import * as React from "react";import ImageTile from "../../../components/ImageTile";-import Toggle from "../../../components/Toggle";-import CategoryDeleteImage from "../CategoryDeleteImage";const decorate = withStyles({});interface CategoryBackgroundImageProps {- onImageDelete?: (id: string) => () => void;- backgroundImage?: {- url?: string;+ onImageDelete: () => void;+ backgroundImage: {+ url: string;};}const CategoryBackgroundImage = decorate<CategoryBackgroundImageProps>(({ onImageDelete, backgroundImage }) => (- <Toggle>- {(opened, { toggle }) => (- <>- <ImageTile- tile={backgroundImage}- onImageDelete={toggle}- deleteIcon={true}- editIcon={false}- />- <CategoryDeleteImage- open={opened}- onClose={toggle}- onConfirm={() => {- onImageDelete(backgroundImage.url)();- toggle();- }}- title={"Remove category background"}- dialogText={"Are you sure you want to delete this image?"}- />- </>- )}- </Toggle>+ <ImageTile+ tile={backgroundImage}+ onImageDelete={onImageDelete}+ deleteIcon={true}+ editIcon={false}+ />));diff --git a/saleor/static/dashboard-next/categories/components/CategoryUpdatePage/CategoryUpdatePage.tsx b/saleor/static/dashboard-next/categories/components/CategoryUpdatePage/CategoryUpdatePage.tsxindex dc5418c5c9..e409d5f9ad 100644--- a/saleor/static/dashboard-next/categories/components/CategoryUpdatePage/CategoryUpdatePage.tsx+++ b/saleor/static/dashboard-next/categories/components/CategoryUpdatePage/CategoryUpdatePage.tsx@@ -2,6 +2,7 @@ import { withStyles } from "@material-ui/core/styles";import * as React from "react";import { UserError } from "../../../";+import { CardSpacer } from "../../../components/CardSpacer";import Container from "../../../components/Container";import Form from "../../../components/Form";import PageHeader from "../../../components/PageHeader";@@ -10,15 +11,14 @@ import SaveButtonBar, {} from "../../../components/SaveButtonBar/SaveButtonBar";import SeoForm from "../../../components/SeoForm";import Tabs, { Tab } from "../../../components/Tab";+import i18n from "../../../i18n";+import { maybe } from "../../../misc";import { MoneyType } from "../../../products";import CategoryDetailsForm from "../../components/CategoryDetailsForm";import CategoryList from "../../components/CategoryList";import CategoryBackground from "../CategoryBackground";import CategoryProductsCard from "../CategoryProductsCard";-import { CardSpacer } from "../../../components/CardSpacer";-import i18n from "../../../i18n";-interface FormData {description: string;name: string;@@ -33,12 +33,13 @@ export interface CategoryUpdatePageProps {category: {SeoDescription: string;SeoTitle: string;+ backgroundImage: {+ url: string;+ };+ id: string;name: string;description: string;};- backgroundImage?: {- url?: string;- };products: Array<{id: string;name: string;@@ -67,7 +68,7 @@ export interface CategoryUpdatePageProps {};loading: boolean;saveButtonBarState?: SaveButtonBarState;- onImageDelete: (id: string) => () => void;+ onImageDelete: () => void;onSubmit(data: FormData);onImageUpload(event: React.ChangeEvent<any>);onNextPage();@@ -88,28 +89,27 @@ const decorate = withStyles({export const CategoryUpdatePage = decorate<CategoryUpdatePageProps>(({+ category,classes,disabled,errors: userErrors,- category,- onImageUpload,- subcategories,loading,- products,pageInfo,- onNextPage,- onPreviousPage,- onProductClick,- onAddProduct,- onDelete,+ placeholderImage,+ products,saveButtonBarState,- onSubmit,- onBack,+ subcategories,onAddCategory,+ onAddProduct,+ onBack,onCategoryClick,+ onDelete,onImageDelete,- placeholderImage,- backgroundImage+ onImageUpload,+ onNextPage,+ onPreviousPage,+ onProductClick,+ onSubmit}) => {const initialData = category? {@@ -139,7 +139,7 @@ export const CategoryUpdatePage = decorate<CategoryUpdatePageProps>(<CategoryBackgroundonImageUpload={onImageUpload}onImageDelete={onImageDelete}- backgroundImage={backgroundImage}+ backgroundImage={maybe(() => category.backgroundImage)}placeholderImage={placeholderImage}/><CardSpacer />diff --git a/saleor/static/dashboard-next/categories/fixtures.ts b/saleor/static/dashboard-next/categories/fixtures.tsindex 404aea367c..7518560b27 100644--- a/saleor/static/dashboard-next/categories/fixtures.ts+++ b/saleor/static/dashboard-next/categories/fixtures.ts@@ -1,5 +1,4 @@import * as block1 from "../../images/block1.jpg";-import { products } from "../products/fixtures";export const categories = [{@@ -63,20 +62,18 @@ export const categories = [}}];-export const category = (placeholderImage: string) => ({+export const category = {SeoDescription:"Across pressure PM food discover recognize. Send letter reach listen. Quickly work plan rule.\nTell lose part purpose do when. Whatever drug contain particularly defense.",SeoTitle: "Apparel",backgroundImage: {url: block1},- children: categories,description:"Across pressure PM food discover recognize. Send letter reach listen. Quickly work plan rule.\nTell lose part purpose do when. Whatever drug contain particularly defense.",id: "c1",- name: "Apparel",- products: products(placeholderImage)-});+ name: "Apparel"+};export const errors = [{field: "name",diff --git a/saleor/static/dashboard-next/storybook/stories/categories/CategoryDeleteDialog.tsx b/saleor/static/dashboard-next/storybook/stories/categories/CategoryDeleteDialog.tsxindex f1bea78281..9697f4bda5 100644--- a/saleor/static/dashboard-next/storybook/stories/categories/CategoryDeleteDialog.tsx+++ b/saleor/static/dashboard-next/storybook/stories/categories/CategoryDeleteDialog.tsx@@ -2,11 +2,9 @@ import { storiesOf } from "@storybook/react";import * as React from "react";import CategoryDeleteDialog from "../../../categories/components/CategoryDeleteDialog";-import { category as categoryFixture } from "../../../categories/fixtures";+import { category } from "../../../categories/fixtures";import Decorator from "../../Decorator";-const category = categoryFixture("");-storiesOf("Views / Categories / Category Delete Dialog", module).addDecorator(Decorator).add("default", () => (diff --git a/saleor/static/dashboard-next/storybook/stories/categories/CategoryUpdatePage.tsx b/saleor/static/dashboard-next/storybook/stories/categories/CategoryUpdatePage.tsxindex b0ef8821f9..fa7a403288 100644--- a/saleor/static/dashboard-next/storybook/stories/categories/CategoryUpdatePage.tsx+++ b/saleor/static/dashboard-next/storybook/stories/categories/CategoryUpdatePage.tsx@@ -2,17 +2,17 @@ import { storiesOf } from "@storybook/react";import * as React from "react";import * as placeholderImage from "../../../../images/placeholder255x255.png";-import { category as categoryFixture } from "../../../categories/fixtures";+import { categories, category } from "../../../categories/fixtures";+import { products as productsFixture } from "../../../products/fixtures";import CategoryUpdatePage, {CategoryUpdatePageProps} from "../../../categories/components/CategoryUpdatePage";import Decorator from "../../Decorator";-const category = categoryFixture(placeholderImage);+const products = productsFixture(placeholderImage);const updateProps: CategoryUpdatePageProps = {- backgroundImage: category.backgroundImage,category,disabled: false,errors: [],@@ -33,15 +33,24 @@ const updateProps: CategoryUpdatePageProps = {hasPreviousPage: true},placeholderImage,- products: category.products,- subcategories: category.children+ products,+ subcategories: categories};storiesOf("Views / Categories / Update category", module).addDecorator(Decorator).add("default", () => <CategoryUpdatePage {...updateProps} />).add("no background", () => (- <CategoryUpdatePage {...updateProps} backgroundImage={{}} />+ <CategoryUpdatePage+ {...updateProps}+ category={{ ...category, backgroundImage: null }}+ />+ ))+ .add("no subcategories", () => (+ <CategoryUpdatePage {...updateProps} subcategories={[]} />+ ))+ .add("no products", () => (+ <CategoryUpdatePage {...updateProps} products={[]} />)).add("loading", () => (<CategoryUpdatePage@@ -51,6 +60,5 @@ storiesOf("Views / Categories / Update category", module)products={undefined}loading={true}category={undefined}- backgroundImage={undefined}/>));