feature @k8slens/routing

Signed-off-by: Gabriel <gaccettola@mirantis.com>
This commit is contained in:
Gabriel authored and Sebastian Malton committed 2023-04-25 17:38:02 -04:00
1 parent f3b13b0816
commit e8c94abc0b
39 files changed
+251 -32

No files matched your search

@@ -12,13 +12,12 @@ import { frontEndRouteInjectionToken } from "../../common/front-end-routing/fron
import { computed, runInAction } from "mobx";
import React from "react";
import { routeSpecificComponentInjectionToken } from "../../renderer/routes/route-specific-component-injection-token";
import observableHistoryInjectable from "../../renderer/navigation/observable-history.injectable";
import { observableHistoryInjectable, searchParamsOptions } from "@k8slens/routing";
import { createMemoryHistory } from "history";
import { createObservableHistory } from "mobx-observable-history";
import navigateToFrontPageInjectable from "../../common/front-end-routing/navigate-to-front-page.injectable";
import { navigateToRouteInjectionToken } from "../../common/front-end-routing/navigate-to-route-injection-token";
import { preferenceItemInjectionToken } from "./renderer/preference-items/preference-item-injection-token";
import { searchParamsOptions } from "../../renderer/navigation/search-params";
describe("preferences - closing-preferences", () => {
let builder: ApplicationBuilder;
@@ -3,7 +3,7 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import observableHistoryInjectable from "../../../../renderer/navigation/observable-history.injectable";
import { observableHistoryInjectable } from "@k8slens/routing";
import navigateToFrontPageInjectable from "../../../../common/front-end-routing/navigate-to-front-page.injectable";
const closePreferencesInjectable = getInjectable({
@@ -7,7 +7,7 @@ import { reaction, when } from "mobx";
import type { GeneralEntity } from "../../../common/catalog-entities";
import generalCategoryInjectable from "../../../common/catalog/categories/general.injectable";
import isActiveRouteInjectable from "../../navigation/is-route-active.injectable";
import observableHistoryInjectable from "../../navigation/observable-history.injectable";
import { observableHistoryInjectable } from "@k8slens/routing";
import type { Disposer } from "@k8slens/utilities";
import { disposer } from "@k8slens/utilities";
import catalogEntityRegistryInjectable from "../catalog/entity/registry.injectable";
@@ -6,7 +6,7 @@ import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { action } from "mobx";
import { byOrderNumber } from "../../../common/utils/composable-responsibilities/orderable/orderable";
import type { CatalogEntity } from "../../api/catalog-entity";
import observableHistoryInjectable from "../../navigation/observable-history.injectable";
import { observableHistoryInjectable } from "@k8slens/routing";
import type { RegisteredEntitySetting } from "./extension-registrator.injectable";
import catalogEntitySettingItemsInjectable from "./settings.injectable";
@@ -13,7 +13,7 @@ import { Animate } from "../animate";
import { cssNames, noop, stopPropagation } from "@k8slens/utilities";
import type { ObservableHistory } from "mobx-observable-history";
import { withInjectables } from "@ogre-tools/injectable-react";
import observableHistoryInjectable from "../../navigation/observable-history.injectable";
import { observableHistoryInjectable } from "@k8slens/routing";
import requestAnimationFrameInjectable from "../animate/request-animation-frame.injectable";
// todo: refactor + handle animation-end in props.onClose()?
@@ -16,7 +16,7 @@ import { Animate } from "../animate";
import { ResizeDirection, ResizeGrowthDirection, ResizeSide, ResizingAnchor } from "../resizing-anchor";
import drawerStorageInjectable, { defaultDrawerWidth } from "./drawer-storage/drawer-storage.injectable";
import { withInjectables } from "@ogre-tools/injectable-react";
import historyInjectable from "../../navigation/history.injectable";
import { historyInjectable } from "@k8slens/routing";
import type { History } from "history";
import type { StorageLayer } from "../../utils/storage-helper";
@@ -13,7 +13,7 @@ import { issuesTrackerUrl, forumsUrl } from "../../../common/vars";
import type { SingleOrMany } from "@k8slens/utilities";
import type { ObservableHistory } from "mobx-observable-history";
import { withInjectables } from "@ogre-tools/injectable-react";
import observableHistoryInjectable from "../../navigation/observable-history.injectable";
import { observableHistoryInjectable } from "@k8slens/routing";
export interface ErrorBoundaryProps {
children?: SingleOrMany<React.ReactNode>;
@@ -3,7 +3,7 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import observableHistoryInjectable from "../../navigation/observable-history.injectable";
import { observableHistoryInjectable } from "@k8slens/routing";
import kubeDetailsUrlParamInjectable from "./kube-details-url.injectable";
import kubeSelectedUrlParamInjectable from "./kube-selected-url.injectable";
@@ -3,7 +3,7 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import observableHistoryInjectable from "../../navigation/observable-history.injectable";
import { observableHistoryInjectable } from "@k8slens/routing";
import getDetailsUrlInjectable from "./get-details-url.injectable";
/**
@@ -12,7 +12,7 @@ import { cssNames } from "@k8slens/utilities";
import { CloseButton } from "./close-button";
import { getLegacyGlobalDiForExtensionApi } from "../../../extensions/as-legacy-globals-for-extension-api/legacy-global-di-for-extension-api";
import navigateToCatalogInjectable from "../../../common/front-end-routing/routes/catalog/navigate-to-catalog.injectable";
import observableHistoryInjectable from "../../navigation/observable-history.injectable";
import { observableHistoryInjectable } from "@k8slens/routing";
export interface SettingLayoutProps extends React.DOMAttributes<any> {
className?: IClassName;
@@ -15,7 +15,7 @@ import { Tab, Tabs } from "../tabs";
import { ErrorBoundary } from "../error-boundary";
import type { ObservableHistory } from "mobx-observable-history";
import { withInjectables } from "@ogre-tools/injectable-react";
import observableHistoryInjectable from "../../navigation/observable-history.injectable";
import { observableHistoryInjectable } from "@k8slens/routing";
import type { Navigate } from "../../navigation/navigate.injectable";
import navigateInjectable from "../../navigation/navigate.injectable";
@@ -24,7 +24,7 @@ import navigateToHelmChartsInjectable from "../../../common/front-end-routing/ro
import hostedClusterInjectable from "../../cluster-frame-context/hosted-cluster.injectable";
import { Cluster } from "../../../common/cluster/cluster";
import type { NamespaceStore } from "../+namespaces/store";
import historyInjectable from "../../navigation/history.injectable";
import { historyInjectable } from "@k8slens/routing";
import type { MinimalTrayMenuItem } from "../../../main/tray/electron-tray/electron-tray.injectable";
import electronTrayInjectable from "../../../main/tray/electron-tray/electron-tray.injectable";
import { getDiForUnitTesting as getRendererDi } from "../../getDiForUnitTesting";
@@ -12,7 +12,7 @@ import { DiContextProvider } from "@ogre-tools/injectable-react";
import { Router } from "react-router";
import { DefaultProps } from "../../mui-base-theme";
import { ClusterFrame } from "./cluster-frame";
import historyInjectable from "../../navigation/history.injectable";
import { historyInjectable } from "@k8slens/routing";
import { computed } from "mobx";
import { Cluster } from "../../../common/cluster/cluster";
import subscribeStoresInjectable from "../../kube-watch-api/subscribe-stores.injectable";
@@ -4,7 +4,7 @@
*/
import { getInjectable } from "@ogre-tools/injectable";
import { Router } from "react-router";
import historyInjectable from "../navigation/history.injectable";
import { historyInjectable } from "@k8slens/routing";
import React from "react";
import {
@@ -3,7 +3,7 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import observableHistoryInjectable from "./observable-history.injectable";
import { observableHistoryInjectable } from "@k8slens/routing";
import type { PageParamDependencies, PageParamInit } from "./page-param";
import { PageParam } from "./page-param";
@@ -5,6 +5,6 @@
import { createMemoryHistory } from "history";
import { getGlobalOverride } from "@k8slens/test-utils";
import historyInjectable from "./history.injectable";
import { historyInjectable } from "@k8slens/routing";
export default getGlobalOverride(historyInjectable, () => createMemoryHistory());
@@ -1,14 +0,0 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import { createBrowserHistory } from "history";
import type { History } from "history";
const historyInjectable = getInjectable({
id: "history",
instantiate: (): History => createBrowserHistory(),
});
export default historyInjectable;
@@ -5,7 +5,7 @@
import { getInjectable } from "@ogre-tools/injectable";
import type { match, RouteProps } from "react-router";
import { matchPath } from "react-router";
import observableHistoryInjectable from "./observable-history.injectable";
import { observableHistoryInjectable } from "@k8slens/routing";
export type MatchRoute = <Params extends { [K in keyof Params]?: string }>(route: string | string[] | RouteProps) => match<Params> | null;
@@ -5,7 +5,7 @@
import { getInjectable } from "@ogre-tools/injectable";
import type { LocationDescriptor } from "history";
import { action } from "mobx";
import observableHistoryInjectable from "./observable-history.injectable";
import { observableHistoryInjectable } from "@k8slens/routing";
import { createPath } from "history";
export type Navigate = (location: LocationDescriptor) => void;
@@ -1,23 +0,0 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import { createObservableHistory } from "mobx-observable-history";
import { searchParamsOptions } from "./search-params";
import historyInjectable from "./history.injectable";
const observableHistoryInjectable = getInjectable({
id: "observable-history",
instantiate: (di) => {
const history = di.inject(historyInjectable);
const navigation = createObservableHistory(history, {
searchParams: searchParamsOptions,
});
return navigation;
},
});
export default observableHistoryInjectable;
@@ -1,12 +0,0 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import type { ObservableSearchParamsOptions } from "mobx-observable-history";
export const searchParamsOptions: ObservableSearchParamsOptions = {
skipEmpty: true, // skip empty params, e.g. "?x=&y2=" will be "?y=2"
joinArrays: false, // join multiple params with same name, e.g. "?x=1&x=2" => "?x=1,2"
joinArraysWith: ",", // param values splitter, applicable only with {joinArrays:true}
};
@@ -5,7 +5,7 @@
import { getInjectable } from "@ogre-tools/injectable";
import loggerInjectable from "../../common/logger.injectable";
import { beforeFrameStartsSecondInjectionToken } from "../before-frame-starts/tokens";
import observableHistoryInjectable from "./observable-history.injectable";
import { observableHistoryInjectable } from "@k8slens/routing";
const setupLoggingForNavigationInjectable = getInjectable({
id: "setup-logging-for-navigation",
@@ -6,7 +6,7 @@ import { getInjectable } from "@ogre-tools/injectable";
import { emitWindowLocationChanged } from "../ipc";
import { reaction } from "mobx";
import observableHistoryInjectable from "../navigation/observable-history.injectable";
import { observableHistoryInjectable } from "@k8slens/routing";
const watchHistoryStateInjectable = getInjectable({
id: "watch-history-state",
@@ -4,7 +4,7 @@
*/
import { getInjectable } from "@ogre-tools/injectable";
import { computed } from "mobx";
import observableHistoryInjectable from "../navigation/observable-history.injectable";
import { observableHistoryInjectable } from "@k8slens/routing";
const currentPathInjectable = getInjectable({
id: "current-path",
@@ -3,7 +3,7 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import observableHistoryInjectable from "../navigation/observable-history.injectable";
import { observableHistoryInjectable } from "@k8slens/routing";
import { runInAction } from "mobx";
import type { NavigateToUrl } from "../../common/front-end-routing/navigate-to-url-injection-token";
import { navigateToUrlInjectionToken } from "../../common/front-end-routing/navigate-to-url-injection-token";
@@ -5,7 +5,7 @@
import { getInjectable } from "@ogre-tools/injectable";
import { computed } from "mobx";
import { parse as parseQueryString } from "query-string";
import observableHistoryInjectable from "../navigation/observable-history.injectable";
import { observableHistoryInjectable } from "@k8slens/routing";
const queryParametersInjectable = getInjectable({
id: "query-parameters",