1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

add/remove hotbar actions

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen 2021-03-31 16:02:26 +03:00
parent 4ac0c7c899
commit 813c0df9e7

View File

@ -11,6 +11,7 @@ import { MenuItem, MenuActions } from "../menu";
import { Icon } from "../icon"; import { Icon } from "../icon";
import { CatalogEntityContextMenuContext } from "../../api/catalog-entity-registry"; import { CatalogEntityContextMenuContext } from "../../api/catalog-entity-registry";
import { Badge } from "../badge"; import { Badge } from "../badge";
import { hotbarStore } from "../../../common/hotbar-store";
enum sortBy { enum sortBy {
name = "name", name = "name",
@ -31,6 +32,26 @@ export class LandingPage extends React.Component {
this.disposers.forEach((d) => d()); 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);
}
render() { render() {
if (!this.catalogEntityStore) { if (!this.catalogEntityStore) {
return null; return null;
@ -70,6 +91,12 @@ export class LandingPage extends React.Component {
return ( return (
<MenuActions> <MenuActions>
<MenuItem key="add-to-hotbar" onClick={() => this.addToHotbar(item) }>
<Icon material="add" interactive={true} title="Add to hotbar"/> Add to Hotbar
</MenuItem>
<MenuItem key="remove-from-hotbar" onClick={() => this.removeFromHotbar(item) }>
<Icon material="clear" interactive={true} title="Remove from hotbar"/> Remove from Hotbar
</MenuItem>
{ menuOpenContext.menuItems.map((menuItem) => { { menuOpenContext.menuItems.map((menuItem) => {
return ( return (
<MenuItem key={menuItem.title} onClick={() => menuItem.onClick()}> <MenuItem key={menuItem.title} onClick={() => menuItem.onClick()}>