Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
wip
dominik-zeglen2fb4c85fa401
diff --git a/saleor/static/dashboard-next/attributes/components/AttributeBulkDeleteDialog/AttributeBulkDeleteDialog.tsx b/saleor/static/dashboard-next/attributes/components/AttributeBulkDeleteDialog/AttributeBulkDeleteDialog.tsxnew file mode 100644index 0000000000..7dc1013749--- /dev/null+++ b/saleor/static/dashboard-next/attributes/components/AttributeBulkDeleteDialog/AttributeBulkDeleteDialog.tsx@@ -0,0 +1,40 @@+import DialogContentText from "@material-ui/core/DialogContentText";+import * as React from "react";++import ActionDialog from "@saleor/components/ActionDialog";+import { ConfirmButtonTransitionState } from "@saleor/components/ConfirmButton";+import i18n from "../../../i18n";++export interface AttributeBulkDeleteDialogProps {+ confirmButtonState: ConfirmButtonTransitionState;+ quantity: string;+ open: boolean;+ onConfirm: () => void;+ onClose: () => void;+}++const AttributeBulkDeleteDialog: React.StatelessComponent<+ AttributeBulkDeleteDialogProps+> = ({ confirmButtonState, quantity, onClose, onConfirm, open }) => (+ <ActionDialog+ open={open}+ confirmButtonState={confirmButtonState}+ onClose={onClose}+ onConfirm={onConfirm}+ title={i18n.t("Remove attributes")}+ variant="delete"+ >+ <DialogContentText+ dangerouslySetInnerHTML={{+ __html: i18n.t(+ "Are you sure you want to remove <strong>{{ number }}</strong> attributes?",+ {+ quantity+ }+ )+ }}+ />+ </ActionDialog>+);+AttributeBulkDeleteDialog.displayName = "AttributeBulkDeleteDialog";+export default AttributeBulkDeleteDialog;diff --git a/saleor/static/dashboard-next/attributes/components/AttributeBulkDeleteDialog/index.ts b/saleor/static/dashboard-next/attributes/components/AttributeBulkDeleteDialog/index.tsnew file mode 100644index 0000000000..12ecc24247--- /dev/null+++ b/saleor/static/dashboard-next/attributes/components/AttributeBulkDeleteDialog/index.ts@@ -0,0 +1,2 @@+export { default } from './AttributeBulkDeleteDialog';+export * from './AttributeBulkDeleteDialog';\ No newline at end of filediff --git a/saleor/static/dashboard-next/attributes/components/AttributeDetails/AttributeDetails.tsx b/saleor/static/dashboard-next/attributes/components/AttributeDetails/AttributeDetails.tsxnew file mode 100644index 0000000000..006c8dce70--- /dev/null+++ b/saleor/static/dashboard-next/attributes/components/AttributeDetails/AttributeDetails.tsx@@ -0,0 +1,46 @@+import Card from "@material-ui/core/Card";+import CardContent from "@material-ui/core/CardContent";+import TextField from "@material-ui/core/TextField";+import * as React from "react";++import CardTitle from "../../../components/CardTitle";+import FormSpacer from "../../../components/FormSpacer";+import i18n from "../../../i18n";+import { AttributePageFormData } from "../AttributePage";++export interface AttributeDetailsProps {+ data: AttributePageFormData;+ disabled: boolean;+ onChange: (event: React.ChangeEvent<any>) => void;+}++const AttributeDetails: React.FC<AttributeDetailsProps> = ({+ data,+ disabled,+ onChange+}) => (+ <Card>+ <CardTitle title={i18n.t("General Information")} />+ <CardContent>+ <TextField+ disabled={disabled}+ label={i18n.t("Default Label")}+ name={"name" as keyof AttributePageFormData}+ fullWidth+ value={data.name}+ onChange={onChange}+ />+ <FormSpacer />+ <TextField+ disabled={disabled}+ label={i18n.t("Attribute Code")}+ name={"slug" as keyof AttributePageFormData}+ fullWidth+ value={data.slug}+ onChange={onChange}+ />+ </CardContent>+ </Card>+);+AttributeDetails.displayName = "AttributeDetails";+export default AttributeDetails;diff --git a/saleor/static/dashboard-next/attributes/components/AttributeDetails/index.ts b/saleor/static/dashboard-next/attributes/components/AttributeDetails/index.tsnew file mode 100644index 0000000000..93e888b1e4--- /dev/null+++ b/saleor/static/dashboard-next/attributes/components/AttributeDetails/index.ts@@ -0,0 +1,2 @@+export { default } from './AttributeDetails';+export * from './AttributeDetails';\ No newline at end of filediff --git a/saleor/static/dashboard-next/attributes/components/AttributeList/AttributeList.tsx b/saleor/static/dashboard-next/attributes/components/AttributeList/AttributeList.tsxnew file mode 100644index 0000000000..6f85b2ae3f--- /dev/null+++ b/saleor/static/dashboard-next/attributes/components/AttributeList/AttributeList.tsx@@ -0,0 +1,124 @@+import { Theme } from "@material-ui/core/styles";+import Table from "@material-ui/core/Table";+import TableBody from "@material-ui/core/TableBody";+import TableCell from "@material-ui/core/TableCell";+import TableFooter from "@material-ui/core/TableFooter";+import TableRow from "@material-ui/core/TableRow";+import makeStyles from "@material-ui/styles/makeStyles";+import * as React from "react";++import Checkbox from "@saleor/components/Checkbox";+import Skeleton from "@saleor/components/Skeleton";+import TableHead from "@saleor/components/TableHead";+import TablePagination from "@saleor/components/TablePagination";+import i18n from "@saleor/i18n";+import { renderCollection } from "@saleor/misc";+import { ListActions, ListProps } from "@saleor/types";+import { AttributeList_attributes_edges_node } from "../../types/AttributeList";++export interface AttributeListProps extends ListProps, ListActions {+ attributes: AttributeList_attributes_edges_node[];+}++const useStyles = makeStyles((theme: Theme) => ({+ [theme.breakpoints.up("lg")]: {+ colName: {+ width: "auto"+ },+ colSlug: {+ width: 200+ }+ },+ colName: {},+ colSlug: {},+ link: {+ cursor: "pointer"+ }+}));++const AttributeList: React.StatelessComponent<AttributeListProps> = ({+ attributes,+ disabled,+ isChecked,+ onNextPage,+ onPreviousPage,+ onRowClick,+ pageInfo,+ selected,+ toggle,+ toggleAll,+ toolbar+}) => {+ const classes = useStyles();++ return (+ <Table>+ <TableHead+ selected={selected}+ disabled={disabled}+ items={attributes}+ toggleAll={toggleAll}+ toolbar={toolbar}+ >+ <TableCell className={classes.colSlug}>+ {i18n.t("Attribute Code", { context: "attribute slug" })}+ </TableCell>+ <TableCell className={classes.colName}>+ {i18n.t("Default Label", { context: "attribute name" })}+ </TableCell>+ </TableHead>+ <TableFooter>+ <TableRow>+ <TablePagination+ colSpan={3}+ hasNextPage={pageInfo && !disabled ? pageInfo.hasNextPage : false}+ onNextPage={onNextPage}+ hasPreviousPage={+ pageInfo && !disabled ? pageInfo.hasPreviousPage : false+ }+ onPreviousPage={onPreviousPage}+ />+ </TableRow>+ </TableFooter>+ <TableBody>+ {renderCollection(+ attributes,+ attribute => {+ const isSelected = attribute ? isChecked(attribute.id) : false;++ return (+ <TableRow+ selected={isSelected}+ hover={!!attribute}+ key={attribute ? attribute.id : "skeleton"}+ onClick={attribute && onRowClick(attribute.id)}+ className={classes.link}+ >+ <TableCell padding="checkbox">+ <Checkbox+ checked={isSelected}+ disabled={disabled}+ onChange={() => toggle(attribute.id)}+ />+ </TableCell>+ <TableCell className={classes.colSlug}>+ {attribute ? attribute.slug : <Skeleton />}+ </TableCell>+ <TableCell className={classes.colName}>+ {attribute ? attribute.name : <Skeleton />}+ </TableCell>+ </TableRow>+ );+ },+ () => (+ <TableRow>+ <TableCell colSpan={3}>{i18n.t("No attributes found")}</TableCell>+ </TableRow>+ )+ )}+ </TableBody>+ </Table>+ );+};+AttributeList.displayName = "AttributeList";+export default AttributeList;diff --git a/saleor/static/dashboard-next/attributes/components/AttributeList/index.ts b/saleor/static/dashboard-next/attributes/components/AttributeList/index.tsnew file mode 100644index 0000000000..4a094ce5f3--- /dev/null+++ b/saleor/static/dashboard-next/attributes/components/AttributeList/index.ts@@ -0,0 +1,2 @@+export { default } from './AttributeList';+export * from './AttributeList';\ No newline at end of filediff --git a/saleor/static/dashboard-next/attributes/components/AttributeListPage/AttributeListPage.tsx b/saleor/static/dashboard-next/attributes/components/AttributeListPage/AttributeListPage.tsxnew file mode 100644index 0000000000..e7d6839475--- /dev/null+++ b/saleor/static/dashboard-next/attributes/components/AttributeListPage/AttributeListPage.tsx@@ -0,0 +1,33 @@+import Button from "@material-ui/core/Button";+import Card from "@material-ui/core/Card";+import AddIcon from "@material-ui/icons/Add";+import * as React from "react";++import Container from "../../../components/Container";+import PageHeader from "../../../components/PageHeader";+import i18n from "../../../i18n";+import { ListActions, PageListProps } from "../../../types";+import { AttributeList_attributes_edges_node } from "../../types/AttributeList";+import AttributeList from "../AttributeList/AttributeList";++export interface AttributeListPageProps extends PageListProps, ListActions {+ attributes: AttributeList_attributes_edges_node[];+}++const AttributeListPage: React.FC<AttributeListPageProps> = ({+ onAdd,+ ...listProps+}) => (+ <Container>+ <PageHeader title={i18n.t("Attributes")}>+ <Button onClick={onAdd} color="primary" variant="contained">+ {i18n.t("Add attribute")} <AddIcon />+ </Button>+ </PageHeader>+ <Card>+ <AttributeList {...listProps} />+ </Card>+ </Container>+);+AttributeListPage.displayName = "AttributeListPage";+export default AttributeListPage;diff --git a/saleor/static/dashboard-next/attributes/components/AttributeListPage/index.ts b/saleor/static/dashboard-next/attributes/components/AttributeListPage/index.tsnew file mode 100644index 0000000000..e044052b69--- /dev/null+++ b/saleor/static/dashboard-next/attributes/components/AttributeListPage/index.ts@@ -0,0 +1,2 @@+export { default } from './AttributeListPage';+export * from './AttributeListPage';\ No newline at end of filediff --git a/saleor/static/dashboard-next/attributes/components/AttributePage/AttributePage.tsx b/saleor/static/dashboard-next/attributes/components/AttributePage/AttributePage.tsxnew file mode 100644index 0000000000..4522290f53--- /dev/null+++ b/saleor/static/dashboard-next/attributes/components/AttributePage/AttributePage.tsx@@ -0,0 +1,113 @@+import * as React from "react";++import AppHeader from "../../../components/AppHeader";+import CardSpacer from "../../../components/CardSpacer";+import { ConfirmButtonTransitionState } from "../../../components/ConfirmButton";+import Container from "../../../components/Container";+import Form from "../../../components/Form";+import Grid from "../../../components/Grid";+import PageHeader from "../../../components/PageHeader";+import SaveButtonBar from "../../../components/SaveButtonBar";+import i18n from "../../../i18n";+import { maybe } from "../../../misc";+import {+ AttributeDetailsFragment,+ AttributeDetailsFragment_values+} from "../../types/AttributeDetailsFragment";+import AttributeDetails from "../AttributeDetails";+import AttributeValues from "../AttributeValues";++export interface AttributePageProps {+ attribute: AttributeDetailsFragment | null;+ disabled: boolean;+ saveButtonBarState: ConfirmButtonTransitionState;+ values: AttributeDetailsFragment_values[];+ onBack: () => void;+ onDelete: () => void;+ onSubmit: (data: AttributePageFormData) => void;+ onValueAdd: () => void;+ onValueDelete: (id: string, event: React.MouseEvent<any>) => void;+ onValueUpdate: (id: string) => void;+}++export interface AttributePageFormData {+ name: string;+ slug: string;+}++const AttributePage: React.FC<AttributePageProps> = ({+ attribute,+ disabled,+ saveButtonBarState,+ values,+ onBack,+ onDelete,+ onSubmit,+ onValueAdd,+ onValueDelete,+ onValueUpdate+}) => {+ const initialForm: AttributePageFormData =+ attribute === null+ ? {+ name: "",+ slug: ""+ }+ : {+ name: maybe(() => attribute.name, ""),+ slug: maybe(() => attribute.slug, "")+ };++ return (+ <Form initial={initialForm} onSubmit={onSubmit}>+ {({ change, data, submit }) => (+ <Container>+ <AppHeader onBack={onBack}>{i18n.t("Attributes")}</AppHeader>+ <PageHeader+ title={+ attribute === null+ ? i18n.t("Create New Attribute", {+ context: "page title"+ })+ : maybe(() => attribute.name)+ }+ />+ <Grid>+ <div>+ <AttributeDetails+ data={data}+ disabled={disabled}+ onChange={change}+ />+ <CardSpacer />+ <AttributeValues+ disabled={disabled}+ values={values}+ onValueAdd={onValueAdd}+ onValueDelete={onValueDelete}+ onValueUpdate={onValueUpdate}+ />+ </div>+ {/* TODO: Uncomment after restricting some attributes to be only product attributes */}+ {/* <div>+ <AttributeProperties+ data={data}+ disabled={disabled}+ onChange={change}+ />+ </div> */}+ </Grid>+ <SaveButtonBar+ disabled={disabled}+ state={saveButtonBarState}+ onCancel={onBack}+ onSave={submit}+ onDelete={attribute === null ? undefined : onDelete}+ />+ </Container>+ )}+ </Form>+ );+};+AttributePage.displayName = "AttributePage";+export default AttributePage;diff --git a/saleor/static/dashboard-next/attributes/components/AttributePage/index.ts b/saleor/static/dashboard-next/attributes/components/AttributePage/index.tsnew file mode 100644index 0000000000..08880e9d81--- /dev/null+++ b/saleor/static/dashboard-next/attributes/components/AttributePage/index.ts@@ -0,0 +1,2 @@+export { default } from './AttributePage';+export * from './AttributePage';\ No newline at end of filediff --git a/saleor/static/dashboard-next/attributes/components/AttributeProperties/AttributeProperties.tsx b/saleor/static/dashboard-next/attributes/components/AttributeProperties/AttributeProperties.tsxnew file mode 100644index 0000000000..f9a83460d7--- /dev/null+++ b/saleor/static/dashboard-next/attributes/components/AttributeProperties/AttributeProperties.tsx@@ -0,0 +1,51 @@+import Card from "@material-ui/core/Card";+import CardContent from "@material-ui/core/CardContent";+import Typography from "@material-ui/core/Typography";+import * as React from "react";++import CardSpacer from "../../../components/CardSpacer";+import CardTitle from "../../../components/CardTitle";+import ControlledSwitch from "../../../components/ControlledSwitch";+import Hr from "../../../components/Hr";+import i18n from "../../../i18n";+import { AttributePageFormData } from "../AttributePage";++export interface AttributePropertiesProps {+ data: AttributePageFormData;+ disabled: boolean;+ onChange: (event: React.ChangeEvent<any>) => void;+}++const AttributeProperties: React.FC<AttributePropertiesProps> = ({+ disabled,+ onChange+}) => (+ <Card>+ <CardTitle title={i18n.t("Properties")} />+ <CardContent>+ <Typography variant="subtitle1">+ {i18n.t("General Properties")}+ </Typography>+ <Hr />+ <CardSpacer />+ <ControlledSwitch+ name={"" as keyof AttributePageFormData}+ checked={false}+ disabled={disabled}+ label={+ <>+ <span>{i18n.t("Variant Attribute")}</span>+ <Typography variant="caption">+ {i18n.t(+ "If enabled, you'll be able to use this attribute to create product variants"+ )}+ </Typography>+ </>+ }+ onChange={onChange}+ />+ </CardContent>+ </Card>+);+AttributeProperties.displayName = "AttributeProperties";+export default AttributeProperties;diff --git a/saleor/static/dashboard-next/attributes/components/AttributeProperties/index.ts b/saleor/static/dashboard-next/attributes/components/AttributeProperties/index.tsnew file mode 100644index 0000000000..4f02c2478a--- /dev/null+++ b/saleor/static/dashboard-next/attributes/components/AttributeProperties/index.ts@@ -0,0 +1,2 @@+export { default } from './AttributeProperties';+export * from './AttributeProperties';\ No newline at end of filediff --git a/saleor/static/dashboard-next/attributes/components/AttributeValueBulkDeleteDialog/AttributeValueBulkDeleteDialog.tsx b/saleor/static/dashboard-next/attributes/components/AttributeValueBulkDeleteDialog/AttributeValueBulkDeleteDialog.tsxnew file mode 100644index 0000000000..9944acd618--- /dev/null+++ b/saleor/static/dashboard-next/attributes/components/AttributeValueBulkDeleteDialog/AttributeValueBulkDeleteDialog.tsx@@ -0,0 +1,9 @@+import * as React from "react";++export interface AttributeValueBulkDeleteDialogProps {++}++const AttributeValueBulkDeleteDialog: React.StatelessComponent<AttributeValueBulkDeleteDialogProps> = () => <div />;+AttributeValueBulkDeleteDialog.displayName = "AttributeValueBulkDeleteDialog";+export default AttributeValueBulkDeleteDialog;diff --git a/saleor/static/dashboard-next/attributes/components/AttributeValueBulkDeleteDialog/index.ts b/saleor/static/dashboard-next/attributes/components/AttributeValueBulkDeleteDialog/index.tsnew file mode 100644index 0000000000..8394647b55--- /dev/null+++ b/saleor/static/dashboard-next/attributes/components/AttributeValueBulkDeleteDialog/index.ts@@ -0,0 +1,2 @@+export { default } from './AttributeValueBulkDeleteDialog';+export * from './AttributeValueBulkDeleteDialog';\ No newline at end of filediff --git a/saleor/static/dashboard-next/attributes/components/AttributeValueDeleteDialog/AttributeValueDeleteDialog.tsx b/saleor/static/dashboard-next/attributes/components/AttributeValueDeleteDialog/AttributeValueDeleteDialog.tsxnew file mode 100644index 0000000000..09b8f1e0ab--- /dev/null+++ b/saleor/static/dashboard-next/attributes/components/AttributeValueDeleteDialog/AttributeValueDeleteDialog.tsx@@ -0,0 +1,9 @@+import * as React from "react";++export interface AttributeValueDeleteDialogProps {++}++const AttributeValueDeleteDialog: React.StatelessComponent<AttributeValueDeleteDialogProps> = () => <div />;+AttributeValueDeleteDialog.displayName = "AttributeValueDeleteDialog";+export default AttributeValueDeleteDialog;diff --git a/saleor/static/dashboard-next/attributes/components/AttributeValueDeleteDialog/index.ts b/saleor/static/dashboard-next/attributes/components/AttributeValueDeleteDialog/index.tsnew file mode 100644index 0000000000..b58e72f50e--- /dev/null+++ b/saleor/static/dashboard-next/attributes/components/AttributeValueDeleteDialog/index.ts@@ -0,0 +1,2 @@+export { default } from './AttributeValueDeleteDialog';+export * from './AttributeValueDeleteDialog';\ No newline at end of filediff --git a/saleor/static/dashboard-next/attributes/components/AttributeValueEditDialog/AttributeValueEditDialog.tsx b/saleor/static/dashboard-next/attributes/components/AttributeValueEditDialog/AttributeValueEditDialog.tsxnew file mode 100644index 0000000000..b6efd4bec0--- /dev/null+++ b/saleor/static/dashboard-next/attributes/components/AttributeValueEditDialog/AttributeValueEditDialog.tsx@@ -0,0 +1,9 @@+import * as React from "react";++export interface AttributeValueEditDialogProps {++}++const AttributeValueEditDialog: React.StatelessComponent<AttributeValueEditDialogProps> = () => <div />;+AttributeValueEditDialog.displayName = "AttributeValueEditDialog";+export default AttributeValueEditDialog;diff --git a/saleor/static/dashboard-next/attributes/components/AttributeValueEditDialog/index.ts b/saleor/static/dashboard-next/attributes/components/AttributeValueEditDialog/index.tsnew file mode 100644index 0000000000..1dfc3d061a--- /dev/null+++ b/saleor/static/dashboard-next/attributes/components/AttributeValueEditDialog/index.ts@@ -0,0 +1,2 @@+export { default } from './AttributeValueEditDialog';+export * from './AttributeValueEditDialog';\ No newline at end of filediff --git a/saleor/static/dashboard-next/attributes/components/AttributeValues/AttributeValues.tsx b/saleor/static/dashboard-next/attributes/components/AttributeValues/AttributeValues.tsxnew file mode 100644index 0000000000..500cd38ad2--- /dev/null+++ b/saleor/static/dashboard-next/attributes/components/AttributeValues/AttributeValues.tsx@@ -0,0 +1,115 @@+import Button from "@material-ui/core/Button";+import Card from "@material-ui/core/Card";+import IconButton from "@material-ui/core/IconButton";+import { Theme } from "@material-ui/core/styles";+import Table from "@material-ui/core/Table";+import TableBody from "@material-ui/core/TableBody";+import TableCell from "@material-ui/core/TableCell";+import TableHead from "@material-ui/core/TableHead";+import TableRow from "@material-ui/core/TableRow";+import DeleteIcon from "@material-ui/icons/Delete";+import makeStyles from "@material-ui/styles/makeStyles";+import * as React from "react";++import CardTitle from "../../../components/CardTitle";+import Skeleton from "../../../components/Skeleton";+import i18n from "../../../i18n";+import { maybe, renderCollection } from "../../../misc";+import { AttributeDetailsFragment_values } from "../../types/AttributeDetailsFragment";++export interface AttributeValuesProps {+ disabled: boolean;+ values: AttributeDetailsFragment_values[];+ onValueAdd: () => void;+ onValueDelete: (id: string, event: React.MouseEvent<any>) => void;+ onValueUpdate: (id: string) => void;+}++const useStyles = makeStyles((theme: Theme) => ({+ columnAdmin: {+ width: 300+ },+ columnStore: {+ width: 300+ },+ iconCell: {+ "&:last-child": {+ paddingRight: 0+ },+ width: 48 + theme.spacing.unit / 2+ },+ link: {+ cursor: "pointer"+ }+}));++const AttributeValues: React.FC<AttributeValuesProps> = ({+ disabled,+ onValueAdd,+ onValueDelete,+ onValueUpdate,+ values+}) => {+ const classes = useStyles();++ return (+ <Card>+ <CardTitle+ title={i18n.t("Attribute Values")}+ toolbar={+ <Button color="primary" variant="text" onClick={onValueAdd}>+ {i18n.t("Add value", { context: "button" })}+ </Button>+ }+ />+ <Table>+ <TableHead>+ <TableRow>+ <TableCell className={classes.columnAdmin}>+ {i18n.t("Admin")}+ </TableCell>+ <TableCell className={classes.columnStore}>+ {i18n.t("Default Store View")}+ </TableCell>+ <TableCell />+ </TableRow>+ </TableHead>+ <TableBody>+ {renderCollection(+ values.sort((a, b) => (a.sortOrder > b.sortOrder ? 1 : -1)),+ value => (+ <TableRow+ className={!!value ? classes.link : undefined}+ hover={!!value}+ onClick={!!value ? () => onValueUpdate(value.id) : undefined}+ key={maybe(() => value.id)}+ >+ <TableCell>+ {maybe(() => value.slug) ? value.slug : <Skeleton />}+ </TableCell>+ <TableCell>+ {maybe(() => value.name) ? value.name : <Skeleton />}+ </TableCell>+ <TableCell className={classes.iconCell}>+ <IconButton+ disabled={disabled}+ onClick={event => onValueDelete(value.id, event)}+ >+ <DeleteIcon color="primary" />+ </IconButton>+ </TableCell>+ </TableRow>+ ),+ () => (+ <TableRow>+ <TableCell colSpan={2}>{i18n.t("No values found")}</TableCell>+ </TableRow>+ )+ )}+ </TableBody>+ </Table>+ </Card>+ );+};+AttributeValues.displayName = "AttributeValues";+export default AttributeValues;diff --git a/saleor/static/dashboard-next/attributes/components/AttributeValues/index.ts b/saleor/static/dashboard-next/attributes/components/AttributeValues/index.tsnew file mode 100644index 0000000000..dae7f6baf1--- /dev/null+++ b/saleor/static/dashboard-next/attributes/components/AttributeValues/index.ts@@ -0,0 +1,2 @@+export { default } from './AttributeValues';+export * from './AttributeValues';\ No newline at end of filediff --git a/saleor/static/dashboard-next/attributes/fixtures.ts b/saleor/static/dashboard-next/attributes/fixtures.tsnew file mode 100644index 0000000000..c61b092f9d--- /dev/null+++ b/saleor/static/dashboard-next/attributes/fixtures.ts@@ -0,0 +1,466 @@+import { AttributeList_attributes_edges_node } from "./types/AttributeList";++export const attribute = {+ __typename: "Attribute" as "Attribute",+ id: "UHJvZHVjdEF0dHJpYnV0ZTo5",+ name: "Author",+ slug: "author",+ values: [+ {+ __typename: "AttributeValue" as "AttributeValue",+ id: "UHJvZHVjdEF0dHJpYnV0ZVZhbHVlOjI0",+ name: "John Doe",+ slug: "john-doe",+ sortOrder: 0,+ type: "STRING",+ value: ""+ },+ {+ __typename: "AttributeValue" as "AttributeValue",+ id: "UHJvZHVjdEF0dHJpYnV0ZVZhbHVlOjI1",+ name: "Milionare Pirate",+ slug: "milionare-pirate",+ sortOrder: 1,+ type: "STRING",+ value: ""+ }+ ]+};++export const attributes: AttributeList_attributes_edges_node[] = [+ {+ node: {+ __typename: "Attribute" as "Attribute",+ id: "UHJvZHVjdEF0dHJpYnV0ZTo5",+ name: "Author",+ slug: "author",+ values: [+ {+ __typename: "AttributeValue" as "AttributeValue",+ id: "UHJvZHVjdEF0dHJpYnV0ZVZhbHVlOjI0",+ name: "John Doe",+ slug: "john-doe",+ sortOrder: 0,+ type: "STRING",+ value: ""+ },+ {+ __typename: "AttributeValue" as "AttributeValue",+ id: "UHJvZHVjdEF0dHJpYnV0ZVZhbHVlOjI1",+ name: "Milionare Pirate",+ slug: "milionare-pirate",+ sortOrder: 1,+ type: "STRING",+ value: ""+ }+ ]+ }+ },+ {+ node: {+ __typename: "Attribute" as "Attribute",+ id: "UHJvZHVjdEF0dHJpYnV0ZTo2",+ name: "Box Size",+ slug: "box-size",+ values: [+ {+ __typename: "AttributeValue" as "AttributeValue",+ id: "UHJvZHVjdEF0dHJpYnV0ZVZhbHVlOjE1",+ name: "100g",+ slug: "100g",+ sortOrder: 0,+ type: "STRING",+ value: ""+ },+ {+ __typename: "AttributeValue" as "AttributeValue",+ id: "UHJvZHVjdEF0dHJpYnV0ZVZhbHVlOjE2",+ name: "250g",+ slug: "250g",+ sortOrder: 1,+ type: "STRING",+ value: ""+ },+ {+ __typename: "AttributeValue" as "AttributeValue",+ id: "UHJvZHVjdEF0dHJpYnV0ZVZhbHVlOjE3",+ name: "500g",+ slug: "500g",+ sortOrder: 2,+ type: "STRING",+ value: ""+ },+ {+ __typename: "AttributeValue" as "AttributeValue",+ id: "UHJvZHVjdEF0dHJpYnV0ZVZhbHVlOjE4",+ name: "1kg",+ slug: "1kg",+ sortOrder: 3,+ type: "STRING",+ value: ""+ }+ ]+ }+ },+ {+ node: {+ __typename: "Attribute" as "Attribute",+ id: "UHJvZHVjdEF0dHJpYnV0ZToz",+ name: "Brand",+ slug: "brand",+ values: [+ {+ __typename: "AttributeValue" as "AttributeValue",+ id: "UHJvZHVjdEF0dHJpYnV0ZVZhbHVlOjY=",+ name: "Saleor",+ slug: "saleor",+ sortOrder: 0,+ type: "STRING",+ value: ""+ }+ ]+ }+ },+ {+ node: {+ __typename: "Attribute" as "Attribute",+ id: "UHJvZHVjdEF0dHJpYnV0ZTo4",+ name: "Candy Box Size",+ slug: "candy-box-size",+ values: [+ {+ __typename: "AttributeValue" as "AttributeValue",+ id: "UHJvZHVjdEF0dHJpYnV0ZVZhbHVlOjIx",+ name: "100g",+ slug: "100g",+ sortOrder: 0,+ type: "STRING",+ value: ""+ },+ {+ __typename: "AttributeValue" as "AttributeValue",+ id: "UHJvZHVjdEF0dHJpYnV0ZVZhbHVlOjIy",+ name: "250g",+ slug: "250g",+ sortOrder: 1,+ type: "STRING",+ value: ""+ },+ {+ __typename: "AttributeValue" as "AttributeValue",+ id: "UHJvZHVjdEF0dHJpYnV0ZVZhbHVlOjIz",+ name: "500g",+ slug: "500g",+ sortOrder: 2,+ type: "STRING",+ value: ""+ }+ ]+ }+ },+ {+ node: {+ __typename: "Attribute" as "Attribute",+ id: "UHJvZHVjdEF0dHJpYnV0ZTo1",+ name: "Coffee Genre",+ slug: "coffee-genre",+ values: [+ {+ __typename: "AttributeValue" as "AttributeValue",+ id: "UHJvZHVjdEF0dHJpYnV0ZVZhbHVlOjEz",+ name: "Arabica",+ slug: "arabica",+ sortOrder: 0,+ type: "STRING",+ value: ""+ },+ {+ __typename: "AttributeValue" as "AttributeValue",+ id: "UHJvZHVjdEF0dHJpYnV0ZVZhbHVlOjE0",+ name: "Robusta",+ slug: "robusta",+ sortOrder: 1,+ type: "STRING",+ value: ""+ }+ ]+ }+ },+ {+ node: {+ __typename: "Attribute" as "Attribute",+ id: "UHJvZHVjdEF0dHJpYnV0ZToy",+ name: "Collar",+ slug: "collar",+ values: [+ {+ __typename: "AttributeValue" as "AttributeValue",+ id: "UHJvZHVjdEF0dHJpYnV0ZVZhbHVlOjM=",+ name: "Round",+ slug: "round",+ sortOrder: 0,+ type: "STRING",+ value: ""+ },+ {+ __typename: "AttributeValue" as "AttributeValue",+ id: "UHJvZHVjdEF0dHJpYnV0ZVZhbHVlOjQ=",+ name: "V-Neck",+ slug: "v-neck",+ sortOrder: 1,+ type: "STRING",+ value: ""+ },+ {+ __typename: "AttributeValue" as "AttributeValue",+ id: "UHJvZHVjdEF0dHJpYnV0ZVZhbHVlOjU=",+ name: "Polo",+ slug: "polo",+ sortOrder: 2,+ type: "STRING",+ value: ""+ }+ ]+ }+ },+ {+ node: {+ __typename: "Attribute" as "Attribute",+ id: "UHJvZHVjdEF0dHJpYnV0ZTox",+ name: "Color",+ slug: "color",+ values: [+ {+ __typename: "AttributeValue" as "AttributeValue",+ id: "UHJvZHVjdEF0dHJpYnV0ZVZhbHVlOjE=",+ name: "Blue",+ slug: "blue",+ sortOrder: 0,+ type: "STRING",+ value: ""+ },+ {+ __typename: "AttributeValue" as "AttributeValue",+ id: "UHJvZHVjdEF0dHJpYnV0ZVZhbHVlOjI=",+ name: "White",+ slug: "white",+ sortOrder: 1,+ type: "STRING",+ value: ""+ }+ ]+ }+ },+ {+ node: {+ __typename: "Attribute" as "Attribute",+ id: "UHJvZHVjdEF0dHJpYnV0ZToxMg==",+ name: "Cover",+ slug: "cover",+ values: [+ {+ __typename: "AttributeValue" as "AttributeValue",+ id: "UHJvZHVjdEF0dHJpYnV0ZVZhbHVlOjMw",+ name: "Soft",+ slug: "soft",+ sortOrder: 0,+ type: "STRING",+ value: ""+ },+ {+ __typename: "AttributeValue" as "AttributeValue",+ id: "UHJvZHVjdEF0dHJpYnV0ZVZhbHVlOjMx",+ name: "Hard",+ slug: "hard",+ sortOrder: 1,+ type: "STRING",+ value: ""+ },+ {+ __typename: "AttributeValue" as "AttributeValue",+ id: "UHJvZHVjdEF0dHJpYnV0ZVZhbHVlOjMy",+ name: "Middle soft",+ slug: "middle-soft",+ sortOrder: 2,+ type: "STRING",+ value: ""+ },+ {+ __typename: "AttributeValue" as "AttributeValue",+ id: "UHJvZHVjdEF0dHJpYnV0ZVZhbHVlOjMz",+ name: "Middle hard",+ slug: "middle-hard",+ sortOrder: 3,+ type: "STRING",+ value: ""+ },+ {+ __typename: "AttributeValue" as "AttributeValue",+ id: "UHJvZHVjdEF0dHJpYnV0ZVZhbHVlOjM0",+ name: "Middle",+ slug: "middle",+ sortOrder: 4,+ type: "STRING",+ value: ""+ },+ {+ __typename: "AttributeValue" as "AttributeValue",+ id: "UHJvZHVjdEF0dHJpYnV0ZVZhbHVlOjM1",+ name: "Very hard",+ slug: "very-hard",+ sortOrder: 5,+ type: "STRING",+ value: ""+ }+ ]+ }+ },+ {+ node: {+ __typename: "Attribute" as "Attribute",+ id: "UHJvZHVjdEF0dHJpYnV0ZTo3",+ name: "Flavor",+ slug: "flavor",+ values: [+ {+ __typename: "AttributeValue" as "AttributeValue",+ id: "UHJvZHVjdEF0dHJpYnV0ZVZhbHVlOjE5",+ name: "Sour",+ slug: "sour",+ sortOrder: 0,+ type: "STRING",+ value: ""+ },+ {+ __typename: "AttributeValue" as "AttributeValue",+ id: "UHJvZHVjdEF0dHJpYnV0ZVZhbHVlOjIw",+ name: "Sweet",+ slug: "sweet",+ sortOrder: 1,+ type: "STRING",+ value: ""+ }+ ]+ }+ },+ {+ node: {+ __typename: "Attribute" as "Attribute",+ id: "UHJvZHVjdEF0dHJpYnV0ZToxMQ==",+ name: "Language",+ slug: "language",+ values: [+ {+ __typename: "AttributeValue" as "AttributeValue",+ id: "UHJvZHVjdEF0dHJpYnV0ZVZhbHVlOjI4",+ name: "English",+ slug: "english",+ sortOrder: 0,+ type: "STRING",+ value: ""+ },+ {+ __typename: "AttributeValue" as "AttributeValue",+ id: "UHJvZHVjdEF0dHJpYnV0ZVZhbHVlOjI5",+ name: "Pirate",+ slug: "pirate",+ sortOrder: 1,+ type: "STRING",+ value: ""+ }+ ]+ }+ },+ {+ node: {+ __typename: "Attribute" as "Attribute",+ id: "UHJvZHVjdEF0dHJpYnV0ZToxMA==",+ name: "Publisher",+ slug: "publisher",+ values: [+ {+ __typename: "AttributeValue" as "AttributeValue",+ id: "UHJvZHVjdEF0dHJpYnV0ZVZhbHVlOjI2",+ name: "Mirumee Press",+ slug: "mirumee-press",+ sortOrder: 0,+ type: "STRING",+ value: ""+ },+ {+ __typename: "AttributeValue" as "AttributeValue",+ id: "UHJvZHVjdEF0dHJpYnV0ZVZhbHVlOjI3",+ name: "Saleor Publishing",+ slug: "saleor-publishing",+ sortOrder: 1,+ type: "STRING",+ value: ""+ }+ ]+ }+ },+ {+ node: {+ __typename: "Attribute" as "Attribute",+ id: "UHJvZHVjdEF0dHJpYnV0ZTo0",+ name: "Size",+ slug: "size",+ values: [+ {+ __typename: "AttributeValue" as "AttributeValue",+ id: "UHJvZHVjdEF0dHJpYnV0ZVZhbHVlOjc=",+ name: "XS",+ slug: "xs",+ sortOrder: 0,+ type: "STRING",+ value: ""+ },+ {+ __typename: "AttributeValue" as "AttributeValue",+ id: "UHJvZHVjdEF0dHJpYnV0ZVZhbHVlOjg=",+ name: "S",+ slug: "s",+ sortOrder: 1,+ type: "STRING",+ value: ""+ },+ {+ __typename: "AttributeValue" as "AttributeValue",+ id: "UHJvZHVjdEF0dHJpYnV0ZVZhbHVlOjk=",+ name: "M",+ slug: "m",+ sortOrder: 2,+ type: "STRING",+ value: ""+ },+ {+ __typename: "AttributeValue" as "AttributeValue",+ id: "UHJvZHVjdEF0dHJpYnV0ZVZhbHVlOjEw",+ name: "L",+ slug: "l",+ sortOrder: 3,+ type: "STRING",+ value: ""+ },+ {+ __typename: "AttributeValue" as "AttributeValue",+ id: "UHJvZHVjdEF0dHJpYnV0ZVZhbHVlOjEx",+ name: "XL",+ slug: "xl",+ sortOrder: 4,+ type: "STRING",+ value: ""+ },+ {+ __typename: "AttributeValue" as "AttributeValue",+ id: "UHJvZHVjdEF0dHJpYnV0ZVZhbHVlOjEy",+ name: "XXL",+ slug: "xxl",+ sortOrder: 5,+ type: "STRING",+ value: ""+ }+ ]+ }+ }+].map(edge => edge.node);diff --git a/saleor/static/dashboard-next/attributes/index.tsx b/saleor/static/dashboard-next/attributes/index.tsxnew file mode 100644index 0000000000..9aa9ffb435--- /dev/null+++ b/saleor/static/dashboard-next/attributes/index.tsx@@ -0,0 +1,28 @@+import { parse as parseQs } from "qs";+import * as React from "react";+import { Route, RouteComponentProps, Switch } from "react-router-dom";++import { WindowTitle } from "../components/WindowTitle";+import i18n from "../i18n";+import {+ attributeAddPath,+ attributeListPath,+ AttributeListUrlQueryParams+} from "./urls";+import AttributeListComponent from "./views/AttributeList";++const AttributeList: React.FC<RouteComponentProps<{}>> = ({ location }) => {+ const qs = parseQs(location.search.substr(1));+ const params: AttributeListUrlQueryParams = qs;+ return <AttributeListComponent params={params} />;+};++export const AttributeSection: React.FC = () => (+ <>+ <WindowTitle title={i18n.t("Attributes")} />+ <Switch>+ <Route exact path={attributeListPath} component={AttributeList} />+ </Switch>+ </>+);+export default AttributeSection;diff --git a/saleor/static/dashboard-next/attributes/mutations.ts b/saleor/static/dashboard-next/attributes/mutations.tsnew file mode 100644index 0000000000..1f323d3f9c--- /dev/null+++ b/saleor/static/dashboard-next/attributes/mutations.ts@@ -0,0 +1,22 @@+import gql from "graphql-tag";++import { TypedMutation } from "@saleor/mutations";+import {+ AttributeBulkDelete,+ AttributeBulkDeleteVariables+} from "./types/AttributeBulkDelete";++const attributeBulkDelete = gql`+ mutation AttributeBulkDelete($ids: [ID!]!) {+ attributeBulkDelete(ids: $ids) {+ errors {+ field+ message+ }+ }+ }+`;+export const AttributeBulkDeleteMutation = TypedMutation<+ AttributeBulkDelete,+ AttributeBulkDeleteVariables+>(attributeBulkDelete);diff --git a/saleor/static/dashboard-next/attributes/queries.ts b/saleor/static/dashboard-next/attributes/queries.tsnew file mode 100644index 0000000000..7a06aa6e49--- /dev/null+++ b/saleor/static/dashboard-next/attributes/queries.ts@@ -0,0 +1,81 @@+import gql from "graphql-tag";++import { pageInfoFragment, TypedQuery } from "../queries";+import {+ AttributeDetails,+ AttributeDetailsVariables+} from "./types/AttributeDetails";+import { AttributeList, AttributeListVariables } from "./types/AttributeList";++export const attributeFragment = gql`+ fragment AttributeFragment on Attribute {+ id+ name+ slug+ }+`;++export const attributeDetailsFragment = gql`+ ${attributeFragment}+ fragment AttributeDetailsFragment on Attribute {+ ...AttributeFragment+ values {+ id+ name+ slug+ sortOrder+ type+ value+ }+ }+`;++const attributeDetails = gql`+ ${attributeDetailsFragment}+ query AttributeDetails($id: ID!) {+ attribute(id: $id) {+ ...AttributeDetailsFragment+ }+ }+`;+export const AttributeDetailsQuery = TypedQuery<+ AttributeDetails,+ AttributeDetailsVariables+>(attributeDetails);++const attributeList = gql`+ ${attributeFragment}+ ${pageInfoFragment}+ query AttributeList(+ $query: String+ $inCategory: ID+ $inCollection: ID+ $before: String+ $after: String+ $first: Int+ $last: Int+ ) {+ attributes(+ query: $query+ inCategory: $inCategory+ inCollection: $inCollection+ before: $before+ after: $after+ first: $first+ last: $last+ ) {+ edges {+ node {+ ...AttributeFragment+ }+ }+ pageInfo {+ ...PageInfoFragment+ }+ }+ }+`;+export const AttributeListQuery = TypedQuery<+ AttributeList,+ AttributeListVariables+>(attributeList);diff --git a/saleor/static/dashboard-next/attributes/types/AttributeBulkDelete.ts b/saleor/static/dashboard-next/attributes/types/AttributeBulkDelete.tsnew file mode 100644index 0000000000..06ff83fd72--- /dev/null+++ b/saleor/static/dashboard-next/attributes/types/AttributeBulkDelete.ts@@ -0,0 +1,26 @@+/* tslint:disable */+/* eslint-disable */+// This file was automatically generated and should not be edited.++// ====================================================+// GraphQL mutation operation: AttributeBulkDelete+// ====================================================++export interface AttributeBulkDelete_attributeBulkDelete_errors {+ __typename: "Error";+ field: string | null;+ message: string | null;+}++export interface AttributeBulkDelete_attributeBulkDelete {+ __typename: "AttributeBulkDelete";+ errors: AttributeBulkDelete_attributeBulkDelete_errors[] | null;+}++export interface AttributeBulkDelete {+ attributeBulkDelete: AttributeBulkDelete_attributeBulkDelete | null;+}++export interface AttributeBulkDeleteVariables {+ ids: string[];+}diff --git a/saleor/static/dashboard-next/attributes/types/AttributeDetails.ts b/saleor/static/dashboard-next/attributes/types/AttributeDetails.tsnew file mode 100644index 0000000000..9c3947fa51--- /dev/null+++ b/saleor/static/dashboard-next/attributes/types/AttributeDetails.ts@@ -0,0 +1,35 @@+/* tslint:disable */+/* eslint-disable */+// This file was automatically generated and should not be edited.++import { AttributeValueType } from "./../../types/globalTypes";++// ====================================================+// GraphQL query operation: AttributeDetails+// ====================================================++export interface AttributeDetails_attribute_values {+ __typename: "AttributeValue";+ id: string;+ name: string | null;+ slug: string | null;+ sortOrder: number | null;+ type: AttributeValueType | null;+ value: string | null;+}++export interface AttributeDetails_attribute {+ __typename: "Attribute";+ id: string;+ name: string | null;+ slug: string | null;+ values: (AttributeDetails_attribute_values | null)[] | null;+}++export interface AttributeDetails {+ attribute: AttributeDetails_attribute | null;+}++export interface AttributeDetailsVariables {+ id: string;+}diff --git a/saleor/static/dashboard-next/attributes/types/AttributeDetailsFragment.ts b/saleor/static/dashboard-next/attributes/types/AttributeDetailsFragment.tsnew file mode 100644index 0000000000..95d1fd1bd9--- /dev/null+++ b/saleor/static/dashboard-next/attributes/types/AttributeDetailsFragment.ts@@ -0,0 +1,27 @@+/* tslint:disable */+/* eslint-disable */+// This file was automatically generated and should not be edited.++import { AttributeValueType } from "./../../types/globalTypes";++// ====================================================+// GraphQL fragment: AttributeDetailsFragment+// ====================================================++export interface AttributeDetailsFragment_values {+ __typename: "AttributeValue";+ id: string;+ name: string | null;+ slug: string | null;+ sortOrder: number | null;+ type: AttributeValueType | null;+ value: string | null;+}++export interface AttributeDetailsFragment {+ __typename: "Attribute";+ id: string;+ name: string | null;+ slug: string | null;+ values: (AttributeDetailsFragment_values | null)[] | null;+}diff --git a/saleor/static/dashboard-next/attributes/types/AttributeList.ts b/saleor/static/dashboard-next/attributes/types/AttributeList.tsnew file mode 100644index 0000000000..6fbcd8338a--- /dev/null+++ b/saleor/static/dashboard-next/attributes/types/AttributeList.ts@@ -0,0 +1,55 @@+/* tslint:disable */+/* eslint-disable */+// This file was automatically generated and should not be edited.++// ====================================================+// GraphQL query operation: AttributeList+// ====================================================++export interface AttributeList_attributes_edges_node_values {+ __typename: "AttributeValue";+ id: string;+ name: string | null;+ slug: string | null;+}++export interface AttributeList_attributes_edges_node {+ __typename: "Attribute";+ id: string;+ name: string | null;+ slug: string | null;+ values: (AttributeList_attributes_edges_node_values | null)[] | null;+}++export interface AttributeList_attributes_edges {+ __typename: "AttributeCountableEdge";+ node: AttributeList_attributes_edges_node;+}++export interface AttributeList_attributes_pageInfo {+ __typename: "PageInfo";+ endCursor: string | null;+ hasNextPage: boolean;+ hasPreviousPage: boolean;+ startCursor: string | null;+}++export interface AttributeList_attributes {+ __typename: "AttributeCountableConnection";+ edges: AttributeList_attributes_edges[];+ pageInfo: AttributeList_attributes_pageInfo;+}++export interface AttributeList {+ attributes: AttributeList_attributes | null;+}++export interface AttributeListVariables {+ query?: string | null;+ inCategory?: string | null;+ inCollection?: string | null;+ before?: string | null;+ after?: string | null;+ first?: number | null;+ last?: number | null;+}diff --git a/saleor/static/dashboard-next/attributes/urls.ts b/saleor/static/dashboard-next/attributes/urls.tsnew file mode 100644index 0000000000..bb50944e51--- /dev/null+++ b/saleor/static/dashboard-next/attributes/urls.ts@@ -0,0 +1,27 @@+import { stringify as stringifyQs } from "qs";+import * as urlJoin from "url-join";++import { BulkAction, Dialog, Pagination } from "../types";++export const attributeSection = "/attributes/";++export type AttributeListUrlDialog = "remove";+export type AttributeListUrlQueryParams = BulkAction &+ Dialog<AttributeListUrlDialog> &+ Pagination;+export const attributeListPath = attributeSection;+export const attributeListUrl = (params?: AttributeListUrlQueryParams) =>+ attributeListPath + "?" + stringifyQs(params);++export type AttributeAddUrlDialog =+ | "add-value"+ | "remove-value"+ | "remove-values";+export type AttributeAddUrlQueryParams = Dialog<AttributeAddUrlDialog>;+export const attributeAddPath = urlJoin(attributeSection, "add");+export const attributeAddUrl = (params?: AttributeAddUrlQueryParams) =>+ attributeAddPath + "?" + stringifyQs(params);++export const attributePath = (id: string) => urlJoin(attributeSection, id);+export const attributeUrl = (id: string) =>+ attributePath(encodeURIComponent(id));diff --git a/saleor/static/dashboard-next/attributes/views/AttributeCreate/AttributeCreate.tsx b/saleor/static/dashboard-next/attributes/views/AttributeCreate/AttributeCreate.tsxnew file mode 100644index 0000000000..e69de29bb2diff --git a/saleor/static/dashboard-next/attributes/views/AttributeCreate/index.ts b/saleor/static/dashboard-next/attributes/views/AttributeCreate/index.tsnew file mode 100644index 0000000000..d6f344ce61--- /dev/null+++ b/saleor/static/dashboard-next/attributes/views/AttributeCreate/index.ts@@ -0,0 +1,2 @@+export * from "./AttributeCreate";+export { default } from "./AttributeCreate";diff --git a/saleor/static/dashboard-next/attributes/views/AttributeList/AttributeList.tsx b/saleor/static/dashboard-next/attributes/views/AttributeList/AttributeList.tsxnew file mode 100644index 0000000000..e105cd38fe--- /dev/null+++ b/saleor/static/dashboard-next/attributes/views/AttributeList/AttributeList.tsx@@ -0,0 +1,137 @@+import IconButton from "@material-ui/core/IconButton";+import DeleteIcon from "@material-ui/icons/Delete";+import * as React from "react";++import useNavigator from "@saleor/hooks/useNavigator";+import useNotifier from "@saleor/hooks/useNotifier";+import usePaginator, {+ createPaginationState+} from "@saleor/hooks/usePaginator";+import { PAGINATE_BY } from "../../../config";+import useBulkActions from "../../../hooks/useBulkActions";+import i18n from "../../../i18n";+import { getMutationState, maybe } from "../../../misc";+import AttributeBulkDeleteDialog from "../../components/AttributeBulkDeleteDialog";+import AttributeListPage from "../../components/AttributeListPage";+import { AttributeBulkDeleteMutation } from "../../mutations";+import { AttributeListQuery } from "../../queries";+import { AttributeBulkDelete } from "../../types/AttributeBulkDelete";+import {+ attributeAddUrl,+ attributeListUrl,+ AttributeListUrlDialog,+ AttributeListUrlQueryParams,+ attributeUrl+} from "../../urls";++interface AttributeListProps {+ params: AttributeListUrlQueryParams;+}++const AttributeList: React.FC<AttributeListProps> = ({ params }) => {+ const navigate = useNavigator();+ const paginate = usePaginator();+ const notify = useNotifier();+ const { isSelected, listElements, reset, toggle, toggleAll } = useBulkActions(+ params.ids+ );++ const closeModal = () =>+ navigate(+ attributeListUrl({+ ...params,+ action: undefined,+ ids: undefined+ }),+ true+ );++ const openModal = (action: AttributeListUrlDialog, ids?: string[]) =>+ navigate(+ attributeListUrl({+ ...params,+ action,+ ids+ })+ );++ const paginationState = createPaginationState(PAGINATE_BY, params);+ const queryVariables = React.useMemo(() => paginationState, [params]);++ return (+ <AttributeListQuery variables={queryVariables}>+ {({ data, loading, refetch }) => {+ const { loadNextPage, loadPreviousPage, pageInfo } = paginate(+ maybe(() => data.attributes.pageInfo),+ paginationState,+ params+ );++ const handleBulkDelete = (data: AttributeBulkDelete) => {+ if (data.attributeBulkDelete.errors.length === 0) {+ closeModal();+ notify({+ text: i18n.t("Attributes removed")+ });+ reset();+ refetch();+ }+ };++ return (+ <AttributeBulkDeleteMutation onCompleted={handleBulkDelete}>+ {(attributeBulkDelete, attributeBulkDeleteOpts) => {+ const bulkDeleteMutationState = getMutationState(+ attributeBulkDeleteOpts.called,+ attributeBulkDeleteOpts.loading,+ maybe(+ () => attributeBulkDeleteOpts.data.attributeBulkDelete.errors+ )+ );++ return (+ <>+ <AttributeListPage+ attributes={maybe(() =>+ data.attributes.edges.map(edge => edge.node)+ )}+ disabled={loading || attributeBulkDeleteOpts.loading}+ isChecked={isSelected}+ onAdd={() => navigate(attributeAddUrl())}+ onNextPage={loadNextPage}+ onPreviousPage={loadPreviousPage}+ onRowClick={id => () => navigate(attributeUrl(id))}+ pageInfo={pageInfo}+ selected={listElements.length}+ toggle={toggle}+ toggleAll={toggleAll}+ toolbar={+ <IconButton+ color="primary"+ onClick={() => openModal("remove", listElements)}+ >+ <DeleteIcon />+ </IconButton>+ }+ />+ <AttributeBulkDeleteDialog+ confirmButtonState={bulkDeleteMutationState}+ open={params.action === "remove"}+ onConfirm={() =>+ attributeBulkDelete({ variables: { ids: params.ids } })+ }+ onClose={closeModal}+ quantity={maybe(() => params.ids.length.toString(), "...")}+ />+ </>+ );+ }}+ </AttributeBulkDeleteMutation>+ );+ }}+ </AttributeListQuery>+ );+};+AttributeList.displayName = "AttributeList";++export default AttributeList;diff --git a/saleor/static/dashboard-next/attributes/views/AttributeList/index.ts b/saleor/static/dashboard-next/attributes/views/AttributeList/index.tsnew file mode 100644index 0000000000..216f3b4bc1--- /dev/null+++ b/saleor/static/dashboard-next/attributes/views/AttributeList/index.ts@@ -0,0 +1,2 @@+export * from "./AttributeList";+export { default } from "./AttributeList";diff --git a/saleor/static/dashboard-next/components/CardTitle/CardTitle.tsx b/saleor/static/dashboard-next/components/CardTitle/CardTitle.tsxindex 8f46657def..55b92178d1 100644--- a/saleor/static/dashboard-next/components/CardTitle/CardTitle.tsx+++ b/saleor/static/dashboard-next/components/CardTitle/CardTitle.tsx@@ -32,7 +32,7 @@ const styles = (theme: Theme) =>lineHeight: 1},toolbar: {- marginRight: -theme.spacing.unit * 2+ marginRight: -theme.spacing.unit}});diff --git a/saleor/static/dashboard-next/components/Skeleton.tsx b/saleor/static/dashboard-next/components/Skeleton.tsxindex 5bcefc1941..7327f3418c 100644--- a/saleor/static/dashboard-next/components/Skeleton.tsx+++ b/saleor/static/dashboard-next/components/Skeleton.tsx@@ -17,6 +17,11 @@ const styles = (theme: Theme) =>opacity: 1}},+ primary: {+ "&$skeleton": {+ background: theme.palette.primary.main+ }+ },skeleton: {animation: "skeleton-animation .75s linear infinite forwards alternate",background: theme.palette.background.default,@@ -29,12 +34,18 @@ const styles = (theme: Theme) =>interface SkeletonProps extends WithStyles<typeof styles> {className?: string;+ primary?: boolean;style?: React.CSSProperties;}const Skeleton = withStyles(styles, { name: "Skeleton" })(- ({ className, classes, style }: SkeletonProps) => (- <span className={classNames(classes.skeleton, className)} style={style}>+ ({ className, classes, primary, style }: SkeletonProps) => (+ <span+ className={classNames(classes.skeleton, className, {+ [classes.primary]: primary+ })}+ style={style}+ >‌</span>)diff --git a/saleor/static/dashboard-next/index.tsx b/saleor/static/dashboard-next/index.tsxindex f587f43082..de995a8be1 100644--- a/saleor/static/dashboard-next/index.tsx+++ b/saleor/static/dashboard-next/index.tsx@@ -10,6 +10,8 @@ import { ApolloProvider } from "react-apollo";import { render } from "react-dom";import { BrowserRouter, Route, Switch } from "react-router-dom";+import AttributeSection from "./attributes";+import { attributeSection } from "./attributes/urls";import { getAuthToken, removeAuthToken } from "./auth";import AuthProvider from "./auth/AuthProvider";import LoginLoading from "./auth/components/LoginLoading/LoginLoading";@@ -194,6 +196,11 @@ const App: React.FC = () => {path={navigationSection}component={NavigationSection}/>+ <SectionRoute+ permissions={[PermissionEnum.MANAGE_PRODUCTS]}+ path={attributeSection}+ component={AttributeSection}+ />{configurationMenu.filter(menuItem =>hasPermission(menuItem.permission, user)).length > 0 && (diff --git a/saleor/static/dashboard-next/productTypes/mutations.ts b/saleor/static/dashboard-next/productTypes/mutations.tsindex de7cc95438..c1259e28dc 100644--- a/saleor/static/dashboard-next/productTypes/mutations.ts+++ b/saleor/static/dashboard-next/productTypes/mutations.ts@@ -102,24 +102,7 @@ export const TypedProductTypeCreateMutation = TypedMutation<ProductTypeCreateVariables>(productTypeCreateMutation);-export const attributeCreateMutation = gql`- ${productTypeDetailsFragment}- mutation AttributeCreate(- $id: ID!- $input: AttributeCreateInput!- $type: AttributeTypeEnum!- ) {- attributeCreate(id: $id, input: $input, type: $type) {- errors {- field- message- }- productType {- ...ProductTypeDetailsFragment- }- }- }-`;+export const attributeCreateMutation = "";export const TypedAttributeCreateMutation = TypedMutation<AttributeCreate,AttributeCreateVariables@@ -145,16 +128,12 @@ export const TypedAttributeUpdateMutation = TypedMutation<>(attributeUpdateMutation);export const attributeDeleteMutation = gql`- ${productTypeDetailsFragment}mutation AttributeDelete($id: ID!) {attributeDelete(id: $id) {errors {fieldmessage}- productType {- ...ProductTypeDetailsFragment- }}}`;diff --git a/saleor/static/dashboard-next/productTypes/types/AttributeDelete.ts b/saleor/static/dashboard-next/productTypes/types/AttributeDelete.tsindex 456bc2f21b..2cd44da904 100644--- a/saleor/static/dashboard-next/productTypes/types/AttributeDelete.ts+++ b/saleor/static/dashboard-next/productTypes/types/AttributeDelete.ts@@ -12,64 +12,9 @@ export interface AttributeDelete_attributeDelete_errors {message: string | null;}-export interface AttributeDelete_attributeDelete_productType_taxType {- __typename: "TaxType";- description: string | null;- taxCode: string | null;-}--export interface AttributeDelete_attributeDelete_productType_productAttributes_values {- __typename: "AttributeValue";- id: string;- name: string | null;- slug: string | null;-}--export interface AttributeDelete_attributeDelete_productType_productAttributes {- __typename: "Attribute";- id: string;- name: string | null;- slug: string | null;- values: (AttributeDelete_attributeDelete_productType_productAttributes_values | null)[] | null;-}--export interface AttributeDelete_attributeDelete_productType_variantAttributes_values {- __typename: "AttributeValue";- id: string;- name: string | null;- slug: string | null;-}--export interface AttributeDelete_attributeDelete_productType_variantAttributes {- __typename: "Attribute";- id: string;- name: string | null;- slug: string | null;- values: (AttributeDelete_attributeDelete_productType_variantAttributes_values | null)[] | null;-}--export interface AttributeDelete_attributeDelete_productType_weight {- __typename: "Weight";- unit: string;- value: number;-}--export interface AttributeDelete_attributeDelete_productType {- __typename: "ProductType";- id: string;- name: string;- hasVariants: boolean;- isShippingRequired: boolean;- taxType: AttributeDelete_attributeDelete_productType_taxType | null;- productAttributes: (AttributeDelete_attributeDelete_productType_productAttributes | null)[] | null;- variantAttributes: (AttributeDelete_attributeDelete_productType_variantAttributes | null)[] | null;- weight: AttributeDelete_attributeDelete_productType_weight | null;-}-export interface AttributeDelete_attributeDelete {__typename: "AttributeDelete";errors: AttributeDelete_attributeDelete_errors[] | null;- productType: AttributeDelete_attributeDelete_productType | null;}export interface AttributeDelete {diff --git a/saleor/static/dashboard-next/storybook/config.js b/saleor/static/dashboard-next/storybook/config.jsindex 57e6efbceb..c57cb39cac 100644--- a/saleor/static/dashboard-next/storybook/config.js+++ b/saleor/static/dashboard-next/storybook/config.js@@ -44,6 +44,10 @@ function loadStories() {require("./stories/auth/LoginPage");require("./stories/auth/LoginLoading");+ // Attributes+ require("./stories/attributes/AttributePage");+ require("./stories/attributes/AttributeListPage");+// Categoriesrequire("./stories/categories/CategoryProducts");require("./stories/categories/CategoryCreatePage");diff --git a/saleor/static/dashboard-next/storybook/stories/attributes/AttributeBulkDeleteDialog.tsx b/saleor/static/dashboard-next/storybook/stories/attributes/AttributeBulkDeleteDialog.tsxnew file mode 100644index 0000000000..5a8a177dbc--- /dev/null+++ b/saleor/static/dashboard-next/storybook/stories/attributes/AttributeBulkDeleteDialog.tsx@@ -0,0 +1,15 @@+import { storiesOf } from "@storybook/react";+import * as React from "react";++import AttributeBulkDeleteDialog, {+ AttributeBulkDeleteDialogProps+} from "../../../attributes/components/AttributeBulkDeleteDialog";+import Decorator from "../../Decorator";++const props: AttributeBulkDeleteDialogProps = {++};++storiesOf("Attributes / AttributeBulkDeleteDialog", module)+ .addDecorator(Decorator)+ .add("default", () => <AttributeBulkDeleteDialog {...props} />);diff --git a/saleor/static/dashboard-next/storybook/stories/attributes/AttributeListPage.tsx b/saleor/static/dashboard-next/storybook/stories/attributes/AttributeListPage.tsxnew file mode 100644index 0000000000..636af6e472--- /dev/null+++ b/saleor/static/dashboard-next/storybook/stories/attributes/AttributeListPage.tsx@@ -0,0 +1,23 @@+import { storiesOf } from "@storybook/react";+import * as React from "react";++import AttributeListPage, {+ AttributeListPageProps+} from "@saleor/attributes/components/AttributeListPage";+import { attributes } from "@saleor/attributes/fixtures";+import { listActionsProps, pageListProps } from "@saleor/fixtures";+import Decorator from "../../Decorator";++const props: AttributeListPageProps = {+ ...pageListProps.default,+ ...listActionsProps,+ attributes+};++storiesOf("Views / Attributes / Attribute list", module)+ .addDecorator(Decorator)+ .add("default", () => <AttributeListPage {...props} />)+ .add("loading", () => (+ <AttributeListPage {...props} attributes={undefined} disabled={true} />+ ))+ .add("no data", () => <AttributeListPage {...props} attributes={[]} />);diff --git a/saleor/static/dashboard-next/storybook/stories/attributes/AttributePage.tsx b/saleor/static/dashboard-next/storybook/stories/attributes/AttributePage.tsxnew file mode 100644index 0000000000..12841b3468--- /dev/null+++ b/saleor/static/dashboard-next/storybook/stories/attributes/AttributePage.tsx@@ -0,0 +1,35 @@+import { storiesOf } from "@storybook/react";+import * as React from "react";++import { attribute } from "@saleor/attributes/fixtures";+import AttributePage, {+ AttributePageProps+} from "../../../attributes/components/AttributePage";+import Decorator from "../../Decorator";++const props: AttributePageProps = {+ attribute,+ disabled: false,+ onBack: () => undefined,+ onDelete: () => undefined,+ onSubmit: () => undefined,+ onValueAdd: () => undefined,+ onValueDelete: () => undefined,+ onValueUpdate: () => undefined,+ saveButtonBarState: "default",+ values: attribute.values+};++storiesOf("Views / Attributes / Attribute details", module)+ .addDecorator(Decorator)+ .add("default", () => <AttributePage {...props} />)+ .add("loading", () => (+ <AttributePage+ {...props}+ attribute={undefined}+ disabled={true}+ values={undefined}+ />+ ))+ .add("no values", () => <AttributePage {...props} values={undefined} />)+ .add("create", () => <AttributePage {...props} attribute={null} />);diff --git a/saleor/static/dashboard-next/storybook/stories/attributes/AttributeValueBulkDeleteDialog.tsx b/saleor/static/dashboard-next/storybook/stories/attributes/AttributeValueBulkDeleteDialog.tsxnew file mode 100644index 0000000000..02e51eb604--- /dev/null+++ b/saleor/static/dashboard-next/storybook/stories/attributes/AttributeValueBulkDeleteDialog.tsx@@ -0,0 +1,15 @@+import { storiesOf } from "@storybook/react";+import * as React from "react";++import AttributeValueBulkDeleteDialog, {+ AttributeValueBulkDeleteDialogProps+} from "../../../attributes/components/AttributeValueBulkDeleteDialog";+import Decorator from "../../Decorator";++const props: AttributeValueBulkDeleteDialogProps = {++};++storiesOf("Attributes / AttributeValueBulkDeleteDialog", module)+ .addDecorator(Decorator)+ .add("default", () => <AttributeValueBulkDeleteDialog {...props} />);diff --git a/saleor/static/dashboard-next/storybook/stories/attributes/AttributeValueDeleteDialog.tsx b/saleor/static/dashboard-next/storybook/stories/attributes/AttributeValueDeleteDialog.tsxnew file mode 100644index 0000000000..325d436f31--- /dev/null+++ b/saleor/static/dashboard-next/storybook/stories/attributes/AttributeValueDeleteDialog.tsx@@ -0,0 +1,15 @@+import { storiesOf } from "@storybook/react";+import * as React from "react";++import AttributeValueDeleteDialog, {+ AttributeValueDeleteDialogProps+} from "../../../attributes/components/AttributeValueDeleteDialog";+import Decorator from "../../Decorator";++const props: AttributeValueDeleteDialogProps = {++};++storiesOf("Attributes / AttributeValueDeleteDialog", module)+ .addDecorator(Decorator)+ .add("default", () => <AttributeValueDeleteDialog {...props} />);diff --git a/saleor/static/dashboard-next/storybook/stories/attributes/AttributeValueEditDialog.tsx b/saleor/static/dashboard-next/storybook/stories/attributes/AttributeValueEditDialog.tsxnew file mode 100644index 0000000000..2cf9e5da4b--- /dev/null+++ b/saleor/static/dashboard-next/storybook/stories/attributes/AttributeValueEditDialog.tsx@@ -0,0 +1,15 @@+import { storiesOf } from "@storybook/react";+import * as React from "react";++import AttributeValueEditDialog, {+ AttributeValueEditDialogProps+} from "../../../attributes/components/AttributeValueEditDialog";+import Decorator from "../../Decorator";++const props: AttributeValueEditDialogProps = {++};++storiesOf("Attributes / AttributeValueEditDialog", module)+ .addDecorator(Decorator)+ .add("default", () => <AttributeValueEditDialog {...props} />);diff --git a/saleor/static/dashboard-next/theme.ts b/saleor/static/dashboard-next/theme.tsindex 26bef4379c..3544641da2 100644--- a/saleor/static/dashboard-next/theme.ts+++ b/saleor/static/dashboard-next/theme.ts@@ -127,6 +127,7 @@ export default (colors: IThemeColors): Theme =>color: colors.input.text},shrink: {+ // Negates x0.75 scalewidth: "133%"}},diff --git a/saleor/static/dashboard-next/types/globalTypes.ts b/saleor/static/dashboard-next/types/globalTypes.tsindex 6613647704..cc70a45498 100644--- a/saleor/static/dashboard-next/types/globalTypes.ts+++ b/saleor/static/dashboard-next/types/globalTypes.ts@@ -11,9 +11,11 @@ export enum AddressTypeEnum {SHIPPING = "SHIPPING"}-export enum AttributeTypeEnum {- PRODUCT = "PRODUCT",- VARIANT = "VARIANT"+export enum AttributeValueType {+ COLOR = "COLOR",+ GRADIENT = "GRADIENT",+ STRING = "STRING",+ URL = "URL"}export enum AuthorizationKeyType {@@ -237,11 +239,6 @@ export interface AddressInput {phone?: string | null;}-export interface AttributeCreateInput {- name: string;- values?: (AttributeValueCreateInput | null)[] | null;-}-export interface AttributeInput {slug: string;value: string;@@ -249,6 +246,7 @@ export interface AttributeInput {export interface AttributeUpdateInput {name?: string | null;+ slug?: string | null;removeValues?: (string | null)[] | null;addValues?: (AttributeValueCreateInput | null)[] | null;}