2019-06-19 14:40:52 +00:00
|
|
|
import { stringify as stringifyQs } from "qs";
|
2019-08-09 10:26:22 +00:00
|
|
|
import urlJoin from "url-join";
|
2019-06-19 14:40:52 +00:00
|
|
|
|
2019-12-17 17:13:56 +00:00
|
|
|
import { BulkAction, Dialog, Pagination, Sort } from "../types";
|
2019-06-19 14:40:52 +00:00
|
|
|
|
|
|
|
export const pagesSection = "/pages/";
|
|
|
|
|
|
|
|
export const pageListPath = pagesSection;
|
|
|
|
export type PageListUrlDialog = "publish" | "unpublish" | "remove";
|
2019-12-17 17:13:56 +00:00
|
|
|
export enum PageListUrlSortField {
|
|
|
|
title = "title",
|
|
|
|
slug = "slug",
|
|
|
|
visible = "visible"
|
|
|
|
}
|
|
|
|
export type PageListUrlSort = Sort<PageListUrlSortField>;
|
2019-06-19 14:40:52 +00:00
|
|
|
export type PageListUrlQueryParams = BulkAction &
|
|
|
|
Dialog<PageListUrlDialog> &
|
2019-12-17 17:13:56 +00:00
|
|
|
PageListUrlSort &
|
2019-06-19 14:40:52 +00:00
|
|
|
Pagination;
|
|
|
|
export const pageListUrl = (params?: PageListUrlQueryParams) =>
|
|
|
|
pageListPath + "?" + stringifyQs(params);
|
|
|
|
|
|
|
|
export const pagePath = (id: string) => urlJoin(pagesSection, id);
|
|
|
|
export type PageUrlDialog = "remove";
|
|
|
|
export type PageUrlQueryParams = Dialog<PageUrlDialog>;
|
|
|
|
export const pageUrl = (id: string, params?: PageUrlQueryParams) =>
|
|
|
|
pagePath(encodeURIComponent(id)) + "?" + stringifyQs(params);
|
|
|
|
|
|
|
|
export const pageCreatePath = urlJoin(pagesSection, "add");
|
|
|
|
export const pageCreateUrl = pageCreatePath;
|