import "./catalog.scss"; import React from "react"; import { observer } from "mobx-react"; import { ItemListLayout } from "../item-object-list"; import { IReactionDisposer, observable } from "mobx"; import { CatalogEntityItem, CatalogEntityStore } from "./catalog-entity.store"; import { navigate } from "../../navigation"; import { kebabCase } from "lodash"; import { PageLayout } from "../layout/page-layout"; import { MenuItem, MenuActions } from "../menu"; import { Icon } from "../icon"; import { CatalogEntityContextMenuContext } from "../../api/catalog-entity-registry"; import { Badge } from "../badge"; import { hotbarStore } from "../../../common/hotbar-store"; import { addClusterURL } from "../+add-cluster"; import { autobind } from "../../utils"; import { Notifications } from "../notifications"; enum sortBy { name = "name", source = "source", status = "status" } @observer export class Catalog extends React.Component { @observable private catalogEntityStore?: CatalogEntityStore; @observable.deep private contextMenu: CatalogEntityContextMenuContext; private disposers: IReactionDisposer[] = []; componentDidMount() { this.contextMenu = { menuItems: [], navigate: (url: string) => navigate(url) }; this.catalogEntityStore = new CatalogEntityStore(); this.disposers.push(this.catalogEntityStore.watch()); if (this.catalogEntityStore.items.length === 0) { Notifications.info(<>Welcome!
Get started by associating one or more clusters to Lens
>, { timeout: 30_000, id: "catalog-welcome" }); } } componentWillUnmount() { this.disposers.forEach((d) => d()); } addToHotbar(item: CatalogEntityItem) { const hotbar = hotbarStore.getByName("default"); // FIXME if (!hotbar) { return; } hotbar.items.push({ entity: { uid: item.id }}); } removeFromHotbar(item: CatalogEntityItem) { const hotbar = hotbarStore.getByName("default"); // FIXME if (!hotbar) { return; } hotbar.items = hotbar.items.filter((i) => i.entity.uid !== item.id); } @autobind() renderItemMenu(item: CatalogEntityItem) { const onOpen = async () => { await item.onContextMenuOpen(this.contextMenu); }; return (