Refactor PageRegistration to separate registries/interfaces #1130 (#1144)

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman authored and GitHub committed 2020-10-26 15:40:34 +02:00
1 parent 48d8d985ae
commit 9b9bf47970
9 files changed
+35 -37

No files matched your search

+2 -2
View File
@@ -35,7 +35,7 @@ import { getHostedCluster, getHostedClusterId } from "../../common/cluster-store
import logger from "../../main/logger";
import { clusterIpc } from "../../common/cluster-ipc";
import { webFrame } from "electron";
import { pageRegistry } from "../../extensions/registries/page-registry";
import { clusterPageRegistry } from "../../extensions/registries/page-registry";
import { DynamicPage } from "../../extensions/dynamic-page";
import { extensionLoader } from "../../extensions/extension-loader";
import { appEventBus } from "../../common/event-bus"
@@ -81,7 +81,7 @@ export class App extends React.Component {
<Route component={CustomResources} {...crdRoute}/>
<Route component={UserManagement} {...usersManagementRoute}/>
<Route component={Apps} {...appsRoute}/>
{pageRegistry.clusterPages.map(page => {
{clusterPageRegistry.getItems().map(page => {
return <Route {...page} key={String(page.path)} render={() => <DynamicPage page={page}/>}/>
})}
<Redirect exact from="/" to={this.startURL}/>
@@ -14,7 +14,7 @@ import { ClusterSettings, clusterSettingsRoute } from "../+cluster-settings";
import { clusterViewRoute, clusterViewURL, getMatchedCluster, getMatchedClusterId } from "./cluster-view.route";
import { clusterStore } from "../../../common/cluster-store";
import { hasLoadedView, initView, lensViews, refreshViews } from "./lens-views";
import { pageRegistry } from "../../../extensions/registries/page-registry";
import { globalPageRegistry } from "../../../extensions/registries/page-registry";
@observer
export class ClusterManager extends React.Component {
@@ -63,7 +63,7 @@ export class ClusterManager extends React.Component {
<Route component={AddCluster} {...addClusterRoute} />
<Route component={ClusterView} {...clusterViewRoute} />
<Route component={ClusterSettings} {...clusterSettingsRoute} />
{pageRegistry.globalPages.map(({ path, url = String(path), components: { Page } }) => {
{globalPageRegistry.getItems().map(({ path, url = String(path), components: { Page } }) => {
return <Route key={url} path={path} component={Page}/>
})}
<Redirect exact to={this.startUrl} />
@@ -22,7 +22,7 @@ import { ConfirmDialog } from "../confirm-dialog";
import { clusterIpc } from "../../../common/cluster-ipc";
import { clusterViewURL } from "./cluster-view.route";
import { DragDropContext, Draggable, DraggableProvided, Droppable, DroppableProvided, DropResult } from "react-beautiful-dnd";
import { pageRegistry } from "../../../extensions/registries/page-registry";
import { globalPageRegistry } from "../../../extensions/registries/page-registry";
interface Props {
className?: IClassName;
@@ -156,8 +156,10 @@ export class ClustersMenu extends React.Component<Props> {
)}
</div>
<div className="extensions">
{pageRegistry.globalPages.map(({ path, url = String(path), components: { MenuIcon } }) => {
if (!MenuIcon) return;
{globalPageRegistry.getItems().map(({ path, url = String(path), hideInMenu, components: { MenuIcon } }) => {
if (!MenuIcon || hideInMenu) {
return;
}
return <MenuIcon key={url} onClick={() => navigate(url)}/>
})}
</div>
+5 -3
View File
@@ -28,7 +28,7 @@ import { CrdList, crdResourcesRoute, crdRoute, crdURL } from "../+custom-resourc
import { CustomResources } from "../+custom-resources/custom-resources";
import { navigation } from "../../navigation";
import { isAllowedResource } from "../../../common/rbac"
import { pageRegistry } from "../../../extensions/registries/page-registry";
import { clusterPageRegistry } from "../../../extensions/registries/page-registry";
const SidebarContext = React.createContext<SidebarContextValue>({ pinned: false });
type SidebarContextValue = {
@@ -184,8 +184,10 @@ export class Sidebar extends React.Component<Props> {
>
{this.renderCustomResources()}
</SidebarNavItem>
{pageRegistry.clusterPages.map(({ path, title, url = String(path), components: { MenuIcon } }) => {
if (!MenuIcon) return;
{clusterPageRegistry.getItems().map(({ path, title, url = String(path), hideInMenu, components: { MenuIcon } }) => {
if (!MenuIcon || hideInMenu) {
return;
}
return (
<SidebarNavItem
key={url} id={`sidebar_item_${url}`}