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

Moving CacheProvider into bootstrap

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2021-03-24 15:51:03 +03:00
parent eab03bf03f
commit 2418de9140
3 changed files with 46 additions and 50 deletions

View File

@ -19,6 +19,8 @@ import { filesystemProvisionerStore } from "../main/extension-filesystem";
import { App } from "./components/app"; import { App } from "./components/app";
import { LensApp } from "./lens-app"; import { LensApp } from "./lens-app";
import { themeStore } from "./theme.store"; import { themeStore } from "./theme.store";
import { CacheProvider } from "@emotion/react";
import createCache from "@emotion/cache";
/** /**
* If this is a development buid, wait a second to attach * If this is a development buid, wait a second to attach
@ -82,7 +84,9 @@ export async function bootstrap(App: AppComponent) {
}); });
render(<> render(<>
{isMac && <div id="draggable-top" />} {isMac && <div id="draggable-top" />}
<App /> <CacheProvider value={createCache({ key: "lens" })}>
<App />
</CacheProvider>
</>, rootElem); </>, rootElem);
} }

View File

@ -50,8 +50,6 @@ 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 {
@ -155,39 +153,37 @@ 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> <Route component={ClusterOverview} {...clusterRoute}/>
<Route component={ClusterOverview} {...clusterRoute}/> <Route component={Nodes} {...nodesRoute}/>
<Route component={Nodes} {...nodesRoute}/> <Route component={Workloads} {...workloadsRoute}/>
<Route component={Workloads} {...workloadsRoute}/> <Route component={Config} {...configRoute}/>
<Route component={Config} {...configRoute}/> <Route component={Network} {...networkRoute}/>
<Route component={Network} {...networkRoute}/> <Route component={Storage} {...storageRoute}/>
<Route component={Storage} {...storageRoute}/> <Route component={Namespaces} {...namespacesRoute}/>
<Route component={Namespaces} {...namespacesRoute}/> <Route component={Events} {...eventRoute}/>
<Route component={Events} {...eventRoute}/> <Route component={CustomResources} {...crdRoute}/>
<Route component={CustomResources} {...crdRoute}/> <Route component={UserManagement} {...usersManagementRoute}/>
<Route component={UserManagement} {...usersManagementRoute}/> <Route component={Apps} {...appsRoute}/>
<Route component={Apps} {...appsRoute}/> {this.renderExtensionTabLayoutRoutes()}
{this.renderExtensionTabLayoutRoutes()} {this.renderExtensionRoutes()}
{this.renderExtensionRoutes()} <Redirect exact from="/" to={this.startUrl}/>
<Redirect exact from="/" to={this.startUrl}/> <Route component={NotFound}/>
<Route component={NotFound}/> </Switch>
</Switch> </MainLayout>
</MainLayout> <Notifications/>
<Notifications/> <ConfirmDialog/>
<ConfirmDialog/> <KubeObjectDetails/>
<KubeObjectDetails/> <KubeConfigDialog/>
<KubeConfigDialog/> <AddRoleBindingDialog/>
<AddRoleBindingDialog/> <DeploymentScaleDialog/>
<DeploymentScaleDialog/> <StatefulSetScaleDialog/>
<StatefulSetScaleDialog/> <ReplicaSetScaleDialog/>
<ReplicaSetScaleDialog/> <CronJobTriggerDialog/>
<CronJobTriggerDialog/> <CommandContainer clusterId={getHostedCluster()?.id}/>
<CommandContainer clusterId={getHostedCluster()?.id}/> </ErrorBoundary>
</ErrorBoundary>
</CacheProvider>
</Router> </Router>
); );
} }

View File

@ -15,9 +15,7 @@ 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 { IpcRendererNavigationEvents } from "./navigation/events"; import { IpcRendererNavigationEvents } from "./navigation/events";
import createCache from "@emotion/cache";
@observer @observer
export class LensApp extends React.Component { export class LensApp extends React.Component {
@ -39,18 +37,16 @@ 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}/>} <Route component={WhatsNew} {...whatsNewRoute}/>
<Route component={WhatsNew} {...whatsNewRoute}/> <Route component={ClusterManager}/>
<Route component={ClusterManager}/> </Switch>
</Switch> </ErrorBoundary>
</ErrorBoundary> <Notifications/>
<Notifications/> <ConfirmDialog/>
<ConfirmDialog/> <CommandContainer />
<CommandContainer />
</CacheProvider>
</Router> </Router>
); );
} }