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:
parent
56f5d2ede0
commit
bb87e6cd5a
@ -24,6 +24,8 @@ describe("HotbarStore", () => {
|
|||||||
|
|
||||||
describe("add", () => {
|
describe("add", () => {
|
||||||
it("adds a hotbar", () => {
|
it("adds a hotbar", () => {
|
||||||
|
const hotbarStore = HotbarStore.getInstanceOrCreate();
|
||||||
|
|
||||||
hotbarStore.add({ name: "hottest" });
|
hotbarStore.add({ name: "hottest" });
|
||||||
expect(hotbarStore.hotbars.length).toEqual(2);
|
expect(hotbarStore.hotbars.length).toEqual(2);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -116,6 +116,7 @@ export class HotbarStore extends BaseStore<HotbarStoreModel> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switchToPrevious() {
|
switchToPrevious() {
|
||||||
|
const hotbarStore = HotbarStore.getInstance();
|
||||||
let index = hotbarStore.activeHotbarIndex - 1;
|
let index = hotbarStore.activeHotbarIndex - 1;
|
||||||
|
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
@ -126,6 +127,7 @@ export class HotbarStore extends BaseStore<HotbarStoreModel> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switchToNext() {
|
switchToNext() {
|
||||||
|
const hotbarStore = HotbarStore.getInstance();
|
||||||
let index = hotbarStore.activeHotbarIndex + 1;
|
let index = hotbarStore.activeHotbarIndex + 1;
|
||||||
|
|
||||||
if (index >= hotbarStore.hotbars.length) {
|
if (index >= hotbarStore.hotbars.length) {
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
import { hotbarStore } from "../../../common/hotbar-store";
|
import { HotbarStore } from "../../../common/hotbar-store";
|
||||||
import { CommandOverlay } from "../command-palette";
|
import { CommandOverlay } from "../command-palette";
|
||||||
import { Input, InputValidator } from "../input";
|
import { Input, InputValidator } from "../input";
|
||||||
|
|
||||||
const uniqueHotbarName: InputValidator = {
|
const uniqueHotbarName: InputValidator = {
|
||||||
condition: ({ required }) => required,
|
condition: ({ required }) => required,
|
||||||
message: () => "Hotbar with this name already exists",
|
message: () => "Hotbar with this name already exists",
|
||||||
validate: value => !hotbarStore.getByName(value),
|
validate: value => !HotbarStore.getInstance().getByName(value),
|
||||||
};
|
};
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
@ -18,6 +18,8 @@ export class HotbarAddCommand extends React.Component {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const hotbarStore = HotbarStore.getInstance();
|
||||||
|
|
||||||
const hotbar = hotbarStore.add({
|
const hotbar = hotbarStore.add({
|
||||||
name
|
name
|
||||||
});
|
});
|
||||||
|
|||||||
@ -30,11 +30,11 @@ export class HotbarMenu extends React.Component<Props> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
previous() {
|
previous() {
|
||||||
hotbarStore.switchToPrevious();
|
HotbarStore.getInstance().switchToPrevious();
|
||||||
}
|
}
|
||||||
|
|
||||||
next() {
|
next() {
|
||||||
hotbarStore.switchToNext();
|
HotbarStore.getInstance().switchToNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
openSelector() {
|
openSelector() {
|
||||||
@ -43,7 +43,7 @@ export class HotbarMenu extends React.Component<Props> {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { className } = this.props;
|
const { className } = this.props;
|
||||||
const hotbarIndex = hotbarStore.activeHotbarIndex + 1;
|
const hotbarIndex = HotbarStore.getInstance().activeHotbarIndex + 1;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={cssNames("HotbarMenu flex column", className)}>
|
<div className={cssNames("HotbarMenu flex column", className)}>
|
||||||
|
|||||||
@ -2,19 +2,20 @@ import React from "react";
|
|||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
import { Select } from "../select";
|
import { Select } from "../select";
|
||||||
import { computed } from "mobx";
|
import { computed } from "mobx";
|
||||||
import { hotbarStore } from "../../../common/hotbar-store";
|
import { HotbarStore } from "../../../common/hotbar-store";
|
||||||
import { CommandOverlay } from "../command-palette";
|
import { CommandOverlay } from "../command-palette";
|
||||||
import { ConfirmDialog } from "../confirm-dialog";
|
import { ConfirmDialog } from "../confirm-dialog";
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
export class HotbarRemoveCommand extends React.Component {
|
export class HotbarRemoveCommand extends React.Component {
|
||||||
@computed get options() {
|
@computed get options() {
|
||||||
return hotbarStore.hotbars.map((hotbar) => {
|
return HotbarStore.getInstance().hotbars.map((hotbar) => {
|
||||||
return { value: hotbar.id, label: hotbar.name };
|
return { value: hotbar.id, label: hotbar.name };
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onChange(id: string): void {
|
onChange(id: string): void {
|
||||||
|
const hotbarStore = HotbarStore.getInstance();
|
||||||
const hotbar = hotbarStore.getById(id);
|
const hotbar = hotbarStore.getById(id);
|
||||||
|
|
||||||
if (!hotbar) {
|
if (!hotbar) {
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import React from "react";
|
|||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
import { Select } from "../select";
|
import { Select } from "../select";
|
||||||
import { computed } from "mobx";
|
import { computed } from "mobx";
|
||||||
import { hotbarStore } from "../../../common/hotbar-store";
|
import { HotbarStore } from "../../../common/hotbar-store";
|
||||||
import { CommandOverlay } from "../command-palette";
|
import { CommandOverlay } from "../command-palette";
|
||||||
import { HotbarAddCommand } from "./hotbar-add-command";
|
import { HotbarAddCommand } from "./hotbar-add-command";
|
||||||
import { HotbarRemoveCommand } from "./hotbar-remove-command";
|
import { HotbarRemoveCommand } from "./hotbar-remove-command";
|
||||||
@ -13,6 +13,7 @@ export class HotbarSwitchCommand extends React.Component {
|
|||||||
private static removeActionId = "__remove__";
|
private static removeActionId = "__remove__";
|
||||||
|
|
||||||
@computed get options() {
|
@computed get options() {
|
||||||
|
const hotbarStore = HotbarStore.getInstance();
|
||||||
const options = hotbarStore.hotbars.map((hotbar) => {
|
const options = hotbarStore.hotbars.map((hotbar) => {
|
||||||
return { value: hotbar.id, label: hotbar.name };
|
return { value: hotbar.id, label: hotbar.name };
|
||||||
});
|
});
|
||||||
@ -37,7 +38,7 @@ export class HotbarSwitchCommand extends React.Component {
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
hotbarStore.activeHotbarId = idOrAction;
|
HotbarStore.getInstance().activeHotbarId = idOrAction;
|
||||||
CommandOverlay.close();
|
CommandOverlay.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user