Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add collection availability card
dominik-zeglenba6345bb8214
diff --git a/saleor/static/dashboard-next/collections/components/CollectionDetailsPage/CollectionDetailsPage.tsx b/saleor/static/dashboard-next/collections/components/CollectionDetailsPage/CollectionDetailsPage.tsxindex b66aec1c30..3573289e02 100644--- a/saleor/static/dashboard-next/collections/components/CollectionDetailsPage/CollectionDetailsPage.tsx+++ b/saleor/static/dashboard-next/collections/components/CollectionDetailsPage/CollectionDetailsPage.tsx@@ -6,23 +6,26 @@ import { Container } from "../../../components/Container";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 { maybe } from "../../../misc";import { CollectionDetails_collection } from "../../types/CollectionDetails";import CollectionDetails from "../CollectionDetails/CollectionDetails";-import CollectionProducts from "../CollectionProducts/CollectionProducts";import { CollectionImage } from "../CollectionImage/CollectionImage";-import SeoForm from "../../../components/SeoForm";-import i18n from "../../../i18n";+import CollectionProducts from "../CollectionProducts/CollectionProducts";+import CollectionStatus from "../CollectionStatus/CollectionStatus";export interface CollectionDetailsPageFormData {name: string;seoDescription: string;seoTitle: string;+ isFeatured: boolean;isPublished: boolean;}export interface CollectionDetailsPageProps extends PageListProps {collection: CollectionDetails_collection;+ isFeatured: boolean;onBack: () => void;onCollectionRemove: () => void;onImageDelete: () => void;@@ -42,6 +45,7 @@ const CollectionDetailsPage = decorate<CollectionDetailsPageProps>(classes,collection,disabled,+ isFeatured,onBack,onCollectionRemove,onImageDelete,@@ -51,6 +55,7 @@ const CollectionDetailsPage = decorate<CollectionDetailsPageProps>(}) => (<Forminitial={{+ isFeatured,isPublished: maybe(() => collection.isPublished),name: maybe(() => collection.name),seoDescription: maybe(() => collection.seoDescription),@@ -97,7 +102,15 @@ const CollectionDetailsPage = decorate<CollectionDetailsPageProps>(onChange={change}/></div>- <div />+ <div>+ <div>+ <CollectionStatus+ data={data}+ disabled={disabled}+ onChange={change}+ />+ </div>+ </div></div><SaveButtonBardisabled={disabled || !hasChanged}diff --git a/saleor/static/dashboard-next/collections/components/CollectionStatus/CollectionStatus.tsx b/saleor/static/dashboard-next/collections/components/CollectionStatus/CollectionStatus.tsxnew file mode 100644index 0000000000..395bb26315--- /dev/null+++ b/saleor/static/dashboard-next/collections/components/CollectionStatus/CollectionStatus.tsx@@ -0,0 +1,54 @@+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 CardTitle from "../../../components/CardTitle";+import { ControlledSwitch } from "../../../components/ControlledSwitch";+import { FormSpacer } from "../../../components/FormSpacer";+import i18n from "../../../i18n";++export interface CollectionStatusProps {+ data: {+ isFeatured: boolean;+ isPublished: boolean;+ };+ disabled: boolean;+ onChange: (event: React.ChangeEvent<any>) => void;+}++const decorate = withStyles({ root: {} });+const CollectionStatus = decorate<CollectionStatusProps>(+ ({ data, disabled, onChange }) => (+ <Card>+ <CardTitle+ title={i18n.t("Availability", {+ context: "collection status"+ })}+ />+ <CardContent>+ <ControlledSwitch+ checked={data.isPublished}+ disabled={disabled}+ name="isPublished"+ onChange={onChange}+ label={i18n.t("Publish on storefront", {+ context: "button"+ })}+ />+ <FormSpacer />+ <ControlledSwitch+ checked={data.isFeatured}+ disabled={disabled}+ name="isFeatured"+ onChange={onChange}+ label={i18n.t("Feature on Homepage", {+ context: "button"+ })}+ />+ </CardContent>+ </Card>+ )+);+CollectionStatus.displayName = "CollectionStatus";+export default CollectionStatus;diff --git a/saleor/static/dashboard-next/collections/components/CollectionStatus/index.ts b/saleor/static/dashboard-next/collections/components/CollectionStatus/index.tsnew file mode 100644index 0000000000..6ac9c935bd--- /dev/null+++ b/saleor/static/dashboard-next/collections/components/CollectionStatus/index.ts@@ -0,0 +1,2 @@+export { default } from "./CollectionStatus";+export * from "./CollectionStatus";diff --git a/saleor/static/dashboard-next/storybook/stories/collections/CollectionDetailsPage.tsx b/saleor/static/dashboard-next/storybook/stories/collections/CollectionDetailsPage.tsxindex 1062d41fb6..6ea600b275 100644--- a/saleor/static/dashboard-next/storybook/stories/collections/CollectionDetailsPage.tsx+++ b/saleor/static/dashboard-next/storybook/stories/collections/CollectionDetailsPage.tsx@@ -19,6 +19,7 @@ const props: CollectionDetailsPageProps = {...pageListProps.default,collection,disabled: false,+ isFeatured: true,onBack: () => undefined,onCollectionRemove: () => undefined,onImageDelete: () => undefined,