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

fix bad merge

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen 2021-04-22 07:25:57 +03:00
parent 56f5d2ede0
commit bb87e6cd5a
6 changed files with 17 additions and 9 deletions

View File

@ -24,6 +24,8 @@ describe("HotbarStore", () => {
describe("add", () => {
it("adds a hotbar", () => {
const hotbarStore = HotbarStore.getInstanceOrCreate();
hotbarStore.add({ name: "hottest" });
expect(hotbarStore.hotbars.length).toEqual(2);
});

View File

@ -116,6 +116,7 @@ export class HotbarStore extends BaseStore<HotbarStoreModel> {
}
switchToPrevious() {
const hotbarStore = HotbarStore.getInstance();
let index = hotbarStore.activeHotbarIndex - 1;
if (index < 0) {
@ -126,6 +127,7 @@ export class HotbarStore extends BaseStore<HotbarStoreModel> {
}
switchToNext() {
const hotbarStore = HotbarStore.getInstance();
let index = hotbarStore.activeHotbarIndex + 1;
if (index >= hotbarStore.hotbars.length) {

View File

@ -1,13 +1,13 @@
import React from "react";
import { observer } from "mobx-react";
import { hotbarStore } from "../../../common/hotbar-store";
import { HotbarStore } from "../../../common/hotbar-store";
import { CommandOverlay } from "../command-palette";
import { Input, InputValidator } from "../input";
const uniqueHotbarName: InputValidator = {
condition: ({ required }) => required,
message: () => "Hotbar with this name already exists",
validate: value => !hotbarStore.getByName(value),
validate: value => !HotbarStore.getInstance().getByName(value),
};
@observer
@ -18,6 +18,8 @@ export class HotbarAddCommand extends React.Component {
return;
}
const hotbarStore = HotbarStore.getInstance();
const hotbar = hotbarStore.add({
name
});

View File

@ -30,11 +30,11 @@ export class HotbarMenu extends React.Component<Props> {
}
previous() {
hotbarStore.switchToPrevious();
HotbarStore.getInstance().switchToPrevious();
}
next() {
hotbarStore.switchToNext();
HotbarStore.getInstance().switchToNext();
}
openSelector() {
@ -43,7 +43,7 @@ export class HotbarMenu extends React.Component<Props> {
render() {
const { className } = this.props;
const hotbarIndex = hotbarStore.activeHotbarIndex + 1;
const hotbarIndex = HotbarStore.getInstance().activeHotbarIndex + 1;
return (
<div className={cssNames("HotbarMenu flex column", className)}>

View File

@ -2,19 +2,20 @@ import React from "react";
import { observer } from "mobx-react";
import { Select } from "../select";
import { computed } from "mobx";
import { hotbarStore } from "../../../common/hotbar-store";
import { HotbarStore } from "../../../common/hotbar-store";
import { CommandOverlay } from "../command-palette";
import { ConfirmDialog } from "../confirm-dialog";
@observer
export class HotbarRemoveCommand extends React.Component {
@computed get options() {
return hotbarStore.hotbars.map((hotbar) => {
return HotbarStore.getInstance().hotbars.map((hotbar) => {
return { value: hotbar.id, label: hotbar.name };
});
}
onChange(id: string): void {
const hotbarStore = HotbarStore.getInstance();
const hotbar = hotbarStore.getById(id);
if (!hotbar) {

View File

@ -2,7 +2,7 @@ import React from "react";
import { observer } from "mobx-react";
import { Select } from "../select";
import { computed } from "mobx";
import { hotbarStore } from "../../../common/hotbar-store";
import { HotbarStore } from "../../../common/hotbar-store";
import { CommandOverlay } from "../command-palette";
import { HotbarAddCommand } from "./hotbar-add-command";
import { HotbarRemoveCommand } from "./hotbar-remove-command";
@ -13,6 +13,7 @@ export class HotbarSwitchCommand extends React.Component {
private static removeActionId = "__remove__";
@computed get options() {
const hotbarStore = HotbarStore.getInstance();
const options = hotbarStore.hotbars.map((hotbar) => {
return { value: hotbar.id, label: hotbar.name };
});
@ -37,7 +38,7 @@ export class HotbarSwitchCommand extends React.Component {
return;
default:
hotbarStore.activeHotbarId = idOrAction;
HotbarStore.getInstance().activeHotbarId = idOrAction;
CommandOverlay.close();
}
}