mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Move hotbarManagerInjectable to different file
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
f8ae1149fb
commit
3ce9bfe4f9
14 files changed
+396
-340
No files matched your search
@@ -27,10 +27,11 @@ import { AppPaths } from "../../../../common/app-paths";
|
||||
import type { ConfigurableDependencyInjectionContainer } from "@ogre-tools/injectable";
|
||||
import { getDiForUnitTesting } from "../../../getDiForUnitTesting";
|
||||
import { type DiRender, renderFor } from "../../test-utils/renderFor";
|
||||
import hotbarManagerInjectable, { HotbarStore } from "../../../../common/hotbar-store.injectable";
|
||||
import hotbarManagerInjectable from "../../../../common/hotbar-store.injectable";
|
||||
import { UserStore } from "../../../../common/user-store";
|
||||
import { ThemeStore } from "../../../theme.store";
|
||||
import { ConfirmDialog } from "../../confirm-dialog";
|
||||
import type { HotbarStore } from "../../../../common/hotbar-store";
|
||||
|
||||
jest.mock("electron", () => ({
|
||||
app: {
|
||||
|
||||
@@ -21,24 +21,20 @@
|
||||
|
||||
import React from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import hotbarManagerInjectable, { HotbarStore } from "../../../common/hotbar-store.injectable";
|
||||
import { Input, InputValidator } from "../input";
|
||||
import type { CreateHotbarData, CreateHotbarOptions } from "../../../common/hotbar-types";
|
||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||
import commandOverlayInjectable from "../command-palette/command-overlay.injectable";
|
||||
|
||||
export const uniqueHotbarName: InputValidator = {
|
||||
condition: ({ required }) => required,
|
||||
message: () => "Hotbar with this name already exists",
|
||||
validate: value => !HotbarStore.getInstance().getByName(value),
|
||||
};
|
||||
import hotbarManagerInjectable from "../../../common/hotbar-store.injectable";
|
||||
import uniqueHotbarNameInjectable from "../input/validators/unique-hotbar-name.injectable";
|
||||
|
||||
interface Dependencies {
|
||||
closeCommandOverlay: () => void;
|
||||
addHotbar: (data: CreateHotbarData, { setActive }?: CreateHotbarOptions) => void;
|
||||
uniqueHotbarName: InputValidator;
|
||||
}
|
||||
|
||||
const NonInjectedHotbarAddCommand = observer(({ closeCommandOverlay, addHotbar }: Dependencies) => {
|
||||
const NonInjectedHotbarAddCommand = observer(({ closeCommandOverlay, addHotbar, uniqueHotbarName }: Dependencies) => {
|
||||
const onSubmit = (name: string) => {
|
||||
if (!name.trim()) {
|
||||
return;
|
||||
@@ -71,6 +67,7 @@ export const HotbarAddCommand = withInjectables<Dependencies>(NonInjectedHotbarA
|
||||
getProps: (di, props) => ({
|
||||
closeCommandOverlay: di.inject(commandOverlayInjectable).close,
|
||||
addHotbar: di.inject(hotbarManagerInjectable).add,
|
||||
uniqueHotbarName: di.inject(uniqueHotbarNameInjectable),
|
||||
...props,
|
||||
}),
|
||||
});
|
||||
@@ -26,7 +26,7 @@ import { observer } from "mobx-react";
|
||||
import { HotbarEntityIcon } from "./hotbar-entity-icon";
|
||||
import { cssNames, IClassName } from "../../utils";
|
||||
import { catalogEntityRegistry } from "../../api/catalog-entity-registry";
|
||||
import { HotbarStore } from "../../../common/hotbar-store.injectable";
|
||||
import { HotbarStore } from "../../../common/hotbar-store";
|
||||
import type { CatalogEntity } from "../../api/catalog-entity";
|
||||
import { DragDropContext, Draggable, Droppable, DropResult } from "react-beautiful-dnd";
|
||||
import { HotbarSelector } from "./hotbar-selector";
|
||||
|
||||
@@ -23,11 +23,11 @@ import React, { useState } from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import { Select } from "../select";
|
||||
import hotbarManagerInjectable from "../../../common/hotbar-store.injectable";
|
||||
import { Input } from "../input";
|
||||
import { uniqueHotbarName } from "./hotbar-add-command";
|
||||
import { Input, InputValidator } from "../input";
|
||||
import type { Hotbar } from "../../../common/hotbar-types";
|
||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||
import commandOverlayInjectable from "../command-palette/command-overlay.injectable";
|
||||
import uniqueHotbarNameInjectable from "../input/validators/unique-hotbar-name.injectable";
|
||||
|
||||
interface Dependencies {
|
||||
closeCommandOverlay: () => void;
|
||||
@@ -37,9 +37,10 @@ interface Dependencies {
|
||||
setHotbarName: (id: string, name: string) => void;
|
||||
getDisplayLabel: (hotbar: Hotbar) => string;
|
||||
};
|
||||
uniqueHotbarName: InputValidator;
|
||||
}
|
||||
|
||||
const NonInjectedHotbarRenameCommand = observer(({ closeCommandOverlay, hotbarManager }: Dependencies) => {
|
||||
const NonInjectedHotbarRenameCommand = observer(({ closeCommandOverlay, hotbarManager, uniqueHotbarName }: Dependencies) => {
|
||||
const [hotbarId, setHotbarId] = useState("");
|
||||
const [hotbarName, setHotbarName] = useState("");
|
||||
|
||||
@@ -100,6 +101,7 @@ export const HotbarRenameCommand = withInjectables<Dependencies>(NonInjectedHotb
|
||||
getProps: (di, props) => ({
|
||||
closeCommandOverlay: di.inject(commandOverlayInjectable).close,
|
||||
hotbarManager: di.inject(hotbarManagerInjectable),
|
||||
uniqueHotbarName: di.inject(uniqueHotbarNameInjectable),
|
||||
...props,
|
||||
}),
|
||||
});
|
||||
Reference in new issue
Block a user