1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Covering more components with CacheProvider

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2021-03-24 10:28:04 +03:00
parent cd5ee6188f
commit a649e07cb6
4 changed files with 56 additions and 56 deletions

View File

@ -50,6 +50,8 @@ import { ReplicaSetScaleDialog } from "./+workloads-replicasets/replicaset-scale
import { CommandContainer } from "./command-palette/command-container"; import { CommandContainer } from "./command-palette/command-container";
import { KubeObjectStore } from "../kube-object.store"; import { KubeObjectStore } from "../kube-object.store";
import { clusterContext } from "./context"; import { clusterContext } from "./context";
import { CacheProvider } from "@emotion/react";
import createCache from "@emotion/cache";
@observer @observer
export class App extends React.Component { export class App extends React.Component {
@ -153,37 +155,39 @@ export class App extends React.Component {
render() { render() {
return ( return (
<Router history={history}> <Router history={history}>
<ErrorBoundary> <CacheProvider value={createCache({ key: "dashboard" })}>
<MainLayout> <ErrorBoundary>
<Switch> <MainLayout>
<Route component={ClusterOverview} {...clusterRoute}/> <Switch>
<Route component={Nodes} {...nodesRoute}/> <Route component={ClusterOverview} {...clusterRoute}/>
<Route component={Workloads} {...workloadsRoute}/> <Route component={Nodes} {...nodesRoute}/>
<Route component={Config} {...configRoute}/> <Route component={Workloads} {...workloadsRoute}/>
<Route component={Network} {...networkRoute}/> <Route component={Config} {...configRoute}/>
<Route component={Storage} {...storageRoute}/> <Route component={Network} {...networkRoute}/>
<Route component={Namespaces} {...namespacesRoute}/> <Route component={Storage} {...storageRoute}/>
<Route component={Events} {...eventRoute}/> <Route component={Namespaces} {...namespacesRoute}/>
<Route component={CustomResources} {...crdRoute}/> <Route component={Events} {...eventRoute}/>
<Route component={UserManagement} {...usersManagementRoute}/> <Route component={CustomResources} {...crdRoute}/>
<Route component={Apps} {...appsRoute}/> <Route component={UserManagement} {...usersManagementRoute}/>
{this.renderExtensionTabLayoutRoutes()} <Route component={Apps} {...appsRoute}/>
{this.renderExtensionRoutes()} {this.renderExtensionTabLayoutRoutes()}
<Redirect exact from="/" to={this.startUrl}/> {this.renderExtensionRoutes()}
<Route component={NotFound}/> <Redirect exact from="/" to={this.startUrl}/>
</Switch> <Route component={NotFound}/>
</MainLayout> </Switch>
<Notifications/> </MainLayout>
<ConfirmDialog/> <Notifications/>
<KubeObjectDetails/> <ConfirmDialog/>
<KubeConfigDialog/> <KubeObjectDetails/>
<AddRoleBindingDialog/> <KubeConfigDialog/>
<DeploymentScaleDialog/> <AddRoleBindingDialog/>
<StatefulSetScaleDialog/> <DeploymentScaleDialog/>
<ReplicaSetScaleDialog/> <StatefulSetScaleDialog/>
<CronJobTriggerDialog/> <ReplicaSetScaleDialog/>
<CommandContainer clusterId={getHostedCluster()?.id}/> <CronJobTriggerDialog/>
</ErrorBoundary> <CommandContainer clusterId={getHostedCluster()?.id}/>
</ErrorBoundary>
</CacheProvider>
</Router> </Router>
); );
} }

View File

@ -10,8 +10,6 @@ import { ResizeDirection, ResizeGrowthDirection, ResizeSide, ResizingAnchor } fr
import { MainLayoutHeader } from "./main-layout-header"; import { MainLayoutHeader } from "./main-layout-header";
import { Sidebar } from "./sidebar"; import { Sidebar } from "./sidebar";
import { sidebarStorage } from "./sidebar-storage"; import { sidebarStorage } from "./sidebar-storage";
import { CacheProvider } from "@emotion/react";
import createCache from "@emotion/cache";
export interface MainLayoutProps { export interface MainLayoutProps {
className?: any; className?: any;
@ -62,11 +60,9 @@ export class MainLayout extends React.Component<MainLayoutProps> {
/> />
</aside> </aside>
<CacheProvider value={createCache({ key: "main-layout" })}> <main>
<main> <ErrorBoundary>{children}</ErrorBoundary>
<ErrorBoundary>{children}</ErrorBoundary> </main>
</main>
</CacheProvider>
<footer className={footerClass}>{footer ?? <Dock/>}</footer> <footer className={footerClass}>{footer ?? <Dock/>}</footer>
</div> </div>

View File

@ -6,8 +6,6 @@ import { autobind, cssNames, IClassName } from "../../utils";
import { Icon } from "../icon"; import { Icon } from "../icon";
import { navigation } from "../../navigation"; import { navigation } from "../../navigation";
import { NavigationTree, RecursiveTreeView } from "../tree-view"; import { NavigationTree, RecursiveTreeView } from "../tree-view";
import { CacheProvider } from "@emotion/react";
import createCache from "@emotion/cache";
export interface PageLayoutProps extends React.DOMAttributes<any> { export interface PageLayoutProps extends React.DOMAttributes<any> {
className?: IClassName; className?: IClassName;
@ -82,13 +80,11 @@ export class PageLayout extends React.Component<PageLayoutProps> {
<RecursiveTreeView data={navigation}/> <RecursiveTreeView data={navigation}/>
</nav> </nav>
)} )}
<CacheProvider value={createCache({ key: "page-layout" })}> <div className="content-wrapper" id="ScrollSpyRoot">
<div className="content-wrapper" id="ScrollSpyRoot"> <div className={cssNames("content", contentClass, contentGaps && "flex column gaps")}>
<div className={cssNames("content", contentClass, contentGaps && "flex column gaps")}> {children}
{children}
</div>
</div> </div>
</CacheProvider> </div>
</div> </div>
); );
} }

View File

@ -15,6 +15,8 @@ import { CommandContainer } from "./components/command-palette/command-container
import { LensProtocolRouterRenderer, bindProtocolAddRouteHandlers } from "./protocol-handler"; import { LensProtocolRouterRenderer, bindProtocolAddRouteHandlers } from "./protocol-handler";
import { registerIpcHandlers } from "./ipc"; import { registerIpcHandlers } from "./ipc";
import { ipcRenderer } from "electron"; import { ipcRenderer } from "electron";
import { CacheProvider } from "@emotion/react";
import createCache from "@emotion/cache";
@observer @observer
export class LensApp extends React.Component { export class LensApp extends React.Component {
@ -36,16 +38,18 @@ export class LensApp extends React.Component {
render() { render() {
return ( return (
<Router history={history}> <Router history={history}>
<ErrorBoundary> <CacheProvider value={createCache({ key: "app" })}>
<Switch> <ErrorBoundary>
{userStore.isNewVersion && <Route component={WhatsNew}/>} <Switch>
<Route component={WhatsNew} {...whatsNewRoute}/> {userStore.isNewVersion && <Route component={WhatsNew}/>}
<Route component={ClusterManager}/> <Route component={WhatsNew} {...whatsNewRoute}/>
</Switch> <Route component={ClusterManager}/>
</ErrorBoundary> </Switch>
<Notifications/> </ErrorBoundary>
<ConfirmDialog/> <Notifications/>
<CommandContainer /> <ConfirmDialog/>
<CommandContainer />
</CacheProvider>
</Router> </Router>
); );
} }