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
|
@observer
|
||||||
export class HotbarEntityIcon extends React.Component<Props> {
|
export class HotbarEntityIcon extends React.Component<Props> {
|
||||||
@observable private contextMenu: CatalogEntityContextMenuContext;
|
@observable private contextMenu: CatalogEntityContextMenuContext = {
|
||||||
|
menuItems: [],
|
||||||
|
navigate: (url: string) => navigate(url),
|
||||||
|
};
|
||||||
|
|
||||||
constructor(props: Props) {
|
constructor(props: Props) {
|
||||||
super(props);
|
super(props);
|
||||||
makeObservable(this);
|
makeObservable(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
this.contextMenu = {
|
|
||||||
menuItems: [],
|
|
||||||
navigate: (url: string) => navigate(url),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
get kindIcon() {
|
get kindIcon() {
|
||||||
const className = "badge";
|
const className = "badge";
|
||||||
const category = catalogCategoryRegistry.getCategoryForEntity(this.props.entity);
|
const category = catalogCategoryRegistry.getCategoryForEntity(this.props.entity);
|
||||||
|
|||||||
@ -42,6 +42,8 @@ import * as routes from "../../../common/routes";
|
|||||||
import { Config } from "../+config";
|
import { Config } from "../+config";
|
||||||
import { catalogEntityRegistry } from "../../api/catalog-entity-registry";
|
import { catalogEntityRegistry } from "../../api/catalog-entity-registry";
|
||||||
import { HotbarIcon } from "../hotbar/hotbar-icon";
|
import { HotbarIcon } from "../hotbar/hotbar-icon";
|
||||||
|
import { observable } from "mobx";
|
||||||
|
import type { CatalogEntityContextMenuContext } from "../../../common/catalog";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
className?: string;
|
className?: string;
|
||||||
@ -50,6 +52,10 @@ interface Props {
|
|||||||
@observer
|
@observer
|
||||||
export class Sidebar extends React.Component<Props> {
|
export class Sidebar extends React.Component<Props> {
|
||||||
static displayName = "Sidebar";
|
static displayName = "Sidebar";
|
||||||
|
@observable private contextMenu: CatalogEntityContextMenuContext = {
|
||||||
|
menuItems: [],
|
||||||
|
navigate: (url: string) => navigate(url),
|
||||||
|
};
|
||||||
|
|
||||||
async componentDidMount() {
|
async componentDidMount() {
|
||||||
crdStore.reloadAll();
|
crdStore.reloadAll();
|
||||||
@ -194,6 +200,8 @@ export class Sidebar extends React.Component<Props> {
|
|||||||
src={spec.icon?.src}
|
src={spec.icon?.src}
|
||||||
className="mr-5"
|
className="mr-5"
|
||||||
onClick={() => navigate("/")}
|
onClick={() => navigate("/")}
|
||||||
|
menuItems={this.contextMenu.menuItems}
|
||||||
|
onMenuOpen={() => this.clusterEntity.onContextMenuOpen(this.contextMenu)}
|
||||||
/>
|
/>
|
||||||
<div className={styles.clusterName}>
|
<div className={styles.clusterName}>
|
||||||
{metadata.name}
|
{metadata.name}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user