Skip to content

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

Add pagination to category views

dominik-zeglen6f7340808950
diff --git a/saleor/static/dashboard-next/categories/components/CategoryList/CategoryList.tsx b/saleor/static/dashboard-next/categories/components/CategoryList/CategoryList.tsx
index 9220529f14..eb2cefc5a4 100644
--- a/saleor/static/dashboard-next/categories/components/CategoryList/CategoryList.tsx
+++ b/saleor/static/dashboard-next/categories/components/CategoryList/CategoryList.tsx
@@ -4,14 +4,17 @@ import { createStyles, withStyles, 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 TableFooter from "@material-ui/core/TableFooter";
import TableHead from "@material-ui/core/TableHead";
import TableRow from "@material-ui/core/TableRow";
import * as React from "react";
import CardTitle from "../../../components/CardTitle";
import Skeleton from "../../../components/Skeleton";
+import TablePagination from "../../../components/TablePagination";
import i18n from "../../../i18n";
import { renderCollection } from "../../../misc";
+import { ListProps } from "../../../types";
const styles = createStyles({
centerText: {
@@ -25,7 +28,7 @@ const styles = createStyles({
}
});
-interface CategoryListProps extends WithStyles<typeof styles> {
+interface CategoryListProps extends ListProps, WithStyles<typeof styles> {
categories?: Array<{
id: string;
name: string;
@@ -38,11 +41,20 @@ interface CategoryListProps extends WithStyles<typeof styles> {
}>;
isRoot: boolean;
onAdd?();
- onRowClick?(id: string): () => void;
}
const CategoryList = withStyles(styles, { name: "CategoryList" })(
- ({ categories, classes, isRoot, onAdd, onRowClick }: CategoryListProps) => (
+ ({
+ categories,
+ classes,
+ disabled,
+ pageInfo,
+ onNextPage,
+ onPreviousPage,
+ isRoot,
+ onAdd,
+ onRowClick
+ }: CategoryListProps) => (
<Card>
{!isRoot && (
<CardTitle
@@ -70,6 +82,19 @@ const CategoryList = withStyles(styles, { name: "CategoryList" })(
</TableCell>
</TableRow>
</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(
categories,
diff --git a/saleor/static/dashboard-next/categories/components/CategoryListPage/CategoryListPage.tsx b/saleor/static/dashboard-next/categories/components/CategoryListPage/CategoryListPage.tsx
index 465bb5c2c4..5e7f5cf341 100644
--- a/saleor/static/dashboard-next/categories/components/CategoryListPage/CategoryListPage.tsx
+++ b/saleor/static/dashboard-next/categories/components/CategoryListPage/CategoryListPage.tsx
@@ -5,9 +5,10 @@ import * as React from "react";
import Container from "../../../components/Container";
import PageHeader from "../../../components/PageHeader";
import i18n from "../../../i18n";
+import { PageListProps } from "../../../types";
import CategoryList from "../CategoryList";
-export interface CategoryTableProps {
+export interface CategoryTableProps extends PageListProps {
categories: Array<{
id: string;
name: string;
@@ -18,26 +19,32 @@ export interface CategoryTableProps {
totalCount: number;
};
}>;
- onAddCategory();
- onCategoryClick(id: string): () => void;
}
export const CategoryListPage: React.StatelessComponent<CategoryTableProps> = ({
categories,
- onAddCategory,
- onCategoryClick
+ disabled,
+ onAdd,
+ onNextPage,
+ onPreviousPage,
+ onRowClick,
+ pageInfo
}) => (
<Container width="md">
<PageHeader title={i18n.t("Category")}>
- <Button color="secondary" variant="contained" onClick={onAddCategory}>
+ <Button color="secondary" variant="contained" onClick={onAdd}>
{i18n.t("Add category")} <AddIcon />
</Button>
</PageHeader>
<CategoryList
categories={categories}
- onAdd={onAddCategory}
- onRowClick={onCategoryClick}
+ onAdd={onAdd}
+ onRowClick={onRowClick}
+ disabled={disabled}
isRoot={true}
+ onNextPage={onNextPage}
+ onPreviousPage={onPreviousPage}
+ pageInfo={pageInfo}
/>
</Container>
);
diff --git a/saleor/static/dashboard-next/categories/components/CategoryUpdatePage/CategoryUpdatePage.tsx b/saleor/static/dashboard-next/categories/components/CategoryUpdatePage/CategoryUpdatePage.tsx
index 48d8bfc5da..adcd5e2eaa 100644
--- a/saleor/static/dashboard-next/categories/components/CategoryUpdatePage/CategoryUpdatePage.tsx
+++ b/saleor/static/dashboard-next/categories/components/CategoryUpdatePage/CategoryUpdatePage.tsx
@@ -8,7 +8,7 @@ import Form from "../../../components/Form";
import PageHeader from "../../../components/PageHeader";
import SaveButtonBar from "../../../components/SaveButtonBar/SaveButtonBar";
import SeoForm from "../../../components/SeoForm";
-import Tabs, { Tab } from "../../../components/Tab";
+import { Tab } from "../../../components/Tab";
import i18n from "../../../i18n";
import { maybe } from "../../../misc";
import { UserError } from "../../../types";
@@ -35,7 +35,14 @@ const styles = createStyles({
}
});
+export enum CategoryPageTab {
+ categories = "categories",
+ products = "products"
+}
+
export interface CategoryUpdatePageProps extends WithStyles<typeof styles> {
+ changeTab: (index: CategoryPageTab) => void;
+ currentTab: CategoryPageTab;
errors: UserError[];
disabled: boolean;
placeholderImage: string;
@@ -60,10 +67,15 @@ export interface CategoryUpdatePageProps extends WithStyles<typeof styles> {
onCategoryClick(id: string): () => void;
}
+const CategoriesTab = Tab(CategoryPageTab.categories);
+const ProductsTab = Tab(CategoryPageTab.products);
+
export const CategoryUpdatePage = withStyles(styles, {
name: "CategoryUpdatePage"
})(
({
+ changeTab,
+ currentTab,
category,
classes,
disabled,
@@ -131,49 +143,45 @@ export const CategoryUpdatePage = withStyles(styles, {
disabled={disabled}
/>
<CardSpacer />
- <Tabs>
- {({ changeTab, currentTab }) => (
- <>
- <div className={classes.tabsBorder}>
- <Tab
- isActive={currentTab === 0}
- value={0}
- changeTab={changeTab}
- >
- {i18n.t("Subcategories")}
- </Tab>
- <Tab
- isActive={currentTab === 1}
- value={1}
- changeTab={changeTab}
- >
- {i18n.t("Products")}
- </Tab>
- </div>
- <CardSpacer />
- {currentTab === 0 && (
- <CategoryList
- isRoot={false}
- categories={subcategories}
- onAdd={onAddCategory}
- onRowClick={onCategoryClick}
- />
- )}
- {currentTab === 1 && (
- <CategoryProductsCard
- categoryName={maybe(() => category.name)}
- products={products}
- disabled={disabled}
- pageInfo={pageInfo}
- onNextPage={onNextPage}
- onPreviousPage={onPreviousPage}
- onRowClick={onProductClick}
- onAdd={onAddProduct}
- />
- )}
- </>
- )}
- </Tabs>
+ <div className={classes.tabsBorder}>
+ <CategoriesTab
+ isActive={currentTab === CategoryPageTab.categories}
+ changeTab={changeTab}
+ >
+ {i18n.t("Subcategories")}
+ </CategoriesTab>
+ <ProductsTab
+ isActive={currentTab === CategoryPageTab.products}
+ changeTab={changeTab}
+ >
+ {i18n.t("Products")}
+ </ProductsTab>
+ </div>
+ <CardSpacer />
+ {currentTab === CategoryPageTab.categories && (
+ <CategoryList
+ disabled={disabled}
+ isRoot={false}
+ categories={subcategories}
+ onAdd={onAddCategory}
+ onRowClick={onCategoryClick}
+ onNextPage={onNextPage}
+ onPreviousPage={onPreviousPage}
+ pageInfo={pageInfo}
+ />
+ )}
+ {currentTab === CategoryPageTab.products && (
+ <CategoryProductsCard
+ categoryName={maybe(() => category.name)}
+ products={products}
+ disabled={disabled}
+ pageInfo={pageInfo}
+ onNextPage={onNextPage}
+ onPreviousPage={onPreviousPage}
+ onRowClick={onProductClick}
+ onAdd={onAddProduct}
+ />
+ )}
<SaveButtonBar
onCancel={onBack}
onDelete={onDelete}
diff --git a/saleor/static/dashboard-next/categories/index.tsx b/saleor/static/dashboard-next/categories/index.tsx
index f8515e45f3..1aad88dd04 100644
--- a/saleor/static/dashboard-next/categories/index.tsx
+++ b/saleor/static/dashboard-next/categories/index.tsx
@@ -6,9 +6,12 @@ import i18n from "../i18n";
import { categoryAddPath, categoryListPath, categoryPath } from "./urls";
import { CategoryCreateView } from "./views/CategoryCreate";
import CategoryDetailsView, {
- CategoryDetailsQueryParams
+ CategoryDetailsQueryParams,
+ getActiveTab
} from "./views/CategoryDetails";
-import CategoryList from "./views/CategoryList";
+import CategoryListComponent, {
+ CategoryListQueryParams
+} from "./views/CategoryList";
interface CategoryDetailsRouteParams {
id: string;
@@ -18,6 +21,7 @@ const CategoryDetails: React.StatelessComponent<
> = ({ location, match }) => {
const qs = parseQs(location.search.substr(1));
const params: CategoryDetailsQueryParams = {
+ activeTab: getActiveTab(qs.activeTab),
after: qs.after,
before: qs.before
};
@@ -44,6 +48,17 @@ const CategoryCreate: React.StatelessComponent<
);
};
+const CategoryList: React.StatelessComponent<RouteComponentProps<{}>> = ({
+ location
+}) => {
+ const qs = parseQs(location.search.substr(1));
+ const params: CategoryListQueryParams = {
+ after: qs.after,
+ before: qs.before
+ };
+ return <CategoryListComponent params={params} />;
+};
+
const Component = () => (
<>
<WindowTitle title={i18n.t("Categories")} />
diff --git a/saleor/static/dashboard-next/categories/queries.ts b/saleor/static/dashboard-next/categories/queries.ts
index e3e492f986..6184ead263 100644
--- a/saleor/static/dashboard-next/categories/queries.ts
+++ b/saleor/static/dashboard-next/categories/queries.ts
@@ -21,8 +21,19 @@ export const categoryDetailsFragment = gql`
`;
export const rootCategories = gql`
- query RootCategories {
- categories(level: 0, first: 20) {
+ query RootCategories(
+ $first: Int
+ $after: String
+ $last: Int
+ $before: String
+ ) {
+ categories(
+ level: 0
+ first: $first
+ after: $after
+ last: $last
+ before: $before
+ ) {
edges {
node {
id
@@ -35,6 +46,12 @@ export const rootCategories = gql`
}
}
}
+ pageInfo {
+ endCursor
+ hasNextPage
+ hasPreviousPage
+ startCursor
+ }
}
}
`;
diff --git a/saleor/static/dashboard-next/categories/types/RootCategories.ts b/saleor/static/dashboard-next/categories/types/RootCategories.ts
index c44f498e53..95ddbf743f 100644
--- a/saleor/static/dashboard-next/categories/types/RootCategories.ts
+++ b/saleor/static/dashboard-next/categories/types/RootCategories.ts
@@ -28,9 +28,18 @@ export interface RootCategories_categories_edges {
node: RootCategories_categories_edges_node;
}
+export interface RootCategories_categories_pageInfo {
+ __typename: "PageInfo";
+ endCursor: string | null;
+ hasNextPage: boolean;
+ hasPreviousPage: boolean;
+ startCursor: string | null;
+}
+
export interface RootCategories_categories {
__typename: "CategoryCountableConnection";
edges: RootCategories_categories_edges[];
+ pageInfo: RootCategories_categories_pageInfo;
}
export interface RootCategories {
diff --git a/saleor/static/dashboard-next/categories/views/CategoryDetails/index.tsx b/saleor/static/dashboard-next/categories/views/CategoryDetails/index.tsx
index 053f764ee2..96c38a769a 100644
--- a/saleor/static/dashboard-next/categories/views/CategoryDetails/index.tsx
+++ b/saleor/static/dashboard-next/categories/views/CategoryDetails/index.tsx
@@ -1,4 +1,5 @@
import DialogContentText from "@material-ui/core/DialogContentText";
+import { stringify as stringifyQs } from "qs";
import * as React from "react";
import { Route } from "react-router-dom";
@@ -13,7 +14,10 @@ import { WindowTitle } from "../../../components/WindowTitle";
import i18n from "../../../i18n";
import { getMutationState, maybe } from "../../../misc";
import { productAddUrl, productUrl } from "../../../products/urls";
-import { CategoryUpdatePage } from "../../components/CategoryUpdatePage/CategoryUpdatePage";
+import {
+ CategoryPageTab,
+ CategoryUpdatePage
+} from "../../components/CategoryUpdatePage/CategoryUpdatePage";
import {
TypedCategoryDeleteMutation,
TypedCategoryUpdateMutation
@@ -24,6 +28,7 @@ import { categoryAddUrl, categoryListUrl, categoryUrl } from "../../urls";
import { categoryDeletePath, categoryDeleteUrl } from "./urls";
export type CategoryDetailsQueryParams = Partial<{
+ activeTab: CategoryPageTab;
after: string;
before: string;
}>;
@@ -32,6 +37,12 @@ export interface CategoryDetailsProps {
id: string;
}
+export function getActiveTab(tabName: string): CategoryPageTab {
+ return tabName === CategoryPageTab.products
+ ? CategoryPageTab.products
+ : CategoryPageTab.categories;
+}
+
const PAGINATE_BY = 20;
export const CategoryDetails: React.StatelessComponent<
@@ -55,6 +66,14 @@ export const CategoryDetails: React.StatelessComponent<
}
};
+ const changeTab = (tabName: CategoryPageTab) =>
+ navigate(
+ "?" +
+ stringifyQs({
+ activeTab: tabName
+ })
+ );
+
return (
<TypedCategoryDeleteMutation onCompleted={onCategoryDelete}>
{(deleteCategory, deleteResult) => (
@@ -97,6 +116,8 @@ export const CategoryDetails: React.StatelessComponent<
pageInfo
}) => (
<CategoryUpdatePage
+ changeTab={changeTab}
+ currentTab={params.activeTab}
category={maybe(() => data.category)}
disabled={loading}
errors={maybe(
diff --git a/saleor/static/dashboard-next/categories/views/CategoryList.tsx b/saleor/static/dashboard-next/categories/views/CategoryList.tsx
index 1efb0a4995..168ac7b692 100644
--- a/saleor/static/dashboard-next/categories/views/CategoryList.tsx
+++ b/saleor/static/dashboard-next/categories/views/CategoryList.tsx
@@ -1,27 +1,56 @@
import * as React from "react";
import Navigator from "../../components/Navigator";
+import { createPaginationState, Paginator } from "../../components/Paginator";
import { maybe } from "../../misc";
import { CategoryListPage } from "../components/CategoryListPage/CategoryListPage";
import { TypedRootCategoriesQuery } from "../queries";
import { categoryAddUrl, categoryUrl } from "../urls";
-export const CategoryList: React.StatelessComponent = () => (
+export type CategoryListQueryParams = Partial<{
+ after: string;
+ before: string;
+}>;
+
+interface CategoryListProps {
+ params: CategoryListQueryParams;
+}
+
+const PAGINATE_BY = 20;
+
+export const CategoryList: React.StatelessComponent<CategoryListProps> = ({
+ params
+}) => (
<Navigator>
- {navigate => (
- <TypedRootCategoriesQuery displayLoader>
- {({ data }) => (
- <CategoryListPage
- categories={maybe(
- () => data.categories.edges.map(edge => edge.node),
- []
- )}
- onAddCategory={() => navigate(categoryAddUrl())}
- onCategoryClick={id => () => navigate(categoryUrl(id))}
- />
- )}
- </TypedRootCategoriesQuery>
- )}
+ {navigate => {
+ const paginationState = createPaginationState(PAGINATE_BY, params);
+ return (
+ <TypedRootCategoriesQuery displayLoader variables={paginationState}>
+ {({ data, loading }) => (
+ <Paginator
+ pageInfo={maybe(() => data.categories.pageInfo)}
+ paginationState={paginationState}
+ queryString={params}
+ >
+ {({ loadNextPage, loadPreviousPage, pageInfo }) => (
+ <CategoryListPage
+ categories={maybe(
+ () => data.categories.edges.map(edge => edge.node),
+ []
+ )}
+ onAdd={() => navigate(categoryAddUrl())}
+ onRowClick={id => () => navigate(categoryUrl(id))}
+ disabled={loading}
+ onNextPage={loadNextPage}
+ onPreviousPage={loadPreviousPage}
+ pageInfo={pageInfo}
+ />
+ )}
+ </Paginator>
+ )}
+ </TypedRootCategoriesQuery>
+ );
+ }}
</Navigator>
);
export default CategoryList;
diff --git a/saleor/static/dashboard-next/components/Tab/Tab.tsx b/saleor/static/dashboard-next/components/Tab/Tab.tsx
index 5c304539ad..36963cbe32 100644
--- a/saleor/static/dashboard-next/components/Tab/Tab.tsx
+++ b/saleor/static/dashboard-next/components/Tab/Tab.tsx
@@ -30,27 +30,27 @@ const styles = (theme: Theme) =>
}
});
-interface TabProps extends WithStyles<typeof styles> {
+interface TabProps<T> extends WithStyles<typeof styles> {
children?: React.ReactNode;
isActive: boolean;
- value: number;
- changeTab: (index: number) => void;
+ changeTab: (index: T) => void;
}
-export const Tab = withStyles(styles, { name: "Tab" })(
- ({ classes, children, isActive, value, changeTab }: TabProps) => (
- <Typography
- component="span"
- className={classNames({
- [classes.root]: true,
- [classes.active]: isActive
- })}
- onClick={() => changeTab(value)}
- >
- {children}
- </Typography>
- )
-);
+export function Tab<T>(value: T) {
+ return withStyles(styles, { name: "Tab" })(
+ ({ classes, children, isActive, changeTab }: TabProps<T>) => (
+ <Typography
+ component="span"
+ className={classNames({
+ [classes.root]: true,
+ [classes.active]: isActive
+ })}
+ onClick={() => changeTab(value)}
+ >
+ {children}
+ </Typography>
+ )
+ );
+}
-Tab.displayName = "Tab";
export default Tab;
diff --git a/saleor/static/dashboard-next/storybook/__snapshots__/Stories.test.ts.snap b/saleor/static/dashboard-next/storybook/__snapshots__/Stories.test.ts.snap
index 3f17147d76..0f6181e1c0 100644
--- a/saleor/static/dashboard-next/storybook/__snapshots__/Stories.test.ts.snap
+++ b/saleor/static/dashboard-next/storybook/__snapshots__/Stories.test.ts.snap
@@ -6501,6 +6501,73 @@ exports[`Storyshots Views / Categories / Category list default 1`] = `
</th>
</tr>
</thead>
+ <tfoot
+ class="MuiTableFooter-root-id"
+ >
+ <tr
+ class="MuiTableRow-root-id MuiTableRow-footer-id"
+ >
+ <td
+ class="MuiTableCell-root-id MuiTableCell-footer-id TablePagination-root-id"
+ colspan="3"
+ >
+ <div
+ class="MuiToolbar-root-id MuiToolbar-regular-id MuiToolbar-gutters-id TablePagination-toolbar-id"
+ >
+ <div
+ class="TablePagination-spacer-id"
+ />
+ <div
+ class="TablePaginationActions-root-id"
+ >
+ <button
+ class="MuiButtonBase-root-id MuiButtonBase-disabled-id MuiIconButton-root-id MuiIconButton-disabled-id"
+ disabled=""
+ tabindex="-1"
+ type="button"
+ >
+ <span
+ class="MuiIconButton-label-id"
+ >
+ <svg
+ aria-hidden="true"
+ class="MuiSvgIcon-root-id"
+ focusable="false"
+ role="presentation"
+ viewBox="0 0 24 24"
+ >
+ <path
+ d="M15.41 16.09l-4.58-4.59 4.58-4.59L14 5.5l-6 6 6 6z"
+ />
+ </svg>
+ </span>
+ </button>
+ <button
+ class="MuiButtonBase-root-id MuiIconButton-root-id"
+ tabindex="0"
+ type="button"
+ >
+ <span
+ class="MuiIconButton-label-id"
+ >
+ <svg
+ aria-hidden="true"
+ class="MuiSvgIcon-root-id"
+ focusable="false"
+ role="presentation"
+ viewBox="0 0 24 24"
+ >
+ <path
+ d="M8.59 16.34l4.58-4.59-4.58-4.59L10 5.75l6 6-6 6z"
+ />
+ </svg>
+ </span>
+ </button>
+ </div>
+ </div>
+ </td>
+ </tr>
+ </tfoot>
<tbody
class="MuiTableBody-root-id"
>
@@ -6701,6 +6768,73 @@ exports[`Storyshots Views / Categories / Category list empty 1`] = `
</th>
</tr>
</thead>
+ <tfoot
+ class="MuiTableFooter-root-id"
+ >
+ <tr
+ class="MuiTableRow-root-id MuiTableRow-footer-id"
+ >
+ <td
+ class="MuiTableCell-root-id MuiTableCell-footer-id TablePagination-root-id"
+ colspan="3"
+ >
+ <div
+ class="MuiToolbar-root-id MuiToolbar-regular-id MuiToolbar-gutters-id TablePagination-toolbar-id"
+ >
+ <div
+ class="TablePagination-spacer-id"
+ />
+ <div
+ class="TablePaginationActions-root-id"
+ >
+ <button
+ class="MuiButtonBase-root-id MuiButtonBase-disabled-id MuiIconButton-root-id MuiIconButton-disabled-id"
+ disabled=""
+ tabindex="-1"
+ type="button"
+ >
+ <span
+ class="MuiIconButton-label-id"
+ >
+ <svg
+ aria-hidden="true"
+ class="MuiSvgIcon-root-id"
+ focusable="false"
+ role="presentation"
+ viewBox="0 0 24 24"
+ >
+ <path
+ d="M15.41 16.09l-4.58-4.59 4.58-4.59L14 5.5l-6 6 6 6z"
+ />
+ </svg>
+ </span>
+ </button>
+ <button
+ class="MuiButtonBase-root-id MuiIconButton-root-id"
+ tabindex="0"
+ type="button"
+ >
+ <span
+ class="MuiIconButton-label-id"
+ >
+ <svg
+ aria-hidden="true"
+ class="MuiSvgIcon-root-id"
+ focusable="false"
+ role="presentation"
+ viewBox="0 0 24 24"
+ >
+ <path
+ d="M8.59 16.34l4.58-4.59-4.58-4.59L10 5.75l6 6-6 6z"
+ />
+ </svg>
+ </span>
+ </button>
+ </div>
+ </div>
+ </td>
+ </tr>
+ </tfoot>
<tbody
class="MuiTableBody-root-id"
>
@@ -6797,6 +6931,73 @@ exports[`Storyshots Views / Categories / Category list loading 1`] = `
</th>
</tr>
</thead>
+ <tfoot
+ class="MuiTableFooter-root-id"
+ >
+ <tr
+ class="MuiTableRow-root-id MuiTableRow-footer-id"
+ >
+ <td
+ class="MuiTableCell-root-id MuiTableCell-footer-id TablePagination-root-id"
+ colspan="3"
+ >
+ <div
+ class="MuiToolbar-root-id MuiToolbar-regular-id MuiToolbar-gutters-id TablePagination-toolbar-id"
+ >
+ <div
+ class="TablePagination-spacer-id"
+ />
+ <div
+ class="TablePaginationActions-root-id"
+ >
+ <button
+ class="MuiButtonBase-root-id MuiButtonBase-disabled-id MuiIconButton-root-id MuiIconButton-disabled-id"
+ disabled=""
+ tabindex="-1"
+ type="button"
+ >
+ <span
+ class="MuiIconButton-label-id"
+ >
+ <svg
+ aria-hidden="true"
+ class="MuiSvgIcon-root-id"
+ focusable="false"
+ role="presentation"
+ viewBox="0 0 24 24"
+ >
+ <path
+ d="M15.41 16.09l-4.58-4.59 4.58-4.59L14 5.5l-6 6 6 6z"
+ />
+ </svg>
+ </span>
+ </button>
+ <button
+ class="MuiButtonBase-root-id MuiIconButton-root-id"
+ tabindex="0"
+ type="button"
+ >
+ <span
+ class="MuiIconButton-label-id"
+ >
+ <svg
+ aria-hidden="true"
+ class="MuiSvgIcon-root-id"
+ focusable="false"
+ role="presentation"
+ viewBox="0 0 24 24"
+ >
+ <path
+ d="M8.59 16.34l4.58-4.59-4.58-4.59L10 5.75l6 6-6 6z"
+ />
+ </svg>
+ </span>
+ </button>
+ </div>
+ </div>
+ </td>
+ </tr>
+ </tfoot>
<tbody
class="MuiTableBody-root-id"
>
@@ -7637,6 +7838,72 @@ exports[`Storyshots Views / Categories / Update category default 1`] = `
</th>
</tr>
</thead>
+ <tfoot
+ class="MuiTableFooter-root-id"
+ >
+ <tr
+ class="MuiTableRow-root-id MuiTableRow-footer-id"
+ >
+ <td
+ class="MuiTableCell-root-id MuiTableCell-footer-id TablePagination-root-id"
+ colspan="3"
+ >
+ <div
+ class="MuiToolbar-root-id MuiToolbar-regular-id MuiToolbar-gutters-id TablePagination-toolbar-id"
+ >
+ <div
+ class="TablePagination-spacer-id"
+ />
+ <div
+ class="TablePaginationActions-root-id"
+ >
+ <button
+ class="MuiButtonBase-root-id MuiIconButton-root-id"
+ tabindex="0"
+ type="button"
+ >
+ <span
+ class="MuiIconButton-label-id"
+ >
+ <svg
+ aria-hidden="true"
+ class="MuiSvgIcon-root-id"
+ focusable="false"
+ role="presentation"
+ viewBox="0 0 24 24"
+ >
+ <path
+ d="M15.41 16.09l-4.58-4.59 4.58-4.59L14 5.5l-6 6 6 6z"
+ />
+ </svg>
+ </span>
+ </button>
+ <button
+ class="MuiButtonBase-root-id MuiIconButton-root-id"
+ tabindex="0"
+ type="button"
+ >
+ <span
+ class="MuiIconButton-label-id"
+ >
+ <svg
+ aria-hidden="true"
+ class="MuiSvgIcon-root-id"
+ focusable="false"
+ role="presentation"
+ viewBox="0 0 24 24"
+ >
+ <path
+ d="M8.59 16.34l4.58-4.59-4.58-4.59L10 5.75l6 6-6 6z"
+ />
+ </svg>
+ </span>
+ </button>
+ </div>
+ </div>
+ </td>
+ </tr>
+ </tfoot>
<tbody
class="MuiTableBody-root-id"
>
@@ -8015,6 +8282,74 @@ exports[`Storyshots Views / Categories / Update category loading 1`] = `
</th>
</tr>
</thead>
+ <tfoot
+ class="MuiTableFooter-root-id"
+ >
+ <tr
+ class="MuiTableRow-root-id MuiTableRow-footer-id"
+ >
+ <td
+ class="MuiTableCell-root-id MuiTableCell-footer-id TablePagination-root-id"
+ colspan="3"
+ >
+ <div
+ class="MuiToolbar-root-id MuiToolbar-regular-id MuiToolbar-gutters-id TablePagination-toolbar-id"
+ >
+ <div
+ class="TablePagination-spacer-id"
+ />
+ <div
+ class="TablePaginationActions-root-id"
+ >
+ <button
+ class="MuiButtonBase-root-id MuiButtonBase-disabled-id MuiIconButton-root-id MuiIconButton-disabled-id"
+ disabled=""
+ tabindex="-1"
+ type="button"
+ >
+ <span
+ class="MuiIconButton-label-id"
+ >
+ <svg
+ aria-hidden="true"
+ class="MuiSvgIcon-root-id"
+ focusable="false"
+ role="presentation"
+ viewBox="0 0 24 24"
+ >
+ <path
+ d="M15.41 16.09l-4.58-4.59 4.58-4.59L14 5.5l-6 6 6 6z"
+ />
+ </svg>
+ </span>
+ </button>
+ <button
+ class="MuiButtonBase-root-id MuiButtonBase-disabled-id MuiIconButton-root-id MuiIconButton-disabled-id"
+ disabled=""
+ tabindex="-1"
+ type="button"
+ >
+ <span
+ class="MuiIconButton-label-id"
+ >
+ <svg
+ aria-hidden="true"
+ class="MuiSvgIcon-root-id"
+ focusable="false"
+ role="presentation"
+ viewBox="0 0 24 24"
+ >
+ <path
+ d="M8.59 16.34l4.58-4.59-4.58-4.59L10 5.75l6 6-6 6z"
+ />
+ </svg>
+ </span>
+ </button>
+ </div>
+ </div>
+ </td>
+ </tr>
+ </tfoot>
<tbody
class="MuiTableBody-root-id"
>
@@ -8411,6 +8746,72 @@ exports[`Storyshots Views / Categories / Update category no background 1`] = `
</th>
</tr>
</thead>
+ <tfoot
+ class="MuiTableFooter-root-id"
+ >
+ <tr
+ class="MuiTableRow-root-id MuiTableRow-footer-id"
+ >
+ <td
+ class="MuiTableCell-root-id MuiTableCell-footer-id TablePagination-root-id"
+ colspan="3"
+ >
+ <div
+ class="MuiToolbar-root-id MuiToolbar-regular-id MuiToolbar-gutters-id TablePagination-toolbar-id"
+ >
+ <div
+ class="TablePagination-spacer-id"
+ />
+ <div
+ class="TablePaginationActions-root-id"
+ >
+ <button
+ class="MuiButtonBase-root-id MuiIconButton-root-id"
+ tabindex="0"
+ type="button"
+ >
+ <span
+ class="MuiIconButton-label-id"
+ >
+ <svg
+ aria-hidden="true"
+ class="MuiSvgIcon-root-id"
+ focusable="false"
+ role="presentation"
+ viewBox="0 0 24 24"
+ >
+ <path
+ d="M15.41 16.09l-4.58-4.59 4.58-4.59L14 5.5l-6 6 6 6z"
+ />
+ </svg>
+ </span>
+ </button>
+ <button
+ class="MuiButtonBase-root-id MuiIconButton-root-id"
+ tabindex="0"
+ type="button"
+ >
+ <span
+ class="MuiIconButton-label-id"
+ >
+ <svg
+ aria-hidden="true"
+ class="MuiSvgIcon-root-id"
+ focusable="false"
+ role="presentation"
+ viewBox="0 0 24 24"
+ >
+ <path
+ d="M8.59 16.34l4.58-4.59-4.58-4.59L10 5.75l6 6-6 6z"
+ />
+ </svg>
+ </span>
+ </button>
+ </div>
+ </div>
+ </td>
+ </tr>
+ </tfoot>
<tbody
class="MuiTableBody-root-id"
>
@@ -8711,12 +9112,12 @@ exports[`Storyshots Views / Categories / Update category no products 1`] = `
class="CategoryUpdatePage-tabsBorder-id"
>
<span
- class="MuiTypography-root-id MuiTypography-body1-id Tab-root-id Tab-active-id"
+ class="MuiTypography-root-id MuiTypography-body1-id Tab-root-id"
>
Subcategories
</span>
<span
- class="MuiTypography-root-id MuiTypography-body1-id Tab-root-id"
+ class="MuiTypography-root-id MuiTypography-body1-id Tab-root-id Tab-active-id"
>
Products
</span>
@@ -8733,7 +9134,7 @@ exports[`Storyshots Views / Categories / Update category no products 1`] = `
<span
class="MuiTypography-root-id MuiTypography-body1-id CardTitle-title-id"
>
- All Subcategories
+ Products in Coffees
</span>
<div
class="CardTitle-toolbar-id"
@@ -8746,7 +9147,7 @@ exports[`Storyshots Views / Categories / Update category no products 1`] = `
<span
class="MuiButton-label-id"
>
- Add subcategory
+ Add product
</span>
</button>
</div>
@@ -8767,25 +9168,97 @@ exports[`Storyshots Views / Categories / Update category no products 1`] = `
class="MuiTableRow-root-id MuiTableRow-head-id"
>
<th
- class="MuiTableCell-root-id MuiTableCell-head-id CategoryList-wideColumn-id"
+ class="MuiTableCell-root-id MuiTableCell-head-id ProductList-textLeft-id"
scope="col"
>
- Category Name
+ Name
</th>
<th
- class="MuiTableCell-root-id MuiTableCell-head-id CategoryList-centerText-id"
+ class="MuiTableCell-root-id MuiTableCell-head-id"
scope="col"
>
- Subcategories
+ Type
</th>
<th
- class="MuiTableCell-root-id MuiTableCell-head-id CategoryList-centerText-id"
+ class="MuiTableCell-root-id MuiTableCell-head-id"
scope="col"
>
- No. Products
+ Published
+ </th>
+ <th
+ class="MuiTableCell-root-id MuiTableCell-head-id ProductList-textRight-id"
+ scope="col"
+ >
+ Price
</th>
</tr>
</thead>
+ <tfoot
+ class="MuiTableFooter-root-id"
+ >
+ <tr
+ class="MuiTableRow-root-id MuiTableRow-footer-id"
+ >
+ <td
+ class="MuiTableCell-root-id MuiTableCell-footer-id TablePagination-root-id"
+ colspan="5"
+ >
+ <div
+ class="MuiToolbar-root-id MuiToolbar-regular-id MuiToolbar-gutters-id TablePagination-toolbar-id"
+ >
+ <div
+ class="TablePagination-spacer-id"
+ />
+ <div
+ class="TablePaginationActions-root-id"
+ >
+ <button
+ class="MuiButtonBase-root-id MuiIconButton-root-id"
+ tabindex="0"
+ type="button"
+ >
+ <span
+ class="MuiIconButton-label-id"
+ >
+ <svg
+ aria-hidden="true"
+ class="MuiSvgIcon-root-id"
+ focusable="false"
+ role="presentation"
+ viewBox="0 0 24 24"
+ >
+ <path
+ d="M15.41 16.09l-4.58-4.59 4.58-4.59L14 5.5l-6 6 6 6z"
+ />
+ </svg>
+ </span>
+ </button>
+ <button
+ class="MuiButtonBase-root-id MuiIconButton-root-id"
+ tabindex="0"
+ type="button"
+ >
+ <span
+ class="MuiIconButton-label-id"
+ >
+ <svg
+ aria-hidden="true"
+ class="MuiSvgIcon-root-id"
+ focusable="false"
+ role="presentation"
+ viewBox="0 0 24 24"
+ >
+ <path
+ d="M8.59 16.34l4.58-4.59-4.58-4.59L10 5.75l6 6-6 6z"
+ />
+ </svg>
+ </span>
+ </button>
+ </div>
+ </div>
+ </td>
+ </tr>
+ </tfoot>
<tbody
class="MuiTableBody-root-id"
>
@@ -8794,9 +9267,9 @@ exports[`Storyshots Views / Categories / Update category no products 1`] = `
>
<td
class="MuiTableCell-root-id MuiTableCell-body-id"
- colspan="3"
+ colspan="5"
>
- No subcategories found
+ No products found
</td>
</tr>
</tbody>
@@ -9161,6 +9634,72 @@ exports[`Storyshots Views / Categories / Update category no subcategories 1`] =
</th>
</tr>
</thead>
+ <tfoot
+ class="MuiTableFooter-root-id"
+ >
+ <tr
+ class="MuiTableRow-root-id MuiTableRow-footer-id"
+ >
+ <td
+ class="MuiTableCell-root-id MuiTableCell-footer-id TablePagination-root-id"
+ colspan="3"
+ >
+ <div
+ class="MuiToolbar-root-id MuiToolbar-regular-id MuiToolbar-gutters-id TablePagination-toolbar-id"
+ >
+ <div
+ class="TablePagination-spacer-id"
+ />
+ <div
+ class="TablePaginationActions-root-id"
+ >
+ <button
+ class="MuiButtonBase-root-id MuiIconButton-root-id"
+ tabindex="0"
+ type="button"
+ >
+ <span
+ class="MuiIconButton-label-id"
+ >
+ <svg
+ aria-hidden="true"
+ class="MuiSvgIcon-root-id"
+ focusable="false"
+ role="presentation"
+ viewBox="0 0 24 24"
+ >
+ <path
+ d="M15.41 16.09l-4.58-4.59 4.58-4.59L14 5.5l-6 6 6 6z"
+ />
+ </svg>
+ </span>
+ </button>
+ <button
+ class="MuiButtonBase-root-id MuiIconButton-root-id"
+ tabindex="0"
+ type="button"
+ >
+ <span
+ class="MuiIconButton-label-id"
+ >
+ <svg
+ aria-hidden="true"
+ class="MuiSvgIcon-root-id"
+ focusable="false"
+ role="presentation"
+ viewBox="0 0 24 24"
+ >
+ <path
+ d="M8.59 16.34l4.58-4.59-4.58-4.59L10 5.75l6 6-6 6z"
+ />
+ </svg>
+ </span>
+ </button>
+ </div>
+ </div>
+ </td>
+ </tr>
+ </tfoot>
<tbody
class="MuiTableBody-root-id"
>
diff --git a/saleor/static/dashboard-next/storybook/stories/categories/CategoryListPage.tsx b/saleor/static/dashboard-next/storybook/stories/categories/CategoryListPage.tsx
index 1b1844b67c..11b1bda8e4 100644
--- a/saleor/static/dashboard-next/storybook/stories/categories/CategoryListPage.tsx
+++ b/saleor/static/dashboard-next/storybook/stories/categories/CategoryListPage.tsx
@@ -3,12 +3,14 @@ import * as React from "react";
import CategoryListPage from "../../../categories/components/CategoryListPage";
import { categories } from "../../../categories/fixtures";
+import { pageListProps } from "../../../fixtures";
import Decorator from "../../Decorator";
const categoryTableProps = {
categories,
onAddCategory: undefined,
- onCategoryClick: () => undefined
+ onCategoryClick: () => undefined,
+ ...pageListProps.default
};
storiesOf("Views / Categories / Category list", module)
diff --git a/saleor/static/dashboard-next/storybook/stories/categories/CategoryUpdatePage.tsx b/saleor/static/dashboard-next/storybook/stories/categories/CategoryUpdatePage.tsx
index 0325554d11..7c1d91757a 100644
--- a/saleor/static/dashboard-next/storybook/stories/categories/CategoryUpdatePage.tsx
+++ b/saleor/static/dashboard-next/storybook/stories/categories/CategoryUpdatePage.tsx
@@ -6,6 +6,7 @@ import * as placeholderImage from "../../../../images/placeholder255x255.png";
import { category as categoryFixture } from "../../../categories/fixtures";
import CategoryUpdatePage, {
+ CategoryPageTab,
CategoryUpdatePageProps
} from "../../../categories/components/CategoryUpdatePage";
import Decorator from "../../Decorator";
@@ -14,6 +15,8 @@ const category = categoryFixture(placeholderImage);
const updateProps: Omit<CategoryUpdatePageProps, "classes"> = {
category,
+ changeTab: undefined,
+ currentTab: CategoryPageTab.categories,
disabled: false,
errors: [],
onAddCategory: undefined,
@@ -47,7 +50,11 @@ storiesOf("Views / Categories / Update category", module)
<CategoryUpdatePage {...updateProps} subcategories={[]} />
))
.add("no products", () => (
- <CategoryUpdatePage {...updateProps} products={[]} />
+ <CategoryUpdatePage
+ {...updateProps}
+ products={[]}
+ currentTab={CategoryPageTab.products}
+ />
))
.add("loading", () => (
<CategoryUpdatePage