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

Make component transient

Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com>
Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
Janne Savolainen 2021-11-29 08:10:35 +02:00
parent 1707a95eef
commit 667e90ba0e
3 changed files with 58 additions and 6 deletions

View File

@ -18,7 +18,7 @@ exports[`kube-object-menu given kube object renders 1`] = `
>
<i
class="Icon material interactive focusable"
id="tooltip_target_4"
id="tooltip_target_6"
tabindex="0"
>
<span
@ -68,7 +68,7 @@ exports[`kube-object-menu given kube object when removing kube object renders 1`
>
<i
class="Icon material interactive focusable"
id="tooltip_target_8"
id="tooltip_target_10"
tabindex="0"
>
<span
@ -171,7 +171,7 @@ exports[`kube-object-menu given kube object with namespace when removing kube ob
>
<i
class="Icon material interactive focusable"
id="tooltip_target_33"
id="tooltip_target_35"
tabindex="0"
>
<span
@ -274,7 +274,7 @@ exports[`kube-object-menu given kube object without namespace when removing kube
>
<i
class="Icon material interactive focusable"
id="tooltip_target_41"
id="tooltip_target_43"
tabindex="0"
>
<span
@ -369,3 +369,23 @@ exports[`kube-object-menu given no kube object, renders 1`] = `
</div>
</body>
`;
exports[`kube-object-menu given rendered multiple times, renders separate instances 1`] = `
<body>
<div>
<ul
class="Animate opacity Menu MenuActions flex KubeObjectMenu toolbar gaps right bottom"
style="--enter-duration: 100ms; --leave-duration: 100ms;"
/>
<ul
class="Animate opacity Menu MenuActions flex KubeObjectMenu toolbar gaps right bottom"
style="--enter-duration: 100ms; --leave-duration: 100ms;"
>
<li>
Some menu item
</li>
</ul>
,
</div>
</body>
`;

View File

@ -28,7 +28,7 @@ import {
} from "./kube-object-menu";
import type { KubeObject } from "../../../common/k8s-api/kube-object";
import type { Injectable } from "@ogre-tools/injectable";
import { lifecycleEnum, Injectable } from "@ogre-tools/injectable";
import apiManagerInjectable from "./dependencies/apiManager.injectable";
import clusterNameInjectable from "./dependencies/clusterName.injectable";
import kubeObjectMenuRegistryInjectable from "./dependencies/kubeObjectMenuRegistry.injectable";
@ -49,8 +49,10 @@ const KubeObjectMenuInjectable: Injectable<
}),
instantiate: (dependencies, props) => (
<KubeObjectMenu<KubeObject> {...dependencies} {...props} />
<KubeObjectMenu {...dependencies} {...props} />
),
lifecycle: lifecycleEnum.transient,
};
export default KubeObjectMenuInjectable;

View File

@ -110,6 +110,36 @@ describe("kube-object-menu", () => {
}).not.toThrow();
});
it("given rendered multiple times, renders separate instances", () => {
di.override(clusterInjectable, null);
const { baseElement } = render(
<>
<Inject
injectableKey={KubeObjectMenuInjectable}
toolbar={true}
object={null} />
<Inject
injectableKey={KubeObjectMenuInjectable}
toolbar={true}
object={KubeObject.create({
apiVersion: "some-api-version",
kind: "some-kind",
metadata: {
uid: "some-uid",
name: "some-other-name",
resourceVersion: "some-resource-version",
namespace: "some-namespace",
},
})}
/>,
</>,
);
expect(baseElement).toMatchSnapshot();
});
it("given no kube object, renders", () => {
objectStub = null;