mirror of
https://github.com/lensapp/lens.git
synced 2024-09-20 13:57:23 +03: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 class CatalogEntityRegistry {
|
||||
@observable.ref activeEntity: CatalogEntity;
|
||||
@observable protected activeEntityId: string | undefined = undefined;
|
||||
protected _entities = observable.map<string, CatalogEntity>([], { deep: true });
|
||||
protected filters = observable.set<EntityFilter>([], {
|
||||
deep: false,
|
||||
@ -46,6 +46,22 @@ export class CatalogEntityRegistry {
|
||||
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() {
|
||||
ipcRendererOn("catalog:items", (event, items: (CatalogEntityData & CatalogEntityKindData)[]) => {
|
||||
this.updateItems(items);
|
||||
|
@ -19,7 +19,7 @@
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
import React from "react";
|
||||
import { observable, makeObservable, reaction } from "mobx";
|
||||
import { observable, makeObservable } from "mobx";
|
||||
import { disposeOnUnmount, observer } from "mobx-react";
|
||||
import { Redirect, Route, Router, Switch } from "react-router";
|
||||
import { history } from "../navigation";
|
||||
@ -97,13 +97,7 @@ export class App extends React.Component {
|
||||
|
||||
await cluster.whenReady; // cluster.activate() is done at this point
|
||||
|
||||
const activeEntityDisposer = reaction(() => catalogEntityRegistry.getById(App.clusterId), (entity) => {
|
||||
if (!entity) {
|
||||
return;
|
||||
}
|
||||
catalogEntityRegistry.activeEntity = entity;
|
||||
activeEntityDisposer();
|
||||
}, {fireImmediately: true});
|
||||
catalogEntityRegistry.activeEntity = App.clusterId;
|
||||
|
||||
ExtensionLoader.getInstance().loadOnClusterRenderer();
|
||||
setTimeout(() => {
|
||||
|
Loading…
Reference in New Issue
Block a user