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

@@ -2,9 +2,7 @@ import type { DiContainer } from "@ogre-tools/injectable";
import type { Feature } from "./feature";
import { featureContextMapInjectable } from "./feature-context-map-injectable";
const getDependingFeaturesFor = (
featureContextMap: Map<Feature, { dependedBy: Map<Feature, number> }>,
) => {
const getDependingFeaturesFor = (featureContextMap: Map<Feature, { dependedBy: Map<Feature, number> }>) => {
const getDependingFeaturesForRecursion = (feature: Feature, atRoot = true): string[] => {
const context = featureContextMap.get(feature);
@@ -36,11 +34,9 @@ const deregisterFeatureRecursed = (di: DiContainer, feature: Feature, dependedBy
const dependingFeatures = getDependingFeatures(feature);
if (!dependedBy && dependingFeatures.length) {
throw new Error(
`Tried to deregister Feature "${
feature.id
}", but it is the dependency of Features "${dependingFeatures.join(", ")}"`,
);
const names = dependingFeatures.join(", ");
throw new Error(`Tried to deregister Feature "${feature.id}", but it is the dependency of Features "${names}"`);
}
if (dependedBy) {
@@ -59,9 +59,7 @@ describe("feature-dependencies", () => {
expect(() => {
deregisterFeature(di, someDependencyFeature);
}).toThrow(
'Tried to deregister feature "some-dependency-feature", but it was not registered.',
);
}).toThrow('Tried to deregister feature "some-dependency-feature", but it was not registered.');
});
it("given the parent Feature is deregistered, when injecting an injectable from the dependency Feature, throws", () => {
@@ -104,9 +102,7 @@ describe("feature-dependencies", () => {
it("when the first Feature is deregistered, throws", () => {
expect(() => {
deregisterFeature(di, someFeature1);
}).toThrow(
'Tried to deregister Feature "some-feature-1", but it is the dependency of Features "some-feature-2"',
);
}).toThrow('Tried to deregister Feature "some-feature-1", but it is the dependency of Features "some-feature-2"');
});
it("given the second Feature is deregistered, when injecting an injectable from the first Feature, still does so", () => {
@@ -180,9 +176,7 @@ describe("feature-dependencies", () => {
expect(() => {
di.inject(someInjectableInDependencyFeature);
}).toThrow(
'Tried to inject non-registered injectable "irrelevant" -> "some-injectable-in-dependency-feature".',
);
}).toThrow('Tried to inject non-registered injectable "irrelevant" -> "some-injectable-in-dependency-feature".');
});
});
@@ -256,9 +250,7 @@ describe("feature-dependencies", () => {
expect(() => {
di.inject(someInjectableInDependencyFeature);
}).toThrow(
'Tried to inject non-registered injectable "irrelevant" -> "some-injectable-in-dependency-feature".',
);
}).toThrow('Tried to inject non-registered injectable "irrelevant" -> "some-injectable-in-dependency-feature".');
});
});
});
@@ -1,10 +1,7 @@
import type { DiContainer } from "@ogre-tools/injectable";
import { getInjectable } from "@ogre-tools/injectable";
import type { Feature } from "./feature";
import {
featureContextMapInjectable,
featureContextMapInjectionToken,
} from "./feature-context-map-injectable";
import { featureContextMapInjectable, featureContextMapInjectionToken } from "./feature-context-map-injectable";
const createFeatureContext = (feature: Feature, di: DiContainer) => {
const featureContextInjectable = getInjectable({
@@ -58,10 +55,9 @@ const registerFeatureRecursed = (di: DiContainer, feature: Feature, dependedBy?:
if (dependedBy) {
const oldNumberOfDependents = featureContext.dependedBy.get(dependedBy) || 0;
const newNumberOfDependents = oldNumberOfDependents + 1;
const newNumberOfDependants = oldNumberOfDependents + 1;
featureContext.dependedBy.set(dependedBy, newNumberOfDependants);
featureContext.dependedBy.set(dependedBy, newNumberOfDependents);
}
if (!existingFeatureContext) {