2022-01-28 12:34:20 +00:00
|
|
|
import { Card } from "@material-ui/core";
|
2020-05-14 09:30:32 +00:00
|
|
|
import { AttributeListUrlSortField } from "@saleor/attributes/urls";
|
2020-01-10 11:34:49 +00:00
|
|
|
import FilterBar from "@saleor/components/FilterBar";
|
2022-03-09 08:56:55 +00:00
|
|
|
import { AttributeFragment } from "@saleor/graphql";
|
2019-08-16 11:47:30 +00:00
|
|
|
import { sectionNames } from "@saleor/intl";
|
2022-01-28 12:34:20 +00:00
|
|
|
import { Backlink, Button } from "@saleor/macaw-ui";
|
2020-05-14 09:30:32 +00:00
|
|
|
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 {
|
2020-05-14 09:30:32 +00:00
|
|
|
FilterPageProps,
|
2019-09-10 15:32:47 +00:00
|
|
|
ListActions,
|
|
|
|
PageListProps,
|
2020-05-14 09:30:32 +00:00
|
|
|
SortPage,
|
|
|
|
TabPageProps
|
2019-09-10 15:32:47 +00:00
|
|
|
} from "../../../types";
|
2019-08-09 10:17:04 +00:00
|
|
|
import AttributeList from "../AttributeList/AttributeList";
|
2020-01-10 14:27:44 +00:00
|
|
|
import {
|
2020-05-14 09:30:32 +00:00
|
|
|
AttributeFilterKeys,
|
2020-01-10 14:27:44 +00:00
|
|
|
AttributeListFilterOpts,
|
2020-05-14 09:30:32 +00:00
|
|
|
createFilterStructure
|
2020-01-10 14:27:44 +00:00
|
|
|
} 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 {
|
2022-03-09 08:56:55 +00:00
|
|
|
attributes: AttributeFragment[];
|
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
|
2019-08-16 11:47:30 +00:00
|
|
|
}) => {
|
|
|
|
const intl = useIntl();
|
|
|
|
|
2020-01-10 11:34:49 +00:00
|
|
|
const structure = createFilterStructure(intl, filterOpts);
|
|
|
|
|
2019-08-16 11:47:30 +00:00
|
|
|
return (
|
|
|
|
<Container>
|
2021-07-21 08:59:52 +00:00
|
|
|
<Backlink onClick={onBack}>
|
2019-09-30 13:14:11 +00:00
|
|
|
<FormattedMessage {...sectionNames.configuration} />
|
2021-07-21 08:59:52 +00:00
|
|
|
</Backlink>
|
2019-08-22 16:19:16 +00:00
|
|
|
<PageHeader title={intl.formatMessage(sectionNames.attributes)}>
|
2021-07-09 09:43:45 +00:00
|
|
|
<Button
|
|
|
|
onClick={onAdd}
|
2022-01-28 12:34:20 +00:00
|
|
|
variant="primary"
|
2022-02-11 11:28:55 +00:00
|
|
|
data-test-id="create-attribute-button"
|
2021-07-09 09:43:45 +00:00
|
|
|
>
|
2019-08-16 11:47:30 +00:00
|
|
|
<FormattedMessage
|
2019-09-05 13:33:50 +00:00
|
|
|
defaultMessage="Create attribute"
|
2019-08-16 11:47:30 +00:00
|
|
|
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}
|
|
|
|
/>
|
2019-08-16 11:47:30 +00:00
|
|
|
<AttributeList {...listProps} />
|
|
|
|
</Card>
|
|
|
|
</Container>
|
|
|
|
);
|
|
|
|
};
|
2019-08-09 10:17:04 +00:00
|
|
|
AttributeListPage.displayName = "AttributeListPage";
|
|
|
|
export default AttributeListPage;
|