mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
fix: observableHistoryInjectionToken and 1 revert for GlobalOverride
Signed-off-by: Gabriel <gaccettola@mirantis.com>
This commit is contained in:
parent
db9a3675e1
commit
8c0220c353
@ -12,7 +12,7 @@ import { frontEndRouteInjectionToken } from "../../common/front-end-routing/fron
|
|||||||
import { computed, runInAction } from "mobx";
|
import { computed, runInAction } from "mobx";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { routeSpecificComponentInjectionToken } from "../../renderer/routes/route-specific-component-injection-token";
|
import { routeSpecificComponentInjectionToken } from "../../renderer/routes/route-specific-component-injection-token";
|
||||||
import { observableHistoryInjectable, searchParamsOptions } from "@k8slens/routing";
|
import { observableHistoryInjectionToken, searchParamsOptions } from "@k8slens/routing";
|
||||||
import { createMemoryHistory } from "history";
|
import { createMemoryHistory } from "history";
|
||||||
import { createObservableHistory } from "mobx-observable-history";
|
import { createObservableHistory } from "mobx-observable-history";
|
||||||
import navigateToFrontPageInjectable from "../../common/front-end-routing/navigate-to-front-page.injectable";
|
import navigateToFrontPageInjectable from "../../common/front-end-routing/navigate-to-front-page.injectable";
|
||||||
@ -54,7 +54,7 @@ describe("preferences - closing-preferences", () => {
|
|||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
builder.beforeWindowStart(({ windowDi }) => {
|
builder.beforeWindowStart(({ windowDi }) => {
|
||||||
windowDi.override(observableHistoryInjectable, () => {
|
windowDi.override(observableHistoryInjectionToken, () => {
|
||||||
const historyFake = createMemoryHistory({
|
const historyFake = createMemoryHistory({
|
||||||
initialEntries: ["/some-page"],
|
initialEntries: ["/some-page"],
|
||||||
initialIndex: 0,
|
initialIndex: 0,
|
||||||
@ -135,7 +135,7 @@ describe("preferences - closing-preferences", () => {
|
|||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
builder.beforeWindowStart(({ windowDi }) => {
|
builder.beforeWindowStart(({ windowDi }) => {
|
||||||
windowDi.override(observableHistoryInjectable, () => {
|
windowDi.override(observableHistoryInjectionToken, () => {
|
||||||
const historyFake = createMemoryHistory({
|
const historyFake = createMemoryHistory({
|
||||||
initialEntries: ["/preferences/app"],
|
initialEntries: ["/preferences/app"],
|
||||||
initialIndex: 0,
|
initialIndex: 0,
|
||||||
|
|||||||
@ -3,14 +3,14 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { observableHistoryInjectable } from "@k8slens/routing";
|
import { observableHistoryInjectionToken } from "@k8slens/routing";
|
||||||
import navigateToFrontPageInjectable from "../../../../common/front-end-routing/navigate-to-front-page.injectable";
|
import navigateToFrontPageInjectable from "../../../../common/front-end-routing/navigate-to-front-page.injectable";
|
||||||
|
|
||||||
const closePreferencesInjectable = getInjectable({
|
const closePreferencesInjectable = getInjectable({
|
||||||
id: "close-preferences",
|
id: "close-preferences",
|
||||||
|
|
||||||
instantiate: (di) => {
|
instantiate: (di) => {
|
||||||
const observableHistory = di.inject(observableHistoryInjectable);
|
const observableHistory = di.inject(observableHistoryInjectionToken);
|
||||||
const navigateToFrontPage = di.inject(navigateToFrontPageInjectable);
|
const navigateToFrontPage = di.inject(navigateToFrontPageInjectable);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import { reaction, when } from "mobx";
|
|||||||
import type { GeneralEntity } from "../../../common/catalog-entities";
|
import type { GeneralEntity } from "../../../common/catalog-entities";
|
||||||
import generalCategoryInjectable from "../../../common/catalog/categories/general.injectable";
|
import generalCategoryInjectable from "../../../common/catalog/categories/general.injectable";
|
||||||
import isActiveRouteInjectable from "../../navigation/is-route-active.injectable";
|
import isActiveRouteInjectable from "../../navigation/is-route-active.injectable";
|
||||||
import { observableHistoryInjectable } from "@k8slens/routing";
|
import { observableHistoryInjectionToken } from "@k8slens/routing";
|
||||||
import type { Disposer } from "@k8slens/utilities";
|
import type { Disposer } from "@k8slens/utilities";
|
||||||
import { disposer } from "@k8slens/utilities";
|
import { disposer } from "@k8slens/utilities";
|
||||||
import catalogEntityRegistryInjectable from "../catalog/entity/registry.injectable";
|
import catalogEntityRegistryInjectable from "../catalog/entity/registry.injectable";
|
||||||
@ -17,7 +17,7 @@ export type WatchForGeneralEntityNavigation = () => Disposer;
|
|||||||
const watchForGeneralEntityNavigationInjectable = getInjectable({
|
const watchForGeneralEntityNavigationInjectable = getInjectable({
|
||||||
id: "watch-for-general-entity-navigation",
|
id: "watch-for-general-entity-navigation",
|
||||||
instantiate: (di): WatchForGeneralEntityNavigation => {
|
instantiate: (di): WatchForGeneralEntityNavigation => {
|
||||||
const observableHistory = di.inject(observableHistoryInjectable);
|
const observableHistory = di.inject(observableHistoryInjectionToken);
|
||||||
const isActiveRoute = di.inject(isActiveRouteInjectable);
|
const isActiveRoute = di.inject(isActiveRouteInjectable);
|
||||||
const entityRegistry = di.inject(catalogEntityRegistryInjectable);
|
const entityRegistry = di.inject(catalogEntityRegistryInjectable);
|
||||||
const generalCategory = di.inject(generalCategoryInjectable);
|
const generalCategory = di.inject(generalCategoryInjectable);
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
|
|||||||
import { action } from "mobx";
|
import { action } from "mobx";
|
||||||
import { byOrderNumber } from "../../../common/utils/composable-responsibilities/orderable/orderable";
|
import { byOrderNumber } from "../../../common/utils/composable-responsibilities/orderable/orderable";
|
||||||
import type { CatalogEntity } from "../../api/catalog-entity";
|
import type { CatalogEntity } from "../../api/catalog-entity";
|
||||||
import { observableHistoryInjectable } from "@k8slens/routing";
|
import { observableHistoryInjectionToken } from "@k8slens/routing";
|
||||||
import type { RegisteredEntitySetting } from "./extension-registrator.injectable";
|
import type { RegisteredEntitySetting } from "./extension-registrator.injectable";
|
||||||
import catalogEntitySettingItemsInjectable from "./settings.injectable";
|
import catalogEntitySettingItemsInjectable from "./settings.injectable";
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ const getSettingGroups = (items: RegisteredEntitySetting[]): SettingGroup[] => {
|
|||||||
const activeEntitySettingsTabInjectable = getInjectable({
|
const activeEntitySettingsTabInjectable = getInjectable({
|
||||||
id: "active-entity-settings-tab",
|
id: "active-entity-settings-tab",
|
||||||
instantiate: (di, entity): ActiveEntitySettings => {
|
instantiate: (di, entity): ActiveEntitySettings => {
|
||||||
const observableHistory = di.inject(observableHistoryInjectable);
|
const observableHistory = di.inject(observableHistoryInjectionToken);
|
||||||
const items = di.inject(catalogEntitySettingItemsInjectable, entity);
|
const items = di.inject(catalogEntitySettingItemsInjectable, entity);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@ -13,7 +13,7 @@ import { Animate } from "../animate";
|
|||||||
import { cssNames, noop, stopPropagation } from "@k8slens/utilities";
|
import { cssNames, noop, stopPropagation } from "@k8slens/utilities";
|
||||||
import type { ObservableHistory } from "mobx-observable-history";
|
import type { ObservableHistory } from "mobx-observable-history";
|
||||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||||
import { observableHistoryInjectable } from "@k8slens/routing";
|
import { observableHistoryInjectionToken } from "@k8slens/routing";
|
||||||
import requestAnimationFrameInjectable from "../animate/request-animation-frame.injectable";
|
import requestAnimationFrameInjectable from "../animate/request-animation-frame.injectable";
|
||||||
|
|
||||||
// todo: refactor + handle animation-end in props.onClose()?
|
// todo: refactor + handle animation-end in props.onClose()?
|
||||||
@ -181,7 +181,7 @@ class NonInjectedDialog extends React.PureComponent<DialogProps & Dependencies &
|
|||||||
export const Dialog = withInjectables<Dependencies, DialogProps>((props) => <NonInjectedDialog {...props} />, {
|
export const Dialog = withInjectables<Dependencies, DialogProps>((props) => <NonInjectedDialog {...props} />, {
|
||||||
getProps: (di, props) => ({
|
getProps: (di, props) => ({
|
||||||
...props,
|
...props,
|
||||||
navigation: di.inject(observableHistoryInjectable),
|
navigation: di.inject(observableHistoryInjectionToken),
|
||||||
requestAnimationFrame: di.inject(requestAnimationFrameInjectable),
|
requestAnimationFrame: di.inject(requestAnimationFrameInjectable),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|||||||
@ -13,7 +13,7 @@ import { issuesTrackerUrl, forumsUrl } from "../../../common/vars";
|
|||||||
import type { SingleOrMany } from "@k8slens/utilities";
|
import type { SingleOrMany } from "@k8slens/utilities";
|
||||||
import type { ObservableHistory } from "mobx-observable-history";
|
import type { ObservableHistory } from "mobx-observable-history";
|
||||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||||
import { observableHistoryInjectable } from "@k8slens/routing";
|
import { observableHistoryInjectionToken } from "@k8slens/routing";
|
||||||
|
|
||||||
export interface ErrorBoundaryProps {
|
export interface ErrorBoundaryProps {
|
||||||
children?: SingleOrMany<React.ReactNode>;
|
children?: SingleOrMany<React.ReactNode>;
|
||||||
@ -98,6 +98,6 @@ class NonInjectedErrorBoundary extends React.Component<ErrorBoundaryProps & Depe
|
|||||||
export const ErrorBoundary = withInjectables<Dependencies, ErrorBoundaryProps>(NonInjectedErrorBoundary, {
|
export const ErrorBoundary = withInjectables<Dependencies, ErrorBoundaryProps>(NonInjectedErrorBoundary, {
|
||||||
getProps: (di, props) => ({
|
getProps: (di, props) => ({
|
||||||
...props,
|
...props,
|
||||||
observableHistory: di.inject(observableHistoryInjectable),
|
observableHistory: di.inject(observableHistoryInjectionToken),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { observableHistoryInjectable } from "@k8slens/routing";
|
import { observableHistoryInjectionToken } from "@k8slens/routing";
|
||||||
import kubeDetailsUrlParamInjectable from "./kube-details-url.injectable";
|
import kubeDetailsUrlParamInjectable from "./kube-details-url.injectable";
|
||||||
import kubeSelectedUrlParamInjectable from "./kube-selected-url.injectable";
|
import kubeSelectedUrlParamInjectable from "./kube-selected-url.injectable";
|
||||||
|
|
||||||
@ -12,7 +12,7 @@ export type GetDetailsUrl = (selfLink: string, resetSelected?: boolean, mergeGlo
|
|||||||
const getDetailsUrlInjectable = getInjectable({
|
const getDetailsUrlInjectable = getInjectable({
|
||||||
id: "get-details-url",
|
id: "get-details-url",
|
||||||
instantiate: (di): GetDetailsUrl => {
|
instantiate: (di): GetDetailsUrl => {
|
||||||
const observableHistory = di.inject(observableHistoryInjectable);
|
const observableHistory = di.inject(observableHistoryInjectionToken);
|
||||||
const kubeDetailsUrlParam = di.inject(kubeDetailsUrlParamInjectable);
|
const kubeDetailsUrlParam = di.inject(kubeDetailsUrlParamInjectable);
|
||||||
const kubeSelectedUrlParam = di.inject(kubeSelectedUrlParamInjectable);
|
const kubeSelectedUrlParam = di.inject(kubeSelectedUrlParamInjectable);
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { observableHistoryInjectable } from "@k8slens/routing";
|
import { observableHistoryInjectionToken } from "@k8slens/routing";
|
||||||
import getDetailsUrlInjectable from "./get-details-url.injectable";
|
import getDetailsUrlInjectable from "./get-details-url.injectable";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -16,7 +16,7 @@ export type ShowDetails = (selfLink: string | undefined, resetSelected?: boolean
|
|||||||
const showDetailsInjectable = getInjectable({
|
const showDetailsInjectable = getInjectable({
|
||||||
id: "show-details",
|
id: "show-details",
|
||||||
instantiate: (di): ShowDetails => {
|
instantiate: (di): ShowDetails => {
|
||||||
const observableHistory = di.inject(observableHistoryInjectable);
|
const observableHistory = di.inject(observableHistoryInjectionToken);
|
||||||
const getDetailsUrl = di.inject(getDetailsUrlInjectable);
|
const getDetailsUrl = di.inject(getDetailsUrlInjectable);
|
||||||
|
|
||||||
return (selfLink = "", resetSelected = true) => {
|
return (selfLink = "", resetSelected = true) => {
|
||||||
|
|||||||
@ -12,7 +12,7 @@ import { cssNames } from "@k8slens/utilities";
|
|||||||
import { CloseButton } from "./close-button";
|
import { CloseButton } from "./close-button";
|
||||||
import { getLegacyGlobalDiForExtensionApi } from "../../../extensions/as-legacy-globals-for-extension-api/legacy-global-di-for-extension-api";
|
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 navigateToCatalogInjectable from "../../../common/front-end-routing/routes/catalog/navigate-to-catalog.injectable";
|
||||||
import { observableHistoryInjectable } from "@k8slens/routing";
|
import { observableHistoryInjectionToken } from "@k8slens/routing";
|
||||||
|
|
||||||
export interface SettingLayoutProps extends React.DOMAttributes<any> {
|
export interface SettingLayoutProps extends React.DOMAttributes<any> {
|
||||||
className?: IClassName;
|
className?: IClassName;
|
||||||
@ -31,7 +31,7 @@ const defaultProps: Partial<SettingLayoutProps> = {
|
|||||||
back: () => {
|
back: () => {
|
||||||
const di = getLegacyGlobalDiForExtensionApi();
|
const di = getLegacyGlobalDiForExtensionApi();
|
||||||
const navigateToCatalog = di.inject(navigateToCatalogInjectable);
|
const navigateToCatalog = di.inject(navigateToCatalogInjectable);
|
||||||
const observableHistory = di.inject(observableHistoryInjectable);
|
const observableHistory = di.inject(observableHistoryInjectionToken);
|
||||||
|
|
||||||
if (observableHistory.length <= 1) {
|
if (observableHistory.length <= 1) {
|
||||||
navigateToCatalog();
|
navigateToCatalog();
|
||||||
|
|||||||
@ -15,7 +15,7 @@ import { Tab, Tabs } from "../tabs";
|
|||||||
import { ErrorBoundary } from "../error-boundary";
|
import { ErrorBoundary } from "../error-boundary";
|
||||||
import type { ObservableHistory } from "mobx-observable-history";
|
import type { ObservableHistory } from "mobx-observable-history";
|
||||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||||
import { observableHistoryInjectable } from "@k8slens/routing";
|
import { observableHistoryInjectionToken } from "@k8slens/routing";
|
||||||
import type { Navigate } from "../../navigation/navigate.injectable";
|
import type { Navigate } from "../../navigation/navigate.injectable";
|
||||||
import navigateInjectable from "../../navigation/navigate.injectable";
|
import navigateInjectable from "../../navigation/navigate.injectable";
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ const NonInjectedTabLayout = observer((props: TabLayoutProps & Dependencies) =>
|
|||||||
export const TabLayout = withInjectables<Dependencies, TabLayoutProps>(NonInjectedTabLayout, {
|
export const TabLayout = withInjectables<Dependencies, TabLayoutProps>(NonInjectedTabLayout, {
|
||||||
getProps: (di, props) => ({
|
getProps: (di, props) => ({
|
||||||
...props,
|
...props,
|
||||||
observableHistory: di.inject(observableHistoryInjectable),
|
observableHistory: di.inject(observableHistoryInjectionToken),
|
||||||
navigate: di.inject(navigateInjectable),
|
navigate: di.inject(navigateInjectable),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { observableHistoryInjectable } from "@k8slens/routing";
|
import { observableHistoryInjectionToken } from "@k8slens/routing";
|
||||||
import type { PageParamDependencies, PageParamInit } from "./page-param";
|
import type { PageParamDependencies, PageParamInit } from "./page-param";
|
||||||
import { PageParam } from "./page-param";
|
import { PageParam } from "./page-param";
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ const createPageParamInjectable = getInjectable({
|
|||||||
id: "create-page-param",
|
id: "create-page-param",
|
||||||
instantiate: (di): CreatePageParam => {
|
instantiate: (di): CreatePageParam => {
|
||||||
const deps: PageParamDependencies = {
|
const deps: PageParamDependencies = {
|
||||||
history: di.inject(observableHistoryInjectable),
|
history: di.inject(observableHistoryInjectionToken),
|
||||||
};
|
};
|
||||||
|
|
||||||
return (init) => new PageParam(deps, init);
|
return (init) => new PageParam(deps, init);
|
||||||
|
|||||||
@ -5,6 +5,6 @@
|
|||||||
|
|
||||||
import { createMemoryHistory } from "history";
|
import { createMemoryHistory } from "history";
|
||||||
import { getGlobalOverride } from "@k8slens/test-utils";
|
import { getGlobalOverride } from "@k8slens/test-utils";
|
||||||
import { historyInjectionToken } from "@k8slens/routing";
|
import { historyInjectable } from "@k8slens/routing";
|
||||||
|
|
||||||
export default getGlobalOverride(historyInjectionToken, () => createMemoryHistory());
|
export default getGlobalOverride(historyInjectable, () => createMemoryHistory());
|
||||||
|
|||||||
@ -5,14 +5,14 @@
|
|||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import type { match, RouteProps } from "react-router";
|
import type { match, RouteProps } from "react-router";
|
||||||
import { matchPath } from "react-router";
|
import { matchPath } from "react-router";
|
||||||
import { observableHistoryInjectable } from "@k8slens/routing";
|
import { observableHistoryInjectionToken } from "@k8slens/routing";
|
||||||
|
|
||||||
export type MatchRoute = <Params extends { [K in keyof Params]?: string }>(route: string | string[] | RouteProps) => match<Params> | null;
|
export type MatchRoute = <Params extends { [K in keyof Params]?: string }>(route: string | string[] | RouteProps) => match<Params> | null;
|
||||||
|
|
||||||
const matchRouteInjectable = getInjectable({
|
const matchRouteInjectable = getInjectable({
|
||||||
id: "match-route",
|
id: "match-route",
|
||||||
instantiate: (di): MatchRoute => {
|
instantiate: (di): MatchRoute => {
|
||||||
const observableHistory = di.inject(observableHistoryInjectable);
|
const observableHistory = di.inject(observableHistoryInjectionToken);
|
||||||
|
|
||||||
return (route) => matchPath(observableHistory.location.pathname, route);
|
return (route) => matchPath(observableHistory.location.pathname, route);
|
||||||
},
|
},
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import type { LocationDescriptor } from "history";
|
import type { LocationDescriptor } from "history";
|
||||||
import { action } from "mobx";
|
import { action } from "mobx";
|
||||||
import { observableHistoryInjectable } from "@k8slens/routing";
|
import { observableHistoryInjectionToken } from "@k8slens/routing";
|
||||||
import { createPath } from "history";
|
import { createPath } from "history";
|
||||||
|
|
||||||
export type Navigate = (location: LocationDescriptor) => void;
|
export type Navigate = (location: LocationDescriptor) => void;
|
||||||
@ -13,7 +13,7 @@ export type Navigate = (location: LocationDescriptor) => void;
|
|||||||
const navigateInjectable = getInjectable({
|
const navigateInjectable = getInjectable({
|
||||||
id: "navigate",
|
id: "navigate",
|
||||||
instantiate: (di): Navigate => {
|
instantiate: (di): Navigate => {
|
||||||
const observableHistory = di.inject(observableHistoryInjectable);
|
const observableHistory = di.inject(observableHistoryInjectionToken);
|
||||||
|
|
||||||
return action((location) => {
|
return action((location) => {
|
||||||
const currentLocation = createPath(observableHistory.location);
|
const currentLocation = createPath(observableHistory.location);
|
||||||
|
|||||||
@ -5,14 +5,14 @@
|
|||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import loggerInjectable from "../../common/logger.injectable";
|
import loggerInjectable from "../../common/logger.injectable";
|
||||||
import { beforeFrameStartsSecondInjectionToken } from "../before-frame-starts/tokens";
|
import { beforeFrameStartsSecondInjectionToken } from "../before-frame-starts/tokens";
|
||||||
import { observableHistoryInjectable } from "@k8slens/routing";
|
import { observableHistoryInjectionToken } from "@k8slens/routing";
|
||||||
|
|
||||||
const setupLoggingForNavigationInjectable = getInjectable({
|
const setupLoggingForNavigationInjectable = getInjectable({
|
||||||
id: "setup-logging-for-navigation",
|
id: "setup-logging-for-navigation",
|
||||||
instantiate: (di) => ({
|
instantiate: (di) => ({
|
||||||
run: () => {
|
run: () => {
|
||||||
const logger = di.inject(loggerInjectable);
|
const logger = di.inject(loggerInjectable);
|
||||||
const observableHistory = di.inject(observableHistoryInjectable);
|
const observableHistory = di.inject(observableHistoryInjectionToken);
|
||||||
|
|
||||||
observableHistory.listen((location, action) => {
|
observableHistory.listen((location, action) => {
|
||||||
const isClusterView = !process.isMainFrame;
|
const isClusterView = !process.isMainFrame;
|
||||||
|
|||||||
@ -6,13 +6,13 @@ import { getInjectable } from "@ogre-tools/injectable";
|
|||||||
|
|
||||||
import { emitWindowLocationChanged } from "../ipc";
|
import { emitWindowLocationChanged } from "../ipc";
|
||||||
import { reaction } from "mobx";
|
import { reaction } from "mobx";
|
||||||
import { observableHistoryInjectable } from "@k8slens/routing";
|
import { observableHistoryInjectionToken } from "@k8slens/routing";
|
||||||
|
|
||||||
const watchHistoryStateInjectable = getInjectable({
|
const watchHistoryStateInjectable = getInjectable({
|
||||||
id: "watch-history-state",
|
id: "watch-history-state",
|
||||||
|
|
||||||
instantiate: (di) => {
|
instantiate: (di) => {
|
||||||
const observableHistory = di.inject(observableHistoryInjectable);
|
const observableHistory = di.inject(observableHistoryInjectionToken);
|
||||||
|
|
||||||
return () => reaction(
|
return () => reaction(
|
||||||
() => observableHistory.location,
|
() => observableHistory.location,
|
||||||
|
|||||||
@ -4,13 +4,13 @@
|
|||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { computed } from "mobx";
|
import { computed } from "mobx";
|
||||||
import { observableHistoryInjectable } from "@k8slens/routing";
|
import { observableHistoryInjectionToken } from "@k8slens/routing";
|
||||||
|
|
||||||
const currentPathInjectable = getInjectable({
|
const currentPathInjectable = getInjectable({
|
||||||
id: "current-path",
|
id: "current-path",
|
||||||
|
|
||||||
instantiate: (di) => {
|
instantiate: (di) => {
|
||||||
const observableHistory = di.inject(observableHistoryInjectable);
|
const observableHistory = di.inject(observableHistoryInjectionToken);
|
||||||
|
|
||||||
return computed(() => observableHistory.location.pathname);
|
return computed(() => observableHistory.location.pathname);
|
||||||
},
|
},
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { observableHistoryInjectable } from "@k8slens/routing";
|
import { observableHistoryInjectionToken } from "@k8slens/routing";
|
||||||
import { runInAction } from "mobx";
|
import { runInAction } from "mobx";
|
||||||
import type { NavigateToUrl } from "../../common/front-end-routing/navigate-to-url-injection-token";
|
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";
|
import { navigateToUrlInjectionToken } from "../../common/front-end-routing/navigate-to-url-injection-token";
|
||||||
@ -14,7 +14,7 @@ const navigateToUrlInjectable = getInjectable({
|
|||||||
id: "navigate-to-url",
|
id: "navigate-to-url",
|
||||||
|
|
||||||
instantiate: (di): NavigateToUrl => {
|
instantiate: (di): NavigateToUrl => {
|
||||||
const observableHistory = di.inject(observableHistoryInjectable);
|
const observableHistory = di.inject(observableHistoryInjectionToken);
|
||||||
const broadcastMessage = di.inject(broadcastMessageInjectable);
|
const broadcastMessage = di.inject(broadcastMessageInjectable);
|
||||||
|
|
||||||
return (url, options = {}): void => {
|
return (url, options = {}): void => {
|
||||||
|
|||||||
@ -5,13 +5,13 @@
|
|||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { computed } from "mobx";
|
import { computed } from "mobx";
|
||||||
import { parse as parseQueryString } from "query-string";
|
import { parse as parseQueryString } from "query-string";
|
||||||
import { observableHistoryInjectable } from "@k8slens/routing";
|
import { observableHistoryInjectionToken } from "@k8slens/routing";
|
||||||
|
|
||||||
const queryParametersInjectable = getInjectable({
|
const queryParametersInjectable = getInjectable({
|
||||||
id: "query-parameters",
|
id: "query-parameters",
|
||||||
|
|
||||||
instantiate: (di) => {
|
instantiate: (di) => {
|
||||||
const observableHistory = di.inject(observableHistoryInjectable);
|
const observableHistory = di.inject(observableHistoryInjectionToken);
|
||||||
|
|
||||||
return computed(() => parseQueryString(observableHistory.location.search));
|
return computed(() => parseQueryString(observableHistory.location.search));
|
||||||
},
|
},
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export { historyInjectionToken } from "./src/history.injectable";
|
export { historyInjectable, historyInjectionToken } from "./src/history.injectable";
|
||||||
export { observableHistoryInjectable } from "./src/observable-history.injectable";
|
export { observableHistoryInjectionToken } from "./src/observable-history.injectable";
|
||||||
export { searchParamsOptions } from "./src/search-params";
|
export { searchParamsOptions } from "./src/search-params";
|
||||||
export { routingFeature } from "./src/feature";
|
export { routingFeature } from "./src/feature";
|
||||||
|
|||||||
@ -3,10 +3,10 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectable, getInjectionToken } from "@ogre-tools/injectable";
|
import { getInjectable, getInjectionToken } from "@ogre-tools/injectable";
|
||||||
import type { History } from "history";
|
import type { History, LocationState } from "history";
|
||||||
import { createBrowserHistory } from "history";
|
import { createBrowserHistory } from "history";
|
||||||
|
|
||||||
export const historyInjectionToken = getInjectionToken<History>({
|
export const historyInjectionToken = getInjectionToken<History<LocationState>>({
|
||||||
id: "history-injection-token",
|
id: "history-injection-token",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -2,10 +2,15 @@
|
|||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable, getInjectionToken } from "@ogre-tools/injectable";
|
||||||
import { createObservableHistory } from "mobx-observable-history";
|
import { createObservableHistory, ObservableHistory } from "mobx-observable-history";
|
||||||
import { searchParamsOptions } from "./search-params";
|
import { searchParamsOptions } from "./search-params";
|
||||||
import { historyInjectable } from "./history.injectable";
|
import { historyInjectable } from "./history.injectable";
|
||||||
|
import type { LocationState } from "history";
|
||||||
|
|
||||||
|
export const observableHistoryInjectionToken = getInjectionToken<ObservableHistory<LocationState>>({
|
||||||
|
id: "observable-history-injection-token",
|
||||||
|
});
|
||||||
|
|
||||||
export const observableHistoryInjectable = getInjectable({
|
export const observableHistoryInjectable = getInjectable({
|
||||||
id: "observable-history",
|
id: "observable-history",
|
||||||
@ -18,4 +23,5 @@ export const observableHistoryInjectable = getInjectable({
|
|||||||
|
|
||||||
return navigation;
|
return navigation;
|
||||||
},
|
},
|
||||||
|
injectionToken: observableHistoryInjectionToken,
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user