Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add collection create page
dominik-zeglenfbb771ba5bd5
diff --git a/saleor/static/dashboard-next/collections/components/CollectionCreatePage/CollectionCreatePage.tsx b/saleor/static/dashboard-next/collections/components/CollectionCreatePage/CollectionCreatePage.tsxnew file mode 100644index 0000000000..23924b950e--- /dev/null+++ b/saleor/static/dashboard-next/collections/components/CollectionCreatePage/CollectionCreatePage.tsx@@ -0,0 +1,115 @@+import Card from "@material-ui/core/Card";+import CardContent from "@material-ui/core/CardContent";+import { withStyles } from "@material-ui/core/styles";+import * as React from "react";++import { UserError } from "../../..";+import { CardSpacer } from "../../../components/CardSpacer";+import CardTitle from "../../../components/CardTitle";+import { Container } from "../../../components/Container";+import { ControlledSwitch } from "../../../components/ControlledSwitch";+import Form from "../../../components/Form";+import PageHeader from "../../../components/PageHeader";+import SaveButtonBar from "../../../components/SaveButtonBar";+import SeoForm from "../../../components/SeoForm";+import i18n from "../../../i18n";+import CollectionDetails from "../CollectionDetails/CollectionDetails";++export interface CollectionCreatePageFormData {+ name: string;+ isPublished: boolean;+ seoDescription: string;+ seoTitle: string;+}++export interface CollectionCreatePageProps {+ disabled: boolean;+ errors: UserError[];+ onBack: () => void;+ onSubmit: (data: CollectionCreatePageFormData) => void;+}++const initialForm: CollectionCreatePageFormData = {+ isPublished: false,+ name: "",+ seoDescription: "",+ seoTitle: ""+};++const decorate = withStyles(theme => ({+ root: {+ display: "grid" as "grid",+ gridColumnGap: theme.spacing.unit * 2 + "px",+ gridTemplateColumns: "9fr 4fr"+ }+}));+const CollectionCreatePage = decorate<CollectionCreatePageProps>(+ ({ classes, disabled, errors, onBack, onSubmit }) => (+ <Form errors={errors} initial={initialForm} onSubmit={onSubmit}>+ {({ change, data, errors: formErrors, hasChanged, submit }) => (+ <Container width="md">+ <PageHeader+ title={i18n.t("Add collection", {+ context: "page title"+ })}+ onBack={onBack}+ />+ <div className={classes.root}>+ <div>+ <CollectionDetails+ data={data}+ disabled={disabled}+ errors={formErrors}+ onChange={change}+ />+ <CardSpacer />+ <SeoForm+ description={data.seoDescription}+ disabled={disabled}+ descriptionPlaceholder=""+ helperText={i18n.t(+ "Add search engine title and description to make this collection easier to find",+ {+ context: "help text"+ }+ )}+ title={data.seoTitle}+ titlePlaceholder={data.name}+ onChange={change}+ />+ </div>+ <div>+ <div>+ <Card>+ <CardTitle+ title={i18n.t("Availability", {+ context: "collection status"+ })}+ />+ <CardContent>+ <ControlledSwitch+ checked={data.isPublished}+ disabled={disabled}+ name="isPublished"+ onChange={change}+ label={i18n.t("Publish on storefront", {+ context: "button"+ })}+ />+ </CardContent>+ </Card>+ </div>+ </div>+ </div>+ <SaveButtonBar+ disabled={disabled || !hasChanged}+ onCancel={onBack}+ onSave={submit}+ />+ </Container>+ )}+ </Form>+ )+);+CollectionCreatePage.displayName = "CollectionCreatePage";+export default CollectionCreatePage;diff --git a/saleor/static/dashboard-next/collections/components/CollectionCreatePage/index.ts b/saleor/static/dashboard-next/collections/components/CollectionCreatePage/index.tsnew file mode 100644index 0000000000..0ab3d5aa77--- /dev/null+++ b/saleor/static/dashboard-next/collections/components/CollectionCreatePage/index.ts@@ -0,0 +1,2 @@+export { default } from "./CollectionCreatePage";+export * from "./CollectionCreatePage";diff --git a/saleor/static/dashboard-next/collections/fixtures.ts b/saleor/static/dashboard-next/collections/fixtures.tsindex dce2f7e560..fca73c0e03 100644--- a/saleor/static/dashboard-next/collections/fixtures.ts+++ b/saleor/static/dashboard-next/collections/fixtures.ts@@ -105,7 +105,14 @@ export const collection: (thumbnailUrl: placeholderImage}}- ]+ ],+ pageInfo: {+ __typename: "PageInfo",+ endCursor: "",+ hasNextPage: false,+ hasPreviousPage: false,+ startCursor: ""+ }},seoDescription: "",seoTitle: ""diff --git a/saleor/static/dashboard-next/storybook/config.js b/saleor/static/dashboard-next/storybook/config.jsindex 68aaa6cdcb..1b96441cd1 100644--- a/saleor/static/dashboard-next/storybook/config.js+++ b/saleor/static/dashboard-next/storybook/config.js@@ -39,6 +39,7 @@ function loadStories() {require("./stories/categories/CategoryListPage");// Collections+ require("./stories/collections/CollectionCreatePage");require("./stories/collections/CollectionDetailsPage");require("./stories/collections/CollectionListPage");diff --git a/saleor/static/dashboard-next/storybook/stories/collections/CollectionCreatePage.tsx b/saleor/static/dashboard-next/storybook/stories/collections/CollectionCreatePage.tsxnew file mode 100644index 0000000000..f9b99cd468--- /dev/null+++ b/saleor/static/dashboard-next/storybook/stories/collections/CollectionCreatePage.tsx@@ -0,0 +1,18 @@+import { storiesOf } from "@storybook/react";+import * as React from "react";++import CollectionCreatePage, {+ CollectionCreatePageProps+} from "../../../collections/components/CollectionCreatePage";+import Decorator from "../../Decorator";++const props: CollectionCreatePageProps = {+ disabled: false,+ onBack: () => undefined,+ onSubmit: () => undefined+};++storiesOf("Views / Collections / Create collection", module)+ .addDecorator(Decorator)+ .add("default", () => <CollectionCreatePage {...props} />)+ .add("loading", () => <CollectionCreatePage {...props} disabled={true} />);