saleor-dashboard/src/attributes/components/AttributeListPage/AttributeListPage.tsx

100 lines
2.7 KiB
TypeScript
Raw Normal View History

import { Button, Card } from "@material-ui/core";
import { AttributeListUrlSortField } from "@saleor/attributes/urls";
2020-01-10 11:34:49 +00:00
import FilterBar from "@saleor/components/FilterBar";
import { sectionNames } from "@saleor/intl";
Use MacawUI (#1229) * Replace withStyleswith useStyles (#1100) * Replace withStyleswith useStyles * Update messages * Use rem as a spacing unit (#1101) * Use rems as spacing units * Fix visual bugs * Update stories * Use macaw-ui as theme provider (#1108) * Use macaw ui as a theme provider * Add react-dom to aliases * Fix jest module resolution * Update useTheme hook usage * Fix test wrapper * Use macaw from git repo * Fix CI * Update stories * Fix aliasing * Extract savebar to macaw ui (#1146) * wip * Use savebar from macaw * Use confirm button from macaw * Improve file structure * Use sidebar context from macaw * Update macaw * Update macaw version * Remove savebar from storybook * Update stories * Use alerts and notifications from macaw (#1166) * Use alerts from macaw * Add notifications from macaw * Update stories * Pin macaw version * Encapsulate limit reached in one component * Remove unused imports * Use backlinks from macaw (#1183) * Use backlink from macaw * Update macaw version * Use macaw sidebar (#1148) * Use sidebar from macaw * Use shipped logo * Use lowercase * Update stories * Use user chip from macaw (#1191) * Use user chip from macaw * Use dedicated components for menu items * Simplify code * Bump version and fix types (#1210) * Rename onBack to onClick * Rename UserChip to UserChipMenu * Rename IMenuItem to SidebarMenuItem * Update macaw version * Fix tables after changes in macaw (#1220) * Update macaw version * Update changelog * Update stories * Fix after rebase * Update to macaw 0.2.0 * Lint files * Update macaw to 0.2.2
2021-07-21 08:59:52 +00:00
import { Backlink } from "@saleor/macaw-ui";
import React from "react";
import { FormattedMessage, useIntl } from "react-intl";
2019-08-09 10:17:04 +00:00
import Container from "../../../components/Container";
import PageHeader from "../../../components/PageHeader";
2019-09-10 15:32:47 +00:00
import {
FilterPageProps,
2019-09-10 15:32:47 +00:00
ListActions,
PageListProps,
SortPage,
TabPageProps
2019-09-10 15:32:47 +00:00
} from "../../../types";
2019-08-09 10:17:04 +00:00
import { AttributeList_attributes_edges_node } from "../../types/AttributeList";
import AttributeList from "../AttributeList/AttributeList";
import {
AttributeFilterKeys,
AttributeListFilterOpts,
createFilterStructure
} from "./filters";
2019-08-09 10:17:04 +00:00
2019-09-10 15:32:47 +00:00
export interface AttributeListPageProps
extends PageListProps,
ListActions,
2020-01-10 11:34:49 +00:00
FilterPageProps<AttributeFilterKeys, AttributeListFilterOpts>,
2019-12-17 17:13:56 +00:00
SortPage<AttributeListUrlSortField>,
2019-09-10 15:32:47 +00:00
TabPageProps {
2019-08-09 10:17:04 +00:00
attributes: AttributeList_attributes_edges_node[];
2019-09-30 13:14:11 +00:00
onBack: () => void;
2019-08-09 10:17:04 +00:00
}
const AttributeListPage: React.FC<AttributeListPageProps> = ({
2020-01-10 11:34:49 +00:00
filterOpts,
initialSearch,
2019-08-09 10:17:04 +00:00
onAdd,
2019-09-30 13:14:11 +00:00
onBack,
2020-01-10 11:34:49 +00:00
onFilterChange,
2019-09-10 15:32:47 +00:00
onSearchChange,
currentTab,
onAll,
onTabChange,
onTabDelete,
onTabSave,
tabs,
2019-08-09 10:17:04 +00:00
...listProps
}) => {
const intl = useIntl();
2020-01-10 11:34:49 +00:00
const structure = createFilterStructure(intl, filterOpts);
return (
<Container>
Use MacawUI (#1229) * Replace withStyleswith useStyles (#1100) * Replace withStyleswith useStyles * Update messages * Use rem as a spacing unit (#1101) * Use rems as spacing units * Fix visual bugs * Update stories * Use macaw-ui as theme provider (#1108) * Use macaw ui as a theme provider * Add react-dom to aliases * Fix jest module resolution * Update useTheme hook usage * Fix test wrapper * Use macaw from git repo * Fix CI * Update stories * Fix aliasing * Extract savebar to macaw ui (#1146) * wip * Use savebar from macaw * Use confirm button from macaw * Improve file structure * Use sidebar context from macaw * Update macaw * Update macaw version * Remove savebar from storybook * Update stories * Use alerts and notifications from macaw (#1166) * Use alerts from macaw * Add notifications from macaw * Update stories * Pin macaw version * Encapsulate limit reached in one component * Remove unused imports * Use backlinks from macaw (#1183) * Use backlink from macaw * Update macaw version * Use macaw sidebar (#1148) * Use sidebar from macaw * Use shipped logo * Use lowercase * Update stories * Use user chip from macaw (#1191) * Use user chip from macaw * Use dedicated components for menu items * Simplify code * Bump version and fix types (#1210) * Rename onBack to onClick * Rename UserChip to UserChipMenu * Rename IMenuItem to SidebarMenuItem * Update macaw version * Fix tables after changes in macaw (#1220) * Update macaw version * Update changelog * Update stories * Fix after rebase * Update to macaw 0.2.0 * Lint files * Update macaw to 0.2.2
2021-07-21 08:59:52 +00:00
<Backlink onClick={onBack}>
2019-09-30 13:14:11 +00:00
<FormattedMessage {...sectionNames.configuration} />
Use MacawUI (#1229) * Replace withStyleswith useStyles (#1100) * Replace withStyleswith useStyles * Update messages * Use rem as a spacing unit (#1101) * Use rems as spacing units * Fix visual bugs * Update stories * Use macaw-ui as theme provider (#1108) * Use macaw ui as a theme provider * Add react-dom to aliases * Fix jest module resolution * Update useTheme hook usage * Fix test wrapper * Use macaw from git repo * Fix CI * Update stories * Fix aliasing * Extract savebar to macaw ui (#1146) * wip * Use savebar from macaw * Use confirm button from macaw * Improve file structure * Use sidebar context from macaw * Update macaw * Update macaw version * Remove savebar from storybook * Update stories * Use alerts and notifications from macaw (#1166) * Use alerts from macaw * Add notifications from macaw * Update stories * Pin macaw version * Encapsulate limit reached in one component * Remove unused imports * Use backlinks from macaw (#1183) * Use backlink from macaw * Update macaw version * Use macaw sidebar (#1148) * Use sidebar from macaw * Use shipped logo * Use lowercase * Update stories * Use user chip from macaw (#1191) * Use user chip from macaw * Use dedicated components for menu items * Simplify code * Bump version and fix types (#1210) * Rename onBack to onClick * Rename UserChip to UserChipMenu * Rename IMenuItem to SidebarMenuItem * Update macaw version * Fix tables after changes in macaw (#1220) * Update macaw version * Update changelog * Update stories * Fix after rebase * Update to macaw 0.2.0 * Lint files * Update macaw to 0.2.2
2021-07-21 08:59:52 +00:00
</Backlink>
2019-08-22 16:19:16 +00:00
<PageHeader title={intl.formatMessage(sectionNames.attributes)}>
<Button
onClick={onAdd}
color="primary"
variant="contained"
data-test-id="createAttributeButton"
>
<FormattedMessage
2019-09-05 13:33:50 +00:00
defaultMessage="Create attribute"
description="button"
/>
</Button>
</PageHeader>
<Card>
2020-01-10 11:34:49 +00:00
<FilterBar
2019-09-11 15:56:00 +00:00
allTabLabel={intl.formatMessage({
defaultMessage: "All Attributes",
description: "tab name"
})}
2019-09-10 15:32:47 +00:00
currentTab={currentTab}
2020-01-10 11:34:49 +00:00
filterStructure={structure}
2019-09-10 15:32:47 +00:00
initialSearch={initialSearch}
searchPlaceholder={intl.formatMessage({
defaultMessage: "Search Attribute"
})}
tabs={tabs}
onAll={onAll}
2020-01-10 11:34:49 +00:00
onFilterChange={onFilterChange}
2019-09-10 15:32:47 +00:00
onSearchChange={onSearchChange}
onTabChange={onTabChange}
onTabDelete={onTabDelete}
onTabSave={onTabSave}
/>
<AttributeList {...listProps} />
</Card>
</Container>
);
};
2019-08-09 10:17:04 +00:00
AttributeListPage.displayName = "AttributeListPage";
export default AttributeListPage;