Fix hotbar migration of workspaces (#3178)

This commit is contained in:
Sebastian Malton authored and GitHub committed 2021-06-25 09:55:25 -04:00
1 parent b9dfd20a93
commit 51655884c7
39 files changed
+333 -446

No files matched your search

@@ -30,6 +30,7 @@ import { CatalogEntityDrawerMenu } from "./catalog-entity-drawer-menu";
import { CatalogEntityDetailRegistry } from "../../../extensions/registries";
import { HotbarIcon } from "../hotbar/hotbar-icon";
import type { CatalogEntityItem } from "./catalog-entity.store";
import { isDevelopment } from "../../../common/vars";
interface Props<T extends CatalogEntity> {
item: CatalogEntityItem<T> | null | undefined;
@@ -91,6 +92,11 @@ export class CatalogEntityDetails<T extends CatalogEntity> extends Component<Pro
<DrawerItem name="Labels">
{...item.getLabelBadges(this.props.hideDetails)}
</DrawerItem>
{isDevelopment && (
<DrawerItem name="Id">
{item.getId()}
</DrawerItem>
)}
</div>
</div>
)}
@@ -61,7 +61,7 @@ describe("Extensions", () => {
ExtensionInstallationStateStore.reset();
UserStore.resetInstance();
await UserStore.createInstance().load();
UserStore.createInstance();
ExtensionDiscovery.resetInstance();
ExtensionDiscovery.createInstance().uninstallExtension = jest.fn(() => Promise.resolve());
@@ -30,10 +30,11 @@ import type { LogTabData } from "../log-tab.store";
import { dockerPod, deploymentPod1 } from "./pod.mock";
import { ThemeStore } from "../../../theme.store";
import { UserStore } from "../../../../common/user-store";
import mockFs from "mock-fs";
jest.mock("electron", () => ({
app: {
getPath: () => "/foo",
getPath: () => "tmp",
},
}));
@@ -71,6 +72,9 @@ const getFewPodsTabData = (): LogTabData => {
describe("<LogResourceSelector />", () => {
beforeEach(() => {
mockFs({
"tmp": {}
});
UserStore.createInstance();
ThemeStore.createInstance();
});
@@ -78,6 +82,7 @@ describe("<LogResourceSelector />", () => {
afterEach(() => {
UserStore.resetInstance();
ThemeStore.resetInstance();
mockFs.restore();
});
it("renders w/o errors", () => {
@@ -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 &quot;Enter&quot; to confirm or &quot;Escape&quot; to cancel)
</small>