2021-08-09 15:27:13 +00:00
|
|
|
import { stringifyQs } from "@saleor/utils/urls";
|
2019-08-09 10:26:22 +00:00
|
|
|
import urlJoin from "url-join";
|
2019-06-19 14:40:52 +00:00
|
|
|
|
2021-05-11 12:26:17 +00:00
|
|
|
import {
|
2022-03-22 08:53:31 +00:00
|
|
|
ActiveTab,
|
2021-05-11 12:26:17 +00:00
|
|
|
BulkAction,
|
|
|
|
Dialog,
|
2022-03-22 08:53:31 +00:00
|
|
|
Filters,
|
2021-05-11 12:26:17 +00:00
|
|
|
FiltersWithMultipleValues,
|
|
|
|
Pagination,
|
|
|
|
SingleAction,
|
2022-03-22 08:53:31 +00:00
|
|
|
Sort,
|
2022-06-21 09:36:55 +00:00
|
|
|
TabActionDialog,
|
2021-05-11 12:26:17 +00:00
|
|
|
} from "../types";
|
2019-06-19 14:40:52 +00:00
|
|
|
|
|
|
|
export const pagesSection = "/pages/";
|
|
|
|
|
|
|
|
export const pageListPath = pagesSection;
|
2022-03-22 08:53:31 +00:00
|
|
|
export type PageListUrlDialog =
|
|
|
|
| "publish"
|
|
|
|
| "unpublish"
|
|
|
|
| "remove"
|
|
|
|
| TabActionDialog;
|
2019-12-17 17:13:56 +00:00
|
|
|
export enum PageListUrlSortField {
|
|
|
|
title = "title",
|
|
|
|
slug = "slug",
|
2022-06-21 09:36:55 +00:00
|
|
|
visible = "visible",
|
2019-12-17 17:13:56 +00:00
|
|
|
}
|
2021-05-11 12:26:17 +00:00
|
|
|
|
2022-03-22 08:53:31 +00:00
|
|
|
export enum PageListUrlFiltersEnum {
|
2022-06-21 09:36:55 +00:00
|
|
|
query = "query",
|
2022-03-22 08:53:31 +00:00
|
|
|
}
|
|
|
|
|
2021-05-11 12:26:17 +00:00
|
|
|
export enum PageListUrlFiltersWithMultipleValues {
|
2022-06-21 09:36:55 +00:00
|
|
|
pageTypes = "pageTypes",
|
2021-05-11 12:26:17 +00:00
|
|
|
}
|
|
|
|
|
2022-03-22 08:53:31 +00:00
|
|
|
export type PageListUrlFilters = Filters<PageListUrlFiltersEnum> &
|
|
|
|
FiltersWithMultipleValues<PageListUrlFiltersWithMultipleValues>;
|
2019-12-17 17:13:56 +00:00
|
|
|
export type PageListUrlSort = Sort<PageListUrlSortField>;
|
2019-06-19 14:40:52 +00:00
|
|
|
export type PageListUrlQueryParams = BulkAction &
|
2021-05-11 12:26:17 +00:00
|
|
|
PageListUrlFilters &
|
2019-06-19 14:40:52 +00:00
|
|
|
Dialog<PageListUrlDialog> &
|
2019-12-17 17:13:56 +00:00
|
|
|
PageListUrlSort &
|
2022-03-22 08:53:31 +00:00
|
|
|
Pagination &
|
|
|
|
ActiveTab;
|
2019-06-19 14:40:52 +00:00
|
|
|
export const pageListUrl = (params?: PageListUrlQueryParams) =>
|
|
|
|
pageListPath + "?" + stringifyQs(params);
|
|
|
|
|
|
|
|
export const pagePath = (id: string) => urlJoin(pagesSection, id);
|
2021-01-12 11:13:02 +00:00
|
|
|
export type PageUrlDialog = "remove" | "assign-attribute-value";
|
|
|
|
export type PageUrlQueryParams = Dialog<PageUrlDialog> & SingleAction;
|
2019-06-19 14:40:52 +00:00
|
|
|
export const pageUrl = (id: string, params?: PageUrlQueryParams) =>
|
|
|
|
pagePath(encodeURIComponent(id)) + "?" + stringifyQs(params);
|
|
|
|
|
|
|
|
export const pageCreatePath = urlJoin(pagesSection, "add");
|
2021-01-12 11:13:02 +00:00
|
|
|
export const pageCreateUrl = (params?: PageUrlQueryParams) =>
|
|
|
|
pageCreatePath + "?" + stringifyQs(params);
|