mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix reference error when opening cluster view (#3824)
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
8b3d237f3b
commit
e251194cb5
@ -31,7 +31,7 @@ import { once } from "lodash";
|
|||||||
export type EntityFilter = (entity: CatalogEntity) => any;
|
export type EntityFilter = (entity: CatalogEntity) => any;
|
||||||
|
|
||||||
export class CatalogEntityRegistry {
|
export class CatalogEntityRegistry {
|
||||||
@observable.ref activeEntity: CatalogEntity;
|
@observable protected activeEntityId: string | undefined = undefined;
|
||||||
protected _entities = observable.map<string, CatalogEntity>([], { deep: true });
|
protected _entities = observable.map<string, CatalogEntity>([], { deep: true });
|
||||||
protected filters = observable.set<EntityFilter>([], {
|
protected filters = observable.set<EntityFilter>([], {
|
||||||
deep: false,
|
deep: false,
|
||||||
@ -46,6 +46,22 @@ export class CatalogEntityRegistry {
|
|||||||
makeObservable(this);
|
makeObservable(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get activeEntity(): CatalogEntity | null {
|
||||||
|
return this._entities.get(this.activeEntityId) || null;
|
||||||
|
}
|
||||||
|
|
||||||
|
set activeEntity(raw: CatalogEntity | string | null) {
|
||||||
|
if (raw) {
|
||||||
|
const id = typeof raw === "string"
|
||||||
|
? raw
|
||||||
|
: raw.getId();
|
||||||
|
|
||||||
|
this.activeEntityId = id;
|
||||||
|
} else {
|
||||||
|
this.activeEntityId = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
ipcRendererOn("catalog:items", (event, items: (CatalogEntityData & CatalogEntityKindData)[]) => {
|
ipcRendererOn("catalog:items", (event, items: (CatalogEntityData & CatalogEntityKindData)[]) => {
|
||||||
this.updateItems(items);
|
this.updateItems(items);
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { observable, makeObservable, reaction } from "mobx";
|
import { observable, makeObservable } from "mobx";
|
||||||
import { disposeOnUnmount, observer } from "mobx-react";
|
import { disposeOnUnmount, observer } from "mobx-react";
|
||||||
import { Redirect, Route, Router, Switch } from "react-router";
|
import { Redirect, Route, Router, Switch } from "react-router";
|
||||||
import { history } from "../navigation";
|
import { history } from "../navigation";
|
||||||
@ -97,13 +97,7 @@ export class App extends React.Component {
|
|||||||
|
|
||||||
await cluster.whenReady; // cluster.activate() is done at this point
|
await cluster.whenReady; // cluster.activate() is done at this point
|
||||||
|
|
||||||
const activeEntityDisposer = reaction(() => catalogEntityRegistry.getById(App.clusterId), (entity) => {
|
catalogEntityRegistry.activeEntity = App.clusterId;
|
||||||
if (!entity) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
catalogEntityRegistry.activeEntity = entity;
|
|
||||||
activeEntityDisposer();
|
|
||||||
}, {fireImmediately: true});
|
|
||||||
|
|
||||||
ExtensionLoader.getInstance().loadOnClusterRenderer();
|
ExtensionLoader.getInstance().loadOnClusterRenderer();
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user