Fix: cluster commands disappeared from Command Palette (#2886)

* Cluster commands disappeared from Command Palette, close #2760

Signed-off-by: Roman <ixrock@gmail.com>

* refactoring: get rid of ClusterStore.active && ClusterStore.activeCluster (managed via catalog's entity)

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman authored and GitHub committed 2021-05-28 14:06:18 +03:00
1 parent d0dbb8744c
commit 643b0d861f
23 files changed
+99 -155

No files matched your search

+10 -12
View File
@@ -19,15 +19,17 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
import { computed, observable, makeObservable } from "mobx";
import { computed, makeObservable, observable } from "mobx";
import { subscribeToBroadcast } from "../../common/ipc";
import { CatalogCategory, CatalogEntity, CatalogEntityData, catalogCategoryRegistry, CatalogCategoryRegistry, CatalogEntityKindData } from "../../common/catalog";
import { CatalogCategory, catalogCategoryRegistry, CatalogCategoryRegistry, CatalogEntity, CatalogEntityData, CatalogEntityKindData } from "../../common/catalog";
import "../../common/catalog-entities";
import { iter } from "../utils";
import type { Cluster } from "../../main/cluster";
import { ClusterStore } from "../../common/cluster-store";
export class CatalogEntityRegistry {
protected rawItems = observable.array<CatalogEntityData & CatalogEntityKindData>([], { deep: true });
@observable protected _activeEntity: CatalogEntity;
protected rawItems = observable.array<CatalogEntityData & CatalogEntityKindData>();
@observable.ref activeEntity?: CatalogEntity;
constructor(private categoryRegistry: CatalogCategoryRegistry) {
makeObservable(this);
@@ -39,14 +41,6 @@ export class CatalogEntityRegistry {
});
}
set activeEntity(entity: CatalogEntity) {
this._activeEntity = entity;
}
get activeEntity() {
return this._activeEntity;
}
@computed get items() {
return Array.from(iter.filterMap(this.rawItems, rawItem => this.categoryRegistry.getEntityForData(rawItem)));
}
@@ -74,3 +68,7 @@ export class CatalogEntityRegistry {
}
export const catalogEntityRegistry = new CatalogEntityRegistry(catalogCategoryRegistry);
export function getActiveClusterEntity(): Cluster | undefined {
return ClusterStore.getInstance().getById(catalogEntityRegistry.activeEntity?.getId());
}
+3 -3
View File
@@ -20,8 +20,8 @@
*/
import { navigate } from "../navigation";
import { commandRegistry } from "../../extensions/registries";
import type { CatalogEntity } from "../../common/catalog";
import type { CatalogEntity } from "../../common/catalog";
import { catalogEntityRegistry } from "./catalog-entity-registry";
export { CatalogCategory, CatalogEntity } from "../../common/catalog";
export type {
@@ -37,6 +37,6 @@ export type {
export const catalogEntityRunContext = {
navigate: (url: string) => navigate(url),
setCommandPaletteContext: (entity?: CatalogEntity) => {
commandRegistry.activeEntity = entity;
catalogEntityRegistry.activeEntity = entity;
}
};