Skip to content

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

Show pages in storybook (#2251)

Dominik Żegleń1646dde918a9
diff --git a/saleor/static/dashboard-next/category/fixtures.ts b/saleor/static/dashboard-next/category/fixtures.ts
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/saleor/static/dashboard-next/index.tsx b/saleor/static/dashboard-next/index.tsx
index 580db8034e..3a91cf5d12 100644
--- a/saleor/static/dashboard-next/index.tsx
+++ b/saleor/static/dashboard-next/index.tsx
@@ -14,7 +14,7 @@ import * as Cookies from "universal-cookie";
import AppRoot from "./AppRoot";
import CategorySection from "./category";
import "./i18n";
-import PageSection from "./page";
+import PageSection from "./pages";
import ProductSection from "./products";
import theme from "./theme";
diff --git a/saleor/static/dashboard-next/page/components/PageBaseForm/PageBaseForm.tsx b/saleor/static/dashboard-next/page/components/PageBaseForm/PageBaseForm.tsx
deleted file mode 100644
index 462efb8734..0000000000
--- a/saleor/static/dashboard-next/page/components/PageBaseForm/PageBaseForm.tsx
+++ /dev/null
@@ -1,140 +0,0 @@
-import Button from "material-ui/Button";
-import { CardContent } from "material-ui/Card";
-import Grid from "material-ui/Grid";
-import { withStyles, WithStyles } from "material-ui/styles";
-import TextField from "material-ui/TextField";
-import Toolbar from "material-ui/Toolbar";
-import Typography from "material-ui/Typography";
-import * as React from "react";
-
-import ControlledCheckbox from "../../../components/ControlledCheckbox";
-import FormSpacer from "../../../components/FormSpacer";
-import RichTextEditor from "../../../components/RichTextEditor";
-import i18n from "../../../i18n";
-
-interface PageBaseFormComponentProps {
- availableOn: string;
- content: string;
- created?: string;
- errors?: Array<{ field: string; message: string }>;
- isVisible: boolean;
- slug: string;
- title: string;
- onChange?(event: React.ChangeEvent<any>);
-}
-
-const decorate = withStyles(theme => ({
- addHelperTextPadding: {
- [theme.breakpoints.up("md")]: {
- paddingBottom: theme.spacing.unit * 2.5
- }
- },
- cardActions: {
- flexDirection: "row-reverse" as "row-reverse"
- }
-}));
-
-export const PageBaseForm = decorate<PageBaseFormComponentProps>(
- ({
- classes,
- created,
- errors,
- title,
- content,
- slug,
- availableOn,
- isVisible,
- onChange
- }) => {
- const errorList: { [key: string]: string } = errors
- ? errors.reduce((acc, curr) => {
- acc[curr.field] = curr.message;
- return acc;
- }, {})
- : {};
- return (
- <CardContent>
- <Grid container spacing={16}>
- <Grid item xs={12} md={9}>
- <TextField
- autoFocus
- name="title"
- label={i18n.t("Title", { context: "object" })}
- value={title}
- onChange={onChange}
- className={
- (errors ? !errorList.title : true)
- ? classes.addHelperTextPadding
- : ""
- }
- error={!!(errorList && errorList.title)}
- helperText={errorList && errorList.title ? errorList.title : ""}
- fullWidth
- />
- <FormSpacer />
- <RichTextEditor
- value={content}
- name="content"
- label={i18n.t("Content", { context: "object" })}
- helperText={
- errorList && errorList.content
- ? errorList.content
- : i18n.t("Select text to enable text-formatting tools.", {
- context: "object"
- })
- }
- onChange={onChange}
- error={!!(errorList && errorList.content)}
- fullWidth
- />
- </Grid>
- <Grid item xs={12} md={3}>
- <TextField
- name="slug"
- label={i18n.t("Slug", { context: "object" })}
- value={slug}
- helperText={
- errorList && errorList.slug
- ? errorList.slug
- : i18n.t("Slug is being used to create page URL", {
- context: "object"
- })
- }
- onChange={onChange}
- error={!!(errorList && errorList.slug)}
- fullWidth
- />
- <FormSpacer />
- <TextField
- name="availableOn"
- label={i18n.t("Available on", { context: "label" })}
- type="date"
- value={availableOn}
- onChange={onChange}
- InputLabelProps={{
- shrink: true
- }}
- helperText={
- errorList && errorList.availableOn ? errorList.availableOn : ""
- }
- error={!!(errorList && errorList.availableOn)}
- />
- <FormSpacer />
- {created && (
- <Typography variant="body1">Created at: {created}</Typography>
- )}
- <FormSpacer />
- <ControlledCheckbox
- checked={isVisible}
- label={i18n.t("Published", { context: "label" })}
- name="isVisible"
- onChange={onChange}
- />
- </Grid>
- </Grid>
- </CardContent>
- );
- }
-);
-
-export default PageBaseForm;
diff --git a/saleor/static/dashboard-next/page/components/PageBaseForm/index.ts b/saleor/static/dashboard-next/page/components/PageBaseForm/index.ts
deleted file mode 100644
index 7015a74050..0000000000
--- a/saleor/static/dashboard-next/page/components/PageBaseForm/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export { default } from "./PageBaseForm";
-export * from "./PageBaseForm";
diff --git a/saleor/static/dashboard-next/page/components/PageFilters/PageFilters.tsx b/saleor/static/dashboard-next/page/components/PageFilters/PageFilters.tsx
deleted file mode 100644
index 7e022c6abf..0000000000
--- a/saleor/static/dashboard-next/page/components/PageFilters/PageFilters.tsx
+++ /dev/null
@@ -1,83 +0,0 @@
-import TextField from "material-ui/TextField";
-import * as React from "react";
-
-import FilterCard from "../../../components/FilterCard";
-import FormSpacer from "../../../components/FormSpacer";
-import i18n from "../../../i18n";
-
-interface PageFiltersState {
- title: string;
- url: string;
- debounceTimeout: any;
-}
-
-interface PageFiltersProps {
- formState?: {
- title: string;
- url: string;
- };
- handleClear();
- handleSubmit(formState: any);
-}
-
-export class PageFilters extends React.Component<
- PageFiltersProps,
- PageFiltersState
-> {
- static defaultState = {
- title: "",
- url: ""
- };
-
- constructor(props) {
- super(props);
- this.state = { ...PageFilters.defaultState, ...props.formState };
- }
-
- render() {
- const { handleClear, handleSubmit } = this.props;
- 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(PageFilters.defaultState);
- handleClear();
- };
- return (
- <FilterCard handleClear={handleClearButtonClick}>
- <TextField
- fullWidth
- name="title"
- label={i18n.t("Title", {
- context: "Product filter field label"
- })}
- onChange={handleInputChange}
- value={this.state.title || ""}
- />
- <FormSpacer />
- <TextField
- fullWidth
- name="url"
- label={i18n.t("Url", {
- context: "Product filter field label"
- })}
- onChange={handleInputChange}
- value={this.state.url || ""}
- />
- </FilterCard>
- );
- }
-}
-
-export default PageFilters;
diff --git a/saleor/static/dashboard-next/page/components/PageFilters/index.ts b/saleor/static/dashboard-next/page/components/PageFilters/index.ts
deleted file mode 100644
index a5db9b15f5..0000000000
--- a/saleor/static/dashboard-next/page/components/PageFilters/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export { default } from "./PageFilters";
-export * from "./PageFilters";
diff --git a/saleor/static/dashboard-next/page/components/PageList/PageList.tsx b/saleor/static/dashboard-next/page/components/PageList/PageList.tsx
deleted file mode 100644
index 64ebe81f16..0000000000
--- a/saleor/static/dashboard-next/page/components/PageList/PageList.tsx
+++ /dev/null
@@ -1,122 +0,0 @@
-import VisibilityIcon from "@material-ui/icons/Visibility";
-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 { Link } from "react-router-dom";
-
-import Skeleton from "../../../components/Skeleton";
-import TablePagination from "../../../components/TablePagination";
-import { PageListQuery } from "../../../gql-types";
-import i18n from "../../../i18n";
-
-interface PageListComponentProps {
- pages?: PageListQuery["pages"]["edges"];
- pageInfo: PageListQuery["pages"]["pageInfo"];
- handlePreviousPage();
- handleNextPage();
- onEditClick(id: string);
- onShowPageClick(slug: string);
-}
-
-const decorate = withStyles({
- link: {
- color: blue[500],
- cursor: "pointer",
- textDecoration: "none"
- },
- textRight: {
- textAlign: "right"
- }
-});
-
-export const PageListComponent = decorate<PageListComponentProps>(
- ({
- classes,
- handlePreviousPage,
- handleNextPage,
- onEditClick,
- onShowPageClick,
- pages,
- pageInfo
- }) => (
- <Table>
- <TableHead>
- <TableRow>
- <TableCell>{i18n.t("Name", { context: "object" })}</TableCell>
- <TableCell>{i18n.t("Url", { context: "object" })}</TableCell>
- <TableCell>{i18n.t("Visibility", { context: "object" })}</TableCell>
- <TableCell className={classes.textRight}>
- {i18n.t("Actions", { context: "object" })}
- </TableCell>
- </TableRow>
- </TableHead>
- <TableFooter>
- <TableRow>
- <TablePagination
- colSpan={4}
- hasNextPage={pageInfo ? pageInfo.hasNextPage : false}
- onNextPage={handleNextPage}
- hasPreviousPage={pageInfo ? pageInfo.hasPreviousPage : false}
- onPreviousPage={handlePreviousPage}
- />
- </TableRow>
- </TableFooter>
- <TableBody>
- {pages === undefined || pages === null ? (
- <TableRow>
- <TableCell>
- <Skeleton />
- </TableCell>
- <TableCell>
- <Skeleton />
- </TableCell>
- <TableCell>
- <Skeleton />
- </TableCell>
- <TableCell className={classes.textRight}>
- <IconButton disabled>
- <VisibilityIcon />
- </IconButton>
- </TableCell>
- </TableRow>
- ) : pages.length > 0 ? (
- pages.map(edge => (
- <TableRow key={edge.node.id}>
- <TableCell
- onClick={onEditClick(edge.node.id)}
- className={classes.link}
- >
- {edge.node.title}
- </TableCell>
- <TableCell>{`/${edge.node.slug}`}</TableCell>
- <TableCell>
- {edge.node.isVisible
- ? i18n.t("Published", { context: "object" })
- : i18n.t("Not published", { context: "object" })}
- </TableCell>
- <TableCell className={classes.textRight}>
- <IconButton onClick={onShowPageClick(edge.node.slug)}>
- <VisibilityIcon />
- </IconButton>
- </TableCell>
- </TableRow>
- ))
- ) : (
- <TableRow>
- <TableCell colSpan={3}>{i18n.t("No pages found")}</TableCell>
- </TableRow>
- )}
- </TableBody>
- </Table>
- )
-);
-
-export default PageListComponent;
diff --git a/saleor/static/dashboard-next/page/views/PageCreateForm.tsx b/saleor/static/dashboard-next/page/views/PageCreateForm.tsx
deleted file mode 100644
index 9d0b553984..0000000000
--- a/saleor/static/dashboard-next/page/views/PageCreateForm.tsx
+++ /dev/null
@@ -1,83 +0,0 @@
-import Card from "material-ui/Card";
-import * as React from "react";
-import { Redirect } from "react-router";
-
-import { pageListUrl } from "..";
-import Form, { FormActions, FormProps } from "../../components/Form";
-import { NavigatorLink } from "../../components/Navigator";
-import PageHeader from "../../components/PageHeader";
-import { PageCreateMutationVariables } from "../../gql-types";
-import i18n from "../../i18n";
-import PageBaseForm from "../components/PageBaseForm";
-import { pageCreateMutation, TypedPageCreateMutation } from "../mutations";
-
-const PageForm: React.ComponentType<
- FormProps<PageCreateMutationVariables>
-> = Form;
-
-interface PageCreateFormProps {
- id: string;
-}
-
-export const PageCreateForm: React.StatelessComponent<PageCreateFormProps> = ({
- id
-}) => (
- <TypedPageCreateMutation mutation={pageCreateMutation}>
- {(createPage, { called, data: createResult, error, loading }) => {
- if (called && !loading && !createResult.pageCreate.errors.length) {
- return <Redirect to={pageListUrl} push={false} />;
- }
- return (
- <NavigatorLink to={pageListUrl}>
- {handleCancel => (
- <PageForm
- initial={{
- availableOn: "",
- content: "",
- isVisible: false,
- slug: "",
- title: ""
- }}
- onSubmit={data =>
- createPage({
- variables: data
- })
- }
- >
- {({ change, data, submit: handleSubmit }) => (
- <Card>
- <PageHeader
- onBack={handleCancel}
- title={i18n.t("Add page", { context: "title" })}
- />
- <PageBaseForm
- errors={
- called && createResult
- ? createResult.pageCreate.errors
- : []
- }
- title={data.title}
- content={data.content}
- slug={data.slug}
- availableOn={data.availableOn}
- isVisible={data.isVisible}
- onChange={change}
- />
- <FormActions
- onCancel={handleCancel}
- onSubmit={handleSubmit}
- submitLabel={i18n.t("Save", {
- context: "button"
- })}
- />
- </Card>
- )}
- </PageForm>
- )}
- </NavigatorLink>
- );
- }}
- </TypedPageCreateMutation>
-);
-
-export default PageCreateForm;
diff --git a/saleor/static/dashboard-next/page/views/PageUpdateForm.tsx b/saleor/static/dashboard-next/page/views/PageUpdateForm.tsx
deleted file mode 100644
index f75b71260c..0000000000
--- a/saleor/static/dashboard-next/page/views/PageUpdateForm.tsx
+++ /dev/null
@@ -1,213 +0,0 @@
-import DeleteIcon from "@material-ui/icons/Delete";
-import Card from "material-ui/Card";
-import { DialogContentText } from "material-ui/Dialog";
-import Grid from "material-ui/Grid";
-import IconButton from "material-ui/IconButton";
-import { CircularProgress } from "material-ui/Progress";
-import * as React from "react";
-import { Redirect } from "react-router";
-
-import { pageListUrl } from "..";
-import ErrorMessageCard from "../../components/ErrorMessageCard";
-import Form, { FormActions, FormProps } from "../../components/Form";
-import { NavigatorLink } from "../../components/Navigator";
-import PageHeader from "../../components/PageHeader";
-import { PageUpdateMutationVariables } from "../../gql-types";
-import i18n from "../../i18n";
-import PageBaseForm from "../components/PageBaseForm";
-import PageDeleteDialog from "../components/PageDeleteDialog";
-import {
- pageDeleteMutation,
- pageUpdateMutation,
- TypedPageDeleteMutation,
- TypedPageUpdateMutation
-} from "../mutations";
-import { pageDetailsQuery, TypedPageDetailsQuery } from "../queries";
-
-interface PageUpdateFormProps {
- id: string;
-}
-
-interface PageUpdateFormState {
- opened: boolean;
-}
-
-const PageForm: React.ComponentType<
- FormProps<PageUpdateMutationVariables>
-> = Form;
-
-export class PageUpdateForm extends React.Component<
- PageUpdateFormProps,
- PageUpdateFormState
-> {
- state = { opened: false };
-
- handleRemoveButtonClick = () => {
- this.setState(prevState => ({ opened: !prevState.opened }));
- };
-
- render() {
- const { id } = this.props;
- return (
- <TypedPageDetailsQuery query={pageDetailsQuery} variables={{ id }}>
- {({ data: detailsResult, error, loading }) => {
- if (error) {
- return (
- <Grid container spacing={16}>
- <Grid item xs={12} md={9}>
- <ErrorMessageCard
- message={i18n.t("Unable to find matching page.")}
- />
- </Grid>
- </Grid>
- );
- }
- if (loading) {
- return <CircularProgress />;
- }
- const { page } = detailsResult;
- const formInitialValues = {
- availableOn: page.availableOn,
- content: page.content,
- isVisible: page.isVisible,
- slug: page.slug,
- title: page.title
- };
- return (
- <TypedPageDeleteMutation mutation={pageDeleteMutation}>
- {(
- deletePage,
- { called, data: deleteResult, error, loading: deleteInProgress }
- ) => {
- if (called && !deleteInProgress) {
- if (error) {
- console.error(error);
- return;
- }
- if (
- deleteResult.pageDelete.errors &&
- deleteResult.pageDelete.errors.length
- ) {
- console.error(deleteResult.pageDelete);
- return;
- }
- // FIXME: component is loaded with previous state (meaning that deleted page will still be there until table reload)
- this.handleRemoveButtonClick();
- return <Redirect to={pageListUrl} />;
- }
- return (
- <TypedPageUpdateMutation mutation={pageUpdateMutation}>
- {(
- updatePage,
- {
- called,
- data: updateResult,
- error,
- loading: updateInProgress
- }
- ) => {
- if (
- called &&
- !updateInProgress &&
- !updateResult.pageUpdate.errors.length
- ) {
- if (error) {
- console.error(error);
- return;
- }
- return <Redirect to={pageListUrl} />;
- }
- return (
- <NavigatorLink to={pageListUrl}>
- {handleCancel => (
- <>
- <Card>
- <PageForm
- initial={{
- availableOn: page.availableOn || "",
- content: page.content || "",
- id,
- isVisible: page.isVisible,
- slug: page.slug || "",
- title: page.title || ""
- }}
- onSubmit={data =>
- updatePage({
- variables: data
- })
- }
- >
- {({ change, data, submit: handleSubmit }) => (
- <>
- <PageHeader
- onBack={handleCancel}
- title={i18n.t("Page details", {
- context: "title"
- })}
- >
- <IconButton
- onClick={this.handleRemoveButtonClick}
- >
- <DeleteIcon />
- </IconButton>
- </PageHeader>
- <PageBaseForm
- onChange={change}
- created={page.created}
- errors={
- updateResult
- ? updateResult.pageUpdate.errors
- : []
- }
- title={data.title}
- content={data.content}
- slug={data.slug}
- availableOn={data.availableOn}
- isVisible={data.isVisible}
- />
- <FormActions
- onCancel={handleCancel}
- onSubmit={handleSubmit}
- submitLabel={i18n.t("Save", {
- context: "button"
- })}
- />
- </>
- )}
- </PageForm>
- </Card>
- {!loading && (
- <PageDeleteDialog
- onClose={this.handleRemoveButtonClick}
- onConfirm={() =>
- deletePage({ variables: { id } })
- }
- opened={this.state.opened}
- >
- <DialogContentText
- dangerouslySetInnerHTML={{
- __html: i18n.t(
- "Are you sure you want to remove <strong>{{name}}</strong>?",
- { name: page.title }
- )
- }}
- />
- </PageDeleteDialog>
- )}
- </>
- )}
- </NavigatorLink>
- );
- }}
- </TypedPageUpdateMutation>
- );
- }}
- </TypedPageDeleteMutation>
- );
- }}
- </TypedPageDetailsQuery>
- );
- }
-}
-
-export default PageUpdateForm;
diff --git a/saleor/static/dashboard-next/pages/components/PageContent/PageContent.tsx b/saleor/static/dashboard-next/pages/components/PageContent/PageContent.tsx
new file mode 100644
index 0000000000..49b1fc4276
--- /dev/null
+++ b/saleor/static/dashboard-next/pages/components/PageContent/PageContent.tsx
@@ -0,0 +1,76 @@
+import Card, { CardContent } from "material-ui/Card";
+import { withStyles } from "material-ui/styles";
+import TextField from "material-ui/TextField";
+import * as React from "react";
+
+import FormSpacer from "../../../components/FormSpacer";
+import RichTextEditor from "../../../components/RichTextEditor";
+import i18n from "../../../i18n";
+
+interface PageContentProps {
+ content: string;
+ errors?: Array<{ field: string; message: string }>;
+ loading?: boolean;
+ title: string;
+ onChange?(event: React.ChangeEvent<any>);
+}
+
+const decorate = withStyles(theme => ({
+ addHelperTextPadding: {
+ [theme.breakpoints.up("md")]: {
+ paddingBottom: theme.spacing.unit * 2.5
+ }
+ }
+}));
+const PageContent = decorate<PageContentProps>(
+ ({ classes, content, errors, loading, title, onChange }) => {
+ const errorList: { [key: string]: string } = errors
+ ? errors.reduce((acc, curr) => {
+ acc[curr.field] = curr.message;
+ return acc;
+ }, {})
+ : {};
+ return (
+ <Card>
+ <CardContent>
+ <TextField
+ autoFocus
+ disabled={loading}
+ name="title"
+ label={i18n.t("Title", { context: "object" })}
+ value={title}
+ onChange={onChange}
+ className={
+ (errors
+ ? !errorList.title
+ : true)
+ ? classes.addHelperTextPadding
+ : ""
+ }
+ error={!!(errorList && errorList.title)}
+ helperText={errorList && errorList.title ? errorList.title : ""}
+ fullWidth
+ />
+ <FormSpacer />
+ <RichTextEditor
+ disabled={loading}
+ value={content}
+ name="content"
+ label={i18n.t("Content", { context: "object" })}
+ helperText={
+ errorList && errorList.content
+ ? errorList.content
+ : i18n.t("Select text to enable text-formatting tools.", {
+ context: "object"
+ })
+ }
+ onChange={onChange}
+ error={!!(errorList && errorList.content)}
+ fullWidth
+ />
+ </CardContent>
+ </Card>
+ );
+ }
+);
+export default PageContent;
diff --git a/saleor/static/dashboard-next/pages/components/PageContent/index.ts b/saleor/static/dashboard-next/pages/components/PageContent/index.ts
new file mode 100644
index 0000000000..181cfe053d
--- /dev/null
+++ b/saleor/static/dashboard-next/pages/components/PageContent/index.ts
@@ -0,0 +1,2 @@
+export { default } from "./PageContent";
+export * from "./PageContent";
diff --git a/saleor/static/dashboard-next/page/components/PageDeleteDialog.tsx b/saleor/static/dashboard-next/pages/components/PageDeleteDialog/PageDeleteDialog.tsx
similarity index 77%
rename from saleor/static/dashboard-next/page/components/PageDeleteDialog.tsx
rename to saleor/static/dashboard-next/pages/components/PageDeleteDialog/PageDeleteDialog.tsx
index 60cfeb7aa3..836bf44ab0 100644
--- a/saleor/static/dashboard-next/page/components/PageDeleteDialog.tsx
+++ b/saleor/static/dashboard-next/pages/components/PageDeleteDialog/PageDeleteDialog.tsx
@@ -2,12 +2,13 @@ import Button from "material-ui/Button";
import Dialog, {
DialogActions,
DialogContent,
+ DialogContentText,
DialogTitle
} from "material-ui/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: {
@@ -21,6 +22,7 @@ const decorate = withStyles(theme => ({
interface PageDeleteDialogProps {
opened?: boolean;
+ title: string;
onClose?();
onConfirm?();
}
@@ -30,6 +32,7 @@ const PageDeleteDialog = decorate<PageDeleteDialogProps>(props => {
children,
classes,
opened,
+ title,
onConfirm,
onClose,
...dialogProps
@@ -37,7 +40,16 @@ const PageDeleteDialog = decorate<PageDeleteDialogProps>(props => {
return (
<Dialog open={opened} {...dialogProps}>
<DialogTitle>{i18n.t("Delete page", { context: "title" })}</DialogTitle>
- <DialogContent>{children}</DialogContent>
+ <DialogContent>
+ <DialogContentText
+ dangerouslySetInnerHTML={{
+ __html: i18n.t(
+ "Are you sure you want to remove <strong>{{name}}</strong>?",
+ { name: title }
+ )
+ }}
+ />
+ </DialogContent>
<DialogActions>
<Button onClick={onClose}>
{i18n.t("Cancel", { context: "button" })}
diff --git a/saleor/static/dashboard-next/pages/components/PageDeleteDialog/index.ts b/saleor/static/dashboard-next/pages/components/PageDeleteDialog/index.ts
new file mode 100644
index 0000000000..44f9256bb3
--- /dev/null
+++ b/saleor/static/dashboard-next/pages/components/PageDeleteDialog/index.ts
@@ -0,0 +1,2 @@
+export { default } from "./PageDeleteDialog";
+export * from "./PageDeleteDialog";
diff --git a/saleor/static/dashboard-next/pages/components/PageDetailsPage/PageDetailsPage.tsx b/saleor/static/dashboard-next/pages/components/PageDetailsPage/PageDetailsPage.tsx
new file mode 100644
index 0000000000..3f66de3527
--- /dev/null
+++ b/saleor/static/dashboard-next/pages/components/PageDetailsPage/PageDetailsPage.tsx
@@ -0,0 +1,110 @@
+import DeleteIcon from "@material-ui/icons/Delete";
+import IconButton from "material-ui/IconButton";
+import { withStyles } from "material-ui/styles";
+import * as React from "react";
+
+import { Container } from "../../../components/Container";
+import Form, { FormProps } from "../../../components/Form";
+import PageHeader from "../../../components/PageHeader";
+import SaveButtonBar from "../../../components/SaveButtonBar";
+import Toggle from "../../../components/Toggle";
+import i18n from "../../../i18n";
+import PageContent from "../PageContent";
+import PageDeleteDialog from "../PageDeleteDialog";
+import PageProperties from "../PageProperties";
+
+interface PageInput {
+ title: string;
+ content: string;
+ slug: string;
+ availableOn: string;
+ isVisible: boolean;
+}
+interface PageDetailsPageProps {
+ page?: PageInput & {
+ created?: string;
+ };
+ errors?: Array<{
+ field: string;
+ message: string;
+ }>;
+ disabled?: boolean;
+ title?: string;
+ onBack?();
+ onDelete?();
+ onSubmit(data: PageInput);
+}
+
+const defaultPage = {
+ availableOn: "",
+ content: "",
+ isVisible: false,
+ slug: "",
+ title: ""
+};
+const PageForm: React.ComponentType<FormProps<PageInput>> = Form;
+const decorate = withStyles(theme => ({
+ root: {
+ display: "grid" as "grid",
+ gridColumnGap: `${theme.spacing.unit * 2}px`,
+ gridTemplateColumns: "3fr 1fr"
+ }
+}));
+const PageDetailsPage = decorate<PageDetailsPageProps>(
+ ({ classes, errors, disabled, page, title, onBack, onDelete, onSubmit }) => (
+ <PageForm
+ key={page ? "ready" : "loading"}
+ initial={page ? page : defaultPage}
+ onSubmit={onSubmit}
+ >
+ {({ change, data, submit }) => (
+ <Toggle>
+ {(opened, { toggle: togglePageDeleteDialog }) => (
+ <Container width="md">
+ <>
+ <PageHeader onBack={onBack} title={title}>
+ {!!onDelete && (
+ <IconButton onClick={togglePageDeleteDialog}>
+ <DeleteIcon />
+ </IconButton>
+ )}
+ </PageHeader>
+ <div className={classes.root}>
+ <div>
+ <PageContent
+ loading={disabled}
+ onChange={change}
+ content={data.content}
+ title={data.title}
+ />
+ </div>
+ <div>
+ <PageProperties
+ availableOn={data.availableOn}
+ created={page ? page.created : undefined}
+ isVisible={data.isVisible}
+ loading={disabled}
+ onChange={change}
+ slug={data.slug}
+ />
+ </div>
+ </div>
+ <SaveButtonBar onBack={onBack} onSave={submit} />
+ {!!onDelete &&
+ !disabled && (
+ <PageDeleteDialog
+ opened={opened}
+ onConfirm={onDelete}
+ onClose={togglePageDeleteDialog}
+ title={page.title}
+ />
+ )}
+ </>
+ </Container>
+ )}
+ </Toggle>
+ )}
+ </PageForm>
+ )
+);
+export default PageDetailsPage;
diff --git a/saleor/static/dashboard-next/pages/components/PageDetailsPage/index.ts b/saleor/static/dashboard-next/pages/components/PageDetailsPage/index.ts
new file mode 100644
index 0000000000..20a714c9cc
--- /dev/null
+++ b/saleor/static/dashboard-next/pages/components/PageDetailsPage/index.ts
@@ -0,0 +1,2 @@
+export { default } from "./PageDetailsPage";
+export * from "./PageDetailsPage";
diff --git a/saleor/static/dashboard-next/pages/components/PageList/PageList.tsx b/saleor/static/dashboard-next/pages/components/PageList/PageList.tsx
new file mode 100644
index 0000000000..211a19d5d5
--- /dev/null
+++ b/saleor/static/dashboard-next/pages/components/PageList/PageList.tsx
@@ -0,0 +1,133 @@
+import VisibilityIcon from "@material-ui/icons/Visibility";
+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 { Link } from "react-router-dom";
+
+import Skeleton from "../../../components/Skeleton";
+import TablePagination from "../../../components/TablePagination";
+import { PageListQuery } from "../../../gql-types";
+import i18n from "../../../i18n";
+
+interface PageListComponentProps {
+ pages?: Array<{
+ id: string;
+ title: string;
+ slug: string;
+ isVisible: boolean;
+ }>;
+ pageInfo?: {
+ hasNextPage: boolean;
+ hasPreviousPage: boolean;
+ };
+ onEditClick(id: string);
+ onNextPage();
+ onPreviousPage();
+ onShowPageClick(slug: string);
+}
+
+const decorate = withStyles({
+ link: {
+ color: blue[500],
+ cursor: "pointer",
+ textDecoration: "none"
+ },
+ textRight: {
+ textAlign: "right"
+ }
+});
+
+export const PageListComponent = decorate<PageListComponentProps>(
+ ({
+ classes,
+ onEditClick,
+ onNextPage,
+ onPreviousPage,
+ onShowPageClick,
+ pageInfo,
+ pages
+ }) => (
+ <Card>
+ <Table>
+ <TableHead>
+ <TableRow>
+ <TableCell>{i18n.t("Name", { context: "object" })}</TableCell>
+ <TableCell>{i18n.t("Url", { context: "object" })}</TableCell>
+ <TableCell>{i18n.t("Visibility", { context: "object" })}</TableCell>
+ <TableCell className={classes.textRight}>
+ {i18n.t("Actions", { context: "object" })}
+ </TableCell>
+ </TableRow>
+ </TableHead>
+ <TableFooter>
+ <TableRow>
+ <TablePagination
+ colSpan={4}
+ hasNextPage={pageInfo ? pageInfo.hasNextPage : false}
+ hasPreviousPage={pageInfo ? pageInfo.hasPreviousPage : false}
+ onNextPage={onNextPage}
+ onPreviousPage={onPreviousPage}
+ />
+ </TableRow>
+ </TableFooter>
+ <TableBody>
+ {pages === undefined || pages === null ? (
+ <TableRow>
+ <TableCell>
+ <Skeleton />
+ </TableCell>
+ <TableCell>
+ <Skeleton />
+ </TableCell>
+ <TableCell>
+ <Skeleton />
+ </TableCell>
+ <TableCell className={classes.textRight}>
+ <IconButton disabled>
+ <VisibilityIcon />
+ </IconButton>
+ </TableCell>
+ </TableRow>
+ ) : pages.length > 0 ? (
+ pages.map(page => (
+ <TableRow key={page.id}>
+ <TableCell
+ onClick={onEditClick(page.id)}
+ className={classes.link}
+ >
+ {page.title}
+ </TableCell>
+ <TableCell>{`/${page.slug}`}</TableCell>
+ <TableCell>
+ {page.isVisible
+ ? i18n.t("Published", { context: "object" })
+ : i18n.t("Not published", { context: "object" })}
+ </TableCell>
+ <TableCell className={classes.textRight}>
+ <IconButton onClick={onShowPageClick(page.slug)}>
+ <VisibilityIcon />
+ </IconButton>
+ </TableCell>
+ </TableRow>
+ ))
+ ) : (
+ <TableRow>
+ <TableCell colSpan={4}>{i18n.t("No pages found")}</TableCell>
+ </TableRow>
+ )}
+ </TableBody>
+ </Table>
+ </Card>
+ )
+);
+
+export default PageListComponent;
diff --git a/saleor/static/dashboard-next/page/components/PageList/index.ts b/saleor/static/dashboard-next/pages/components/PageList/index.ts
similarity index 100%
rename from saleor/static/dashboard-next/page/components/PageList/index.ts
rename to saleor/static/dashboard-next/pages/components/PageList/index.ts
diff --git a/saleor/static/dashboard-next/pages/components/PageListPage/PageListPage.tsx b/saleor/static/dashboard-next/pages/components/PageListPage/PageListPage.tsx
new file mode 100644
index 0000000000..8cf1475777
--- /dev/null
+++ b/saleor/static/dashboard-next/pages/components/PageListPage/PageListPage.tsx
@@ -0,0 +1,65 @@
+import AddIcon from "@material-ui/icons/Add";
+import Card from "material-ui/Card";
+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 i18n from "../../../i18n";
+import PageList from "../../components/PageList";
+
+interface PageListPageProps {
+ pages?: Array<{
+ id: string;
+ title: string;
+ slug: string;
+ isVisible: boolean;
+ }>;
+ pageInfo?: {
+ hasNextPage: boolean;
+ hasPreviousPage: boolean;
+ };
+ onAddPage?();
+ onBack?();
+ onEditPage?(id: string);
+ onNextPage?();
+ onPreviousPage?();
+ onShowPage?(slug: string);
+}
+
+const decorate = withStyles(theme => ({ root: {} }));
+const PageListPage = decorate<PageListPageProps>(
+ ({
+ classes,
+ pages,
+ pageInfo,
+ onAddPage,
+ onBack,
+ onEditPage,
+ onNextPage,
+ onPreviousPage,
+ onShowPage
+ }) => (
+ <Container width="md">
+ <PageHeader
+ title={i18n.t("Pages", {
+ context: "title"
+ })}
+ >
+ <IconButton disabled={!onAddPage} onClick={onAddPage}>
+ <AddIcon />
+ </IconButton>
+ </PageHeader>
+ <PageList
+ pageInfo={pageInfo}
+ pages={pages}
+ onNextPage={onNextPage}
+ onPreviousPage={onPreviousPage}
+ onEditClick={onEditPage}
+ onShowPageClick={onShowPage}
+ />
+ </Container>
+ )
+);
+export default PageListPage;
diff --git a/saleor/static/dashboard-next/pages/components/PageListPage/index.ts b/saleor/static/dashboard-next/pages/components/PageListPage/index.ts
new file mode 100644
index 0000000000..f91170df48
--- /dev/null
+++ b/saleor/static/dashboard-next/pages/components/PageListPage/index.ts
@@ -0,0 +1,2 @@
+export { default } from "./PageListPage";
+export * from "./PageListPage";
diff --git a/saleor/static/dashboard-next/pages/components/PageProperties/PageProperties.tsx b/saleor/static/dashboard-next/pages/components/PageProperties/PageProperties.tsx
new file mode 100644
index 0000000000..e6a46cdbc4
--- /dev/null
+++ b/saleor/static/dashboard-next/pages/components/PageProperties/PageProperties.tsx
@@ -0,0 +1,96 @@
+import Card, { CardContent } from "material-ui/Card";
+import { withStyles } from "material-ui/styles";
+import TextField from "material-ui/TextField";
+import Typography from "material-ui/Typography";
+import * as React from "react";
+
+import ControlledCheckbox from "../../../components/ControlledCheckbox";
+import DateFormatter from "../../../components/DateFormatter";
+import FormSpacer from "../../../components/FormSpacer";
+import i18n from "../../../i18n";
+
+interface PagePropertiesProps {
+ availableOn: string;
+ created?: string;
+ errors?: Array<{ field: string; message: string }>;
+ isVisible: boolean;
+ loading?: boolean;
+ slug?: string;
+ onChange?(event: React.ChangeEvent<any>);
+}
+
+const decorate = withStyles(theme => ({ root: {} }));
+const PageProperties = decorate<PagePropertiesProps>(
+ ({
+ classes,
+ created,
+ errors,
+ slug,
+ availableOn,
+ loading,
+ isVisible,
+ onChange
+ }) => {
+ const errorList: { [key: string]: string } = errors
+ ? errors.reduce((acc, curr) => {
+ acc[curr.field] = curr.message;
+ return acc;
+ }, {})
+ : {};
+ return (
+ <Card>
+ <CardContent>
+ <TextField
+ disabled={loading}
+ name="slug"
+ label={i18n.t("Slug", { context: "object" })}
+ value={slug}
+ helperText={
+ errorList && errorList.slug
+ ? errorList.slug
+ : i18n.t("Slug is being used to create page URL", {
+ context: "object"
+ })
+ }
+ onChange={onChange}
+ error={!!(errorList && errorList.slug)}
+ fullWidth
+ />
+ <FormSpacer />
+ <TextField
+ disabled={loading}
+ name="availableOn"
+ label={i18n.t("Available on", { context: "label" })}
+ type="date"
+ value={availableOn}
+ onChange={onChange}
+ InputLabelProps={{
+ shrink: true
+ }}
+ helperText={
+ errorList && errorList.availableOn ? errorList.availableOn : ""
+ }
+ error={!!(errorList && errorList.availableOn)}
+ fullWidth
+ />
+ <FormSpacer />
+ {created && (
+ <div>
+ <Typography variant="body1">{i18n.t("Created:")} </Typography>
+ <DateFormatter date={created} />
+ </div>
+ )}
+ <FormSpacer />
+ <ControlledCheckbox
+ checked={isVisible}
+ disabled={loading}
+ label={i18n.t("Published", { context: "label" })}
+ name="isVisible"
+ onChange={onChange}
+ />
+ </CardContent>
+ </Card>
+ );
+ }
+);
+export default PageProperties;
diff --git a/saleor/static/dashboard-next/pages/components/PageProperties/index.ts b/saleor/static/dashboard-next/pages/components/PageProperties/index.ts
new file mode 100644
index 0000000000..dc1d91027f
--- /dev/null
+++ b/saleor/static/dashboard-next/pages/components/PageProperties/index.ts
@@ -0,0 +1,2 @@
+export { default } from "./PageProperties";
+export * from "./PageProperties";
diff --git a/saleor/static/dashboard-next/pages/fixtures.ts b/saleor/static/dashboard-next/pages/fixtures.ts
new file mode 100644
index 0000000000..c3c41ea8f9
--- /dev/null
+++ b/saleor/static/dashboard-next/pages/fixtures.ts
@@ -0,0 +1,23 @@
+export const pages = [
+ {
+ id: "UGFnZTox",
+ isVisible: true,
+ slug: "about",
+ title: "About"
+ },
+ {
+ id: "UGFnZToy",
+ isVisible: false,
+ slug: "terms-of-use",
+ title: "Terms of use"
+ }
+];
+export const page = {
+ availableOn: "2018-03-20T16:39:08.850105+00:00",
+ 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.",
+ createdAt: "2018-03-13T16:39:08.850105+00:00",
+ isVisible: true,
+ slug: "lorem-ipsum-dolor",
+ title: "Lorem Ipsum"
+};
diff --git a/saleor/static/dashboard-next/page/index.tsx b/saleor/static/dashboard-next/pages/index.tsx
similarity index 69%
rename from saleor/static/dashboard-next/page/index.tsx
rename to saleor/static/dashboard-next/pages/index.tsx
index 06664ee697..35d14009e0 100644
--- a/saleor/static/dashboard-next/page/index.tsx
+++ b/saleor/static/dashboard-next/pages/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 PageCreateForm from "./views/PageCreateForm";
+import PageCreate from "./views/PageCreate";
+import PageDetailsComponent from "./views/PageDetails";
import PageListComponent from "./views/PageList";
-import PageUpdateFormComponent from "./views/PageUpdateForm";
const PageList: React.StatelessComponent<RouteComponentProps<any>> = ({
location,
@@ -13,17 +13,17 @@ const PageList: React.StatelessComponent<RouteComponentProps<any>> = ({
const qs = parseQs(location.search.substr(1));
return <PageListComponent filters={qs} />;
};
-const PageUpdateForm: React.StatelessComponent<RouteComponentProps<any>> = ({
+const PageDetails: React.StatelessComponent<RouteComponentProps<any>> = ({
match
}) => {
- return <PageUpdateFormComponent id={match.params.id} />;
+ return <PageDetailsComponent id={match.params.id} />;
};
const Component = ({ match }) => (
<Switch>
<Route exact path={match.url} component={PageList} />
- <Route exact path={`${match.url}/add/`} component={PageCreateForm} />
- <Route exact path={`${match.url}/:id/`} component={PageUpdateForm} />
+ <Route exact path={`${match.url}/add/`} component={PageCreate} />
+ <Route exact path={`${match.url}/:id/`} component={PageDetails} />
</Switch>
);
@@ -36,5 +36,6 @@ export function pageStorefrontUrl(slug: string) {
}
export const pageListUrl = "/pages/";
+export const pageAddUrl = "/pages/add/";
export default Component;
diff --git a/saleor/static/dashboard-next/page/mutations.ts b/saleor/static/dashboard-next/pages/mutations.ts
similarity index 100%
rename from saleor/static/dashboard-next/page/mutations.ts
rename to saleor/static/dashboard-next/pages/mutations.ts
diff --git a/saleor/static/dashboard-next/page/queries.ts b/saleor/static/dashboard-next/pages/queries.ts
similarity index 100%
rename from saleor/static/dashboard-next/page/queries.ts
rename to saleor/static/dashboard-next/pages/queries.ts
diff --git a/saleor/static/dashboard-next/pages/views/PageCreate.tsx b/saleor/static/dashboard-next/pages/views/PageCreate.tsx
new file mode 100644
index 0000000000..76810a01c0
--- /dev/null
+++ b/saleor/static/dashboard-next/pages/views/PageCreate.tsx
@@ -0,0 +1,49 @@
+import * as React from "react";
+import { Redirect } from "react-router";
+
+import { pageListUrl } from "..";
+import { NavigatorLink } from "../../components/Navigator";
+import { PageCreateMutationVariables } from "../../gql-types";
+import i18n from "../../i18n";
+import PageDetailsPage from "../../pages/components/PageDetailsPage";
+import { pageCreateMutation, TypedPageCreateMutation } from "../mutations";
+
+interface PageCreateFormProps {
+ id: string;
+}
+export const PageCreateForm: React.StatelessComponent<PageCreateFormProps> = ({
+ id
+}) => (
+ <TypedPageCreateMutation mutation={pageCreateMutation}>
+ {(createPage, { called, data: createResult, error, loading }) => {
+ if (called && !loading && !createResult.pageCreate.errors.length) {
+ return <Redirect to={pageListUrl} push={false} />;
+ }
+ return (
+ <NavigatorLink to={pageListUrl}>
+ {handleCancel => (
+ <PageDetailsPage
+ disabled={loading}
+ page={{
+ availableOn: "",
+ content: "",
+ isVisible: false,
+ slug: "",
+ title: ""
+ }}
+ onBack={handleCancel}
+ onSubmit={data =>
+ createPage({
+ variables: data
+ })
+ }
+ title={i18n.t("Add page", { context: "title" })}
+ />
+ )}
+ </NavigatorLink>
+ );
+ }}
+ </TypedPageCreateMutation>
+);
+
+export default PageCreateForm;
diff --git a/saleor/static/dashboard-next/pages/views/PageDetails.tsx b/saleor/static/dashboard-next/pages/views/PageDetails.tsx
new file mode 100644
index 0000000000..fa68f941ed
--- /dev/null
+++ b/saleor/static/dashboard-next/pages/views/PageDetails.tsx
@@ -0,0 +1,134 @@
+import * as React from "react";
+import { Redirect } from "react-router";
+
+import { pageListUrl } from "..";
+import ErrorMessageCard from "../../components/ErrorMessageCard";
+import { NavigatorLink } from "../../components/Navigator";
+import PageHeader from "../../components/PageHeader";
+import i18n from "../../i18n";
+import PageDetailsPage from "../components/PageDetailsPage";
+import {
+ pageDeleteMutation,
+ pageUpdateMutation,
+ TypedPageDeleteMutation,
+ TypedPageUpdateMutation
+} from "../mutations";
+import { pageDetailsQuery, TypedPageDetailsQuery } from "../queries";
+
+interface PageUpdateFormProps {
+ id: string;
+}
+
+interface PageUpdateFormState {
+ opened: boolean;
+}
+
+export class PageUpdateForm extends React.Component<
+ PageUpdateFormProps,
+ PageUpdateFormState
+> {
+ state = { opened: false };
+
+ handleRemoveButtonClick = () => {
+ this.setState(prevState => ({ opened: !prevState.opened }));
+ };
+
+ render() {
+ const { id } = this.props;
+ return (
+ <TypedPageDetailsQuery query={pageDetailsQuery} variables={{ id }}>
+ {({ data: detailsResult, error, loading }) => {
+ if (error) {
+ return (
+ <ErrorMessageCard
+ message={i18n.t("Unable to find matching page.")}
+ />
+ );
+ }
+ return (
+ <TypedPageDeleteMutation mutation={pageDeleteMutation}>
+ {(
+ deletePage,
+ { called, data: deleteResult, error, loading: deleteInProgress }
+ ) => {
+ if (called && !deleteInProgress) {
+ if (error) {
+ console.error(error);
+ return;
+ }
+ if (
+ deleteResult.pageDelete.errors &&
+ deleteResult.pageDelete.errors.length
+ ) {
+ console.error(deleteResult.pageDelete);
+ return;
+ }
+ // FIXME: component is loaded with previous state (meaning that deleted page will still be there until table reload)
+ this.handleRemoveButtonClick();
+ return <Redirect to={pageListUrl} />;
+ }
+ return (
+ <TypedPageUpdateMutation mutation={pageUpdateMutation}>
+ {(
+ updatePage,
+ {
+ called,
+ data: updateResult,
+ error,
+ loading: updateInProgress
+ }
+ ) => {
+ if (
+ called &&
+ !updateInProgress &&
+ updateResult &&
+ updateResult.pageUpdate &&
+ !updateResult.pageUpdate.errors.length
+ ) {
+ if (error) {
+ console.error(error);
+ return;
+ }
+ return <Redirect to={pageListUrl} />;
+ }
+ return (
+ <NavigatorLink to={pageListUrl}>
+ {handleCancel => (
+ <PageDetailsPage
+ onBack={handleCancel}
+ page={loading ? undefined : detailsResult.page}
+ onSubmit={data =>
+ updatePage({
+ variables: { id, ...data }
+ })
+ }
+ errors={
+ updateResult
+ ? updateResult.pageUpdate.errors
+ : []
+ }
+ title={
+ detailsResult && detailsResult.page
+ ? detailsResult.page.title
+ : undefined
+ }
+ disabled={
+ loading || deleteInProgress || updateInProgress
+ }
+ />
+ )}
+ </NavigatorLink>
+ );
+ }}
+ </TypedPageUpdateMutation>
+ );
+ }}
+ </TypedPageDeleteMutation>
+ );
+ }}
+ </TypedPageDetailsQuery>
+ );
+ }
+}
+
+export default PageUpdateForm;
diff --git a/saleor/static/dashboard-next/page/views/PageList.tsx b/saleor/static/dashboard-next/pages/views/PageList.tsx
similarity index 53%
rename from saleor/static/dashboard-next/page/views/PageList.tsx
rename to saleor/static/dashboard-next/pages/views/PageList.tsx
index 64e6922c34..156145d3ce 100644
--- a/saleor/static/dashboard-next/page/views/PageList.tsx
+++ b/saleor/static/dashboard-next/pages/views/PageList.tsx
@@ -13,9 +13,9 @@ import ErrorMessageCard from "../../components/ErrorMessageCard";
import Navigator from "../../components/Navigator";
import PageHeader from "../../components/PageHeader";
import i18n from "../../i18n";
-import PageFilters from "../components/PageFilters";
import PageListComponent from "../components/PageList";
-import { pageEditUrl, pageStorefrontUrl } from "../index";
+import PageListPage from "../components/PageListPage/PageListPage";
+import { pageAddUrl, pageEditUrl, pageStorefrontUrl } from "../index";
import { pageListQuery, TypedPageListQuery } from "../queries";
interface PageListProps {
@@ -101,76 +101,28 @@ export class PageList extends React.Component<PageListProps, PageListState> {
return (
<Navigator>
{navigate => {
- const applyFilters = data => {
- navigate(
- `?${stringifyQs({ ...filters, ...data.formData })}`,
- true
- );
- };
- const clearFilters = () => navigate("?");
const handleEditClick = (id: string) => () =>
navigate(pageEditUrl(id));
const handleShowPageClick = (slug: string) => () =>
window.open(pageStorefrontUrl(slug));
return (
- <Grid container spacing={16}>
- <Grid item xs={12}>
- <Grid container spacing={16}>
- <Grid item xs={12} md={9}>
- <Card>
- <PageHeader
- title={i18n.t("Pages", {
- context: "title"
- })}
- >
- <IconButton
- disabled={loading}
- onClick={() => navigate("/pages/add/")}
- >
- <Add />
- </IconButton>
- <Hidden mdUp>
- <IconButton
- disabled={loading}
- onClick={this.handleFilterMenuOpen}
- >
- <FilterListIcon />
- </IconButton>
- </Hidden>
- </PageHeader>
- <PageListComponent
- pageInfo={loading ? null : data.pages.pageInfo}
- pages={loading ? null : data.pages.edges}
- handlePreviousPage={loadPreviousPage}
- handleNextPage={loadNextPage}
- onEditClick={handleEditClick}
- onShowPageClick={handleShowPageClick}
- />
- </Card>
- </Grid>
- <Grid item xs={12} md={3}>
- <Hidden smDown>
- <PageFilters
- handleSubmit={applyFilters}
- handleClear={clearFilters}
- formState={filters}
- />
- </Hidden>
- <Drawer
- open={this.state.isFilterMenuOpened}
- onClose={this.handleFilterMenuOpen}
- anchor="bottom"
- >
- <PageFilters
- handleSubmit={applyFilters}
- handleClear={clearFilters}
- formState={filters}
- />
- </Drawer>
- </Grid>
- </Grid>
- </Grid>
- </Grid>
+ <PageListPage
+ pages={
+ data && data.pages
+ ? data.pages.edges.map(edge => edge.node)
+ : undefined
+ }
+ pageInfo={
+ data && data.pages && data.pages.pageInfo
+ ? data.pages.pageInfo
+ : undefined
+ }
+ onAddPage={() => navigate(pageAddUrl)}
+ onEditPage={handleEditClick}
+ onNextPage={loadNextPage}
+ onPreviousPage={loadPreviousPage}
+ onShowPage={handleShowPageClick}
+ />
);
}}
</Navigator>
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 10aa64c7b7..46ccc5a8a0 100644
--- a/saleor/static/dashboard-next/storybook/__snapshots__/Stories.test.ts.snap
+++ b/saleor/static/dashboard-next/storybook/__snapshots__/Stories.test.ts.snap
@@ -3907,237 +3907,156 @@ Array [
]
`;
-exports[`Storyshots Pages / PageBaseForm with 'created' property 1`] = `
+exports[`Storyshots Pages / PageContent when loaded 1`] = `
<Component
availableOn="2018-03-20T16:39:08.850105+00:00"
classes={
Object {
"addHelperTextPadding": "Component-addHelperTextPadding-23",
- "cardActions": "Component-cardActions-24",
}
}
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."
- created="2018-03-20T16:39:08.850105+00:00"
+ createdAt="2018-03-13T16:39:08.850105+00:00"
isVisible={true}
slug="lorem-ipsum-dolor"
- title="Lorem ipsum"
+ title="Lorem Ipsum"
/>
`;
-exports[`Storyshots Pages / PageBaseForm with 'errors' property 1`] = `
+exports[`Storyshots Pages / PageContent when loading 1`] = `
<Component
- availableOn="2018-03-20T16:39:08.850105+00:00"
classes={
Object {
"addHelperTextPadding": "Component-addHelperTextPadding-23",
- "cardActions": "Component-cardActions-24",
}
}
- 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."
- errors={
- Array [
- Object {
- "field": "slug",
- "message": "To pole jest wymagane.",
- },
- Object {
- "field": "title",
- "message": "To pole jest wymagane.",
- },
- Object {
- "field": "content",
- "message": "To pole jest wymagane.",
- },
- ]
- }
- isVisible={true}
- slug="lorem-ipsum-dolor"
- title="Lorem ipsum"
+ content=""
+ loading={true}
+ title=""
/>
`;
-exports[`Storyshots Pages / PageBaseForm with initial data 1`] = `
+exports[`Storyshots Pages / PageDeleteDialog default 1`] = `
<Component
- availableOn="2018-03-20T16:39:08.850105+00:00"
classes={
Object {
- "addHelperTextPadding": "Component-addHelperTextPadding-23",
- "cardActions": "Component-cardActions-24",
+ "deleteButton": "Component-deleteButton-24",
}
}
- 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."
- isVisible={true}
- slug="lorem-ipsum-dolor"
- title="Lorem ipsum"
+ onClose={[Function]}
+ onConfirm={[Function]}
+ opened={true}
+ title="Lorem Ipsum"
/>
`;
-exports[`Storyshots Pages / PageDeleteDialog default 1`] = `
+exports[`Storyshots Pages / PageList when loading data 1`] = `
<Component
classes={
Object {
- "deleteButton": "Component-deleteButton-25",
+ "link": "Component-link-26",
+ "textRight": "Component-textRight-27",
}
}
- opened={true}
->
- <WithStyles(DialogContentText)>
- Do you really want to delete this page?
- </WithStyles(DialogContentText)>
-</Component>
-`;
-
-exports[`Storyshots Pages / PageFilters with initial data 1`] = `
-<FilterCard
- handleClear={[Function]}
->
- <TextField
- fullWidth={true}
- label="Title"
- name="title"
- onChange={[Function]}
- required={false}
- select={false}
- value="Initial title"
- />
- <WithStyles(Component) />
- <TextField
- fullWidth={true}
- label="Url"
- name="url"
- onChange={[Function]}
- required={false}
- select={false}
- value="initial-url"
- />
-</FilterCard>
-`;
-
-exports[`Storyshots Pages / PageFilters without initial data 1`] = `
-<FilterCard
- handleClear={[Function]}
->
- <TextField
- fullWidth={true}
- label="Title"
- name="title"
- onChange={[Function]}
- required={false}
- select={false}
- value=""
- />
- <WithStyles(Component) />
- <TextField
- fullWidth={true}
- label="Url"
- name="url"
- onChange={[Function]}
- required={false}
- select={false}
- value=""
- />
-</FilterCard>
+ onEditClick={[Function]}
+ onNextPage={[Function]}
+ onPreviousPage={[Function]}
+ onShowPageClick={[Function]}
+ pageInfo={
+ Object {
+ "hasNextPage": false,
+ "hasPreviousPage": false,
+ }
+ }
+/>
`;
-exports[`Storyshots Pages / PageList when loading data 1`] = `
-<Card
+exports[`Storyshots Pages / PageList with data 1`] = `
+<Component
classes={
Object {
- "root": "MuiCard-root-26",
+ "link": "Component-link-26",
+ "textRight": "Component-textRight-27",
}
}
- raised={false}
->
- <WithStyles(Component)
- handleNextPage={[Function]}
- handlePreviousPage={[Function]}
- onEditClick={[Function]}
- onShowPageClick={[Function]}
- pageInfo={
- Object {
- "endCursor": "YXJyYXljb25uZWN0aW9uOjE=",
- "hasNextPage": false,
- "hasPreviousPage": false,
- "startCursor": "YXJyYXljb25uZWN0aW9uOjA=",
- }
+ onEditClick={[Function]}
+ onNextPage={[Function]}
+ onPreviousPage={[Function]}
+ onShowPageClick={[Function]}
+ pageInfo={
+ Object {
+ "hasNextPage": false,
+ "hasPreviousPage": false,
}
- />
-</Card>
+ }
+ pages={
+ Array [
+ Object {
+ "id": "UGFnZTox",
+ "isVisible": true,
+ "slug": "about",
+ "title": "About",
+ },
+ Object {
+ "id": "UGFnZToy",
+ "isVisible": false,
+ "slug": "terms-of-use",
+ "title": "Terms of use",
+ },
+ ]
+ }
+/>
`;
-exports[`Storyshots Pages / PageList with data 1`] = `
-<Card
+exports[`Storyshots Pages / PageList without data 1`] = `
+<Component
classes={
Object {
- "root": "MuiCard-root-26",
+ "link": "Component-link-26",
+ "textRight": "Component-textRight-27",
}
}
- raised={false}
->
- <WithStyles(Component)
- handleNextPage={[Function]}
- handlePreviousPage={[Function]}
- onEditClick={[Function]}
- onShowPageClick={[Function]}
- pageInfo={
- Object {
- "endCursor": "YXJyYXljb25uZWN0aW9uOjE=",
- "hasNextPage": false,
- "hasPreviousPage": false,
- "startCursor": "YXJyYXljb25uZWN0aW9uOjA=",
- }
- }
- pages={
- Array [
- Object {
- "cursor": "YXJyYXljb25uZWN0aW9uOjA=",
- "node": Object {
- "id": "UGFnZTox",
- "isVisible": true,
- "slug": "about",
- "title": "About",
- },
- },
- Object {
- "cursor": "YXJyYXljb25uZWN0aW9uOjE=",
- "node": Object {
- "id": "UGFnZToy",
- "isVisible": false,
- "slug": "terms-of-use",
- "title": "Terms of use",
- },
- },
- ]
+ onEditClick={[Function]}
+ onNextPage={[Function]}
+ onPreviousPage={[Function]}
+ onShowPageClick={[Function]}
+ pageInfo={
+ Object {
+ "hasNextPage": false,
+ "hasPreviousPage": false,
}
- />
-</Card>
+ }
+ pages={Array []}
+/>
`;
-exports[`Storyshots Pages / PageList without data 1`] = `
-<Card
+exports[`Storyshots Pages / PageProperties when loaded 1`] = `
+<Component
+ availableOn="2018-03-20T16:39:08.850105+00:00"
classes={
Object {
- "root": "MuiCard-root-26",
+ "root": "Component-root-29",
}
}
- raised={false}
->
- <WithStyles(Component)
- handleNextPage={[Function]}
- handlePreviousPage={[Function]}
- onEditClick={[Function]}
- onShowPageClick={[Function]}
- pageInfo={
- Object {
- "endCursor": "YXJyYXljb25uZWN0aW9uOjE=",
- "hasNextPage": false,
- "hasPreviousPage": false,
- "startCursor": "YXJyYXljb25uZWN0aW9uOjA=",
- }
+ 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."
+ createdAt="2018-03-13T16:39:08.850105+00:00"
+ isVisible={true}
+ slug="lorem-ipsum-dolor"
+ title="Lorem Ipsum"
+/>
+`;
+
+exports[`Storyshots Pages / PageProperties when loading 1`] = `
+<Component
+ availableOn=""
+ classes={
+ Object {
+ "root": "Component-root-29",
}
- pages={Array []}
- />
-</Card>
+ }
+ isVisible={false}
+ loading={true}
+/>
`;
exports[`Storyshots Products / ProductAttributesForm when data loaded 1`] = `
@@ -4245,7 +4164,7 @@ exports[`Storyshots Products / ProductAvailabilityForm when loading data 1`] = `
<Component
classes={
Object {
- "root": "Component-root-27",
+ "root": "Component-root-30",
}
}
onChange={[Function]}
@@ -4258,7 +4177,7 @@ exports[`Storyshots Products / ProductAvailabilityForm with loaded data 1`] = `
availableOn="04-10-2010"
classes={
Object {
- "root": "Component-root-27",
+ "root": "Component-root-30",
}
}
onChange={[Function]}
@@ -4314,8 +4233,8 @@ exports[`Storyshots Products / ProductCollections when loading data 1`] = `
<Component
classes={
Object {
- "card": "Component-card-28",
- "link": "Component-link-29",
+ "card": "Component-card-31",
+ "link": "Component-link-32",
}
}
onRowClick={[Function]}
@@ -4326,8 +4245,8 @@ exports[`Storyshots Products / ProductCollections with collections 1`] = `
<Component
classes={
Object {
- "card": "Component-card-28",
- "link": "Component-link-29",
+ "card": "Component-card-31",
+ "link": "Component-link-32",
}
}
collections={
@@ -4350,8 +4269,8 @@ exports[`Storyshots Products / ProductCollections with no collections 1`] = `
<Component
classes={
Object {
- "card": "Component-card-28",
- "link": "Component-link-29",
+ "card": "Component-card-31",
+ "link": "Component-link-32",
}
}
collections={Array []}
@@ -4463,7 +4382,7 @@ exports[`Storyshots Products / ProductDetailsForm when loading data 1`] = `
<Component
classes={
Object {
- "root": "Component-root-30",
+ "root": "Component-root-33",
}
}
loading={true}
@@ -4476,7 +4395,7 @@ exports[`Storyshots Products / ProductDetailsForm with initial data 1`] = `
<Component
classes={
Object {
- "root": "Component-root-30",
+ "root": "Component-root-33",
}
}
currencySymbol="USD"
@@ -4492,7 +4411,7 @@ exports[`Storyshots Products / ProductDetailsForm with no initial data 1`] = `
<Component
classes={
Object {
- "root": "Component-root-30",
+ "root": "Component-root-33",
}
}
onBack={[Function]}
@@ -4504,8 +4423,8 @@ exports[`Storyshots Products / ProductImagePage data loaded 1`] = `
<Component
classes={
Object {
- "image": "Component-image-33",
- "root": "Component-root-32",
+ "image": "Component-image-36",
+ "root": "Component-root-35",
}
}
image="placeholder255x255.png"
@@ -4518,8 +4437,8 @@ exports[`Storyshots Products / ProductImagePage loading 1`] = `
<Component
classes={
Object {
- "image": "Component-image-33",
- "root": "Component-root-32",
+ "image": "Component-image-36",
+ "root": "Component-root-35",
}
}
loading={true}
@@ -4532,11 +4451,11 @@ exports[`Storyshots Products / ProductImages when loading data 1`] = `
<Component
classes={
Object {
- "card": "Component-card-35",
- "fileField": "Component-fileField-38",
- "gridElement": "Component-gridElement-36",
- "icon": "Component-icon-37",
- "root": "Component-root-34",
+ "card": "Component-card-38",
+ "fileField": "Component-fileField-41",
+ "gridElement": "Component-gridElement-39",
+ "icon": "Component-icon-40",
+ "root": "Component-root-37",
}
}
onImageReorder={[Function]}
@@ -4549,11 +4468,11 @@ exports[`Storyshots Products / ProductImages with data 1`] = `
<Component
classes={
Object {
- "card": "Component-card-35",
- "fileField": "Component-fileField-38",
- "gridElement": "Component-gridElement-36",
- "icon": "Component-icon-37",
- "root": "Component-root-34",
+ "card": "Component-card-38",
+ "fileField": "Component-fileField-41",
+ "gridElement": "Component-gridElement-39",
+ "icon": "Component-icon-40",
+ "root": "Component-root-37",
}
}
images={
@@ -4587,11 +4506,11 @@ exports[`Storyshots Products / ProductImages without data 1`] = `
<Component
classes={
Object {
- "card": "Component-card-35",
- "fileField": "Component-fileField-38",
- "gridElement": "Component-gridElement-36",
- "icon": "Component-icon-37",
- "root": "Component-root-34",
+ "card": "Component-card-38",
+ "fileField": "Component-fileField-41",
+ "gridElement": "Component-gridElement-39",
+ "icon": "Component-icon-40",
+ "root": "Component-root-37",
}
}
images={Array []}
@@ -4604,10 +4523,10 @@ exports[`Storyshots Products / ProductPriceAndAvailability when loading data 1`]
<Component
classes={
Object {
- "greenText": "Component-greenText-39",
- "leftCell": "Component-leftCell-40",
- "redText": "Component-redText-41",
- "rightCell": "Component-rightCell-42",
+ "greenText": "Component-greenText-42",
+ "leftCell": "Component-leftCell-43",
+ "redText": "Component-redText-44",
+ "rightCell": "Component-rightCell-45",
}
}
onPublish={[Function]}
@@ -4618,10 +4537,10 @@ exports[`Storyshots Products / ProductPriceAndAvailability when product is avail
<Component
classes={
Object {
- "greenText": "Component-greenText-39",
- "leftCell": "Component-leftCell-40",
- "redText": "Component-redText-41",
- "rightCell": "Component-rightCell-42",
+ "greenText": "Component-greenText-42",
+ "leftCell": "Component-leftCell-43",
+ "redText": "Component-redText-44",
+ "rightCell": "Component-rightCell-45",
}
}
grossMargin={
@@ -4651,10 +4570,10 @@ exports[`Storyshots Products / ProductPriceAndAvailability when product is not a
<Component
classes={
Object {
- "greenText": "Component-greenText-39",
- "leftCell": "Component-leftCell-40",
- "redText": "Component-redText-41",
- "rightCell": "Component-rightCell-42",
+ "greenText": "Component-greenText-42",
+ "leftCell": "Component-leftCell-43",
+ "redText": "Component-redText-44",
+ "rightCell": "Component-rightCell-45",
}
}
grossMargin={
@@ -4710,7 +4629,7 @@ exports[`Storyshots Products / ProductVariantAttributes when loaded data 1`] = `
}
classes={
Object {
- "grid": "Component-grid-46",
+ "grid": "Component-grid-49",
}
}
onChange={[Function]}
@@ -4721,7 +4640,7 @@ exports[`Storyshots Products / ProductVariantAttributes when loading data 1`] =
<Component
classes={
Object {
- "grid": "Component-grid-46",
+ "grid": "Component-grid-49",
}
}
loading={true}
@@ -4733,7 +4652,7 @@ exports[`Storyshots Products / ProductVariantDeleteDialog default 1`] = `
<Component
classes={
Object {
- "deleteButton": "Component-deleteButton-47",
+ "deleteButton": "Component-deleteButton-50",
}
}
name="Extended Hard"
@@ -4745,10 +4664,10 @@ exports[`Storyshots Products / ProductVariantImageSelectDialog default 1`] = `
<ProductVariantImageSelectDialogComponent
classes={
Object {
- "gridElement": "ProductVariantImageSelectDialogComponent-gridElement-49",
- "icon": "ProductVariantImageSelectDialogComponent-icon-50",
- "iconChecked": "ProductVariantImageSelectDialogComponent-iconChecked-51",
- "root": "ProductVariantImageSelectDialogComponent-root-48",
+ "gridElement": "ProductVariantImageSelectDialogComponent-gridElement-52",
+ "icon": "ProductVariantImageSelectDialogComponent-icon-53",
+ "iconChecked": "ProductVariantImageSelectDialogComponent-iconChecked-54",
+ "root": "ProductVariantImageSelectDialogComponent-root-51",
}
}
images={
@@ -4833,9 +4752,9 @@ exports[`Storyshots Products / ProductVariantImages when loaded data 1`] = `
<Component
classes={
Object {
- "card": "Component-card-53",
- "gridElement": "Component-gridElement-54",
- "root": "Component-root-52",
+ "card": "Component-card-56",
+ "gridElement": "Component-gridElement-57",
+ "root": "Component-root-55",
}
}
images={
@@ -4905,9 +4824,9 @@ exports[`Storyshots Products / ProductVariantImages when loading data 1`] = `
<Component
classes={
Object {
- "card": "Component-card-53",
- "gridElement": "Component-gridElement-54",
- "root": "Component-root-52",
+ "card": "Component-card-56",
+ "gridElement": "Component-gridElement-57",
+ "root": "Component-root-55",
}
}
loading={true}
@@ -4920,8 +4839,8 @@ exports[`Storyshots Products / ProductVariantNavigation when loaded data 1`] = `
<Component
classes={
Object {
- "card": "Component-card-55",
- "link": "Component-link-56",
+ "card": "Component-card-58",
+ "link": "Component-link-59",
}
}
variants={
@@ -4947,8 +4866,8 @@ exports[`Storyshots Products / ProductVariantNavigation when loading data 1`] =
<Component
classes={
Object {
- "card": "Component-card-55",
- "link": "Component-link-56",
+ "card": "Component-card-58",
+ "link": "Component-link-59",
}
}
loading={true}
@@ -4959,8 +4878,8 @@ exports[`Storyshots Products / ProductVariantNavigation with clickable rows 1`]
<Component
classes={
Object {
- "card": "Component-card-55",
- "link": "Component-link-56",
+ "card": "Component-card-58",
+ "link": "Component-link-59",
}
}
onRowClick={[Function]}
@@ -4987,8 +4906,8 @@ exports[`Storyshots Products / ProductVariantPrice when loaded data 1`] = `
<Component
classes={
Object {
- "grid": "Component-grid-59",
- "root": "Component-root-58",
+ "grid": "Component-grid-62",
+ "root": "Component-root-61",
}
}
costPrice={100}
@@ -5002,8 +4921,8 @@ exports[`Storyshots Products / ProductVariantPrice when loading data 1`] = `
<Component
classes={
Object {
- "grid": "Component-grid-59",
- "root": "Component-root-58",
+ "grid": "Component-grid-62",
+ "root": "Component-root-61",
}
}
loading={true}
@@ -5015,7 +4934,7 @@ exports[`Storyshots Products / ProductVariantProduct when loaded data 1`] = `
<Component
classes={
Object {
- "root": "Component-root-60",
+ "root": "Component-root-63",
}
}
product={
@@ -5131,7 +5050,7 @@ exports[`Storyshots Products / ProductVariantProduct when loading data 1`] = `
<Component
classes={
Object {
- "root": "Component-root-60",
+ "root": "Component-root-63",
}
}
loading={true}
@@ -5143,8 +5062,8 @@ exports[`Storyshots Products / ProductVariantStock when loaded data 1`] = `
<Component
classes={
Object {
- "grid": "Component-grid-62",
- "root": "Component-root-61",
+ "grid": "Component-grid-65",
+ "root": "Component-root-64",
}
}
onChange={[Function]}
@@ -5158,8 +5077,8 @@ exports[`Storyshots Products / ProductVariantStock when loading data 1`] = `
<Component
classes={
Object {
- "grid": "Component-grid-62",
- "root": "Component-root-61",
+ "grid": "Component-grid-65",
+ "root": "Component-root-64",
}
}
loading={true}
@@ -5171,10 +5090,10 @@ exports[`Storyshots Products / ProductVariants when loading data 1`] = `
<Component
classes={
Object {
- "alignRightText": "Component-alignRightText-63",
- "greenDot": "Component-greenDot-64",
- "link": "Component-link-65",
- "redDot": "Component-redDot-66",
+ "alignRightText": "Component-alignRightText-66",
+ "greenDot": "Component-greenDot-67",
+ "link": "Component-link-68",
+ "redDot": "Component-redDot-69",
}
}
/>
@@ -5184,10 +5103,10 @@ exports[`Storyshots Products / ProductVariants when product has no variants 1`]
<Component
classes={
Object {
- "alignRightText": "Component-alignRightText-63",
- "greenDot": "Component-greenDot-64",
- "link": "Component-link-65",
- "redDot": "Component-redDot-66",
+ "alignRightText": "Component-alignRightText-66",
+ "greenDot": "Component-greenDot-67",
+ "link": "Component-link-68",
+ "redDot": "Component-redDot-69",
}
}
variants={Array []}
@@ -5198,10 +5117,10 @@ exports[`Storyshots Products / ProductVariants when product has variants 1`] = `
<Component
classes={
Object {
- "alignRightText": "Component-alignRightText-63",
- "greenDot": "Component-greenDot-64",
- "link": "Component-link-65",
- "redDot": "Component-redDot-66",
+ "alignRightText": "Component-alignRightText-66",
+ "greenDot": "Component-greenDot-67",
+ "link": "Component-link-68",
+ "redDot": "Component-redDot-69",
}
}
fallbackGross="80%"
@@ -5265,10 +5184,10 @@ exports[`Storyshots Products / ProductVariants with clickable rows 1`] = `
<Component
classes={
Object {
- "alignRightText": "Component-alignRightText-63",
- "greenDot": "Component-greenDot-64",
- "link": "Component-link-65",
- "redDot": "Component-redDot-66",
+ "alignRightText": "Component-alignRightText-66",
+ "greenDot": "Component-greenDot-67",
+ "link": "Component-link-68",
+ "redDot": "Component-redDot-69",
}
}
fallbackGross="80%"
@@ -6512,11 +6431,149 @@ Array [
]
`;
+exports[`Storyshots Views / Pages / Page details when loading 1`] = `
+<Component
+ classes={
+ Object {
+ "root": "Component-root-25",
+ }
+ }
+ disabled={true}
+ onBack={[Function]}
+ onSubmit={[Function]}
+/>
+`;
+
+exports[`Storyshots Views / Pages / Page details with delete button 1`] = `
+<Component
+ classes={
+ Object {
+ "root": "Component-root-25",
+ }
+ }
+ onBack={[Function]}
+ onDelete={[Function]}
+ onSubmit={[Function]}
+ page={
+ Object {
+ "availableOn": "2018-03-20T16:39:08.850105+00:00",
+ "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.",
+ "createdAt": "2018-03-13T16:39:08.850105+00:00",
+ "isVisible": true,
+ "slug": "lorem-ipsum-dolor",
+ "title": "Lorem Ipsum",
+ }
+ }
+/>
+`;
+
+exports[`Storyshots Views / Pages / Page details with initial data 1`] = `
+<Component
+ classes={
+ Object {
+ "root": "Component-root-25",
+ }
+ }
+ onBack={[Function]}
+ onSubmit={[Function]}
+ page={
+ Object {
+ "availableOn": "2018-03-20T16:39:08.850105+00:00",
+ "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.",
+ "createdAt": "2018-03-13T16:39:08.850105+00:00",
+ "isVisible": true,
+ "slug": "lorem-ipsum-dolor",
+ "title": "Lorem Ipsum",
+ }
+ }
+/>
+`;
+
+exports[`Storyshots Views / Pages / Page list when loading data 1`] = `
+<Component
+ classes={
+ Object {
+ "root": "Component-root-28",
+ }
+ }
+ onBack={[Function]}
+ onEditPage={[Function]}
+ onNextPage={[Function]}
+ onPreviousPage={[Function]}
+ onShowPage={[Function]}
+ pageInfo={
+ Object {
+ "hasNextPage": false,
+ "hasPreviousPage": false,
+ }
+ }
+/>
+`;
+
+exports[`Storyshots Views / Pages / Page list with data 1`] = `
+<Component
+ classes={
+ Object {
+ "root": "Component-root-28",
+ }
+ }
+ onBack={[Function]}
+ onEditPage={[Function]}
+ onNextPage={[Function]}
+ onPreviousPage={[Function]}
+ onShowPage={[Function]}
+ pageInfo={
+ Object {
+ "hasNextPage": false,
+ "hasPreviousPage": false,
+ }
+ }
+ pages={
+ Array [
+ Object {
+ "id": "UGFnZTox",
+ "isVisible": true,
+ "slug": "about",
+ "title": "About",
+ },
+ Object {
+ "id": "UGFnZToy",
+ "isVisible": false,
+ "slug": "terms-of-use",
+ "title": "Terms of use",
+ },
+ ]
+ }
+/>
+`;
+
+exports[`Storyshots Views / Pages / Page list without data 1`] = `
+<Component
+ classes={
+ Object {
+ "root": "Component-root-28",
+ }
+ }
+ onBack={[Function]}
+ onEditPage={[Function]}
+ onNextPage={[Function]}
+ onPreviousPage={[Function]}
+ onShowPage={[Function]}
+ pageInfo={
+ Object {
+ "hasNextPage": false,
+ "hasPreviousPage": false,
+ }
+ }
+ pages={Array []}
+/>
+`;
+
exports[`Storyshots Views / Products / Product details when loaded data 1`] = `
<Component
classes={
Object {
- "root": "Component-root-31",
+ "root": "Component-root-34",
}
}
onBack={[Function]}
@@ -6702,7 +6759,7 @@ exports[`Storyshots Views / Products / Product details when loading data 1`] = `
<Component
classes={
Object {
- "root": "Component-root-31",
+ "root": "Component-root-34",
}
}
onBack={[Function]}
@@ -6735,9 +6792,9 @@ exports[`Storyshots Views / Products / Product edit when data is fully loaded 1`
}
classes={
Object {
- "cardContainer": "Component-cardContainer-45",
- "grid": "Component-grid-44",
- "root": "Component-root-43",
+ "cardContainer": "Component-cardContainer-48",
+ "grid": "Component-grid-47",
+ "root": "Component-root-46",
}
}
collections={
@@ -6885,9 +6942,9 @@ exports[`Storyshots Views / Products / Product edit when loading data 1`] = `
<Component
classes={
Object {
- "cardContainer": "Component-cardContainer-45",
- "grid": "Component-grid-44",
- "root": "Component-root-43",
+ "cardContainer": "Component-cardContainer-48",
+ "grid": "Component-grid-47",
+ "root": "Component-root-46",
}
}
loading={true}
@@ -7134,7 +7191,7 @@ exports[`Storyshots Views / Products / Product variant details when loaded data
<Component
classes={
Object {
- "root": "Component-root-57",
+ "root": "Component-root-60",
}
}
onBack={[Function]}
@@ -7312,7 +7369,7 @@ exports[`Storyshots Views / Products / Product variant details when loading data
<Component
classes={
Object {
- "root": "Component-root-57",
+ "root": "Component-root-60",
}
}
loading={true}
diff --git a/saleor/static/dashboard-next/storybook/config.js b/saleor/static/dashboard-next/storybook/config.js
index 5734951124..b6ca5273a2 100644
--- a/saleor/static/dashboard-next/storybook/config.js
+++ b/saleor/static/dashboard-next/storybook/config.js
@@ -26,10 +26,12 @@ function loadStories() {
require("./stories/categories/RootCategoryList");
// Pages
- require("./stories/pages/PageBaseForm");
+ require("./stories/pages/PageContent");
require("./stories/pages/PageDeleteDialog");
- require("./stories/pages/PageFilters");
+ require("./stories/pages/PageDetailsPage");
require("./stories/pages/PageList");
+ require("./stories/pages/PageListPage");
+ require("./stories/pages/PageProperties");
// Products
require("./stories/products/ProductAttributesForm");
diff --git a/saleor/static/dashboard-next/storybook/stories/components/PointOfInterestField.tsx b/saleor/static/dashboard-next/storybook/stories/components/PointOfInterestField.tsx
new file mode 100644
index 0000000000..cf1b118d2d
--- /dev/null
+++ b/saleor/static/dashboard-next/storybook/stories/components/PointOfInterestField.tsx
@@ -0,0 +1,14 @@
+import { storiesOf } from "@storybook/react";
+import * as React from "react";
+
+import * as placeholder from "../../../../images/placeholder255x255.png";
+import PointOfInterestField from "../../../components/PointOfInterestField";
+
+storiesOf("components / PointOfInterestField", module).add("default", () => (
+ <PointOfInterestField
+ src={placeholder}
+ onChange={() => {}}
+ value={"0.5x0.5"}
+ />
+));
+// .add("other", () => <PointOfInterestField />);
diff --git a/saleor/static/dashboard-next/storybook/stories/pages/PageBaseForm.tsx b/saleor/static/dashboard-next/storybook/stories/pages/PageBaseForm.tsx
deleted file mode 100644
index 2200c29d88..0000000000
--- a/saleor/static/dashboard-next/storybook/stories/pages/PageBaseForm.tsx
+++ /dev/null
@@ -1,38 +0,0 @@
-import { storiesOf } from "@storybook/react";
-import { DialogContentText } from "material-ui/Dialog";
-import * as React from "react";
-
-import PageBaseForm from "../../../page/components/PageBaseForm";
-
-const page = {
- availableOn: "2018-03-20T16:39:08.850105+00:00",
- 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.",
- isVisible: true,
- slug: "lorem-ipsum-dolor",
- title: "Lorem ipsum"
-};
-
-storiesOf("Pages / PageBaseForm", module)
- .add("with initial data", () => <PageBaseForm {...page} />)
- .add("with 'created' property", () => {
- const created = "2018-03-20T16:39:08.850105+00:00";
- return <PageBaseForm {...page} created={created} />;
- })
- .add("with 'errors' property", () => {
- const errors = [
- {
- field: "slug",
- message: "To pole jest wymagane."
- },
- {
- field: "title",
- message: "To pole jest wymagane."
- },
- {
- field: "content",
- message: "To pole jest wymagane."
- }
- ];
- return <PageBaseForm {...page} errors={errors} />;
- });
diff --git a/saleor/static/dashboard-next/storybook/stories/pages/PageContent.tsx b/saleor/static/dashboard-next/storybook/stories/pages/PageContent.tsx
new file mode 100644
index 0000000000..185fe6919e
--- /dev/null
+++ b/saleor/static/dashboard-next/storybook/stories/pages/PageContent.tsx
@@ -0,0 +1,13 @@
+import { storiesOf } from "@storybook/react";
+import * as React from "react";
+
+import PageContent from "../../../pages/components/PageContent";
+import { page } from "../../../pages/fixtures";
+// import Decorator from "../../Decorator";
+
+storiesOf("Pages / PageContent", module)
+ // .addDecorator(Decorator)
+ .add("when loaded", () => <PageContent {...page} />)
+ .add("when loading", () => (
+ <PageContent loading={true} content="" title="" />
+ ));
diff --git a/saleor/static/dashboard-next/storybook/stories/pages/PageDeleteDialog.tsx b/saleor/static/dashboard-next/storybook/stories/pages/PageDeleteDialog.tsx
index 3016d7880b..cd6b989910 100644
--- a/saleor/static/dashboard-next/storybook/stories/pages/PageDeleteDialog.tsx
+++ b/saleor/static/dashboard-next/storybook/stories/pages/PageDeleteDialog.tsx
@@ -1,13 +1,13 @@
import { storiesOf } from "@storybook/react";
-import { DialogContentText } from "material-ui/Dialog";
import * as React from "react";
-import PageDeleteDialog from "../../../page/components/PageDeleteDialog";
+import PageDeleteDialog from "../../../pages/components/PageDeleteDialog";
storiesOf("Pages / PageDeleteDialog", module).add("default", () => (
- <PageDeleteDialog opened={true}>
- <DialogContentText>
- Do you really want to delete this page?
- </DialogContentText>
- </PageDeleteDialog>
+ <PageDeleteDialog
+ opened={true}
+ onConfirm={() => {}}
+ onClose={() => {}}
+ title="Lorem Ipsum"
+ />
));
diff --git a/saleor/static/dashboard-next/storybook/stories/pages/PageDetailsPage.tsx b/saleor/static/dashboard-next/storybook/stories/pages/PageDetailsPage.tsx
new file mode 100644
index 0000000000..a7bc36e832
--- /dev/null
+++ b/saleor/static/dashboard-next/storybook/stories/pages/PageDetailsPage.tsx
@@ -0,0 +1,22 @@
+import { storiesOf } from "@storybook/react";
+import { DialogContentText } from "material-ui/Dialog";
+import * as React from "react";
+
+import PageDetailsPage from "../../../pages/components/PageDetailsPage";
+import { page } from "../../../pages/fixtures";
+
+const callbacks = {
+ onBack: () => {},
+ onSubmit: () => {}
+};
+
+storiesOf("Views / Pages / Page details", module)
+ .add("with initial data", () => (
+ <PageDetailsPage page={page} {...callbacks} />
+ ))
+ .add("with delete button", () => (
+ <PageDetailsPage page={page} {...callbacks} onDelete={() => {}} />
+ ))
+ .add("when loading", () => (
+ <PageDetailsPage disabled={true} {...callbacks} />
+ ));
diff --git a/saleor/static/dashboard-next/storybook/stories/pages/PageFilters.tsx b/saleor/static/dashboard-next/storybook/stories/pages/PageFilters.tsx
deleted file mode 100644
index f3972d9153..0000000000
--- a/saleor/static/dashboard-next/storybook/stories/pages/PageFilters.tsx
+++ /dev/null
@@ -1,16 +0,0 @@
-import { storiesOf } from "@storybook/react";
-import * as React from "react";
-
-import PageFilters from "../../../page/components/PageFilters";
-
-storiesOf("Pages / PageFilters", module)
- .add("with initial data", () => (
- <PageFilters
- handleClear={() => {}}
- handleSubmit={() => {}}
- formState={{ title: "Initial title", url: "initial-url" }}
- />
- ))
- .add("without initial data", () => (
- <PageFilters handleClear={() => {}} handleSubmit={() => {}} />
- ));
diff --git a/saleor/static/dashboard-next/storybook/stories/pages/PageList.tsx b/saleor/static/dashboard-next/storybook/stories/pages/PageList.tsx
index db913f20ed..a3e7e72799 100644
--- a/saleor/static/dashboard-next/storybook/stories/pages/PageList.tsx
+++ b/saleor/static/dashboard-next/storybook/stories/pages/PageList.tsx
@@ -1,69 +1,42 @@
import { storiesOf } from "@storybook/react";
-import * as React from "react";
import Card from "material-ui/Card";
+import * as React from "react";
-import PageList from "../../../page/components/PageList";
+import PageList from "../../../pages/components/PageList";
+import { pages } from "../../../pages/fixtures";
-const pages = [
- {
- cursor: "YXJyYXljb25uZWN0aW9uOjA=",
- node: {
- id: "UGFnZTox",
- slug: "about",
- title: "About",
- isVisible: true
- }
- },
- {
- cursor: "YXJyYXljb25uZWN0aW9uOjE=",
- node: {
- id: "UGFnZToy",
- slug: "terms-of-use",
- title: "Terms of use",
- isVisible: false
- }
- }
-];
const pageInfo = {
- hasPreviousPage: false,
hasNextPage: false,
- startCursor: "YXJyYXljb25uZWN0aW9uOjA=",
- endCursor: "YXJyYXljb25uZWN0aW9uOjE="
+ hasPreviousPage: false
};
storiesOf("Pages / PageList", module)
.add("with data", () => (
- <Card>
- <PageList
- pages={pages}
- pageInfo={pageInfo}
- handlePreviousPage={() => {}}
- handleNextPage={() => {}}
- onEditClick={() => {}}
- onShowPageClick={() => {}}
- />
- </Card>
+ <PageList
+ pages={pages}
+ pageInfo={pageInfo}
+ onEditClick={() => {}}
+ onNextPage={() => {}}
+ onPreviousPage={() => {}}
+ onShowPageClick={() => {}}
+ />
))
.add("without data", () => (
- <Card>
- <PageList
- pages={[]}
- pageInfo={pageInfo}
- handlePreviousPage={() => {}}
- handleNextPage={() => {}}
- onEditClick={() => {}}
- onShowPageClick={() => {}}
- />
- </Card>
+ <PageList
+ pages={[]}
+ pageInfo={pageInfo}
+ onEditClick={() => {}}
+ onNextPage={() => {}}
+ onPreviousPage={() => {}}
+ onShowPageClick={() => {}}
+ />
))
.add("when loading data", () => (
- <Card>
- <PageList
- pageInfo={pageInfo}
- handlePreviousPage={() => {}}
- handleNextPage={() => {}}
- onEditClick={() => {}}
- onShowPageClick={() => {}}
- />
- </Card>
+ <PageList
+ pageInfo={pageInfo}
+ onEditClick={() => {}}
+ onNextPage={() => {}}
+ onPreviousPage={() => {}}
+ onShowPageClick={() => {}}
+ />
));
diff --git a/saleor/static/dashboard-next/storybook/stories/pages/PageListPage.tsx b/saleor/static/dashboard-next/storybook/stories/pages/PageListPage.tsx
new file mode 100644
index 0000000000..64b7212db2
--- /dev/null
+++ b/saleor/static/dashboard-next/storybook/stories/pages/PageListPage.tsx
@@ -0,0 +1,45 @@
+import { storiesOf } from "@storybook/react";
+import Card from "material-ui/Card";
+import * as React from "react";
+
+import PageList from "../../../pages/components/PageListPage";
+import { pages } from "../../../pages/fixtures";
+
+const pageInfo = {
+ hasNextPage: false,
+ hasPreviousPage: false
+};
+
+storiesOf("Views / Pages / Page list", module)
+ .add("with data", () => (
+ <PageList
+ pages={pages}
+ pageInfo={pageInfo}
+ onBack={() => {}}
+ onEditPage={() => {}}
+ onNextPage={() => {}}
+ onPreviousPage={() => {}}
+ onShowPage={() => {}}
+ />
+ ))
+ .add("without data", () => (
+ <PageList
+ pages={[]}
+ pageInfo={pageInfo}
+ onBack={() => {}}
+ onEditPage={() => {}}
+ onNextPage={() => {}}
+ onPreviousPage={() => {}}
+ onShowPage={() => {}}
+ />
+ ))
+ .add("when loading data", () => (
+ <PageList
+ pageInfo={pageInfo}
+ onBack={() => {}}
+ onEditPage={() => {}}
+ onNextPage={() => {}}
+ onPreviousPage={() => {}}
+ onShowPage={() => {}}
+ />
+ ));
diff --git a/saleor/static/dashboard-next/storybook/stories/pages/PageProperties.tsx b/saleor/static/dashboard-next/storybook/stories/pages/PageProperties.tsx
new file mode 100644
index 0000000000..df137c4e1e
--- /dev/null
+++ b/saleor/static/dashboard-next/storybook/stories/pages/PageProperties.tsx
@@ -0,0 +1,13 @@
+import { storiesOf } from "@storybook/react";
+import * as React from "react";
+
+import PageProperties from "../../../pages/components/PageProperties";
+import { page } from "../../../pages/fixtures";
+// import Decorator from "../../Decorator";
+
+storiesOf("Pages / PageProperties", module)
+ // .addDecorator(Decorator)
+ .add("when loaded", () => <PageProperties {...page} />)
+ .add("when loading", () => (
+ <PageProperties loading={true} availableOn="" isVisible={false} />
+ ));