Add search and filters to Pages list page (#1901)
* Uppdate queries * Add page list search and filters * Update types * Update tests * Update messages * Change pageType -> pageTypes * Updae types for page list * run lint
This commit is contained in:
parent
d35ca150dc
commit
5059557987
12 changed files with 1351 additions and 779 deletions
|
@ -5671,6 +5671,14 @@
|
||||||
"context": "button",
|
"context": "button",
|
||||||
"string": "Create page"
|
"string": "Create page"
|
||||||
},
|
},
|
||||||
|
"src_dot_pages_dot_components_dot_PageListPage_dot_pageType": {
|
||||||
|
"context": "Types",
|
||||||
|
"string": "Page Types"
|
||||||
|
},
|
||||||
|
"src_dot_pages_dot_components_dot_PageListPage_dot_searchPlaceholder": {
|
||||||
|
"context": "search pages placeholder",
|
||||||
|
"string": "Search Pages"
|
||||||
|
},
|
||||||
"src_dot_pages_dot_components_dot_PageList_dot_1124600214": {
|
"src_dot_pages_dot_components_dot_PageList_dot_1124600214": {
|
||||||
"context": "dialog header",
|
"context": "dialog header",
|
||||||
"string": "Title"
|
"string": "Title"
|
||||||
|
|
|
@ -1,23 +1,40 @@
|
||||||
|
import { Card } from "@material-ui/core";
|
||||||
import Container from "@saleor/components/Container";
|
import Container from "@saleor/components/Container";
|
||||||
import PageHeader from "@saleor/components/PageHeader";
|
import PageHeader from "@saleor/components/PageHeader";
|
||||||
import { PageFragment } from "@saleor/graphql";
|
import { PageFragment } from "@saleor/graphql";
|
||||||
import { sectionNames } from "@saleor/intl";
|
import { sectionNames } from "@saleor/intl";
|
||||||
import { Button } from "@saleor/macaw-ui";
|
import { Button } from "@saleor/macaw-ui";
|
||||||
import { PageListUrlSortField } from "@saleor/pages/urls";
|
import {
|
||||||
|
PageListUrlDialog,
|
||||||
|
PageListUrlQueryParams,
|
||||||
|
PageListUrlSortField
|
||||||
|
} from "@saleor/pages/urls";
|
||||||
import { ListActions, PageListProps, SortPage } from "@saleor/types";
|
import { ListActions, PageListProps, SortPage } from "@saleor/types";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { FormattedMessage, useIntl } from "react-intl";
|
import { FormattedMessage, useIntl } from "react-intl";
|
||||||
|
|
||||||
import PageList from "../PageList";
|
import PageList from "../PageList";
|
||||||
|
import PageListSearchAndFilters from "./PageListSearchAndFilters";
|
||||||
|
|
||||||
|
export interface PageListActionDialogOpts {
|
||||||
|
open: (action: PageListUrlDialog, newParams?: PageListUrlQueryParams) => void;
|
||||||
|
close: () => void;
|
||||||
|
}
|
||||||
export interface PageListPageProps
|
export interface PageListPageProps
|
||||||
extends PageListProps,
|
extends PageListProps,
|
||||||
ListActions,
|
ListActions,
|
||||||
SortPage<PageListUrlSortField> {
|
SortPage<PageListUrlSortField> {
|
||||||
pages: PageFragment[];
|
pages: PageFragment[];
|
||||||
|
params: PageListUrlQueryParams;
|
||||||
|
actionDialogOpts: PageListActionDialogOpts;
|
||||||
}
|
}
|
||||||
|
|
||||||
const PageListPage: React.FC<PageListPageProps> = ({ onAdd, ...listProps }) => {
|
const PageListPage: React.FC<PageListPageProps> = ({
|
||||||
|
onAdd,
|
||||||
|
params,
|
||||||
|
actionDialogOpts,
|
||||||
|
...listProps
|
||||||
|
}) => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -27,7 +44,13 @@ const PageListPage: React.FC<PageListPageProps> = ({ onAdd, ...listProps }) => {
|
||||||
<FormattedMessage defaultMessage="Create page" description="button" />
|
<FormattedMessage defaultMessage="Create page" description="button" />
|
||||||
</Button>
|
</Button>
|
||||||
</PageHeader>
|
</PageHeader>
|
||||||
<PageList {...listProps} />
|
<Card>
|
||||||
|
<PageListSearchAndFilters
|
||||||
|
params={params}
|
||||||
|
actionDialogOpts={actionDialogOpts}
|
||||||
|
/>
|
||||||
|
<PageList {...listProps} />
|
||||||
|
</Card>
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
138
src/pages/components/PageListPage/PageListSearchAndFilters.tsx
Normal file
138
src/pages/components/PageListPage/PageListSearchAndFilters.tsx
Normal file
|
@ -0,0 +1,138 @@
|
||||||
|
import DeleteFilterTabDialog from "@saleor/components/DeleteFilterTabDialog";
|
||||||
|
import FilterBar from "@saleor/components/FilterBar";
|
||||||
|
import SaveFilterTabDialog, {
|
||||||
|
SaveFilterTabDialogFormData
|
||||||
|
} from "@saleor/components/SaveFilterTabDialog";
|
||||||
|
import { DEFAULT_INITIAL_SEARCH_DATA } from "@saleor/config";
|
||||||
|
import { getSearchFetchMoreProps } from "@saleor/hooks/makeTopLevelSearch/utils";
|
||||||
|
import useBulkActions from "@saleor/hooks/useBulkActions";
|
||||||
|
import useNavigator from "@saleor/hooks/useNavigator";
|
||||||
|
import { pageListUrl, PageListUrlQueryParams } from "@saleor/pages/urls";
|
||||||
|
import usePageTypeSearch from "@saleor/searches/usePageTypeSearch";
|
||||||
|
import createFilterHandlers from "@saleor/utils/handlers/filterHandlers";
|
||||||
|
import { mapEdgesToItems } from "@saleor/utils/maps";
|
||||||
|
import React from "react";
|
||||||
|
import { useIntl } from "react-intl";
|
||||||
|
|
||||||
|
import {
|
||||||
|
createFilterStructure,
|
||||||
|
deleteFilterTab,
|
||||||
|
getActiveFilters,
|
||||||
|
getFilterOpts,
|
||||||
|
getFilterQueryParam,
|
||||||
|
getFiltersCurrentTab,
|
||||||
|
getFilterTabs,
|
||||||
|
saveFilterTab
|
||||||
|
} from "./filters";
|
||||||
|
import { pagesListSearchAndFiltersMessages as messages } from "./messages";
|
||||||
|
import { PageListActionDialogOpts } from "./PageListPage";
|
||||||
|
|
||||||
|
interface PageListSearchAndFiltersProps {
|
||||||
|
params: PageListUrlQueryParams;
|
||||||
|
actionDialogOpts: PageListActionDialogOpts;
|
||||||
|
}
|
||||||
|
|
||||||
|
const PageListSearchAndFilters: React.FC<PageListSearchAndFiltersProps> = ({
|
||||||
|
params,
|
||||||
|
actionDialogOpts
|
||||||
|
}) => {
|
||||||
|
const navigate = useNavigator();
|
||||||
|
const intl = useIntl();
|
||||||
|
|
||||||
|
const defaultSearchVariables = {
|
||||||
|
variables: {
|
||||||
|
...DEFAULT_INITIAL_SEARCH_DATA,
|
||||||
|
first: 5
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const { reset } = useBulkActions(params.ids);
|
||||||
|
|
||||||
|
const {
|
||||||
|
loadMore: fetchMorePageTypes,
|
||||||
|
search: searchPageTypes,
|
||||||
|
result: searchPageTypesResult
|
||||||
|
} = usePageTypeSearch(defaultSearchVariables);
|
||||||
|
|
||||||
|
const filterOpts = getFilterOpts({
|
||||||
|
params,
|
||||||
|
pageTypes: mapEdgesToItems(searchPageTypesResult?.data?.search),
|
||||||
|
pageTypesProps: {
|
||||||
|
...getSearchFetchMoreProps(searchPageTypesResult, fetchMorePageTypes),
|
||||||
|
onSearchChange: searchPageTypes
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const [
|
||||||
|
changeFilters,
|
||||||
|
resetFilters,
|
||||||
|
handleSearchChange
|
||||||
|
] = createFilterHandlers({
|
||||||
|
createUrl: pageListUrl,
|
||||||
|
getFilterQueryParam,
|
||||||
|
navigate,
|
||||||
|
params,
|
||||||
|
cleanupFn: reset
|
||||||
|
});
|
||||||
|
|
||||||
|
const filterStrucutre = createFilterStructure(intl, filterOpts);
|
||||||
|
|
||||||
|
const { open: openModal, close: closeModal } = actionDialogOpts;
|
||||||
|
|
||||||
|
const handleTabChange = (tab: number) => {
|
||||||
|
navigate(
|
||||||
|
pageListUrl({
|
||||||
|
activeTab: tab.toString(),
|
||||||
|
...getFilterTabs()[tab - 1].data
|
||||||
|
})
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const tabs = getFilterTabs();
|
||||||
|
const currentTab = getFiltersCurrentTab(params, tabs);
|
||||||
|
|
||||||
|
const handleTabSave = (data: SaveFilterTabDialogFormData) => {
|
||||||
|
saveFilterTab(data.name, getActiveFilters(params));
|
||||||
|
handleTabChange(tabs.length + 1);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleTabDelete = () => {
|
||||||
|
deleteFilterTab(currentTab);
|
||||||
|
reset();
|
||||||
|
navigate(pageListUrl());
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<FilterBar
|
||||||
|
filterStructure={filterStrucutre}
|
||||||
|
initialSearch={""}
|
||||||
|
onAll={resetFilters}
|
||||||
|
onFilterChange={changeFilters}
|
||||||
|
onSearchChange={handleSearchChange}
|
||||||
|
searchPlaceholder={intl.formatMessage(messages.searchPlaceholder)}
|
||||||
|
allTabLabel={"All Pages"}
|
||||||
|
tabs={tabs.map(({ name }) => name)}
|
||||||
|
currentTab={currentTab}
|
||||||
|
onTabDelete={handleTabDelete}
|
||||||
|
onTabChange={handleTabChange}
|
||||||
|
onTabSave={() => openModal("save-search")}
|
||||||
|
/>
|
||||||
|
<SaveFilterTabDialog
|
||||||
|
open={params.action === "save-search"}
|
||||||
|
confirmButtonState="default"
|
||||||
|
onClose={closeModal}
|
||||||
|
onSubmit={handleTabSave}
|
||||||
|
/>
|
||||||
|
<DeleteFilterTabDialog
|
||||||
|
open={params.action === "delete-search"}
|
||||||
|
confirmButtonState="default"
|
||||||
|
onClose={closeModal}
|
||||||
|
onSubmit={handleTabDelete}
|
||||||
|
tabName={tabs[currentTab - 1]?.name ?? "..."}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default PageListSearchAndFilters;
|
126
src/pages/components/PageListPage/filters.ts
Normal file
126
src/pages/components/PageListPage/filters.ts
Normal file
|
@ -0,0 +1,126 @@
|
||||||
|
import { IFilter, IFilterElement } from "@saleor/components/Filter";
|
||||||
|
import { SearchWithFetchMoreProps } from "@saleor/giftCards/GiftCardsList/GiftCardListSearchAndFilters/types";
|
||||||
|
import { SearchPageTypesQuery } from "@saleor/graphql";
|
||||||
|
import {
|
||||||
|
PageListUrlFilters,
|
||||||
|
PageListUrlFiltersWithMultipleValues,
|
||||||
|
PageListUrlSort
|
||||||
|
} from "@saleor/pages/urls";
|
||||||
|
import {
|
||||||
|
ActiveTab,
|
||||||
|
AutocompleteFilterOpts,
|
||||||
|
FilterOpts,
|
||||||
|
Pagination,
|
||||||
|
Search
|
||||||
|
} from "@saleor/types";
|
||||||
|
import {
|
||||||
|
createFilterTabUtils,
|
||||||
|
createFilterUtils,
|
||||||
|
getMultipleValueQueryParam
|
||||||
|
} from "@saleor/utils/filters";
|
||||||
|
import { createAutocompleteField } from "@saleor/utils/filters/fields";
|
||||||
|
import {
|
||||||
|
mapNodeToChoice,
|
||||||
|
mapSingleValueNodeToChoice
|
||||||
|
} from "@saleor/utils/maps";
|
||||||
|
import { defineMessages, IntlShape } from "react-intl";
|
||||||
|
|
||||||
|
export enum PageListFilterKeys {
|
||||||
|
pageTypes = "pageTypes"
|
||||||
|
}
|
||||||
|
|
||||||
|
export const PAGES_FILTERS_KEY = "pagesFilters";
|
||||||
|
|
||||||
|
export interface PageListFilterOpts {
|
||||||
|
pageType: FilterOpts<string[]> & AutocompleteFilterOpts;
|
||||||
|
}
|
||||||
|
|
||||||
|
const messages = defineMessages({
|
||||||
|
pageType: {
|
||||||
|
defaultMessage: "Page Types",
|
||||||
|
description: "Types"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
interface PageListFilterOptsProps {
|
||||||
|
params: PageListUrlFilters;
|
||||||
|
pageTypes: Array<SearchPageTypesQuery["search"]["edges"][0]["node"]>;
|
||||||
|
pageTypesProps: SearchWithFetchMoreProps;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getFilterOpts = ({
|
||||||
|
params,
|
||||||
|
pageTypes,
|
||||||
|
pageTypesProps
|
||||||
|
}: PageListFilterOptsProps): PageListFilterOpts => ({
|
||||||
|
pageType: {
|
||||||
|
active: !!params?.pageTypes,
|
||||||
|
value: params?.pageTypes,
|
||||||
|
choices: mapNodeToChoice(pageTypes),
|
||||||
|
displayValues: mapSingleValueNodeToChoice(pageTypes),
|
||||||
|
initialSearch: "",
|
||||||
|
hasMore: pageTypesProps.hasMore,
|
||||||
|
loading: pageTypesProps.loading,
|
||||||
|
onFetchMore: pageTypesProps.onFetchMore,
|
||||||
|
onSearchChange: pageTypesProps.onSearchChange
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export function createFilterStructure(
|
||||||
|
intl: IntlShape,
|
||||||
|
opts: PageListFilterOpts
|
||||||
|
): IFilter<PageListFilterKeys> {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
...createAutocompleteField(
|
||||||
|
PageListFilterKeys.pageTypes,
|
||||||
|
intl.formatMessage(messages.pageType),
|
||||||
|
opts.pageType.value,
|
||||||
|
opts.pageType.displayValues,
|
||||||
|
true,
|
||||||
|
opts.pageType.choices,
|
||||||
|
{
|
||||||
|
hasMore: opts.pageType.hasMore,
|
||||||
|
initialSearch: "",
|
||||||
|
loading: opts.pageType.loading,
|
||||||
|
onFetchMore: opts.pageType.onFetchMore,
|
||||||
|
onSearchChange: opts.pageType.onSearchChange
|
||||||
|
}
|
||||||
|
),
|
||||||
|
active: opts.pageType.active
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getFilterQueryParam(
|
||||||
|
filter: IFilterElement<PageListFilterKeys>
|
||||||
|
): PageListUrlFilters {
|
||||||
|
const { name } = filter;
|
||||||
|
|
||||||
|
const { pageTypes } = PageListFilterKeys;
|
||||||
|
|
||||||
|
switch (name) {
|
||||||
|
case pageTypes:
|
||||||
|
return getMultipleValueQueryParam(filter, name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export type PageListUrlQueryParams = Pagination &
|
||||||
|
PageListUrlFilters &
|
||||||
|
PageListUrlSort &
|
||||||
|
ActiveTab &
|
||||||
|
Search;
|
||||||
|
|
||||||
|
export const {
|
||||||
|
deleteFilterTab,
|
||||||
|
getFilterTabs,
|
||||||
|
saveFilterTab
|
||||||
|
} = createFilterTabUtils<PageListUrlFilters>(PAGES_FILTERS_KEY);
|
||||||
|
|
||||||
|
export const {
|
||||||
|
areFiltersApplied,
|
||||||
|
getActiveFilters,
|
||||||
|
getFiltersCurrentTab
|
||||||
|
} = createFilterUtils<PageListUrlQueryParams, PageListUrlFilters>(
|
||||||
|
PageListUrlFiltersWithMultipleValues
|
||||||
|
);
|
8
src/pages/components/PageListPage/messages.ts
Normal file
8
src/pages/components/PageListPage/messages.ts
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
import { defineMessages } from "react-intl";
|
||||||
|
|
||||||
|
export const pagesListSearchAndFiltersMessages = defineMessages({
|
||||||
|
searchPlaceholder: {
|
||||||
|
defaultMessage: "Search Pages",
|
||||||
|
description: "search pages placeholder"
|
||||||
|
}
|
||||||
|
});
|
|
@ -18,7 +18,7 @@ import PageCreateComponent from "./views/PageCreate";
|
||||||
import PageDetailsComponent from "./views/PageDetails";
|
import PageDetailsComponent from "./views/PageDetails";
|
||||||
import PageListComponent from "./views/PageList";
|
import PageListComponent from "./views/PageList";
|
||||||
|
|
||||||
const PageList: React.FC<RouteComponentProps<any>> = ({ location }) => {
|
const PageList: React.FC<RouteComponentProps<{}>> = ({ location }) => {
|
||||||
const qs = parseQs(location.search.substr(1));
|
const qs = parseQs(location.search.substr(1));
|
||||||
const params: PageListUrlQueryParams = asSortParams(
|
const params: PageListUrlQueryParams = asSortParams(
|
||||||
qs,
|
qs,
|
||||||
|
|
|
@ -7,6 +7,7 @@ export const pageList = gql`
|
||||||
$last: Int
|
$last: Int
|
||||||
$before: String
|
$before: String
|
||||||
$sort: PageSortingInput
|
$sort: PageSortingInput
|
||||||
|
$filter: PageFilterInput
|
||||||
) {
|
) {
|
||||||
pages(
|
pages(
|
||||||
before: $before
|
before: $before
|
||||||
|
@ -14,6 +15,7 @@ export const pageList = gql`
|
||||||
first: $first
|
first: $first
|
||||||
last: $last
|
last: $last
|
||||||
sortBy: $sort
|
sortBy: $sort
|
||||||
|
filter: $filter
|
||||||
) {
|
) {
|
||||||
edges {
|
edges {
|
||||||
node {
|
node {
|
||||||
|
|
|
@ -2,37 +2,48 @@ import { stringifyQs } from "@saleor/utils/urls";
|
||||||
import urlJoin from "url-join";
|
import urlJoin from "url-join";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
ActiveTab,
|
||||||
BulkAction,
|
BulkAction,
|
||||||
Dialog,
|
Dialog,
|
||||||
|
Filters,
|
||||||
FiltersWithMultipleValues,
|
FiltersWithMultipleValues,
|
||||||
Pagination,
|
Pagination,
|
||||||
SingleAction,
|
SingleAction,
|
||||||
Sort
|
Sort,
|
||||||
|
TabActionDialog
|
||||||
} from "../types";
|
} from "../types";
|
||||||
|
|
||||||
export const pagesSection = "/pages/";
|
export const pagesSection = "/pages/";
|
||||||
|
|
||||||
export const pageListPath = pagesSection;
|
export const pageListPath = pagesSection;
|
||||||
export type PageListUrlDialog = "publish" | "unpublish" | "remove";
|
export type PageListUrlDialog =
|
||||||
|
| "publish"
|
||||||
|
| "unpublish"
|
||||||
|
| "remove"
|
||||||
|
| TabActionDialog;
|
||||||
export enum PageListUrlSortField {
|
export enum PageListUrlSortField {
|
||||||
title = "title",
|
title = "title",
|
||||||
slug = "slug",
|
slug = "slug",
|
||||||
visible = "visible"
|
visible = "visible"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum PageListUrlFiltersEnum {
|
||||||
|
query = "query"
|
||||||
|
}
|
||||||
|
|
||||||
export enum PageListUrlFiltersWithMultipleValues {
|
export enum PageListUrlFiltersWithMultipleValues {
|
||||||
pageTypes = "pageTypes"
|
pageTypes = "pageTypes"
|
||||||
}
|
}
|
||||||
|
|
||||||
export type PageListUrlFilters = FiltersWithMultipleValues<
|
export type PageListUrlFilters = Filters<PageListUrlFiltersEnum> &
|
||||||
PageListUrlFiltersWithMultipleValues
|
FiltersWithMultipleValues<PageListUrlFiltersWithMultipleValues>;
|
||||||
>;
|
|
||||||
export type PageListUrlSort = Sort<PageListUrlSortField>;
|
export type PageListUrlSort = Sort<PageListUrlSortField>;
|
||||||
export type PageListUrlQueryParams = BulkAction &
|
export type PageListUrlQueryParams = BulkAction &
|
||||||
PageListUrlFilters &
|
PageListUrlFilters &
|
||||||
Dialog<PageListUrlDialog> &
|
Dialog<PageListUrlDialog> &
|
||||||
PageListUrlSort &
|
PageListUrlSort &
|
||||||
Pagination;
|
Pagination &
|
||||||
|
ActiveTab;
|
||||||
export const pageListUrl = (params?: PageListUrlQueryParams) =>
|
export const pageListUrl = (params?: PageListUrlQueryParams) =>
|
||||||
pageListPath + "?" + stringifyQs(params);
|
pageListPath + "?" + stringifyQs(params);
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ import {
|
||||||
PageListUrlQueryParams,
|
PageListUrlQueryParams,
|
||||||
pageUrl
|
pageUrl
|
||||||
} from "../../urls";
|
} from "../../urls";
|
||||||
import { getSortQueryVariables } from "./sort";
|
import { getFilterVariables, getSortQueryVariables } from "./sort";
|
||||||
|
|
||||||
interface PageListProps {
|
interface PageListProps {
|
||||||
params: PageListUrlQueryParams;
|
params: PageListUrlQueryParams;
|
||||||
|
@ -56,6 +56,7 @@ export const PageList: React.FC<PageListProps> = ({ params }) => {
|
||||||
const queryVariables = React.useMemo(
|
const queryVariables = React.useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
...paginationState,
|
...paginationState,
|
||||||
|
filter: getFilterVariables(params),
|
||||||
sort: getSortQueryVariables(params)
|
sort: getSortQueryVariables(params)
|
||||||
}),
|
}),
|
||||||
[params, settings.rowNumber]
|
[params, settings.rowNumber]
|
||||||
|
@ -125,6 +126,11 @@ export const PageList: React.FC<PageListProps> = ({ params }) => {
|
||||||
onUpdateListSettings={updateListSettings}
|
onUpdateListSettings={updateListSettings}
|
||||||
onRowClick={id => () => navigate(pageUrl(id))}
|
onRowClick={id => () => navigate(pageUrl(id))}
|
||||||
onSort={handleSort}
|
onSort={handleSort}
|
||||||
|
actionDialogOpts={{
|
||||||
|
open: openModal,
|
||||||
|
close: closeModal
|
||||||
|
}}
|
||||||
|
params={params}
|
||||||
toolbar={
|
toolbar={
|
||||||
<>
|
<>
|
||||||
<Button
|
<Button
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { PageSortField } from "@saleor/graphql";
|
import { PageFilterInput, PageSortField } from "@saleor/graphql";
|
||||||
import { PageListUrlSortField } from "@saleor/pages/urls";
|
import { PageListUrlFilters, PageListUrlSortField } from "@saleor/pages/urls";
|
||||||
import { createGetSortQueryVariables } from "@saleor/utils/sort";
|
import { createGetSortQueryVariables } from "@saleor/utils/sort";
|
||||||
|
|
||||||
export function getSortQueryField(sort: PageListUrlSortField): PageSortField {
|
export function getSortQueryField(sort: PageListUrlSortField): PageSortField {
|
||||||
|
@ -15,6 +15,15 @@ export function getSortQueryField(sort: PageListUrlSortField): PageSortField {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getFilterVariables(
|
||||||
|
params: PageListUrlFilters
|
||||||
|
): PageFilterInput {
|
||||||
|
return {
|
||||||
|
search: params.query,
|
||||||
|
pageTypes: params.pageTypes
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export const getSortQueryVariables = createGetSortQueryVariables(
|
export const getSortQueryVariables = createGetSortQueryVariables(
|
||||||
getSortQueryField
|
getSortQueryField
|
||||||
);
|
);
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -21,6 +21,13 @@ const props: PageListPageProps = {
|
||||||
sort: {
|
sort: {
|
||||||
...sortPageProps.sort,
|
...sortPageProps.sort,
|
||||||
sort: PageListUrlSortField.title
|
sort: PageListUrlSortField.title
|
||||||
|
},
|
||||||
|
actionDialogOpts: {
|
||||||
|
open: () => undefined,
|
||||||
|
close: () => undefined
|
||||||
|
},
|
||||||
|
params: {
|
||||||
|
ids: []
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue