saleor-dashboard/src/collections/components/CollectionListPage/CollectionListPage.tsx
Dominik Żegleń a175fb9497
Add global channel picker (#841)
* Move theme switch to user menu

* Add global channel picker

* Fix picker styles

* Use app channel state

* Improve prop naming to indicate id vs slug

* Disable picker if no reason to pick channel

* Remove settings modal leftovers

* Remove channel settings dialog

* Remove unused props

* Skip channel fetching if user is not authenticated

* Remove channel selection from components

* Update messages

* Fix e2e tests

* Remove channel picker leftover

* Revert ChannelSettingsDialog deletion

* Update snapshots

* Update messages
2020-11-23 10:39:24 +01:00

94 lines
2.5 KiB
TypeScript

import Button from "@material-ui/core/Button";
import Card from "@material-ui/core/Card";
import { CollectionListUrlSortField } from "@saleor/collections/urls";
import { Container } from "@saleor/components/Container";
import PageHeader from "@saleor/components/PageHeader";
import SearchBar from "@saleor/components/SearchBar";
import { sectionNames } from "@saleor/intl";
import {
ChannelProps,
ListActions,
PageListProps,
SearchPageProps,
SortPage,
TabPageProps
} from "@saleor/types";
import React from "react";
import { FormattedMessage, useIntl } from "react-intl";
import { CollectionList_collections_edges_node } from "../../types/CollectionList";
import CollectionList from "../CollectionList/CollectionList";
export interface CollectionListPageProps
extends PageListProps,
ListActions,
SearchPageProps,
SortPage<CollectionListUrlSortField>,
TabPageProps,
ChannelProps {
collections: CollectionList_collections_edges_node[];
channelsCount: number;
}
const CollectionListPage: React.FC<CollectionListPageProps> = ({
channelsCount,
currentTab,
disabled,
initialSearch,
onAdd,
onAll,
onSearchChange,
onTabChange,
onTabDelete,
onTabSave,
selectedChannelId,
tabs,
...listProps
}) => {
const intl = useIntl();
return (
<Container>
<PageHeader title={intl.formatMessage(sectionNames.collections)}>
<Button
color="primary"
disabled={disabled}
variant="contained"
onClick={onAdd}
>
<FormattedMessage
defaultMessage="Create collection"
description="button"
/>
</Button>
</PageHeader>
<Card>
<SearchBar
allTabLabel={intl.formatMessage({
defaultMessage: "All Collections",
description: "tab name"
})}
currentTab={currentTab}
initialSearch={initialSearch}
searchPlaceholder={intl.formatMessage({
defaultMessage: "Search Collection"
})}
tabs={tabs}
onAll={onAll}
onSearchChange={onSearchChange}
onTabChange={onTabChange}
onTabDelete={onTabDelete}
onTabSave={onTabSave}
/>
<CollectionList
disabled={disabled}
channelsCount={channelsCount}
selectedChannelId={selectedChannelId}
{...listProps}
/>
</Card>
</Container>
);
};
CollectionListPage.displayName = "CollectionListPage";
export default CollectionListPage;