{ + params?: P; + query?: Q; +} + +export function buildURL
(path: string | any) { + const pathBuilder = compile(String(path)); + return function ({ params, query }: IURLParams
= {}) {
+ const queryParams = query ? new URLSearchParams(Object.entries(query)).toString() : ""
+ return pathBuilder(params) + (queryParams ? `?${queryParams}` : "")
+ }
+}
diff --git a/src/common/workspace-store.ts b/src/common/workspace-store.ts
index 5cb01788f3..b7f2467013 100644
--- a/src/common/workspace-store.ts
+++ b/src/common/workspace-store.ts
@@ -1,8 +1,6 @@
import { action, computed, observable, toJS } from "mobx";
import { BaseStore } from "./base-store";
import { clusterStore } from "./cluster-store"
-import { landingURL } from "../renderer/components/+landing-page/landing-page.route";
-import { navigate } from "../renderer/navigation";
import { appEventBus } from "./event-bus";
export type WorkspaceId = string;
@@ -57,18 +55,13 @@ export class WorkspaceStore extends BaseStore {
- params?: P;
- query?: IQueryParams & Q;
-}
-
-// todo: extract building urls to commons (also used in menu.ts)
-// fixme: missing types validation for params & query
-export function buildURL (path: string | string[]) {
- const pathBuilder = compile(path.toString());
- return function ({ params, query }: IURLParams = {}) {
- return pathBuilder(params) + (query ? getQueryString(query, false) : "")
- }
-}
-
// common params for all pages
export interface IQueryParams {
namespaces?: string[]; // selected context namespaces
@@ -100,3 +80,33 @@ export function setSearch(text: string) {
export function getSearch() {
return navigation.searchParams.get("search") || "";
}
+
+export function getMatchedClusterId(): string {
+ const matched = matchPath
+