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,6 +155,7 @@ export class App extends React.Component {
render() { render() {
return ( return (
<Router history={history}> <Router history={history}>
<CacheProvider value={createCache({ key: "dashboard" })}>
<ErrorBoundary> <ErrorBoundary>
<MainLayout> <MainLayout>
<Switch> <Switch>
@ -184,6 +187,7 @@ export class App extends React.Component {
<CronJobTriggerDialog/> <CronJobTriggerDialog/>
<CommandContainer clusterId={getHostedCluster()?.id}/> <CommandContainer clusterId={getHostedCluster()?.id}/>
</ErrorBoundary> </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> </div>
</CacheProvider>
</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,6 +38,7 @@ export class LensApp extends React.Component {
render() { render() {
return ( return (
<Router history={history}> <Router history={history}>
<CacheProvider value={createCache({ key: "app" })}>
<ErrorBoundary> <ErrorBoundary>
<Switch> <Switch>
{userStore.isNewVersion && <Route component={WhatsNew}/>} {userStore.isNewVersion && <Route component={WhatsNew}/>}
@ -46,6 +49,7 @@ export class LensApp extends React.Component {
<Notifications/> <Notifications/>
<ConfirmDialog/> <ConfirmDialog/>
<CommandContainer /> <CommandContainer />
</CacheProvider>
</Router> </Router>
); );
} }