mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix hotbar migration of workspaces (#3178)
This commit is contained in:
1 parent
b9dfd20a93
commit
51655884c7
39 files changed
+333
-446
No files matched your search
@@ -26,6 +26,14 @@ import React from "react";
|
||||
import { ThemeStore } from "../../../theme.store";
|
||||
import { UserStore } from "../../../../common/user-store";
|
||||
import { Notifications } from "../../notifications";
|
||||
import mockFs from "mock-fs";
|
||||
|
||||
jest.mock("electron", () => ({
|
||||
app: {
|
||||
getPath: () => "tmp",
|
||||
setLoginItemSettings: jest.fn(),
|
||||
},
|
||||
}));
|
||||
|
||||
const mockHotbars: {[id: string]: any} = {
|
||||
"1": {
|
||||
@@ -48,6 +56,9 @@ jest.mock("../../../../common/hotbar-store", () => ({
|
||||
|
||||
describe("<HotbarRemoveCommand />", () => {
|
||||
beforeEach(() => {
|
||||
mockFs({
|
||||
"tmp": {}
|
||||
});
|
||||
UserStore.createInstance();
|
||||
ThemeStore.createInstance();
|
||||
});
|
||||
@@ -55,11 +66,12 @@ describe("<HotbarRemoveCommand />", () => {
|
||||
afterEach(() => {
|
||||
UserStore.resetInstance();
|
||||
ThemeStore.resetInstance();
|
||||
mockFs.restore();
|
||||
});
|
||||
|
||||
it("renders w/o errors", () => {
|
||||
const { container } = render(<HotbarRemoveCommand/>);
|
||||
|
||||
|
||||
expect(container).toBeInstanceOf(HTMLElement);
|
||||
});
|
||||
|
||||
@@ -73,4 +85,3 @@ describe("<HotbarRemoveCommand />", () => {
|
||||
spy.mockRestore();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -33,22 +33,14 @@ const uniqueHotbarName: InputValidator = {
|
||||
|
||||
@observer
|
||||
export class HotbarAddCommand extends React.Component {
|
||||
|
||||
onSubmit(name: string) {
|
||||
onSubmit = (name: string) => {
|
||||
if (!name.trim()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const hotbarStore = HotbarStore.getInstance();
|
||||
|
||||
const hotbar = hotbarStore.add({
|
||||
name
|
||||
});
|
||||
|
||||
hotbarStore.activeHotbarId = hotbar.id;
|
||||
|
||||
HotbarStore.getInstance().add({ name }, { setActive: true });
|
||||
CommandOverlay.close();
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
return (
|
||||
@@ -58,10 +50,11 @@ export class HotbarAddCommand extends React.Component {
|
||||
autoFocus={true}
|
||||
theme="round-black"
|
||||
data-test-id="command-palette-hotbar-add-name"
|
||||
validators={[uniqueHotbarName]}
|
||||
onSubmit={(v) => this.onSubmit(v)}
|
||||
validators={uniqueHotbarName}
|
||||
onSubmit={this.onSubmit}
|
||||
dirty={true}
|
||||
showValidationLine={true} />
|
||||
showValidationLine={true}
|
||||
/>
|
||||
<small className="hint">
|
||||
Please provide a new hotbar name (Press "Enter" to confirm or "Escape" to cancel)
|
||||
</small>
|
||||
|
||||
Reference in new issue
Block a user