mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Merge remote-tracking branch 'origin/master' into eliminate-gst-from-app-paths
This commit is contained in:
56 files changed
+379
-224
No files matched your search
@@ -20,7 +20,6 @@
|
||||
*/
|
||||
|
||||
import { CatalogEntityRegistry } from "../catalog-entity-registry";
|
||||
import "../../../common/catalog-entities";
|
||||
import { catalogCategoryRegistry } from "../../../common/catalog/catalog-category-registry";
|
||||
import { CatalogCategory, CatalogEntityData, CatalogEntityKindData } from "../catalog-entity";
|
||||
import { KubernetesCluster, WebLink } from "../../../common/catalog-entities";
|
||||
|
||||
@@ -28,14 +28,21 @@ import { ClusterStore } from "../../common/cluster-store/cluster-store";
|
||||
import { Disposer, iter } from "../utils";
|
||||
import { once } from "lodash";
|
||||
import logger from "../../common/logger";
|
||||
import { catalogEntityRunContext } from "./catalog-entity";
|
||||
import { CatalogRunEvent } from "../../common/catalog/catalog-run-event";
|
||||
import { ipcRenderer } from "electron";
|
||||
import { CatalogIpcEvents } from "../../common/ipc/catalog";
|
||||
import { navigate } from "../navigation";
|
||||
|
||||
export type EntityFilter = (entity: CatalogEntity) => any;
|
||||
export type CatalogEntityOnBeforeRun = (event: CatalogRunEvent) => void | Promise<void>;
|
||||
|
||||
export const catalogEntityRunContext = {
|
||||
navigate: (url: string) => navigate(url),
|
||||
setCommandPaletteContext: (entity?: CatalogEntity) => {
|
||||
catalogEntityRegistry.activeEntity = entity;
|
||||
},
|
||||
};
|
||||
|
||||
export class CatalogEntityRegistry {
|
||||
@observable protected activeEntityId: string | undefined = undefined;
|
||||
protected _entities = observable.map<string, CatalogEntity>([], { deep: true });
|
||||
|
||||
@@ -19,10 +19,7 @@
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import { navigate } from "../navigation";
|
||||
import type { CatalogEntity } from "../../common/catalog";
|
||||
import { catalogEntityRegistry } from "./catalog-entity-registry";
|
||||
|
||||
export { catalogEntityRunContext } from "./catalog-entity-registry";
|
||||
export { CatalogCategory, CatalogEntity } from "../../common/catalog";
|
||||
export type {
|
||||
CatalogEntityData,
|
||||
@@ -33,10 +30,3 @@ export type {
|
||||
CatalogEntityContextMenu,
|
||||
CatalogEntityContextMenuContext,
|
||||
} from "../../common/catalog";
|
||||
|
||||
export const catalogEntityRunContext = {
|
||||
navigate: (url: string) => navigate(url),
|
||||
setCommandPaletteContext: (entity?: CatalogEntity) => {
|
||||
catalogEntityRegistry.activeEntity = entity;
|
||||
},
|
||||
};
|
||||
@@ -45,15 +45,17 @@ export class HpaDetails extends React.Component<HpaDetailsProps> {
|
||||
|
||||
const renderName = (metric: IHpaMetric) => {
|
||||
switch (metric.type) {
|
||||
case HpaMetricType.Resource:
|
||||
const addition = metric.resource.targetAverageUtilization ? <>(as a percentage of request)</> : "";
|
||||
case HpaMetricType.Resource: {
|
||||
const addition = metric.resource.targetAverageUtilization
|
||||
? "(as a percentage of request)"
|
||||
: "";
|
||||
|
||||
return <>Resource {metric.resource.name} on Pods {addition}</>;
|
||||
|
||||
}
|
||||
case HpaMetricType.Pods:
|
||||
return <>{metric.pods.metricName} on Pods</>;
|
||||
|
||||
case HpaMetricType.Object:
|
||||
case HpaMetricType.Object: {
|
||||
const { target } = metric.object;
|
||||
const { kind, name } = target;
|
||||
const objectUrl = getDetailsUrl(apiManager.lookupApiLink(target, hpa));
|
||||
@@ -64,6 +66,7 @@ export class HpaDetails extends React.Component<HpaDetailsProps> {
|
||||
<Link to={objectUrl}>{kind}/{name}</Link>
|
||||
</>
|
||||
);
|
||||
}
|
||||
case HpaMetricType.External:
|
||||
return (
|
||||
<>
|
||||
|
||||
+1
-2
@@ -18,8 +18,7 @@
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { lifecycleEnum } from "@ogre-tools/injectable";
|
||||
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
|
||||
import { unpackExtension } from "./unpack-extension";
|
||||
import extensionLoaderInjectable from "../../../../../extensions/extension-loader/extension-loader.injectable";
|
||||
import getExtensionDestFolderInjectable
|
||||
|
||||
@@ -47,8 +47,8 @@ export const getBaseRegistryUrl = ({ getRegistryUrlPreference }: Dependencies) =
|
||||
} catch (error) {
|
||||
Notifications.error(<p>Failed to get configured registry from <code>.npmrc</code>. Falling back to default registry</p>);
|
||||
console.warn("[EXTENSIONS]: failed to get configured registry from .npmrc", error);
|
||||
// fallthrough
|
||||
}
|
||||
// fallthrough
|
||||
}
|
||||
default:
|
||||
case ExtensionRegistryLocation.DEFAULT:
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ import { KubeConfig } from "@kubernetes/client-node";
|
||||
import { fireEvent, render } from "@testing-library/react";
|
||||
import mockFs from "mock-fs";
|
||||
import React from "react";
|
||||
import selectEvent from "react-select-event";
|
||||
import * as selectEvent from "react-select-event";
|
||||
|
||||
import type { Cluster } from "../../../../common/cluster/cluster";
|
||||
import { DeleteClusterDialog } from "../delete-cluster-dialog";
|
||||
|
||||
@@ -21,8 +21,7 @@
|
||||
|
||||
import React from "react";
|
||||
import "@testing-library/jest-dom/extend-expect";
|
||||
import selectEvent from "react-select-event";
|
||||
|
||||
import * as selectEvent from "react-select-event";
|
||||
import { Pod } from "../../../../common/k8s-api/endpoints";
|
||||
import { LogResourceSelector } from "../log-resource-selector";
|
||||
import type { LogTabData } from "../log-tab-store/log-tab.store";
|
||||
@@ -33,8 +32,7 @@ import mockFs from "mock-fs";
|
||||
import { getDiForUnitTesting } from "../../getDiForUnitTesting";
|
||||
import type { DiRender } from "../../test-utils/renderFor";
|
||||
import { renderFor } from "../../test-utils/renderFor";
|
||||
import directoryForUserDataInjectable
|
||||
from "../../../../common/app-paths/directory-for-user-data/directory-for-user-data.injectable";
|
||||
import directoryForUserDataInjectable from "../../../../common/app-paths/directory-for-user-data/directory-for-user-data.injectable";
|
||||
import callForLogsInjectable from "../log-store/call-for-logs/call-for-logs.injectable";
|
||||
|
||||
jest.mock("electron", () => ({
|
||||
|
||||
@@ -133,7 +133,8 @@ export class FilePicker extends React.Component<Props> {
|
||||
switch (onOverSizeLimit) {
|
||||
case OverSizeLimitStyle.FILTER:
|
||||
return files.filter(file => file.size <= maxSize );
|
||||
case OverSizeLimitStyle.REJECT:
|
||||
|
||||
case OverSizeLimitStyle.REJECT: {
|
||||
const firstFileToLarge = files.find(file => file.size > maxSize);
|
||||
|
||||
if (firstFileToLarge) {
|
||||
@@ -141,6 +142,7 @@ export class FilePicker extends React.Component<Props> {
|
||||
}
|
||||
|
||||
return files;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,7 +158,9 @@ export class FilePicker extends React.Component<Props> {
|
||||
switch (onOverTotalSizeLimit) {
|
||||
case OverTotalSizeLimitStyle.FILTER_LARGEST:
|
||||
files = _.orderBy(files, ["size"]);
|
||||
case OverTotalSizeLimitStyle.FILTER_LAST:
|
||||
|
||||
// fallthrough
|
||||
case OverTotalSizeLimitStyle.FILTER_LAST: {
|
||||
let newTotalSize = totalSize;
|
||||
|
||||
for (;files.length > 0;) {
|
||||
@@ -168,6 +172,7 @@ export class FilePicker extends React.Component<Props> {
|
||||
}
|
||||
|
||||
return files;
|
||||
}
|
||||
case OverTotalSizeLimitStyle.REJECT:
|
||||
throw `Total file size to upload is too large. Expected at most ${maxTotalSize}. Found ${totalSize}.`;
|
||||
}
|
||||
|
||||
@@ -73,6 +73,7 @@ export class Icon extends React.PureComponent<IconProps> {
|
||||
switch (evt.nativeEvent.code) {
|
||||
case "Space":
|
||||
|
||||
// fallthrough
|
||||
case "Enter": {
|
||||
// eslint-disable-next-line react/no-find-dom-node
|
||||
const icon = findDOMNode(this) as HTMLElement;
|
||||
|
||||
@@ -39,7 +39,7 @@ export const isRequired: InputValidator = {
|
||||
export const isEmail: InputValidator = {
|
||||
condition: ({ type }) => type === "email",
|
||||
message: () => `Wrong email format`,
|
||||
validate: value => !!value.match(/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/),
|
||||
validate: value => !!value.match(/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/),
|
||||
};
|
||||
|
||||
export const isNumber: InputValidator = {
|
||||
|
||||
@@ -31,7 +31,6 @@ import { apiManager } from "../../../common/k8s-api/api-manager";
|
||||
import { crdStore } from "../+custom-resources/crd.store";
|
||||
import { KubeObjectMenu } from "../kube-object-menu";
|
||||
import { KubeObjectDetailRegistry } from "../../api/kube-object-detail-registry";
|
||||
import logger from "../../../main/logger";
|
||||
import { CrdResourceDetails } from "../+custom-resources";
|
||||
import { KubeObjectMeta } from "../kube-object-meta";
|
||||
import { hideDetails, kubeDetailsUrlParam } from "../kube-detail-params";
|
||||
@@ -62,7 +61,7 @@ export class KubeObjectDetails extends React.Component {
|
||||
.getStore(this.path)
|
||||
?.getByPath(this.path);
|
||||
} catch (error) {
|
||||
logger.error(`[KUBE-OBJECT-DETAILS]: failed to get store or object: ${error}`, { path: this.path });
|
||||
console.error(`[KUBE-OBJECT-DETAILS]: failed to get store or object: ${error}`, { path: this.path });
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
import { hideDetails } from "../../kube-detail-params";
|
||||
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
|
||||
|
||||
export const hideDetailsInjectable = getInjectable({
|
||||
const hideDetailsInjectable = getInjectable({
|
||||
instantiate: () => hideDetails,
|
||||
lifecycle: lifecycleEnum.singleton,
|
||||
});
|
||||
|
||||
@@ -27,7 +27,7 @@ import { observer } from "mobx-react";
|
||||
import { boundMethod, cssNames } from "../../utils";
|
||||
import { ConfirmDialog } from "../confirm-dialog";
|
||||
import { Icon, IconProps } from "../icon";
|
||||
import { Menu, MenuItem, MenuProps } from "../menu";
|
||||
import { Menu, MenuItem, MenuProps } from "./menu";
|
||||
import uniqueId from "lodash/uniqueId";
|
||||
import isString from "lodash/isString";
|
||||
|
||||
|
||||
@@ -243,7 +243,9 @@ export class Menu extends React.Component<MenuProps, State> {
|
||||
break;
|
||||
|
||||
case "Space":
|
||||
case "Enter":
|
||||
// fallthrough
|
||||
|
||||
case "Enter": {
|
||||
const focusedItem = this.focusedItem;
|
||||
|
||||
if (focusedItem) {
|
||||
@@ -251,10 +253,12 @@ export class Menu extends React.Component<MenuProps, State> {
|
||||
evt.preventDefault();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case "ArrowUp":
|
||||
this.focusNextItem(true);
|
||||
break;
|
||||
|
||||
case "ArrowDown":
|
||||
this.focusNextItem();
|
||||
break;
|
||||
|
||||
@@ -24,7 +24,8 @@ import React from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import { action, computed, makeObservable, observable, reaction } from "mobx";
|
||||
import { editor, Uri } from "monaco-editor";
|
||||
import { MonacoTheme, MonacoValidator, monacoValidators } from "./index";
|
||||
import type { MonacoTheme } from "./monaco-themes";
|
||||
import { MonacoValidator, monacoValidators } from "./monaco-validators";
|
||||
import { debounce, merge } from "lodash";
|
||||
import { cssNames, disposer } from "../../utils";
|
||||
import { UserStore } from "../../../common/user-store";
|
||||
|
||||
@@ -20,8 +20,7 @@
|
||||
*/
|
||||
|
||||
import styles from "./react-table.module.scss";
|
||||
import React from "react";
|
||||
import { useCallback, useMemo } from "react";
|
||||
import React, { useCallback, useMemo } from "react";
|
||||
import { useFlexLayout, useSortBy, useTable, UseTableOptions } from "react-table";
|
||||
import { Icon } from "../icon";
|
||||
import { cssNames } from "../../utils";
|
||||
|
||||
@@ -31,7 +31,8 @@ import { Notifications } from "../components/notifications";
|
||||
import { cssNames } from "../utils";
|
||||
import { getPortForwards } from "./port-forward-store/port-forward-store";
|
||||
import type { ForwardedPort } from "./port-forward-item";
|
||||
import { aboutPortForwarding, openPortForward } from ".";
|
||||
import { openPortForward } from "./port-forward-utils";
|
||||
import { aboutPortForwarding } from "./port-forward-notify";
|
||||
import { Checkbox } from "../components/checkbox";
|
||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||
import modifyPortForwardInjectable from "./port-forward-store/modify-port-forward/modify-port-forward.injectable";
|
||||
|
||||
@@ -33,7 +33,7 @@ export class SearchStore {
|
||||
* @param value Unescaped string
|
||||
*/
|
||||
public static escapeRegex(value?: string): string {
|
||||
return value ? value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&") : "";
|
||||
return value ? value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&") : "";
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,6 +27,7 @@ import lensDarkThemeJson from "./themes/lens-dark.json";
|
||||
import lensLightThemeJson from "./themes/lens-light.json";
|
||||
import type { SelectOption } from "./components/select";
|
||||
import type { MonacoEditorProps } from "./components/monaco-editor";
|
||||
import { defaultTheme } from "../common/vars";
|
||||
|
||||
export type ThemeId = string;
|
||||
|
||||
@@ -40,7 +41,6 @@ export interface Theme {
|
||||
}
|
||||
|
||||
export class ThemeStore extends Singleton {
|
||||
static readonly defaultTheme = "lens-dark";
|
||||
protected styles: HTMLStyleElement;
|
||||
|
||||
// bundled themes from `themes/${themeId}.json`
|
||||
@@ -54,7 +54,7 @@ export class ThemeStore extends Singleton {
|
||||
}
|
||||
|
||||
@computed get activeTheme(): Theme {
|
||||
return this.themes.get(this.activeThemeId) ?? this.themes.get(ThemeStore.defaultTheme);
|
||||
return this.themes.get(this.activeThemeId) ?? this.themes.get(defaultTheme);
|
||||
}
|
||||
|
||||
@computed get themeOptions(): SelectOption<string>[] {
|
||||
|
||||
@@ -20,16 +20,8 @@
|
||||
*/
|
||||
|
||||
// Helper for working with storages (e.g. window.localStorage, NodeJS/file-system, etc.)
|
||||
import {
|
||||
action,
|
||||
comparer,
|
||||
computed,
|
||||
makeObservable,
|
||||
observable,
|
||||
toJS,
|
||||
when,
|
||||
} from "mobx";
|
||||
import produce, { Draft, isDraft } from "immer";
|
||||
import { action, comparer, computed, makeObservable, observable, toJS, when } from "mobx";
|
||||
import { produce, Draft, isDraft } from "immer";
|
||||
import { isEqual, isPlainObject } from "lodash";
|
||||
import logger from "../../main/logger";
|
||||
|
||||
@@ -142,7 +134,7 @@ export class StorageHelper<T> {
|
||||
get(): T {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
|
||||
@computed
|
||||
get value(): T {
|
||||
return this.data.get() ?? this.defaultValue;
|
||||
|
||||
Reference in new issue
Block a user