mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Add context menu into sidebar
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
6d003515e7
commit
0d0e8824f8
@ -44,20 +44,16 @@ interface Props extends DOMAttributes<HTMLElement> {
|
||||
|
||||
@observer
|
||||
export class HotbarEntityIcon extends React.Component<Props> {
|
||||
@observable private contextMenu: CatalogEntityContextMenuContext;
|
||||
@observable private contextMenu: CatalogEntityContextMenuContext = {
|
||||
menuItems: [],
|
||||
navigate: (url: string) => navigate(url),
|
||||
};
|
||||
|
||||
constructor(props: Props) {
|
||||
super(props);
|
||||
makeObservable(this);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.contextMenu = {
|
||||
menuItems: [],
|
||||
navigate: (url: string) => navigate(url),
|
||||
};
|
||||
}
|
||||
|
||||
get kindIcon() {
|
||||
const className = "badge";
|
||||
const category = catalogCategoryRegistry.getCategoryForEntity(this.props.entity);
|
||||
|
||||
@ -42,6 +42,8 @@ import * as routes from "../../../common/routes";
|
||||
import { Config } from "../+config";
|
||||
import { catalogEntityRegistry } from "../../api/catalog-entity-registry";
|
||||
import { HotbarIcon } from "../hotbar/hotbar-icon";
|
||||
import { observable } from "mobx";
|
||||
import type { CatalogEntityContextMenuContext } from "../../../common/catalog";
|
||||
|
||||
interface Props {
|
||||
className?: string;
|
||||
@ -50,6 +52,10 @@ interface Props {
|
||||
@observer
|
||||
export class Sidebar extends React.Component<Props> {
|
||||
static displayName = "Sidebar";
|
||||
@observable private contextMenu: CatalogEntityContextMenuContext = {
|
||||
menuItems: [],
|
||||
navigate: (url: string) => navigate(url),
|
||||
};
|
||||
|
||||
async componentDidMount() {
|
||||
crdStore.reloadAll();
|
||||
@ -194,6 +200,8 @@ export class Sidebar extends React.Component<Props> {
|
||||
src={spec.icon?.src}
|
||||
className="mr-5"
|
||||
onClick={() => navigate("/")}
|
||||
menuItems={this.contextMenu.menuItems}
|
||||
onMenuOpen={() => this.clusterEntity.onContextMenuOpen(this.contextMenu)}
|
||||
/>
|
||||
<div className={styles.clusterName}>
|
||||
{metadata.name}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user