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

@@ -26,8 +26,7 @@ export interface Discover {
getSingleElement: GetSingleElement;
}
const getBaseElement = (source: DiscoverySourceTypes) =>
"baseElement" in source ? source.baseElement : source;
const getBaseElement = (source: DiscoverySourceTypes) => ("baseElement" in source ? source.baseElement : source);
export function querySingleElement(getSource: () => DiscoverySourceTypes): QuerySingleElement {
return (attributeName, attributeValue) => {
@@ -35,9 +34,7 @@ export function querySingleElement(getSource: () => DiscoverySourceTypes): Query
const dataAttribute = `data-${attributeName}-test`;
const selector = attributeValue
? `[${dataAttribute}="${attributeValue}"]`
: `[${dataAttribute}]`;
const selector = attributeValue ? `[${dataAttribute}="${attributeValue}"]` : `[${dataAttribute}]`;
const discovered = getBaseElement(source).querySelector(selector);
@@ -78,10 +75,7 @@ export function getSingleElement(getSource: () => DiscoverySourceTypes): GetSing
return (attributeName, attributeValue) => {
const dataAttribute = `data-${attributeName}-test`;
const { discovered, ...nestedDiscover } = querySingleElement(getSource)(
attributeName,
attributeValue,
);
const { discovered, ...nestedDiscover } = querySingleElement(getSource)(attributeName, attributeValue);
if (!discovered) {
// eslint-disable-next-line xss/no-mixed-html
@@ -97,18 +91,14 @@ export function getSingleElement(getSource: () => DiscoverySourceTypes): GetSing
);
}
throw new Error(
`Couldn't find HTML-element with attribute "${dataAttribute}"\n\nHTML is:\n\n${html}`,
);
throw new Error(`Couldn't find HTML-element with attribute "${dataAttribute}"\n\nHTML is:\n\n${html}`);
}
const click = () => {
if ("click" in discovered && typeof discovered.click === "function") {
discovered.click();
} else {
throw new Error(
`Tried to click something that was not clickable:\n\n${prettyDom(discovered)}`,
);
throw new Error(`Tried to click something that was not clickable:\n\n${prettyDom(discovered)}`);
}
};