Persist apiVersion when editing resources in monaco (#4406)

* Persist apiVersion when editing resources in monaco

- Use a new custom k8slens prefixed label

- Means that users aren't surprised when they use lens to update a
  resource to a new apiVersionWithGroup

- Doesn't touch the versions in the stores

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Fix lint

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* fix: Fix lint issues

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* chore: make lint not bail on failure

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* chore: Run lint:fix on all files

Signed-off-by: Sebastian Malton <sebastian@malton.name>

---------

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton authored and GitHub committed 2023-04-05 10:56:23 -04:00
1 parent 058494bc73
commit 807f98ed1b
57 files changed
+295 -400

No files matched your search

@@ -3,7 +3,4 @@ export {
computedChannelObserverInjectionToken,
} from "./src/computed-channel/computed-channel.injectable";
export type {
ChannelObserver,
ComputedChannelFactory,
} from "./src/computed-channel/computed-channel.injectable";
export type { ChannelObserver, ComputedChannelFactory } from "./src/computed-channel/computed-channel.injectable";
@@ -1,23 +1,13 @@
import { getInjectable, getInjectionToken } from "@ogre-tools/injectable";
import {
computed,
IComputedValue,
observable,
onBecomeObserved,
onBecomeUnobserved,
runInAction,
} from "mobx";
import { computed, IComputedValue, observable, onBecomeObserved, onBecomeUnobserved, runInAction } from "mobx";
import type { MessageChannel } from "@k8slens/messaging";
import { getMessageChannelListenerInjectable } from "@k8slens/messaging";
import { sendMessageToChannelInjectionToken } from "@k8slens/messaging";
import { computedChannelAdministrationChannel } from "./computed-channel-administration-channel.injectable";
export type ComputedChannelFactory = <T>(
channel: MessageChannel<T>,
pendingValue: T,
) => IComputedValue<T>;
export type ComputedChannelFactory = <T>(channel: MessageChannel<T>, pendingValue: T) => IComputedValue<T>;
export const computedChannelInjectionToken = getInjectionToken<ComputedChannelFactory>({
id: "computed-channel-injection-token",
@@ -3,23 +3,13 @@ import { act } from "@testing-library/react";
import { createContainer, DiContainer, getInjectable } from "@ogre-tools/injectable";
import { getMessageBridgeFake, MessageBridgeFake } from "@k8slens/messaging-fake-bridge";
import { startApplicationInjectionToken } from "@k8slens/application";
import {
computed,
IComputedValue,
IObservableValue,
observable,
reaction,
runInAction,
} from "mobx";
import { computed, IComputedValue, IObservableValue, observable, reaction, runInAction } from "mobx";
import type { MessageChannel } from "@k8slens/messaging";
import { getMessageChannelListenerInjectable } from "@k8slens/messaging";
import { registerMobX } from "@ogre-tools/injectable-extension-for-mobx";
import { registerFeature } from "@k8slens/feature-core";
import { testUtils } from "@k8slens/messaging";
import {
computedChannelInjectionToken,
computedChannelObserverInjectionToken,
} from "./computed-channel.injectable";
import { computedChannelInjectionToken, computedChannelObserverInjectionToken } from "./computed-channel.injectable";
import { runWithThrownMobxReactions, renderFor } from "@k8slens/test-utils";
import { observer } from "mobx-react";
import {
@@ -36,9 +26,7 @@ const TestComponent = observer(({ someComputed }: { someComputed: IComputedValue
));
[{ scenarioIsAsync: true }, { scenarioIsAsync: false }].forEach(({ scenarioIsAsync }) =>
describe(`computed-channel, given running message bridge fake as ${
scenarioIsAsync ? "async" : "sync"
}`, () => {
describe(`computed-channel, given running message bridge fake as ${scenarioIsAsync ? "async" : "sync"}`, () => {
describe("given multiple dis and a message channel and a channel observer and application has started", () => {
let di1: DiContainer;
let di2: DiContainer;
@@ -87,10 +75,7 @@ const TestComponent = observer(({ someComputed }: { someComputed: IComputedValue
messageBridgeFake.setAsync(scenarioIsAsync);
messageBridgeFake.involve(di1, di2);
await Promise.all([
di1.inject(startApplicationInjectionToken)(),
di2.inject(startApplicationInjectionToken)(),
]);
await Promise.all([di1.inject(startApplicationInjectionToken)(), di2.inject(startApplicationInjectionToken)()]);
});
describe("given a channel observer and matching computed channel for the channel in di-2", () => {
@@ -175,9 +160,7 @@ const TestComponent = observer(({ someComputed }: { someComputed: IComputedValue
expect(observedValue).toBe("some-pending-value");
});
const scenarioName = scenarioIsAsync
? "when admin messages are propagated"
: "immediately";
const scenarioName = scenarioIsAsync ? "when admin messages are propagated" : "immediately";
// eslint-disable-next-line jest/valid-title
describe(scenarioName, () => {
@@ -196,9 +179,7 @@ const TestComponent = observer(({ someComputed }: { someComputed: IComputedValue
});
});
const scenarioName = scenarioIsAsync
? "when returning value-messages propagate"
: "immediately";
const scenarioName = scenarioIsAsync ? "when returning value-messages propagate" : "immediately";
// eslint-disable-next-line jest/valid-title
describe(scenarioName, () => {
@@ -227,9 +208,7 @@ const TestComponent = observer(({ someComputed }: { someComputed: IComputedValue
});
});
const scenarioName = scenarioIsAsync
? "when value-messages propagate"
: "immediately";
const scenarioName = scenarioIsAsync ? "when value-messages propagate" : "immediately";
// eslint-disable-next-line jest/valid-title
describe(scenarioName, () => {
@@ -258,9 +237,7 @@ const TestComponent = observer(({ someComputed }: { someComputed: IComputedValue
stopObserving();
});
const scenarioName = scenarioIsAsync
? "when admin-messages propagate"
: "immediately";
const scenarioName = scenarioIsAsync ? "when admin-messages propagate" : "immediately";
// eslint-disable-next-line jest/valid-title
describe(scenarioName, () => {
@@ -317,9 +294,7 @@ const TestComponent = observer(({ someComputed }: { someComputed: IComputedValue
expect(observedValue).toBe("some-pending-value");
});
const scenarioName = scenarioIsAsync
? "when admin messages propagate"
: "immediately";
const scenarioName = scenarioIsAsync ? "when admin messages propagate" : "immediately";
// eslint-disable-next-line jest/valid-title
describe(scenarioName, () => {
@@ -345,9 +320,7 @@ const TestComponent = observer(({ someComputed }: { someComputed: IComputedValue
expect(observedValue).toBe("some-pending-value");
});
const scenarioTitle = scenarioIsAsync
? "when value-messages propagate back"
: "immediately";
const scenarioTitle = scenarioIsAsync ? "when value-messages propagate back" : "immediately";
// eslint-disable-next-line jest/valid-title
describe(scenarioTitle, () => {
@@ -466,9 +439,7 @@ const TestComponent = observer(({ someComputed }: { someComputed: IComputedValue
expect(nonReactiveValue).toBe("some-initial-value");
});
const scenarioName = scenarioIsAsync
? "when messages would be propagated"
: "immediately";
const scenarioName = scenarioIsAsync ? "when messages would be propagated" : "immediately";
// eslint-disable-next-line jest/valid-title
describe(scenarioName, () => {