mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
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:
1 parent
058494bc73
commit
807f98ed1b
57 files changed
+295
-400
No files matched your search
@@ -1,11 +1,7 @@
|
||||
import { pipeline } from "@ogre-tools/fp";
|
||||
import { filter, isString } from "lodash/fp";
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import {
|
||||
Binding,
|
||||
KeyboardShortcut,
|
||||
keyboardShortcutInjectionToken,
|
||||
} from "./keyboard-shortcut-injection-token";
|
||||
import { Binding, KeyboardShortcut, keyboardShortcutInjectionToken } from "./keyboard-shortcut-injection-token";
|
||||
import platformInjectable from "./platform.injectable";
|
||||
|
||||
export type InvokeShortcut = (event: KeyboardEvent) => void;
|
||||
@@ -46,29 +42,26 @@ const toBindingWithDefaults = (binding: Binding) =>
|
||||
...binding,
|
||||
};
|
||||
|
||||
const toShortcutsWithMatchingBinding =
|
||||
(event: KeyboardEvent, platform: string) => (shortcut: KeyboardShortcut) => {
|
||||
const binding = toBindingWithDefaults(shortcut.binding);
|
||||
const toShortcutsWithMatchingBinding = (event: KeyboardEvent, platform: string) => (shortcut: KeyboardShortcut) => {
|
||||
const binding = toBindingWithDefaults(shortcut.binding);
|
||||
|
||||
const shiftModifierMatches = binding.shift === event.shiftKey;
|
||||
const altModifierMatches = binding.altOrOption === event.altKey;
|
||||
const shiftModifierMatches = binding.shift === event.shiftKey;
|
||||
const altModifierMatches = binding.altOrOption === event.altKey;
|
||||
|
||||
const isMac = platform === "darwin";
|
||||
const isMac = platform === "darwin";
|
||||
|
||||
const ctrlModifierMatches =
|
||||
binding.ctrl === event.ctrlKey || (!isMac && binding.ctrlOrCommand === event.ctrlKey);
|
||||
const ctrlModifierMatches = binding.ctrl === event.ctrlKey || (!isMac && binding.ctrlOrCommand === event.ctrlKey);
|
||||
|
||||
const metaModifierMatches =
|
||||
binding.meta === event.metaKey || (isMac && binding.ctrlOrCommand === event.metaKey);
|
||||
const metaModifierMatches = binding.meta === event.metaKey || (isMac && binding.ctrlOrCommand === event.metaKey);
|
||||
|
||||
return (
|
||||
event.code === binding.code &&
|
||||
shiftModifierMatches &&
|
||||
ctrlModifierMatches &&
|
||||
altModifierMatches &&
|
||||
metaModifierMatches
|
||||
);
|
||||
};
|
||||
return (
|
||||
event.code === binding.code &&
|
||||
shiftModifierMatches &&
|
||||
ctrlModifierMatches &&
|
||||
altModifierMatches &&
|
||||
metaModifierMatches
|
||||
);
|
||||
};
|
||||
|
||||
const invokeShortcutInjectable = getInjectable({
|
||||
id: "invoke-shortcut",
|
||||
|
||||
@@ -26,10 +26,7 @@ const NonInjectedKeyboardShortcutListener = ({
|
||||
return <>{children}</>;
|
||||
};
|
||||
|
||||
export const KeyboardShortcutListener = withInjectables<
|
||||
Dependencies,
|
||||
KeyboardShortcutListenerProps
|
||||
>(
|
||||
export const KeyboardShortcutListener = withInjectables<Dependencies, KeyboardShortcutListenerProps>(
|
||||
NonInjectedKeyboardShortcutListener,
|
||||
|
||||
{
|
||||
|
||||
@@ -175,8 +175,7 @@ describe("keyboard-shortcuts", () => {
|
||||
shouldCallCallback: true,
|
||||
},
|
||||
{
|
||||
scenario:
|
||||
"given shortcut with shift modifier, when shortcut is pressed, calls the callback",
|
||||
scenario: "given shortcut with shift modifier, when shortcut is pressed, calls the callback",
|
||||
|
||||
binding: { shift: true, code: "F1" },
|
||||
keyboard: "{Shift>}[F1]",
|
||||
|
||||
Reference in new issue
Block a user