Skip to content

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

Fix types

Krzysztof Bialoglowiczf1e21bc085f7
diff --git a/saleor/static/dashboard-next/collections/components/CollectionProducts/CollectionProducts.tsx b/saleor/static/dashboard-next/collections/components/CollectionProducts/CollectionProducts.tsx
index 8515214a61..f6bd1b5d9c 100644
--- a/saleor/static/dashboard-next/collections/components/CollectionProducts/CollectionProducts.tsx
+++ b/saleor/static/dashboard-next/collections/components/CollectionProducts/CollectionProducts.tsx
@@ -35,6 +35,9 @@ const styles = (theme: Theme) =>
},
width: 48 + theme.spacing.unit / 2
},
+ relative: {
+ position: "relative"
+ },
tableRow: {
cursor: "pointer"
}
@@ -89,19 +92,27 @@ const CollectionProducts = withStyles(styles, { name: "CollectionProducts" })(
</Button>
}
/>
- <Table>
- <TableHead selected={selected} toolbar={toolbar}>
- <TableRow>
- <TableCell />
- <TableCell />
- <TableCell>{i18n.t("Name", { context: "table header" })}</TableCell>
- <TableCell>{i18n.t("Type", { context: "table header" })}</TableCell>
- <TableCell>
- {i18n.t("Published", { context: "table header" })}
- </TableCell>
- <TableCell />
- </TableRow>
- </TableHead>
+ <Table className={classes.relative}>
+ <TableHead
+ selected={selected}
+ disabled={disabled}
+ items={collection}
+ toggleAll={toggleAll}
+ toolbar={toolbar}
+ tablebar={
+ <>
+ <TableCell>
+ {i18n.t("Name", { context: "table header" })}
+ </TableCell>
+ <TableCell>
+ {i18n.t("Type", { context: "table header" })}
+ </TableCell>
+ <TableCell>
+ {i18n.t("Published", { context: "table header" })}
+ </TableCell>
+ </>
+ }
+ />
<TableFooter>
<TableRow>
<TablePagination
diff --git a/saleor/static/dashboard-next/components/TableActions/TableActions.tsx b/saleor/static/dashboard-next/components/TableActions/TableActions.tsx
deleted file mode 100644
index a528dc00b1..0000000000
--- a/saleor/static/dashboard-next/components/TableActions/TableActions.tsx
+++ /dev/null
@@ -1,68 +0,0 @@
-import {
- createStyles,
- Theme,
- withStyles,
- WithStyles
-} from "@material-ui/core/styles";
-import { fade } from "@material-ui/core/styles/colorManipulator";
-import TableCell from "@material-ui/core/TableCell";
-import TableRow from "@material-ui/core/TableRow";
-import Typography from "@material-ui/core/Typography";
-import * as classNames from "classnames";
-import * as React from "react";
-
-import i18n from "../../i18n";
-
-export interface TableActionsProps {
- children: React.ReactNode;
- className?: string;
- selected?: number;
-}
-
-const styles = (theme: Theme) =>
- createStyles({
- cell: {
- padding: 0
- },
- container: {
- alignItems: "center",
- display: "flex",
- height: 56,
- marginRight: -theme.spacing.unit * 2
- },
- root: {
- backgroundColor: fade(theme.palette.primary.main, 0.05)
- },
- spacer: {
- flex: 1
- },
- toolbar: {
- "& > *": {
- marginLeft: theme.spacing.unit
- }
- }
- });
-const TableActions = withStyles(styles, { name: "TableActions" })(
- ({
- classes,
- className,
- children,
- selected
- }: TableActionsProps & WithStyles<typeof styles>) => (
- <div className={classNames(classes.root, className)}>
- <div className={classes.container}>
- {selected && (
- <Typography>
- {i18n.t("Selected {{ number }} items", {
- number: selected
- })}
- </Typography>
- )}
- <div className={classes.spacer} />
- <div className={classes.toolbar}>{children}</div>
- </div>
- </div>
- )
-);
-TableActions.displayName = "TableActions";
-export default TableActions;
diff --git a/saleor/static/dashboard-next/components/TableActions/index.ts b/saleor/static/dashboard-next/components/TableActions/index.ts
deleted file mode 100644
index 01a797b515..0000000000
--- a/saleor/static/dashboard-next/components/TableActions/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export { default } from './TableActions';
-export * from './TableActions';
\ No newline at end of file
diff --git a/saleor/static/dashboard-next/components/TableHead/TableHead.tsx b/saleor/static/dashboard-next/components/TableHead/TableHead.tsx
index f977a03752..77677cce3e 100644
--- a/saleor/static/dashboard-next/components/TableHead/TableHead.tsx
+++ b/saleor/static/dashboard-next/components/TableHead/TableHead.tsx
@@ -4,23 +4,26 @@ import {
withStyles,
WithStyles
} from "@material-ui/core/styles";
+import { fade } from "@material-ui/core/styles/colorManipulator";
+import TableCell from "@material-ui/core/TableCell";
import MuiTableHead, {
TableHeadProps as MuiTableHeadProps
} from "@material-ui/core/TableHead";
-import * as React from "react";
-import { fade } from "@material-ui/core/styles/colorManipulator";
-import TableActions from "../TableActions";
-import TableCell from "@material-ui/core/TableCell";
import TableRow from "@material-ui/core/TableRow";
import Typography from "@material-ui/core/Typography";
import * as classNames from "classnames";
+import * as React from "react";
-import Checkbox from "../Checkbox";
import i18n from "../../i18n";
+import Checkbox from "../Checkbox";
export interface TableHeadProps extends MuiTableHeadProps {
+ disabled: boolean;
+ items: React.ReactNode | React.ReactNodeArray;
selected: number;
toolbar: React.ReactNode | React.ReactNodeArray;
+ tablebar: React.ReactNode | React.ReactNodeArray;
+ toggleAll: (items: any, selected: any) => void;
}
const styles = (theme: Theme) =>
diff --git a/saleor/static/dashboard-next/discounts/components/VoucherListPage/VoucherListPage.tsx b/saleor/static/dashboard-next/discounts/components/VoucherListPage/VoucherListPage.tsx
index b6c25796d4..fca5e44457 100644
--- a/saleor/static/dashboard-next/discounts/components/VoucherListPage/VoucherListPage.tsx
+++ b/saleor/static/dashboard-next/discounts/components/VoucherListPage/VoucherListPage.tsx
@@ -48,7 +48,6 @@ const VoucherListPage: React.StatelessComponent<VoucherListPageProps> = ({
selected={selected}
toggle={toggle}
toggleAll={toggleAll}
- toggleAll={toggleAll}
toolbar={toolbar}
/>
</Container>
diff --git a/saleor/static/dashboard-next/fixtures.ts b/saleor/static/dashboard-next/fixtures.ts
index 03d1accc61..1be8133ff1 100644
--- a/saleor/static/dashboard-next/fixtures.ts
+++ b/saleor/static/dashboard-next/fixtures.ts
@@ -26,6 +26,7 @@ export const listActionsProps: ListActions = {
isChecked: () => undefined,
selected: 0,
toggle: () => undefined,
+ toggleAll: () => undefined,
toolbar: null
};
diff --git a/saleor/static/dashboard-next/hooks/useBulkActions.ts b/saleor/static/dashboard-next/hooks/useBulkActions.ts
index 48ef9d501a..2165a82c21 100644
--- a/saleor/static/dashboard-next/hooks/useBulkActions.ts
+++ b/saleor/static/dashboard-next/hooks/useBulkActions.ts
@@ -23,7 +23,7 @@ function useBulkActions(initial: string[] = []) {
isSelected(id) ? remove(id) : add(id);
}
- function toggleAll(items, selected) {
+ function toggleAll(items: any, selected: number) {
const allItems = [];
items.map(item => {
allItems.push(item.id);
diff --git a/saleor/static/dashboard-next/products/components/ProductListCard/ProductListCard.tsx b/saleor/static/dashboard-next/products/components/ProductListCard/ProductListCard.tsx
index 74416278ba..6b0c5000ba 100644
--- a/saleor/static/dashboard-next/products/components/ProductListCard/ProductListCard.tsx
+++ b/saleor/static/dashboard-next/products/components/ProductListCard/ProductListCard.tsx
@@ -64,7 +64,6 @@ export const ProductListCard: React.StatelessComponent<
disabled={disabled}
pageInfo={pageInfo}
toolbar={toolbar}
- toggleAll={toggleAll}
selected={selected}
isChecked={isChecked}
toggle={toggle}
diff --git a/saleor/static/dashboard-next/products/components/ProductVariants/ProductVariants.tsx b/saleor/static/dashboard-next/products/components/ProductVariants/ProductVariants.tsx
index bd870970cb..83afbd2bb7 100644
--- a/saleor/static/dashboard-next/products/components/ProductVariants/ProductVariants.tsx
+++ b/saleor/static/dashboard-next/products/components/ProductVariants/ProductVariants.tsx
@@ -112,7 +112,7 @@ export const ProductVariants = withStyles(styles, { name: "ProductVariants" })(
<TableHead
selected={selected}
disabled={disabled}
- items={productTypes}
+ items={variants}
toggleAll={toggleAll}
toolbar={toolbar}
tablebar={
diff --git a/saleor/static/dashboard-next/products/views/ProductUpdate.tsx b/saleor/static/dashboard-next/products/views/ProductUpdate.tsx
index c61b4b5758..336bccb94c 100644
--- a/saleor/static/dashboard-next/products/views/ProductUpdate.tsx
+++ b/saleor/static/dashboard-next/products/views/ProductUpdate.tsx
@@ -43,7 +43,7 @@ export const ProductUpdate: React.StatelessComponent<ProductUpdateProps> = ({
}) => {
const navigate = useNavigator();
const notify = useNotifier();
- const { isSelected, listElements, reset, toggle } = useBulkActions(
+ const { isSelected, listElements, reset, toggle, toggleAll } = useBulkActions(
params.ids
);
diff --git a/saleor/static/dashboard-next/types.ts b/saleor/static/dashboard-next/types.ts
index 33c87fee6b..5f8b0be632 100644
--- a/saleor/static/dashboard-next/types.ts
+++ b/saleor/static/dashboard-next/types.ts
@@ -17,7 +17,7 @@ export interface ListProps {
}
export interface ListActionsWithoutToolbar {
toggle: (id: string) => void;
- toggleAll: () => void;
+ toggleAll: (items: any, selected: number) => void;
isChecked: (id: string) => boolean;
selected: number;
}