2022-05-06 08:59:55 +00:00
|
|
|
import {
|
|
|
|
attributeAddUrl,
|
2022-06-21 09:36:55 +00:00
|
|
|
AttributeListUrlSortField,
|
2023-01-16 09:45:12 +00:00
|
|
|
} from "@dashboard/attributes/urls";
|
2023-02-20 15:21:28 +00:00
|
|
|
import { TopNav } from "@dashboard/components/AppLayout/TopNav";
|
2023-01-16 09:45:12 +00:00
|
|
|
import { Button } from "@dashboard/components/Button";
|
|
|
|
import FilterBar from "@dashboard/components/FilterBar";
|
|
|
|
import { configurationMenuUrl } from "@dashboard/configuration";
|
|
|
|
import { AttributeFragment } from "@dashboard/graphql";
|
|
|
|
import { sectionNames } from "@dashboard/intl";
|
|
|
|
import { Card } from "@material-ui/core";
|
2020-05-14 09:30:32 +00:00
|
|
|
import React from "react";
|
|
|
|
import { FormattedMessage, useIntl } from "react-intl";
|
|
|
|
|
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,
|
2022-06-21 09:36:55 +00:00
|
|
|
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,
|
2022-06-21 09:36:55 +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-08-09 10:17:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const AttributeListPage: React.FC<AttributeListPageProps> = ({
|
2020-01-10 11:34:49 +00:00
|
|
|
filterOpts,
|
|
|
|
initialSearch,
|
|
|
|
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 (
|
2023-02-20 15:21:28 +00:00
|
|
|
<>
|
|
|
|
<TopNav
|
|
|
|
href={configurationMenuUrl}
|
|
|
|
title={intl.formatMessage(sectionNames.attributes)}
|
|
|
|
>
|
2021-07-09 09:43:45 +00:00
|
|
|
<Button
|
2022-05-06 08:59:55 +00:00
|
|
|
href={attributeAddUrl()}
|
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
|
2022-05-05 07:54:28 +00:00
|
|
|
id="IGvQ8k"
|
2019-09-05 13:33:50 +00:00
|
|
|
defaultMessage="Create attribute"
|
2019-08-16 11:47:30 +00:00
|
|
|
description="button"
|
|
|
|
/>
|
|
|
|
</Button>
|
2023-02-20 15:21:28 +00:00
|
|
|
</TopNav>
|
2019-08-16 11:47:30 +00:00
|
|
|
<Card>
|
2020-01-10 11:34:49 +00:00
|
|
|
<FilterBar
|
2019-09-11 15:56:00 +00:00
|
|
|
allTabLabel={intl.formatMessage({
|
2022-05-05 07:54:28 +00:00
|
|
|
id: "dKPMyh",
|
2019-09-11 15:56:00 +00:00
|
|
|
defaultMessage: "All Attributes",
|
2022-06-21 09:36:55 +00:00
|
|
|
description: "tab name",
|
2019-09-11 15:56:00 +00:00
|
|
|
})}
|
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({
|
2022-05-05 07:54:28 +00:00
|
|
|
id: "1div9r",
|
2022-06-21 09:36:55 +00:00
|
|
|
defaultMessage: "Search Attribute",
|
2019-09-10 15:32:47 +00:00
|
|
|
})}
|
|
|
|
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>
|
2023-02-20 15:21:28 +00:00
|
|
|
</>
|
2019-08-16 11:47:30 +00:00
|
|
|
);
|
|
|
|
};
|
2019-08-09 10:17:04 +00:00
|
|
|
AttributeListPage.displayName = "AttributeListPage";
|
|
|
|
export default AttributeListPage;
|