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

tweaks to hotbarDisplayLabel()

Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>
This commit is contained in:
Jim Ehrismann 2021-05-14 11:19:22 -04:00
parent 06ca020c61
commit 793da54763
2 changed files with 14 additions and 13 deletions

View File

@ -21,15 +21,16 @@
import { HotbarStore } from "../../../common/hotbar-store";
export function hotbarDisplayLabel(id: string, withName = true) : string {
const hotbarStore = HotbarStore.getInstance();
const index = hotbarStore.hotbarIndex(id) + 1;
if (withName) {
const hotbar = hotbarStore.getById(id);
return `${index}: ${hotbar.name}`;
}
return index.toString();
function hotbarIndex(id: string) {
return HotbarStore.getInstance().hotbarIndex(id) + 1;
}
export function hotbarDisplayLabel(id: string) : string {
const hotbar = HotbarStore.getInstance().getById(id);
return `${hotbarIndex(id)}: ${hotbar.name}`;
}
export function hotbarDisplayIndex(id: string) : string {
return hotbarIndex(id).toString();
}

View File

@ -26,7 +26,7 @@ import { Badge } from "../badge";
import { Hotbar, HotbarStore } from "../../../common/hotbar-store";
import { CommandOverlay } from "../command-palette";
import { HotbarSwitchCommand } from "./hotbar-switch-command";
import { hotbarDisplayLabel } from "./hotbar-display-label";
import { hotbarDisplayIndex } from "./hotbar-display-label";
import { MaterialTooltip } from "../+catalog/material-tooltip/material-tooltip";
interface Props {
@ -44,7 +44,7 @@ export function HotbarSelector({ hotbar }: Props) {
<Badge
id="hotbarIndex"
small
label={hotbarDisplayLabel(store.activeHotbarId, false)}
label={hotbarDisplayIndex(store.activeHotbarId)}
onClick={() => CommandOverlay.open(<HotbarSwitchCommand />)}
/>
</MaterialTooltip>