mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
23 lines
586 B
TypeScript
23 lines
586 B
TypeScript
import { matchPath, RouteProps } from "react-router";
|
|
import { buildURL, navigation } from "../../navigation";
|
|
|
|
export interface IClusterViewRouteParams {
|
|
clusterId: string;
|
|
}
|
|
|
|
export const clusterViewRoute: RouteProps = {
|
|
path: "/cluster/:clusterId"
|
|
}
|
|
|
|
export const clusterViewURL = buildURL<IClusterViewRouteParams>(clusterViewRoute.path)
|
|
|
|
export function getMatchedClusterId(): string {
|
|
const matched = matchPath<IClusterViewRouteParams>(navigation.location.pathname, {
|
|
...clusterViewRoute,
|
|
exact: true,
|
|
})
|
|
if (matched) {
|
|
return matched.params.clusterId;
|
|
}
|
|
}
|