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 React from "react";
|
||||
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 { createObservableHistory } from "mobx-observable-history";
|
||||
import navigateToFrontPageInjectable from "../../common/front-end-routing/navigate-to-front-page.injectable";
|
||||
@ -54,7 +54,7 @@ describe("preferences - closing-preferences", () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
builder.beforeWindowStart(({ windowDi }) => {
|
||||
windowDi.override(observableHistoryInjectable, () => {
|
||||
windowDi.override(observableHistoryInjectionToken, () => {
|
||||
const historyFake = createMemoryHistory({
|
||||
initialEntries: ["/some-page"],
|
||||
initialIndex: 0,
|
||||
@ -135,7 +135,7 @@ describe("preferences - closing-preferences", () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
builder.beforeWindowStart(({ windowDi }) => {
|
||||
windowDi.override(observableHistoryInjectable, () => {
|
||||
windowDi.override(observableHistoryInjectionToken, () => {
|
||||
const historyFake = createMemoryHistory({
|
||||
initialEntries: ["/preferences/app"],
|
||||
initialIndex: 0,
|
||||
|
||||
@ -3,14 +3,14 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
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";
|
||||
|
||||
const closePreferencesInjectable = getInjectable({
|
||||
id: "close-preferences",
|
||||
|
||||
instantiate: (di) => {
|
||||
const observableHistory = di.inject(observableHistoryInjectable);
|
||||
const observableHistory = di.inject(observableHistoryInjectionToken);
|
||||
const navigateToFrontPage = di.inject(navigateToFrontPageInjectable);
|
||||
|
||||
return () => {
|
||||
|
||||
@ -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 "@k8slens/routing";
|
||||
import { observableHistoryInjectionToken } from "@k8slens/routing";
|
||||
import type { Disposer } from "@k8slens/utilities";
|
||||
import { disposer } from "@k8slens/utilities";
|
||||
import catalogEntityRegistryInjectable from "../catalog/entity/registry.injectable";
|
||||
@ -17,7 +17,7 @@ export type WatchForGeneralEntityNavigation = () => Disposer;
|
||||
const watchForGeneralEntityNavigationInjectable = getInjectable({
|
||||
id: "watch-for-general-entity-navigation",
|
||||
instantiate: (di): WatchForGeneralEntityNavigation => {
|
||||
const observableHistory = di.inject(observableHistoryInjectable);
|
||||
const observableHistory = di.inject(observableHistoryInjectionToken);
|
||||
const isActiveRoute = di.inject(isActiveRouteInjectable);
|
||||
const entityRegistry = di.inject(catalogEntityRegistryInjectable);
|
||||
const generalCategory = di.inject(generalCategoryInjectable);
|
||||
|
||||
@ -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 "@k8slens/routing";
|
||||
import { observableHistoryInjectionToken } from "@k8slens/routing";
|
||||
import type { RegisteredEntitySetting } from "./extension-registrator.injectable";
|
||||
import catalogEntitySettingItemsInjectable from "./settings.injectable";
|
||||
|
||||
@ -54,7 +54,7 @@ const getSettingGroups = (items: RegisteredEntitySetting[]): SettingGroup[] => {
|
||||
const activeEntitySettingsTabInjectable = getInjectable({
|
||||
id: "active-entity-settings-tab",
|
||||
instantiate: (di, entity): ActiveEntitySettings => {
|
||||
const observableHistory = di.inject(observableHistoryInjectable);
|
||||
const observableHistory = di.inject(observableHistoryInjectionToken);
|
||||
const items = di.inject(catalogEntitySettingItemsInjectable, entity);
|
||||
|
||||
return {
|
||||
|
||||
@ -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 "@k8slens/routing";
|
||||
import { observableHistoryInjectionToken } from "@k8slens/routing";
|
||||
import requestAnimationFrameInjectable from "../animate/request-animation-frame.injectable";
|
||||
|
||||
// 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} />, {
|
||||
getProps: (di, props) => ({
|
||||
...props,
|
||||
navigation: di.inject(observableHistoryInjectable),
|
||||
navigation: di.inject(observableHistoryInjectionToken),
|
||||
requestAnimationFrame: di.inject(requestAnimationFrameInjectable),
|
||||
}),
|
||||
});
|
||||
|
||||
@ -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 "@k8slens/routing";
|
||||
import { observableHistoryInjectionToken } from "@k8slens/routing";
|
||||
|
||||
export interface ErrorBoundaryProps {
|
||||
children?: SingleOrMany<React.ReactNode>;
|
||||
@ -98,6 +98,6 @@ class NonInjectedErrorBoundary extends React.Component<ErrorBoundaryProps & Depe
|
||||
export const ErrorBoundary = withInjectables<Dependencies, ErrorBoundaryProps>(NonInjectedErrorBoundary, {
|
||||
getProps: (di, 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.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { observableHistoryInjectable } from "@k8slens/routing";
|
||||
import { observableHistoryInjectionToken } from "@k8slens/routing";
|
||||
import kubeDetailsUrlParamInjectable from "./kube-details-url.injectable";
|
||||
import kubeSelectedUrlParamInjectable from "./kube-selected-url.injectable";
|
||||
|
||||
@ -12,7 +12,7 @@ export type GetDetailsUrl = (selfLink: string, resetSelected?: boolean, mergeGlo
|
||||
const getDetailsUrlInjectable = getInjectable({
|
||||
id: "get-details-url",
|
||||
instantiate: (di): GetDetailsUrl => {
|
||||
const observableHistory = di.inject(observableHistoryInjectable);
|
||||
const observableHistory = di.inject(observableHistoryInjectionToken);
|
||||
const kubeDetailsUrlParam = di.inject(kubeDetailsUrlParamInjectable);
|
||||
const kubeSelectedUrlParam = di.inject(kubeSelectedUrlParamInjectable);
|
||||
|
||||
|
||||
@ -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 "@k8slens/routing";
|
||||
import { observableHistoryInjectionToken } from "@k8slens/routing";
|
||||
import getDetailsUrlInjectable from "./get-details-url.injectable";
|
||||
|
||||
/**
|
||||
@ -16,7 +16,7 @@ export type ShowDetails = (selfLink: string | undefined, resetSelected?: boolean
|
||||
const showDetailsInjectable = getInjectable({
|
||||
id: "show-details",
|
||||
instantiate: (di): ShowDetails => {
|
||||
const observableHistory = di.inject(observableHistoryInjectable);
|
||||
const observableHistory = di.inject(observableHistoryInjectionToken);
|
||||
const getDetailsUrl = di.inject(getDetailsUrlInjectable);
|
||||
|
||||
return (selfLink = "", resetSelected = true) => {
|
||||
|
||||
@ -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 "@k8slens/routing";
|
||||
import { observableHistoryInjectionToken } from "@k8slens/routing";
|
||||
|
||||
export interface SettingLayoutProps extends React.DOMAttributes<any> {
|
||||
className?: IClassName;
|
||||
@ -31,7 +31,7 @@ const defaultProps: Partial<SettingLayoutProps> = {
|
||||
back: () => {
|
||||
const di = getLegacyGlobalDiForExtensionApi();
|
||||
const navigateToCatalog = di.inject(navigateToCatalogInjectable);
|
||||
const observableHistory = di.inject(observableHistoryInjectable);
|
||||
const observableHistory = di.inject(observableHistoryInjectionToken);
|
||||
|
||||
if (observableHistory.length <= 1) {
|
||||
navigateToCatalog();
|
||||
|
||||
@ -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 "@k8slens/routing";
|
||||
import { observableHistoryInjectionToken } from "@k8slens/routing";
|
||||
import type { Navigate } 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, {
|
||||
getProps: (di, props) => ({
|
||||
...props,
|
||||
observableHistory: di.inject(observableHistoryInjectable),
|
||||
observableHistory: di.inject(observableHistoryInjectionToken),
|
||||
navigate: di.inject(navigateInjectable),
|
||||
}),
|
||||
});
|
||||
|
||||
@ -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 "@k8slens/routing";
|
||||
import { observableHistoryInjectionToken } from "@k8slens/routing";
|
||||
import type { PageParamDependencies, PageParamInit } from "./page-param";
|
||||
import { PageParam } from "./page-param";
|
||||
|
||||
@ -13,7 +13,7 @@ const createPageParamInjectable = getInjectable({
|
||||
id: "create-page-param",
|
||||
instantiate: (di): CreatePageParam => {
|
||||
const deps: PageParamDependencies = {
|
||||
history: di.inject(observableHistoryInjectable),
|
||||
history: di.inject(observableHistoryInjectionToken),
|
||||
};
|
||||
|
||||
return (init) => new PageParam(deps, init);
|
||||
|
||||
@ -5,6 +5,6 @@
|
||||
|
||||
import { createMemoryHistory } from "history";
|
||||
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 type { match, RouteProps } 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;
|
||||
|
||||
const matchRouteInjectable = getInjectable({
|
||||
id: "match-route",
|
||||
instantiate: (di): MatchRoute => {
|
||||
const observableHistory = di.inject(observableHistoryInjectable);
|
||||
const observableHistory = di.inject(observableHistoryInjectionToken);
|
||||
|
||||
return (route) => matchPath(observableHistory.location.pathname, route);
|
||||
},
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import type { LocationDescriptor } from "history";
|
||||
import { action } from "mobx";
|
||||
import { observableHistoryInjectable } from "@k8slens/routing";
|
||||
import { observableHistoryInjectionToken } from "@k8slens/routing";
|
||||
import { createPath } from "history";
|
||||
|
||||
export type Navigate = (location: LocationDescriptor) => void;
|
||||
@ -13,7 +13,7 @@ export type Navigate = (location: LocationDescriptor) => void;
|
||||
const navigateInjectable = getInjectable({
|
||||
id: "navigate",
|
||||
instantiate: (di): Navigate => {
|
||||
const observableHistory = di.inject(observableHistoryInjectable);
|
||||
const observableHistory = di.inject(observableHistoryInjectionToken);
|
||||
|
||||
return action((location) => {
|
||||
const currentLocation = createPath(observableHistory.location);
|
||||
|
||||
@ -5,14 +5,14 @@
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import loggerInjectable from "../../common/logger.injectable";
|
||||
import { beforeFrameStartsSecondInjectionToken } from "../before-frame-starts/tokens";
|
||||
import { observableHistoryInjectable } from "@k8slens/routing";
|
||||
import { observableHistoryInjectionToken } from "@k8slens/routing";
|
||||
|
||||
const setupLoggingForNavigationInjectable = getInjectable({
|
||||
id: "setup-logging-for-navigation",
|
||||
instantiate: (di) => ({
|
||||
run: () => {
|
||||
const logger = di.inject(loggerInjectable);
|
||||
const observableHistory = di.inject(observableHistoryInjectable);
|
||||
const observableHistory = di.inject(observableHistoryInjectionToken);
|
||||
|
||||
observableHistory.listen((location, action) => {
|
||||
const isClusterView = !process.isMainFrame;
|
||||
|
||||
@ -6,13 +6,13 @@ import { getInjectable } from "@ogre-tools/injectable";
|
||||
|
||||
import { emitWindowLocationChanged } from "../ipc";
|
||||
import { reaction } from "mobx";
|
||||
import { observableHistoryInjectable } from "@k8slens/routing";
|
||||
import { observableHistoryInjectionToken } from "@k8slens/routing";
|
||||
|
||||
const watchHistoryStateInjectable = getInjectable({
|
||||
id: "watch-history-state",
|
||||
|
||||
instantiate: (di) => {
|
||||
const observableHistory = di.inject(observableHistoryInjectable);
|
||||
const observableHistory = di.inject(observableHistoryInjectionToken);
|
||||
|
||||
return () => reaction(
|
||||
() => observableHistory.location,
|
||||
|
||||
@ -4,13 +4,13 @@
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { computed } from "mobx";
|
||||
import { observableHistoryInjectable } from "@k8slens/routing";
|
||||
import { observableHistoryInjectionToken } from "@k8slens/routing";
|
||||
|
||||
const currentPathInjectable = getInjectable({
|
||||
id: "current-path",
|
||||
|
||||
instantiate: (di) => {
|
||||
const observableHistory = di.inject(observableHistoryInjectable);
|
||||
const observableHistory = di.inject(observableHistoryInjectionToken);
|
||||
|
||||
return computed(() => observableHistory.location.pathname);
|
||||
},
|
||||
|
||||
@ -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 "@k8slens/routing";
|
||||
import { observableHistoryInjectionToken } 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";
|
||||
@ -14,7 +14,7 @@ const navigateToUrlInjectable = getInjectable({
|
||||
id: "navigate-to-url",
|
||||
|
||||
instantiate: (di): NavigateToUrl => {
|
||||
const observableHistory = di.inject(observableHistoryInjectable);
|
||||
const observableHistory = di.inject(observableHistoryInjectionToken);
|
||||
const broadcastMessage = di.inject(broadcastMessageInjectable);
|
||||
|
||||
return (url, options = {}): void => {
|
||||
|
||||
@ -5,13 +5,13 @@
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { computed } from "mobx";
|
||||
import { parse as parseQueryString } from "query-string";
|
||||
import { observableHistoryInjectable } from "@k8slens/routing";
|
||||
import { observableHistoryInjectionToken } from "@k8slens/routing";
|
||||
|
||||
const queryParametersInjectable = getInjectable({
|
||||
id: "query-parameters",
|
||||
|
||||
instantiate: (di) => {
|
||||
const observableHistory = di.inject(observableHistoryInjectable);
|
||||
const observableHistory = di.inject(observableHistoryInjectionToken);
|
||||
|
||||
return computed(() => parseQueryString(observableHistory.location.search));
|
||||
},
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
export { historyInjectionToken } from "./src/history.injectable";
|
||||
export { observableHistoryInjectable } from "./src/observable-history.injectable";
|
||||
export { historyInjectable, historyInjectionToken } from "./src/history.injectable";
|
||||
export { observableHistoryInjectionToken } from "./src/observable-history.injectable";
|
||||
export { searchParamsOptions } from "./src/search-params";
|
||||
export { routingFeature } from "./src/feature";
|
||||
|
||||
@ -3,10 +3,10 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable, getInjectionToken } from "@ogre-tools/injectable";
|
||||
import type { History } from "history";
|
||||
import type { History, LocationState } from "history";
|
||||
import { createBrowserHistory } from "history";
|
||||
|
||||
export const historyInjectionToken = getInjectionToken<History>({
|
||||
export const historyInjectionToken = getInjectionToken<History<LocationState>>({
|
||||
id: "history-injection-token",
|
||||
});
|
||||
|
||||
|
||||
@ -2,10 +2,15 @@
|
||||
* 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 { getInjectable, getInjectionToken } from "@ogre-tools/injectable";
|
||||
import { createObservableHistory, ObservableHistory } from "mobx-observable-history";
|
||||
import { searchParamsOptions } from "./search-params";
|
||||
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({
|
||||
id: "observable-history",
|
||||
@ -18,4 +23,5 @@ export const observableHistoryInjectable = getInjectable({
|
||||
|
||||
return navigation;
|
||||
},
|
||||
injectionToken: observableHistoryInjectionToken,
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user