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

Release/v5.4.1 (#4969)

* Fix api-manager kubeobject types (#4959)

* loosen api-manager kubeobject types

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* less any

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* less any

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* fix typings

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* fix typings

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* Fix unselect. Add unit tests (#4961)

* Fix unselect. Add unit tests

Signed-off-by: DmitriyNoa <dmytro.zharkov@gmail.com>

* Cleanup

Signed-off-by: DmitriyNoa <dmytro.zharkov@gmail.com>

* Add additional test for undefined

Signed-off-by: DmitriyNoa <dmytro.zharkov@gmail.com>

* quick fix for logs not showing in tabs after first tab (#4964)

* quick fix for logs not showing in tabs after first tab

Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>

* proper fix

Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>

* fix test file for DiContainer reference

Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>

* release v5.4.1

Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>

Co-authored-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
Co-authored-by: Dmitriy Noa <dmytro.zharkov@gmail.com>
This commit is contained in:
Jim Ehrismann 2022-03-04 14:16:11 -05:00 committed by GitHub
parent a04dc2426e
commit 8cf6d51650
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 164 additions and 7 deletions

View File

@ -3,7 +3,7 @@
"productName": "OpenLens",
"description": "OpenLens - Open Source IDE for Kubernetes",
"homepage": "https://github.com/lensapp/lens",
"version": "5.4.0",
"version": "5.4.1",
"main": "static/build/main.js",
"copyright": "© 2021 OpenLens Authors",
"license": "MIT",

View File

@ -32,7 +32,7 @@ export class ApiManager {
return iter.find(this.apis.values(), api => api.kind === kind && api.apiVersionWithGroup === apiVersion);
}
registerApi(apiBase: string, api: KubeApi<KubeObject>) {
registerApi<K extends KubeObject>(apiBase: string, api: KubeApi<K>) {
if (!api.apiBase) return;
if (!this.apis.has(apiBase)) {
@ -46,13 +46,13 @@ export class ApiManager {
}
}
protected resolveApi<K extends KubeObject>(api?: string | KubeApi<K>): KubeApi<K> | undefined {
protected resolveApi(api?: string | KubeApi<KubeObject>): KubeApi<KubeObject> | undefined {
if (!api) {
return undefined;
}
if (typeof api === "string") {
return this.getApi(api) as KubeApi<K>;
return this.getApi(api) as KubeApi<KubeObject>;
}
return api;
@ -69,7 +69,7 @@ export class ApiManager {
}
@action
registerStore(store: KubeObjectStore<KubeObject>, apis: KubeApi<KubeObject>[] = [store.api]) {
registerStore<K extends KubeObject>(store: KubeObjectStore<K>, apis: KubeApi<K>[] = [store.api]) {
apis.filter(Boolean).forEach(api => {
if (api.apiBase) this.stores.set(api.apiBase, store);
});

View File

@ -39,7 +39,7 @@ const NonInjectedLogsDockTab = observer(({ className, tab, model, subscribeStore
model.reloadLogs();
return model.stopLoadingLogs;
}, []);
}, [tab.id]);
useEffect(() => subscribeStores([
podsStore,
], {

View File

@ -0,0 +1,157 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import React from "react";
import "@testing-library/jest-dom/extend-expect";
import { Select } from "./select";
import { UserStore } from "../../../common/user-store";
import { ThemeStore } from "../../theme.store";
import { getDiForUnitTesting } from "../../getDiForUnitTesting";
import type { DependencyInjectionContainer } from "@ogre-tools/injectable";
import { DiRender, renderFor } from "../test-utils/renderFor";
import mockFs from "mock-fs";
import directoryForUserDataInjectable
from "../../../common/app-paths/directory-for-user-data/directory-for-user-data.injectable";
import rendererExtensionsInjectable from "../../../extensions/renderer-extensions.injectable";
import { computed } from "mobx";
import type { LensRendererExtension } from "../../../extensions/lens-renderer-extension";
describe("<Select />", () => {
let di: DependencyInjectionContainer;
let render: DiRender;
beforeEach(async () => {
di = getDiForUnitTesting({ doGeneralOverrides: true });
render = renderFor(di);
mockFs();
await di.runSetups();
di.override(directoryForUserDataInjectable, () => "some-directory-for-user-data");
di.override(rendererExtensionsInjectable, () => computed(() => [] as LensRendererExtension[]));
UserStore.createInstance();
ThemeStore.createInstance();
});
afterEach(() => {
ThemeStore.resetInstance();
UserStore.resetInstance();
mockFs.restore();
});
it("should render the select", async () => {
const options = [
{
label: "Option one label",
value: "optionOneValue",
},
{
label: "Option two label",
value: "optionTwoValue",
},
];
const onChange = jest.fn();
const { container } = render(<Select onChange={onChange} options={options} />);
expect(container).toBeInstanceOf(HTMLElement);
});
it("should show selected option", async () => {
const options = [
{
label: "Option one label",
value: "optionOneValue",
},
{
label: "Option two label",
value: "optionTwoValue",
},
];
const onChange = jest.fn();
const { container } = render(<Select value={options[0].value} onChange={onChange} options={options} />);
const selectedValueContainer = container.querySelector(".Select__single-value");
expect(selectedValueContainer.textContent).toBe(options[0].label);
});
it("should reflect to change value", async () => {
const options = [
{
label: "Option one label",
value: "optionOneValue",
},
{
label: "Option two label",
value: "optionTwoValue",
},
];
const onChange = jest.fn();
const { container, rerender } = render(<Select value={options[0].value} onChange={onChange} options={options} />);
const selectedValueContainer = container.querySelector(".Select__single-value");
expect(selectedValueContainer.textContent).toBe(options[0].label);
rerender(<Select value={options[1].value} onChange={onChange} options={options} />);
expect(container.querySelector(".Select__single-value").textContent).toBe(options[1].label);
});
it("should unselect value if null is passed as a value", async () => {
const options = [
{
label: "Option one label",
value: "optionOneValue",
},
{
label: "Option two label",
value: "optionTwoValue",
},
];
const onChange = jest.fn();
const { container, rerender } = render(<Select value={options[0].value} onChange={onChange} options={options} />);
const selectedValueContainer = container.querySelector(".Select__single-value");
expect(selectedValueContainer.textContent).toBe(options[0].label);
rerender(<Select value={null} onChange={onChange} options={options} />);
expect(container.querySelector(".Select__single-value")).not.toBeInTheDocument();
});
it("should unselect value if undefined is passed as a value", async () => {
const options = [
{
label: "Option one label",
value: "optionOneValue",
},
{
label: "Option two label",
value: "optionTwoValue",
},
];
const onChange = jest.fn();
const { container, rerender } = render(<Select value={options[0].value} onChange={onChange} options={options} />);
const selectedValueContainer = container.querySelector(".Select__single-value");
expect(selectedValueContainer.textContent).toBe(options[0].label);
rerender(<Select value={undefined} onChange={onChange} options={options} />);
expect(container.querySelector(".Select__single-value")).not.toBeInTheDocument();
});
});

View File

@ -78,7 +78,7 @@ export class Select extends React.Component<SelectProps> {
});
}
return this.options.find(opt => opt === value || opt.value === value);
return this.options.find(opt => opt === value || opt.value === value) || null;
}
@computed get options(): SelectOption[] {