saleor-dashboard/src/plugins/urls.ts

42 lines
1.2 KiB
TypeScript
Raw Normal View History

2019-08-21 14:30:56 +00:00
import { stringify as stringifyQs } from "qs";
import urlJoin from "url-join";
2020-01-10 16:30:42 +00:00
import {
ActiveTab,
2020-01-10 16:30:42 +00:00
Dialog,
Filters,
2020-01-10 16:30:42 +00:00
Pagination,
SingleAction,
Sort,
TabActionDialog
} from "../types";
2019-08-21 14:30:56 +00:00
2019-12-17 17:13:56 +00:00
export const pluginSection = "/plugins/";
2019-08-21 14:30:56 +00:00
2019-12-17 17:13:56 +00:00
export const pluginListPath = pluginSection;
2020-01-10 16:30:42 +00:00
export enum PluginListUrlFiltersEnum {
active = "active",
query = "query"
}
export type PluginListUrlFilters = Filters<PluginListUrlFiltersEnum>;
export type PluginListUrlDialog = TabActionDialog;
2019-12-17 17:13:56 +00:00
export enum PluginListUrlSortField {
name = "name",
active = "active"
}
export type PluginListUrlSort = Sort<PluginListUrlSortField>;
2020-01-10 16:30:42 +00:00
export type PluginListUrlQueryParams = ActiveTab &
Dialog<PluginListUrlDialog> &
PluginListUrlFilters &
Pagination &
2019-12-17 17:13:56 +00:00
PluginListUrlSort &
SingleAction;
export const pluginListUrl = (params?: PluginListUrlQueryParams) =>
pluginListPath + "?" + stringifyQs(params);
2019-08-21 14:30:56 +00:00
2019-12-17 17:13:56 +00:00
export const pluginPath = (id: string) => urlJoin(pluginSection, id);
2019-11-07 15:54:05 +00:00
export type PluginUrlDialog = "clear" | "edit";
2019-12-06 14:58:28 +00:00
export type PluginUrlQueryParams = Dialog<PluginUrlDialog> & SingleAction;
export const pluginUrl = (id: string, params?: PluginUrlQueryParams) =>
2020-04-29 14:14:20 +00:00
pluginPath(encodeURIComponent(id)) + "/?" + stringifyQs(params);