Skip to content

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

Add attribute reorder

dominik-zeglen23054f30be05
diff --git a/saleor/static/dashboard-next/attributes/components/AttributePage/AttributePage.tsx b/saleor/static/dashboard-next/attributes/components/AttributePage/AttributePage.tsx
index bc51f783cb..222c9e38f8 100644
--- a/saleor/static/dashboard-next/attributes/components/AttributePage/AttributePage.tsx
+++ b/saleor/static/dashboard-next/attributes/components/AttributePage/AttributePage.tsx
@@ -11,7 +11,7 @@ import PageHeader from "@saleor/components/PageHeader";
import SaveButtonBar from "@saleor/components/SaveButtonBar";
import i18n from "@saleor/i18n";
import { maybe } from "@saleor/misc";
-import { ReorderEvent, UserError } from "@saleor/types";
+import { ReorderAction, UserError } from "@saleor/types";
import { AttributeInputTypeEnum } from "@saleor/types/globalTypes";
import {
AttributeDetailsFragment,
@@ -32,7 +32,7 @@ export interface AttributePageProps {
onSubmit: (data: AttributePageFormData) => void;
onValueAdd: () => void;
onValueDelete: (id: string) => void;
- onValueReorder: ReorderEvent;
+ onValueReorder: ReorderAction;
onValueUpdate: (id: string) => void;
}
diff --git a/saleor/static/dashboard-next/attributes/components/AttributeValues/AttributeValues.tsx b/saleor/static/dashboard-next/attributes/components/AttributeValues/AttributeValues.tsx
index f9b04d195c..528ffdf6fe 100644
--- a/saleor/static/dashboard-next/attributes/components/AttributeValues/AttributeValues.tsx
+++ b/saleor/static/dashboard-next/attributes/components/AttributeValues/AttributeValues.tsx
@@ -18,7 +18,7 @@ import {
} from "@saleor/components/SortableTable";
import i18n from "@saleor/i18n";
import { maybe, renderCollection, stopPropagation } from "@saleor/misc";
-import { ReorderEvent } from "@saleor/types";
+import { ReorderAction } from "@saleor/types";
import { AttributeDetailsFragment_values } from "../../types/AttributeDetailsFragment";
export interface AttributeValuesProps {
@@ -26,7 +26,7 @@ export interface AttributeValuesProps {
values: AttributeDetailsFragment_values[];
onValueAdd: () => void;
onValueDelete: (id: string) => void;
- onValueReorder: ReorderEvent;
+ onValueReorder: ReorderAction;
onValueUpdate: (id: string) => void;
}
@@ -43,15 +43,6 @@ const useStyles = makeStyles((theme: Theme) => ({
dragIcon: {
cursor: "grab"
},
- ghost: {
- "& td": {
- borderBottom: "none"
- },
- background: theme.palette.background.paper,
- fontFamily: theme.typography.fontFamily,
- fontSize: theme.overrides.MuiTableCell.root.fontSize,
- opacity: 0.5
- },
iconCell: {
"&:last-child": {
paddingRight: theme.spacing.unit
@@ -96,12 +87,7 @@ const AttributeValues: React.FC<AttributeValuesProps> = ({
<TableCell />
</TableRow>
</TableHead>
- <SortableTableBody
- helperClass={classes.ghost}
- axis="y"
- lockAxis="y"
- onSortEnd={onValueReorder}
- >
+ <SortableTableBody onSortEnd={onValueReorder}>
{renderCollection(
values
? values.sort((a, b) => (a.sortOrder > b.sortOrder ? 1 : -1))
diff --git a/saleor/static/dashboard-next/components/SortableTable/SortableHandle.tsx b/saleor/static/dashboard-next/components/SortableTable/SortableHandle.tsx
index 5133379729..be8fea416d 100644
--- a/saleor/static/dashboard-next/components/SortableTable/SortableHandle.tsx
+++ b/saleor/static/dashboard-next/components/SortableTable/SortableHandle.tsx
@@ -8,10 +8,11 @@ import Draggable from "@saleor/icons/Draggable";
const useStyles = makeStyles((theme: Theme) => ({
columnDrag: {
+ "&:first-child": {
+ paddingRight: theme.spacing.unit * 2
+ },
+ cursor: "grab",
width: 48 + theme.spacing.unit * 1.5
- },
- dragIcon: {
- cursor: "grab"
}
}));
@@ -20,7 +21,7 @@ const SortableHandle = SortableHandleHoc(() => {
return (
<TableCell className={classes.columnDrag}>
- <Draggable className={classes.dragIcon} />
+ <Draggable />
</TableCell>
);
});
diff --git a/saleor/static/dashboard-next/components/SortableTable/SortableTableBody.tsx b/saleor/static/dashboard-next/components/SortableTable/SortableTableBody.tsx
index ea20734a36..205469bd2e 100644
--- a/saleor/static/dashboard-next/components/SortableTable/SortableTableBody.tsx
+++ b/saleor/static/dashboard-next/components/SortableTable/SortableTableBody.tsx
@@ -1,13 +1,45 @@
-import TableBody from "@material-ui/core/TableBody";
+import { Theme } from "@material-ui/core/styles";
+import TableBody, { TableBodyProps } from "@material-ui/core/TableBody";
+import makeStyles from "@material-ui/styles/makeStyles";
import * as React from "react";
import { SortableContainer } from "react-sortable-hoc";
-interface SortableTableBodyProps {
- children: React.ReactNode | React.ReactNodeArray;
-}
+import { ReorderAction } from "@saleor/types";
-const SortableTableBody = SortableContainer<SortableTableBodyProps>(
- ({ children }) => <TableBody>{children}</TableBody>
+const InnerSortableTableBody = SortableContainer<TableBodyProps>(
+ ({ children, ...props }) => <TableBody {...props}>{children}</TableBody>
);
+export interface SortableTableBodyProps {
+ onSortEnd: ReorderAction;
+}
+
+const useStyles = makeStyles((theme: Theme) => ({
+ ghost: {
+ "& td": {
+ borderBottom: "none"
+ },
+ background: theme.palette.background.paper,
+ fontFamily: theme.typography.fontFamily,
+ fontSize: theme.overrides.MuiTableCell.root.fontSize,
+ opacity: 0.5
+ }
+}));
+
+const SortableTableBody: React.FC<
+ TableBodyProps & SortableTableBodyProps
+> = props => {
+ const classes = useStyles({});
+
+ return (
+ <InnerSortableTableBody
+ helperClass={classes.ghost}
+ axis="y"
+ lockAxis="y"
+ useDragHandle
+ {...props}
+ />
+ );
+};
+
export default SortableTableBody;
diff --git a/saleor/static/dashboard-next/components/TableHead/TableHead.tsx b/saleor/static/dashboard-next/components/TableHead/TableHead.tsx
index 5de852ac7c..3060fda1ac 100644
--- a/saleor/static/dashboard-next/components/TableHead/TableHead.tsx
+++ b/saleor/static/dashboard-next/components/TableHead/TableHead.tsx
@@ -21,6 +21,7 @@ import Checkbox from "../Checkbox";
export interface TableHeadProps extends MuiTableHeadProps {
disabled: boolean;
+ dragRows?: boolean;
selected: number;
items: Node[];
toolbar: React.ReactNode | React.ReactNodeArray;
@@ -50,6 +51,10 @@ const styles = (theme: Theme) =>
height: 47,
marginRight: -theme.spacing.unit * 2
},
+ dragRows: {
+ padding: 0,
+ width: 52
+ },
padding: {
"&:last-child": {
padding: 0
@@ -77,6 +82,7 @@ const TableHead = withStyles(styles, {
classes,
children,
disabled,
+ dragRows,
items,
selected,
toggleAll,
@@ -86,11 +92,19 @@ const TableHead = withStyles(styles, {
return (
<MuiTableHead {...muiTableHeadProps}>
<TableRow>
+ {dragRows && (
+ <TableCell
+ className={classNames({
+ [classes.checkboxSelected]: selected
+ })}
+ />
+ )}
{(items === undefined || items.length > 0) && (
<TableCell
padding="checkbox"
className={classNames({
- [classes.checkboxSelected]: selected
+ [classes.checkboxSelected]: selected,
+ [classes.dragRows]: dragRows
})}
>
<Checkbox
diff --git a/saleor/static/dashboard-next/productTypes/components/ProductTypeAttributes/ProductTypeAttributes.tsx b/saleor/static/dashboard-next/productTypes/components/ProductTypeAttributes/ProductTypeAttributes.tsx
index f22beb810c..2b7f73f2db 100644
--- a/saleor/static/dashboard-next/productTypes/components/ProductTypeAttributes/ProductTypeAttributes.tsx
+++ b/saleor/static/dashboard-next/productTypes/components/ProductTypeAttributes/ProductTypeAttributes.tsx
@@ -8,7 +8,6 @@ import {
WithStyles
} 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 TableRow from "@material-ui/core/TableRow";
import DeleteIcon from "@material-ui/icons/Delete";
@@ -17,10 +16,14 @@ import React from "react";
import CardTitle from "@saleor/components/CardTitle";
import Checkbox from "@saleor/components/Checkbox";
import Skeleton from "@saleor/components/Skeleton";
+import {
+ SortableTableBody,
+ SortableTableRow
+} from "@saleor/components/SortableTable";
import TableHead from "@saleor/components/TableHead";
import i18n from "@saleor/i18n";
import { maybe, renderCollection, stopPropagation } from "@saleor/misc";
-import { ListActions } from "@saleor/types";
+import { ListActions, ReorderAction } from "@saleor/types";
import { AttributeTypeEnum } from "@saleor/types/globalTypes";
import {
ProductTypeDetails_productType_productAttributes,
@@ -33,7 +36,7 @@ const styles = (theme: Theme) =>
"&:last-child": {
paddingRight: 0
},
- width: 48 + theme.spacing.unit / 2
+ width: 48 + theme.spacing.unit * 1.5
},
link: {
cursor: "pointer"
@@ -51,6 +54,7 @@ interface ProductTypeAttributesProps extends ListActions {
type: string;
onAttributeAssign: (type: AttributeTypeEnum) => void;
onAttributeClick: (id: string) => void;
+ onAttributeReorder: ReorderAction;
onAttributeUnassign: (id: string) => void;
}
@@ -69,6 +73,7 @@ const ProductTypeAttributes = withStyles(styles, {
type,
onAttributeAssign,
onAttributeClick,
+ onAttributeReorder,
onAttributeUnassign
}: ProductTypeAttributesProps & WithStyles<typeof styles>) => (
<Card>
@@ -91,6 +96,7 @@ const ProductTypeAttributes = withStyles(styles, {
<Table>
<TableHead
disabled={disabled}
+ dragRows
selected={selected}
items={attributes}
toggleAll={toggleAll}
@@ -99,14 +105,14 @@ const ProductTypeAttributes = withStyles(styles, {
<TableCell>{i18n.t("Attribute name")}</TableCell>
<TableCell />
</TableHead>
- <TableBody>
+ <SortableTableBody onSortEnd={onAttributeReorder}>
{renderCollection(
attributes,
- attribute => {
+ (attribute, attributeIndex) => {
const isSelected = attribute ? isChecked(attribute.id) : false;
return (
- <TableRow
+ <SortableTableRow
selected={isSelected}
className={!!attribute ? classes.link : undefined}
hover={!!attribute}
@@ -116,6 +122,7 @@ const ProductTypeAttributes = withStyles(styles, {
: undefined
}
key={maybe(() => attribute.id)}
+ index={attributeIndex}
>
<TableCell padding="checkbox">
<Checkbox
@@ -140,7 +147,7 @@ const ProductTypeAttributes = withStyles(styles, {
<DeleteIcon color="primary" />
</IconButton>
</TableCell>
- </TableRow>
+ </SortableTableRow>
);
},
() => (
@@ -151,7 +158,7 @@ const ProductTypeAttributes = withStyles(styles, {
</TableRow>
)
)}
- </TableBody>
+ </SortableTableBody>
</Table>
</Card>
)
diff --git a/saleor/static/dashboard-next/productTypes/components/ProductTypeDetailsPage/ProductTypeDetailsPage.tsx b/saleor/static/dashboard-next/productTypes/components/ProductTypeDetailsPage/ProductTypeDetailsPage.tsx
index b1cef6cde6..aab5f7e470 100644
--- a/saleor/static/dashboard-next/productTypes/components/ProductTypeDetailsPage/ProductTypeDetailsPage.tsx
+++ b/saleor/static/dashboard-next/productTypes/components/ProductTypeDetailsPage/ProductTypeDetailsPage.tsx
@@ -13,7 +13,7 @@ import { ChangeEvent, FormChange } from "@saleor/hooks/useForm";
import useStateFromProps from "@saleor/hooks/useStateFromProps";
import i18n from "@saleor/i18n";
import { maybe } from "@saleor/misc";
-import { ListActions, UserError } from "@saleor/types";
+import { ListActions, ReorderEvent, UserError } from "@saleor/types";
import { AttributeTypeEnum, WeightUnitsEnum } from "@saleor/types/globalTypes";
import {
ProductTypeDetails_productType,
@@ -51,6 +51,7 @@ export interface ProductTypeDetailsPageProps {
variantAttributeList: ListActions;
onAttributeAdd: (type: AttributeTypeEnum) => void;
onAttributeClick: (id: string) => void;
+ onAttributeReorder: (event: ReorderEvent, type: AttributeTypeEnum) => void;
onAttributeUnassign: (id: string) => void;
onBack: () => void;
onDelete: () => void;
@@ -83,6 +84,7 @@ const ProductTypeDetailsPage: React.StatelessComponent<
variantAttributeList,
onAttributeAdd,
onAttributeUnassign,
+ onAttributeReorder,
onAttributeClick,
onBack,
onDelete,
@@ -158,6 +160,9 @@ const ProductTypeDetailsPage: React.StatelessComponent<
type={AttributeTypeEnum.PRODUCT}
onAttributeAssign={onAttributeAdd}
onAttributeClick={onAttributeClick}
+ onAttributeReorder={(event: ReorderEvent) =>
+ onAttributeReorder(event, AttributeTypeEnum.PRODUCT)
+ }
onAttributeUnassign={onAttributeUnassign}
{...productAttributeList}
/>
@@ -178,6 +183,9 @@ const ProductTypeDetailsPage: React.StatelessComponent<
type={AttributeTypeEnum.VARIANT}
onAttributeAssign={onAttributeAdd}
onAttributeClick={onAttributeClick}
+ onAttributeReorder={(event: ReorderEvent) =>
+ onAttributeReorder(event, AttributeTypeEnum.VARIANT)
+ }
onAttributeUnassign={onAttributeUnassign}
{...variantAttributeList}
/>
diff --git a/saleor/static/dashboard-next/productTypes/containers/ProductTypeOperations.tsx b/saleor/static/dashboard-next/productTypes/containers/ProductTypeOperations.tsx
index 4b419204f5..a84814042e 100644
--- a/saleor/static/dashboard-next/productTypes/containers/ProductTypeOperations.tsx
+++ b/saleor/static/dashboard-next/productTypes/containers/ProductTypeOperations.tsx
@@ -3,6 +3,7 @@ import React from "react";
import { getMutationProviderData } from "../../misc";
import { PartialMutationProviderOutput } from "../../types";
import {
+ ProductTypeAttributeReorderMutation,
TypedAssignAttributeMutation,
TypedProductTypeDeleteMutation,
TypedProductTypeUpdateMutation,
@@ -12,6 +13,10 @@ import {
AssignAttribute,
AssignAttributeVariables
} from "../types/AssignAttribute";
+import {
+ ProductTypeAttributeReorder,
+ ProductTypeAttributeReorderVariables
+} from "../types/ProductTypeAttributeReorder";
import {
ProductTypeDelete,
ProductTypeDeleteVariables
@@ -39,6 +44,10 @@ interface ProductTypeOperationsProps {
ProductTypeDelete,
ProductTypeDeleteVariables
>;
+ reorderAttribute: PartialMutationProviderOutput<
+ ProductTypeAttributeReorder,
+ ProductTypeAttributeReorderVariables
+ >;
updateProductType: PartialMutationProviderOutput<
ProductTypeUpdate,
ProductTypeUpdateVariables
@@ -46,6 +55,7 @@ interface ProductTypeOperationsProps {
}) => React.ReactNode;
onAssignAttribute: (data: AssignAttribute) => void;
onUnassignAttribute: (data: UnassignAttribute) => void;
+ onProductTypeAttributeReorder: (data: ProductTypeAttributeReorder) => void;
onProductTypeDelete: (data: ProductTypeDelete) => void;
onProductTypeUpdate: (data: ProductTypeUpdate) => void;
}
@@ -56,6 +66,7 @@ const ProductTypeOperations: React.StatelessComponent<
children,
onAssignAttribute,
onUnassignAttribute,
+ onProductTypeAttributeReorder,
onProductTypeDelete,
onProductTypeUpdate
}) => {
@@ -69,22 +80,31 @@ const ProductTypeOperations: React.StatelessComponent<
<TypedUnassignAttributeMutation
onCompleted={onUnassignAttribute}
>
- {(...unassignAttribute) =>
- children({
- assignAttribute: getMutationProviderData(
- ...assignAttribute
- ),
- deleteProductType: getMutationProviderData(
- ...deleteProductType
- ),
- unassignAttribute: getMutationProviderData(
- ...unassignAttribute
- ),
- updateProductType: getMutationProviderData(
- ...updateProductType
- )
- })
- }
+ {(...unassignAttribute) => (
+ <ProductTypeAttributeReorderMutation
+ onCompleted={onProductTypeAttributeReorder}
+ >
+ {(...reorderAttribute) =>
+ children({
+ assignAttribute: getMutationProviderData(
+ ...assignAttribute
+ ),
+ deleteProductType: getMutationProviderData(
+ ...deleteProductType
+ ),
+ reorderAttribute: getMutationProviderData(
+ ...reorderAttribute
+ ),
+ unassignAttribute: getMutationProviderData(
+ ...unassignAttribute
+ ),
+ updateProductType: getMutationProviderData(
+ ...updateProductType
+ )
+ })
+ }
+ </ProductTypeAttributeReorderMutation>
+ )}
</TypedUnassignAttributeMutation>
)}
</TypedAssignAttributeMutation>
diff --git a/saleor/static/dashboard-next/productTypes/mutations.ts b/saleor/static/dashboard-next/productTypes/mutations.ts
index d176a81905..8966558231 100644
--- a/saleor/static/dashboard-next/productTypes/mutations.ts
+++ b/saleor/static/dashboard-next/productTypes/mutations.ts
@@ -6,6 +6,10 @@ import {
AssignAttribute,
AssignAttributeVariables
} from "./types/AssignAttribute";
+import {
+ ProductTypeAttributeReorder,
+ ProductTypeAttributeReorderVariables
+} from "./types/ProductTypeAttributeReorder";
import {
ProductTypeBulkDelete,
ProductTypeBulkDeleteVariables
@@ -135,3 +139,30 @@ export const TypedProductTypeCreateMutation = TypedMutation<
ProductTypeCreate,
ProductTypeCreateVariables
>(productTypeCreateMutation);
+
+const productTypeAttributeReorder = gql`
+ ${productTypeDetailsFragment}
+ mutation ProductTypeAttributeReorder(
+ $move: AttributeReorderInput!
+ $productTypeId: ID!
+ $type: AttributeTypeEnum!
+ ) {
+ productTypeReorderAttributes(
+ moves: [$move]
+ productTypeId: $productTypeId
+ type: $type
+ ) {
+ errors {
+ field
+ message
+ }
+ productType {
+ ...ProductTypeDetailsFragment
+ }
+ }
+ }
+`;
+export const ProductTypeAttributeReorderMutation = TypedMutation<
+ ProductTypeAttributeReorder,
+ ProductTypeAttributeReorderVariables
+>(productTypeAttributeReorder);
diff --git a/saleor/static/dashboard-next/productTypes/types/ProductTypeAttributeReorder.ts b/saleor/static/dashboard-next/productTypes/types/ProductTypeAttributeReorder.ts
new file mode 100644
index 0000000000..38991749af
--- /dev/null
+++ b/saleor/static/dashboard-next/productTypes/types/ProductTypeAttributeReorder.ts
@@ -0,0 +1,63 @@
+/* tslint:disable */
+/* eslint-disable */
+// This file was automatically generated and should not be edited.
+
+import { AttributeReorderInput, AttributeTypeEnum, TaxRateType } from "./../../types/globalTypes";
+
+// ====================================================
+// GraphQL mutation operation: ProductTypeAttributeReorder
+// ====================================================
+
+export interface ProductTypeAttributeReorder_productTypeReorderAttributes_errors {
+ __typename: "Error";
+ field: string | null;
+ message: string | null;
+}
+
+export interface ProductTypeAttributeReorder_productTypeReorderAttributes_productType_productAttributes {
+ __typename: "Attribute";
+ id: string;
+ name: string | null;
+ slug: string | null;
+}
+
+export interface ProductTypeAttributeReorder_productTypeReorderAttributes_productType_variantAttributes {
+ __typename: "Attribute";
+ id: string;
+ name: string | null;
+ slug: string | null;
+}
+
+export interface ProductTypeAttributeReorder_productTypeReorderAttributes_productType_weight {
+ __typename: "Weight";
+ unit: string;
+ value: number;
+}
+
+export interface ProductTypeAttributeReorder_productTypeReorderAttributes_productType {
+ __typename: "ProductType";
+ id: string;
+ name: string;
+ hasVariants: boolean;
+ isShippingRequired: boolean;
+ taxRate: TaxRateType | null;
+ productAttributes: (ProductTypeAttributeReorder_productTypeReorderAttributes_productType_productAttributes | null)[] | null;
+ variantAttributes: (ProductTypeAttributeReorder_productTypeReorderAttributes_productType_variantAttributes | null)[] | null;
+ weight: ProductTypeAttributeReorder_productTypeReorderAttributes_productType_weight | null;
+}
+
+export interface ProductTypeAttributeReorder_productTypeReorderAttributes {
+ __typename: "ProductTypeReorderAttributes";
+ errors: ProductTypeAttributeReorder_productTypeReorderAttributes_errors[] | null;
+ productType: ProductTypeAttributeReorder_productTypeReorderAttributes_productType | null;
+}
+
+export interface ProductTypeAttributeReorder {
+ productTypeReorderAttributes: ProductTypeAttributeReorder_productTypeReorderAttributes | null;
+}
+
+export interface ProductTypeAttributeReorderVariables {
+ move: AttributeReorderInput;
+ productTypeId: string;
+ type: AttributeTypeEnum;
+}
diff --git a/saleor/static/dashboard-next/productTypes/views/ProductTypeUpdate/index.tsx b/saleor/static/dashboard-next/productTypes/views/ProductTypeUpdate/index.tsx
index e54d8d97d8..a317391264 100644
--- a/saleor/static/dashboard-next/productTypes/views/ProductTypeUpdate/index.tsx
+++ b/saleor/static/dashboard-next/productTypes/views/ProductTypeUpdate/index.tsx
@@ -11,6 +11,7 @@ import useNavigator from "@saleor/hooks/useNavigator";
import useNotifier from "@saleor/hooks/useNotifier";
import i18n from "@saleor/i18n";
import { getMutationState, maybe } from "@saleor/misc";
+import { productType } from "@saleor/productTypes/fixtures";
import { AttributeTypeEnum } from "@saleor/types/globalTypes";
import ProductTypeAttributeUnassignDialog from "../../components/ProductTypeAttributeUnassignDialog";
import ProductTypeBulkAttributeUnassignDialog from "../../components/ProductTypeBulkAttributeUnassignDialog";
@@ -123,12 +124,14 @@ export const ProductTypeUpdate: React.FC<ProductTypeUpdateProps> = ({
onUnassignAttribute={handleAttributeUnassignSuccess}
onProductTypeDelete={handleProductTypeDeleteSuccess}
onProductTypeUpdate={handleProductTypeUpdateSuccess}
+ onProductTypeAttributeReorder={() => undefined}
>
{({
assignAttribute,
deleteProductType,
unassignAttribute,
- updateProductType
+ updateProductType,
+ reorderAttribute
}) => {
const handleProductTypeDelete = () =>
deleteProductType.mutate({ id });
@@ -231,6 +234,19 @@ export const ProductTypeUpdate: React.FC<ProductTypeUpdateProps> = ({
onAttributeClick={attributeId =>
navigate(attributeUrl(attributeId))
}
+ onAttributeReorder={(event, type) =>
+ reorderAttribute.mutate({
+ move: {
+ id:
+ data.productType.productAttributes[
+ event.oldIndex
+ ].id,
+ sortOrder: event.newIndex - event.oldIndex
+ },
+ productTypeId: id,
+ type
+ })
+ }
onAttributeUnassign={attributeId =>
navigate(
productTypeUrl(id, {
diff --git a/saleor/static/dashboard-next/products/components/ProductImages/ProductImages.tsx b/saleor/static/dashboard-next/products/components/ProductImages/ProductImages.tsx
index 4446fb57ab..0f259f6a41 100644
--- a/saleor/static/dashboard-next/products/components/ProductImages/ProductImages.tsx
+++ b/saleor/static/dashboard-next/products/components/ProductImages/ProductImages.tsx
@@ -12,7 +12,7 @@ import {
import CardTitle from "@saleor/components/CardTitle";
import ImageTile from "@saleor/components/ImageTile";
import ImageUpload from "@saleor/components/ImageUpload";
-import { ReorderEvent } from "@saleor/types";
+import { ReorderAction } from "@saleor/types";
import React from "react";
import { SortableContainer, SortableElement } from "react-sortable-hoc";
import i18n from "../../../i18n";
@@ -114,7 +114,7 @@ interface ProductImagesProps extends WithStyles<typeof styles> {
loading?: boolean;
onImageDelete: (id: string) => () => void;
onImageEdit: (id: string) => () => void;
- onImageReorder?: ReorderEvent;
+ onImageReorder?: ReorderAction;
onImageUpload(file: File);
}
diff --git a/saleor/static/dashboard-next/theme.ts b/saleor/static/dashboard-next/theme.ts
index 69da6accfe..e5c9d96d2b 100644
--- a/saleor/static/dashboard-next/theme.ts
+++ b/saleor/static/dashboard-next/theme.ts
@@ -266,7 +266,14 @@ export default (colors: IThemeColors): Theme =>
fontWeight: 400
},
paddingCheckbox: {
- width: 72
+ "&:first-child": {
+ padding: "0 12px",
+ width: 72
+ },
+ "&:not(first-child)": {
+ padding: 0,
+ width: 52
+ }
},
root: {
"&:first-child": {
diff --git a/saleor/static/dashboard-next/types.ts b/saleor/static/dashboard-next/types.ts
index 83bc133414..ee179e5ebb 100644
--- a/saleor/static/dashboard-next/types.ts
+++ b/saleor/static/dashboard-next/types.ts
@@ -110,7 +110,8 @@ export type BulkAction = Partial<{
ids: string[];
}>;
-export type ReorderEvent = (event: {
+export interface ReorderEvent {
oldIndex: number;
newIndex: number;
-}) => void;
+}
+export type ReorderAction = (event: ReorderEvent) => void;
diff --git a/saleor/static/dashboard-next/types/globalTypes.ts b/saleor/static/dashboard-next/types/globalTypes.ts
index 7733f2744e..d0123012c2 100644
--- a/saleor/static/dashboard-next/types/globalTypes.ts
+++ b/saleor/static/dashboard-next/types/globalTypes.ts
@@ -272,6 +272,11 @@ export interface AttributeInput {
value: string;
}
+export interface AttributeReorderInput {
+ id: string;
+ sortOrder?: number | null;
+}
+
export interface AttributeUpdateInput {
name?: string | null;
slug?: string | null;