/** * Copyright (c) OpenLens Authors. All rights reserved. * Licensed under MIT License. See LICENSE in root directory for more information. */ import "./cluster-manager.scss"; import React from "react"; import { Redirect } from "react-router"; import { disposeOnUnmount, observer } from "mobx-react"; import { StatusBar } from "../status-bar/status-bar"; import { HotbarMenu } from "../hotbar/hotbar-menu"; import { DeleteClusterDialog } from "../delete-cluster-dialog"; import { withInjectables } from "@ogre-tools/injectable-react"; import { TopBar } from "../layout/top-bar/top-bar"; import catalogPreviousActiveTabStorageInjectable from "../+catalog/catalog-previous-active-tab-storage/catalog-previous-active-tab-storage.injectable"; import type { IComputedValue } from "mobx"; import currentRouteComponentInjectable from "../../routes/current-route-component.injectable"; import welcomeRouteInjectable from "../../../common/front-end-routing/routes/welcome/welcome-route.injectable"; import { buildURL } from "../../../common/utils/buildUrl"; import type { StorageLayer } from "../../utils"; import type { WatchForGeneralEntityNavigation } from "../../api/helpers/watch-for-general-entity-navigation.injectable"; import watchForGeneralEntityNavigationInjectable from "../../api/helpers/watch-for-general-entity-navigation.injectable"; import currentPathInjectable from "../../routes/current-path.injectable"; interface Dependencies { catalogPreviousActiveTabStorage: StorageLayer; currentRouteComponent: IComputedValue; welcomeUrl: string; watchForGeneralEntityNavigation: WatchForGeneralEntityNavigation; currentPath: IComputedValue; } @observer class NonInjectedClusterManager extends React.Component { componentDidMount() { disposeOnUnmount(this, [ this.props.watchForGeneralEntityNavigation(), ]); } renderMainComponent() { const Component = this.props.currentRouteComponent.get(); if (Component) { return ; } const currentPath = this.props.currentPath.get(); if (currentPath !== this.props.welcomeUrl) { return ; } return (

ERROR!!

No matching route for the current path: {" "} {currentPath} {" "} which is the welcomeUrl. This is a bug.

); } render() { return (
{this.renderMainComponent()}
); } } export const ClusterManager = withInjectables(NonInjectedClusterManager, { getProps: (di) => ({ catalogPreviousActiveTabStorage: di.inject(catalogPreviousActiveTabStorageInjectable), currentRouteComponent: di.inject(currentRouteComponentInjectable), welcomeUrl: buildURL(di.inject(welcomeRouteInjectable).path), watchForGeneralEntityNavigation: di.inject(watchForGeneralEntityNavigationInjectable), currentPath: di.inject(currentPathInjectable), }), });