1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

autobind-related fixes / refactoring

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman 2021-05-04 20:21:03 +03:00
parent 4c627b8649
commit 35732e5a59
118 changed files with 263 additions and 182 deletions

View File

@ -108,12 +108,12 @@ export class SearchStore {
return prev; return prev;
} }
@autobind() @autobind
public setNextOverlayActive(): void { public setNextOverlayActive(): void {
this.activeOverlayIndex = this.getNextOverlay(true); this.activeOverlayIndex = this.getNextOverlay(true);
} }
@autobind() @autobind
public setPrevOverlayActive(): void { public setPrevOverlayActive(): void {
this.activeOverlayIndex = this.getPrevOverlay(true); this.activeOverlayIndex = this.getPrevOverlay(true);
} }
@ -139,7 +139,7 @@ export class SearchStore {
* @param line Index of the line where overlay is located * @param line Index of the line where overlay is located
* @param occurrence Number of the overlay within one line * @param occurrence Number of the overlay within one line
*/ */
@autobind() @autobind
public isActiveOverlay(line: number, occurrence: number): boolean { public isActiveOverlay(line: number, occurrence: number): boolean {
const firstLineIndex = this.occurrences.findIndex(item => item === line); const firstLineIndex = this.occurrences.findIndex(item => item === line);

View File

@ -1,46 +1,47 @@
// Decorator for binding class methods // Auto-binding class method(s) to proper "this"-context.
// Can be applied to class or single method as @autobind() // Useful when calling methods after object-destruction or when method copied to scope variable.
type Constructor<T = {}> = new (...args: any[]) => T;
// FIXME-or-REMOVE: doesn't work as class-decorator with mobx-6 decorators, e.g. @action, @computed, etc. type Constructor<T> = new (...args: any[]) => object;
export function autobind() {
return function (target: Constructor | object, prop?: string, descriptor?: PropertyDescriptor) {
if (target instanceof Function) return bindClass(target);
else return bindMethod(target, prop, descriptor);
};
}
function bindClass<T extends Constructor>(constructor: T) { export function autobind<T extends Constructor<any>>(target: T): T;
const proto = constructor.prototype; export function autobind<T extends object>(target: T, prop?: PropertyKey, descriptor?: PropertyDescriptor): PropertyDescriptor;
const descriptors = Object.getOwnPropertyDescriptors(proto);
const skipMethod = (methodName: string) => {
return methodName === "constructor"
|| typeof descriptors[methodName].value !== "function";
};
Object.keys(descriptors).forEach(prop => { export function autobind(target: any, prop?: PropertyKey, descriptor?: PropertyDescriptor) {
if (skipMethod(prop)) return; if (typeof target === "function") {
const boundDescriptor = bindMethod(proto, prop, descriptors[prop]); return bindClass(target);
}
Object.defineProperty(proto, prop, boundDescriptor); if (typeof descriptor === "object") {
}); return bindMethod(target, prop, descriptor);
} }
}
function bindMethod(target: object, prop?: string, descriptor?: PropertyDescriptor) {
if (!descriptor || typeof descriptor.value !== "function") { export function bindClass<T extends Constructor<T>>(target: T): T {
throw new Error(`@autobind() must be used on class or method only`); return new Proxy(target, {
construct(target, args: any[], newTarget?: any) {
const instance = Reflect.construct(target, args, newTarget);
const protoDescriptors = Object.entries(Object.getOwnPropertyDescriptors(target.prototype));
protoDescriptors.forEach(([prop, descriptor]) => bindMethod(instance, prop, descriptor));
return instance;
}
})
}
export function bindMethod<T extends object>(target: T, prop: PropertyKey, descriptor: PropertyDescriptor): PropertyDescriptor {
const originalMethod = descriptor.value;
if (typeof originalMethod === "function") {
const boundDescriptor: PropertyDescriptor = {
configurable: descriptor.configurable,
enumerable: descriptor.enumerable,
get() {
return (...args: any[]) => Reflect.apply(originalMethod, this, args);
},
set(value: any) {
Object.defineProperty(target, prop, { ...descriptor, value });
}
};
Object.defineProperty(target, prop, boundDescriptor);
return boundDescriptor;
} }
const { value: func, enumerable, configurable } = descriptor;
const boundFunc = new WeakMap<object, Function>();
return Object.defineProperty(target, prop, {
enumerable,
configurable,
get() {
if (this === target) return func; // direct access from prototype
if (!boundFunc.has(this)) boundFunc.set(this, func.bind(this));
return boundFunc.get(this);
}
});
} }

View File

@ -1,7 +1,9 @@
import type { KubeObjectStore } from "../kube-object.store"; import type { KubeObjectStore } from "../kube-object.store";
import { action, makeObservable, observable } from "mobx"; import { action, makeObservable, observable } from "mobx";
import { KubeApi, parseKubeApi } from "./kube-api"; import { KubeApi, parseKubeApi } from "./kube-api";
import { autobind } from "../../common/utils";
@autobind
export class ApiManager { export class ApiManager {
private apis = observable.map<string, KubeApi>(); private apis = observable.map<string, KubeApi>();
private stores = observable.map<string, KubeObjectStore>(); private stores = observable.map<string, KubeObjectStore>();

View File

@ -2,7 +2,7 @@ import { autobind } from "../../utils";
import { Role } from "./role.api"; import { Role } from "./role.api";
import { KubeApi } from "../kube-api"; import { KubeApi } from "../kube-api";
@autobind() @autobind
export class ClusterRole extends Role { export class ClusterRole extends Role {
static kind = "ClusterRole"; static kind = "ClusterRole";
static namespaced = false; static namespaced = false;

View File

@ -5,7 +5,7 @@ import { KubeApi } from "../kube-api";
export type ConfigMapData = Record<string, string>; export type ConfigMapData = Record<string, string>;
@autobind() @autobind
export class ConfigMap extends KubeObject { export class ConfigMap extends KubeObject {
static kind = "ConfigMap"; static kind = "ConfigMap";
static namespaced = true; static namespaced = true;

View File

@ -37,7 +37,7 @@ export class CronJobApi extends KubeApi<CronJob> {
} }
} }
@autobind() @autobind
export class CronJob extends KubeObject { export class CronJob extends KubeObject {
static kind = "CronJob"; static kind = "CronJob";
static namespaced = true; static namespaced = true;

View File

@ -4,7 +4,7 @@ import { IAffinity, WorkloadKubeObject } from "../workload-kube-object";
import { autobind } from "../../utils"; import { autobind } from "../../utils";
import { KubeApi } from "../kube-api"; import { KubeApi } from "../kube-api";
@autobind() @autobind
export class DaemonSet extends WorkloadKubeObject { export class DaemonSet extends WorkloadKubeObject {
static kind = "DaemonSet"; static kind = "DaemonSet";
static namespaced = true; static namespaced = true;

View File

@ -66,7 +66,7 @@ interface IContainerProbe {
failureThreshold?: number; failureThreshold?: number;
} }
@autobind() @autobind
export class Deployment extends WorkloadKubeObject { export class Deployment extends WorkloadKubeObject {
static kind = "Deployment"; static kind = "Deployment";
static namespaced = true; static namespaced = true;

View File

@ -100,7 +100,7 @@ export class EndpointSubset implements IEndpointSubset {
} }
} }
@autobind() @autobind
export class Endpoint extends KubeObject { export class Endpoint extends KubeObject {
static kind = "Endpoints"; static kind = "Endpoints";
static namespaced = true; static namespaced = true;

View File

@ -4,7 +4,7 @@ import { formatDuration } from "../../utils/formatDuration";
import { autobind } from "../../utils"; import { autobind } from "../../utils";
import { KubeApi } from "../kube-api"; import { KubeApi } from "../kube-api";
@autobind() @autobind
export class KubeEvent extends KubeObject { export class KubeEvent extends KubeObject {
static kind = "Event"; static kind = "Event";
static namespaced = true; static namespaced = true;

View File

@ -62,7 +62,7 @@ export async function getChartValues(repo: string, name: string, version: string
return apiBase.get<string>(`/v2/charts/${repo}/${name}/values?${stringify({ version })}`); return apiBase.get<string>(`/v2/charts/${repo}/${name}/values?${stringify({ version })}`);
} }
@autobind() @autobind
export class HelmChart { export class HelmChart {
constructor(data: any) { constructor(data: any) {
Object.assign(this, data); Object.assign(this, data);

View File

@ -134,7 +134,7 @@ export async function rollbackRelease(name: string, namespace: string, revision:
}); });
} }
@autobind() @autobind
export class HelmRelease implements ItemObject { export class HelmRelease implements ItemObject {
constructor(data: any) { constructor(data: any) {
Object.assign(this, data); Object.assign(this, data);

View File

@ -61,7 +61,7 @@ export const getBackendServiceNamePort = (backend: IIngressBackend) => {
return { serviceName, servicePort }; return { serviceName, servicePort };
}; };
@autobind() @autobind
export class Ingress extends KubeObject { export class Ingress extends KubeObject {
static kind = "Ingress"; static kind = "Ingress";
static namespaced = true; static namespaced = true;

View File

@ -5,7 +5,7 @@ import { IPodContainer } from "./pods.api";
import { KubeApi } from "../kube-api"; import { KubeApi } from "../kube-api";
import { JsonApiParams } from "../json-api"; import { JsonApiParams } from "../json-api";
@autobind() @autobind
export class Job extends WorkloadKubeObject { export class Job extends WorkloadKubeObject {
static kind = "Job"; static kind = "Job";
static namespaced = true; static namespaced = true;

View File

@ -29,7 +29,7 @@ export interface LimitRangeItem extends LimitRangeParts {
type: string type: string
} }
@autobind() @autobind
export class LimitRange extends KubeObject { export class LimitRange extends KubeObject {
static kind = "LimitRange"; static kind = "LimitRange";
static namespaced = true; static namespaced = true;

View File

@ -7,7 +7,7 @@ export enum NamespaceStatus {
TERMINATING = "Terminating", TERMINATING = "Terminating",
} }
@autobind() @autobind
export class Namespace extends KubeObject { export class Namespace extends KubeObject {
static kind = "Namespace"; static kind = "Namespace";
static namespaced = false; static namespaced = false;

View File

@ -35,7 +35,7 @@ export interface IPolicyEgress {
}[]; }[];
} }
@autobind() @autobind
export class NetworkPolicy extends KubeObject { export class NetworkPolicy extends KubeObject {
static kind = "NetworkPolicy"; static kind = "NetworkPolicy";
static namespaced = true; static namespaced = true;

View File

@ -28,7 +28,7 @@ export interface INodeMetrics<T = IMetrics> {
fsSize: T; fsSize: T;
} }
@autobind() @autobind
export class Node extends KubeObject { export class Node extends KubeObject {
static kind = "Node"; static kind = "Node";
static namespaced = false; static namespaced = false;

View File

@ -21,7 +21,7 @@ export interface IPvcMetrics<T = IMetrics> {
diskCapacity: T; diskCapacity: T;
} }
@autobind() @autobind
export class PersistentVolumeClaim extends KubeObject { export class PersistentVolumeClaim extends KubeObject {
static kind = "PersistentVolumeClaim"; static kind = "PersistentVolumeClaim";
static namespaced = true; static namespaced = true;

View File

@ -3,7 +3,7 @@ import { unitsToBytes } from "../../utils/convertMemory";
import { autobind } from "../../utils"; import { autobind } from "../../utils";
import { KubeApi } from "../kube-api"; import { KubeApi } from "../kube-api";
@autobind() @autobind
export class PersistentVolume extends KubeObject { export class PersistentVolume extends KubeObject {
static kind = "PersistentVolume"; static kind = "PersistentVolume";
static namespaced = false; static namespaced = false;

View File

@ -2,7 +2,7 @@ import { autobind } from "../../utils";
import { KubeObject } from "../kube-object"; import { KubeObject } from "../kube-object";
import { KubeApi } from "../kube-api"; import { KubeApi } from "../kube-api";
@autobind() @autobind
export class PodDisruptionBudget extends KubeObject { export class PodDisruptionBudget extends KubeObject {
static kind = "PodDisruptionBudget"; static kind = "PodDisruptionBudget";
static namespaced = true; static namespaced = true;

View File

@ -181,7 +181,7 @@ export interface IPodContainerStatus {
started?: boolean; started?: boolean;
} }
@autobind() @autobind
export class Pod extends WorkloadKubeObject { export class Pod extends WorkloadKubeObject {
static kind = "Pod"; static kind = "Pod";
static namespaced = true; static namespaced = true;

View File

@ -2,7 +2,7 @@ import { autobind } from "../../utils";
import { KubeObject } from "../kube-object"; import { KubeObject } from "../kube-object";
import { KubeApi } from "../kube-api"; import { KubeApi } from "../kube-api";
@autobind() @autobind
export class PodSecurityPolicy extends KubeObject { export class PodSecurityPolicy extends KubeObject {
static kind = "PodSecurityPolicy"; static kind = "PodSecurityPolicy";
static namespaced = false; static namespaced = false;

View File

@ -27,7 +27,7 @@ export class ReplicaSetApi extends KubeApi<ReplicaSet> {
} }
} }
@autobind() @autobind
export class ReplicaSet extends WorkloadKubeObject { export class ReplicaSet extends WorkloadKubeObject {
static kind = "ReplicaSet"; static kind = "ReplicaSet";
static namespaced = true; static namespaced = true;

View File

@ -9,7 +9,7 @@ export interface IRoleBindingSubject {
apiGroup?: string; apiGroup?: string;
} }
@autobind() @autobind
export class RoleBinding extends KubeObject { export class RoleBinding extends KubeObject {
static kind = "RoleBinding"; static kind = "RoleBinding";
static namespaced = true; static namespaced = true;

View File

@ -19,7 +19,7 @@ export interface ISecretRef {
name: string; name: string;
} }
@autobind() @autobind
export class Secret extends KubeObject { export class Secret extends KubeObject {
static kind = "Secret"; static kind = "Secret";
static namespaced = true; static namespaced = true;

View File

@ -2,7 +2,7 @@ import { autobind } from "../../utils";
import { KubeObject } from "../kube-object"; import { KubeObject } from "../kube-object";
import { KubeApi } from "../kube-api"; import { KubeApi } from "../kube-api";
@autobind() @autobind
export class ServiceAccount extends KubeObject { export class ServiceAccount extends KubeObject {
static kind = "ServiceAccount"; static kind = "ServiceAccount";
static namespaced = true; static namespaced = true;

View File

@ -29,7 +29,7 @@ export class ServicePort implements IServicePort {
} }
} }
@autobind() @autobind
export class Service extends KubeObject { export class Service extends KubeObject {
static kind = "Service"; static kind = "Service";
static namespaced = true; static namespaced = true;

View File

@ -27,7 +27,7 @@ export class StatefulSetApi extends KubeApi<StatefulSet> {
} }
} }
@autobind() @autobind
export class StatefulSet extends WorkloadKubeObject { export class StatefulSet extends WorkloadKubeObject {
static kind = "StatefulSet"; static kind = "StatefulSet";
static namespaced = true; static namespaced = true;

View File

@ -2,7 +2,7 @@ import { autobind } from "../../utils";
import { KubeObject } from "../kube-object"; import { KubeObject } from "../kube-object";
import { KubeApi } from "../kube-api"; import { KubeApi } from "../kube-api";
@autobind() @autobind
export class StorageClass extends KubeObject { export class StorageClass extends KubeObject {
static kind = "StorageClass"; static kind = "StorageClass";
static namespaced = false; static namespaced = false;

View File

@ -66,7 +66,7 @@ export class KubeStatus {
export type IKubeMetaField = keyof IKubeObjectMetadata; export type IKubeMetaField = keyof IKubeObjectMetadata;
@autobind() @autobind
export class KubeObject implements ItemObject { export class KubeObject implements ItemObject {
static readonly kind: string; static readonly kind: string;
static readonly namespaced: boolean; static readonly namespaced: boolean;

View File

@ -5,7 +5,7 @@ import type { KubeObjectStore } from "../kube-object.store";
import type { ClusterContext } from "../components/context"; import type { ClusterContext } from "../components/context";
import plimit from "p-limit"; import plimit from "p-limit";
import { comparer, IReactionDisposer, makeObservable, observable, reaction, when } from "mobx"; import { comparer, IReactionDisposer, makeObservable, observable, reaction, when } from "mobx";
import { noop } from "../utils"; import { autobind, noop } from "../utils";
import { KubeJsonApiData } from "./kube-json-api"; import { KubeJsonApiData } from "./kube-json-api";
import { isDebugging, isProduction } from "../../common/vars"; import { isDebugging, isProduction } from "../../common/vars";
@ -27,6 +27,7 @@ export interface IKubeWatchLog {
cssStyle?: string; cssStyle?: string;
} }
@autobind
export class KubeWatchApi { export class KubeWatchApi {
@observable context: ClusterContext = null; @observable context: ClusterContext = null;

View File

@ -85,7 +85,7 @@ export class TerminalApi extends WebSocketApi {
this.onReady.removeAllListeners(); this.onReady.removeAllListeners();
} }
@autobind() @autobind
protected _onReady(data: string) { protected _onReady(data: string) {
if (!data) return; if (!data) return;
this.isReady = true; this.isReady = true;

View File

@ -51,7 +51,7 @@ export class HelmChartDetails extends Component<Props> {
}); });
}); });
@autobind() @autobind
async onVersionChange({ value: version }: SelectOption<string>) { async onVersionChange({ value: version }: SelectOption<string>) {
this.selectedChart = this.chartVersions.find(chart => chart.version === version); this.selectedChart = this.chartVersions.find(chart => chart.version === version);
this.readme = null; this.readme = null;
@ -68,7 +68,7 @@ export class HelmChartDetails extends Component<Props> {
} }
} }
@autobind() @autobind
install() { install() {
createInstallChartTab(this.selectedChart); createInstallChartTab(this.selectedChart);
this.props.hideDetails(); this.props.hideDetails();

View File

@ -3,12 +3,14 @@ import { makeObservable, observable } from "mobx";
import { getChartDetails, HelmChart, listCharts } from "../../api/endpoints/helm-charts.api"; import { getChartDetails, HelmChart, listCharts } from "../../api/endpoints/helm-charts.api";
import { ItemStore } from "../../item.store"; import { ItemStore } from "../../item.store";
import flatten from "lodash/flatten"; import flatten from "lodash/flatten";
import { autobind } from "../../../common/utils";
export interface IChartVersion { export interface IChartVersion {
repo: string; repo: string;
version: string; version: string;
} }
@autobind
export class HelmChartStore extends ItemStore<HelmChart> { export class HelmChartStore extends ItemStore<HelmChart> {
@observable versions = observable.map<string, IChartVersion[]>(); @observable versions = observable.map<string, IChartVersion[]>();

View File

@ -14,12 +14,12 @@ interface Props extends MenuActionsProps {
} }
export class HelmReleaseMenu extends React.Component<Props> { export class HelmReleaseMenu extends React.Component<Props> {
@autobind() @autobind
remove() { remove() {
return releaseStore.remove(this.props.release); return releaseStore.remove(this.props.release);
} }
@autobind() @autobind
upgrade() { upgrade() {
const { release, hideDetails } = this.props; const { release, hideDetails } = this.props;
@ -27,7 +27,7 @@ export class HelmReleaseMenu extends React.Component<Props> {
hideDetails && hideDetails(); hideDetails && hideDetails();
} }
@autobind() @autobind
rollback() { rollback() {
ReleaseRollbackDialog.open(this.props.release); ReleaseRollbackDialog.open(this.props.release);
} }

View File

@ -6,8 +6,9 @@ import { Secret } from "../../api/endpoints";
import { secretsStore } from "../+config-secrets/secrets.store"; import { secretsStore } from "../+config-secrets/secrets.store";
import { namespaceStore } from "../+namespaces/namespace.store"; import { namespaceStore } from "../+namespaces/namespace.store";
import { Notifications } from "../notifications"; import { Notifications } from "../notifications";
import { toJS } from "../../../common/utils"; import { autobind, toJS } from "../../../common/utils";
@autobind
export class ReleaseStore extends ItemStore<HelmRelease> { export class ReleaseStore extends ItemStore<HelmRelease> {
releaseSecrets = observable.map<string, Secret>(); releaseSecrets = observable.map<string, Secret>();

View File

@ -40,17 +40,17 @@ export class CatalogAddButton extends React.Component<CatalogAddButtonProps> {
]); ]);
} }
@autobind() @autobind
onOpen() { onOpen() {
this.isOpen = true; this.isOpen = true;
} }
@autobind() @autobind
onClose() { onClose() {
this.isOpen = false; this.isOpen = false;
} }
@autobind() @autobind
onButtonClick() { onButtonClick() {
if (this.menuItems.length == 1) { if (this.menuItems.length == 1) {
this.menuItems[0].onClick(); this.menuItems[0].onClick();

View File

@ -3,7 +3,9 @@ import { catalogEntityRegistry } from "../../api/catalog-entity-registry";
import { CatalogEntity, CatalogEntityActionContext } from "../../api/catalog-entity"; import { CatalogEntity, CatalogEntityActionContext } from "../../api/catalog-entity";
import { ItemObject, ItemStore } from "../../item.store"; import { ItemObject, ItemStore } from "../../item.store";
import { CatalogCategory } from "../../../common/catalog"; import { CatalogCategory } from "../../../common/catalog";
import { autobind } from "../../../common/utils";
@autobind
export class CatalogEntityItem implements ItemObject { export class CatalogEntityItem implements ItemObject {
constructor(public entity: CatalogEntity) { constructor(public entity: CatalogEntity) {
makeObservable(this); makeObservable(this);
@ -63,6 +65,7 @@ export class CatalogEntityItem implements ItemObject {
} }
} }
@autobind
export class CatalogEntityStore extends ItemStore<CatalogEntityItem> { export class CatalogEntityStore extends ItemStore<CatalogEntityItem> {
@observable activeCategory?: CatalogCategory; @observable activeCategory?: CatalogCategory;

View File

@ -112,7 +112,7 @@ export class Catalog extends React.Component {
); );
} }
@autobind() @autobind
renderItemMenu(item: CatalogEntityItem) { renderItemMenu(item: CatalogEntityItem) {
const menuItems = this.contextMenu.menuItems.filter((menuItem) => !menuItem.onlyVisibleForSource || menuItem.onlyVisibleForSource === item.entity.metadata.source); const menuItems = this.contextMenu.menuItems.filter((menuItem) => !menuItem.onlyVisibleForSource || menuItem.onlyVisibleForSource === item.entity.metadata.source);

View File

@ -87,7 +87,7 @@ export class ClusterIssues extends React.Component<Props> {
return warnings; return warnings;
} }
@autobind() @autobind
getTableRow(uid: string) { getTableRow(uid: string) {
const { warnings } = this; const { warnings } = this;
const warning = warnings.find(warn => warn.getId() == uid); const warning = warnings.find(warn => warn.getId() == uid);

View File

@ -1,7 +1,7 @@
import { action, makeObservable, observable, reaction, when } from "mobx"; import { action, makeObservable, observable, reaction, when } from "mobx";
import { KubeObjectStore } from "../../kube-object.store"; import { KubeObjectStore } from "../../kube-object.store";
import { Cluster, clusterApi, IClusterMetrics } from "../../api/endpoints"; import { Cluster, clusterApi, IClusterMetrics } from "../../api/endpoints";
import { createStorage, StorageHelper } from "../../utils"; import { autobind, createStorage, StorageHelper } from "../../utils";
import { IMetricsReqParams, normalizeMetrics } from "../../api/endpoints/metrics.api"; import { IMetricsReqParams, normalizeMetrics } from "../../api/endpoints/metrics.api";
import { nodesStore } from "../+nodes/nodes.store"; import { nodesStore } from "../+nodes/nodes.store";
import { apiManager } from "../../api/api-manager"; import { apiManager } from "../../api/api-manager";
@ -21,6 +21,7 @@ export interface ClusterOverviewStorageState {
metricNodeRole: MetricNodeRole, metricNodeRole: MetricNodeRole,
} }
@autobind
export class ClusterOverviewStore extends KubeObjectStore<Cluster> implements ClusterOverviewStorageState { export class ClusterOverviewStore extends KubeObjectStore<Cluster> implements ClusterOverviewStorageState {
api = clusterApi; api = clusterApi;
@ -30,13 +31,13 @@ export class ClusterOverviewStore extends KubeObjectStore<Cluster> implements Cl
constructor() { constructor() {
super(); super();
makeObservable(this);
this.storage = createStorage<ClusterOverviewStorageState>("cluster_overview", { this.storage = createStorage<ClusterOverviewStorageState>("cluster_overview", {
metricType: MetricType.CPU, // setup defaults metricType: MetricType.CPU, // setup defaults
metricNodeRole: MetricNodeRole.WORKER, metricNodeRole: MetricNodeRole.WORKER,
}); });
makeObservable(this);
this.init(); this.init();
} }

View File

@ -1,7 +1,9 @@
import { KubeObjectStore } from "../../kube-object.store"; import { KubeObjectStore } from "../../kube-object.store";
import { HorizontalPodAutoscaler, hpaApi } from "../../api/endpoints/hpa.api"; import { HorizontalPodAutoscaler, hpaApi } from "../../api/endpoints/hpa.api";
import { apiManager } from "../../api/api-manager"; import { apiManager } from "../../api/api-manager";
import { autobind } from "../../../common/utils";
@autobind
export class HPAStore extends KubeObjectStore<HorizontalPodAutoscaler> { export class HPAStore extends KubeObjectStore<HorizontalPodAutoscaler> {
api = hpaApi; api = hpaApi;
} }

View File

@ -1,7 +1,9 @@
import { KubeObjectStore } from "../../kube-object.store"; import { KubeObjectStore } from "../../kube-object.store";
import { apiManager } from "../../api/api-manager"; import { apiManager } from "../../api/api-manager";
import { LimitRange, limitRangeApi } from "../../api/endpoints/limit-range.api"; import { LimitRange, limitRangeApi } from "../../api/endpoints/limit-range.api";
import { autobind } from "../../../common/utils";
@autobind
export class LimitRangesStore extends KubeObjectStore<LimitRange> { export class LimitRangesStore extends KubeObjectStore<LimitRange> {
api = limitRangeApi; api = limitRangeApi;
} }

View File

@ -1,7 +1,9 @@
import { KubeObjectStore } from "../../kube-object.store"; import { KubeObjectStore } from "../../kube-object.store";
import { ConfigMap, configMapApi } from "../../api/endpoints/configmap.api"; import { ConfigMap, configMapApi } from "../../api/endpoints/configmap.api";
import { apiManager } from "../../api/api-manager"; import { apiManager } from "../../api/api-manager";
import { autobind } from "../../../common/utils";
@autobind
export class ConfigMapsStore extends KubeObjectStore<ConfigMap> { export class ConfigMapsStore extends KubeObjectStore<ConfigMap> {
api = configMapApi; api = configMapApi;
} }

View File

@ -1,7 +1,9 @@
import { KubeObjectStore } from "../../kube-object.store"; import { KubeObjectStore } from "../../kube-object.store";
import { pdbApi, PodDisruptionBudget } from "../../api/endpoints/poddisruptionbudget.api"; import { pdbApi, PodDisruptionBudget } from "../../api/endpoints/poddisruptionbudget.api";
import { apiManager } from "../../api/api-manager"; import { apiManager } from "../../api/api-manager";
import { autobind } from "../../../common/utils";
@autobind
export class PodDisruptionBudgetsStore extends KubeObjectStore<PodDisruptionBudget> { export class PodDisruptionBudgetsStore extends KubeObjectStore<PodDisruptionBudget> {
api = pdbApi; api = pdbApi;
} }

View File

@ -1,7 +1,9 @@
import { KubeObjectStore } from "../../kube-object.store"; import { KubeObjectStore } from "../../kube-object.store";
import { ResourceQuota, resourceQuotaApi } from "../../api/endpoints/resource-quota.api"; import { ResourceQuota, resourceQuotaApi } from "../../api/endpoints/resource-quota.api";
import { apiManager } from "../../api/api-manager"; import { apiManager } from "../../api/api-manager";
import { autobind } from "../../../common/utils";
@autobind
export class ResourceQuotasStore extends KubeObjectStore<ResourceQuota> { export class ResourceQuotasStore extends KubeObjectStore<ResourceQuota> {
api = resourceQuotaApi; api = resourceQuotaApi;
} }

View File

@ -1,7 +1,9 @@
import { KubeObjectStore } from "../../kube-object.store"; import { KubeObjectStore } from "../../kube-object.store";
import { Secret, secretsApi } from "../../api/endpoints"; import { Secret, secretsApi } from "../../api/endpoints";
import { apiManager } from "../../api/api-manager"; import { apiManager } from "../../api/api-manager";
import { autobind } from "../../../common/utils";
@autobind
export class SecretsStore extends KubeObjectStore<Secret> { export class SecretsStore extends KubeObjectStore<Secret> {
api = secretsApi; api = secretsApi;
} }

View File

@ -1,7 +1,9 @@
import { KubeApi } from "../../api/kube-api"; import { KubeApi } from "../../api/kube-api";
import { KubeObjectStore } from "../../kube-object.store"; import { KubeObjectStore } from "../../kube-object.store";
import { KubeObject } from "../../api/kube-object"; import { KubeObject } from "../../api/kube-object";
import { autobind } from "../../../common/utils";
@autobind
export class CRDResourceStore<T extends KubeObject = any> extends KubeObjectStore<T> { export class CRDResourceStore<T extends KubeObject = any> extends KubeObjectStore<T> {
api: KubeApi; api: KubeApi;

View File

@ -5,7 +5,7 @@ import { apiManager } from "../../api/api-manager";
import { KubeApi } from "../../api/kube-api"; import { KubeApi } from "../../api/kube-api";
import { CRDResourceStore } from "./crd-resource.store"; import { CRDResourceStore } from "./crd-resource.store";
import { KubeObject } from "../../api/kube-object"; import { KubeObject } from "../../api/kube-object";
import { toJS } from "../../../common/utils"; import { autobind, toJS } from "../../../common/utils";
function initStore(crd: CustomResourceDefinition) { function initStore(crd: CustomResourceDefinition) {
const apiBase = crd.getResourceApiBase(); const apiBase = crd.getResourceApiBase();
@ -18,6 +18,7 @@ function initStore(crd: CustomResourceDefinition) {
} }
} }
@autobind
export class CRDStore extends KubeObjectStore<CustomResourceDefinition> { export class CRDStore extends KubeObjectStore<CustomResourceDefinition> {
api = crdApi; api = crdApi;

View File

@ -6,7 +6,9 @@ import { KubeObject } from "../../api/kube-object";
import { Pod } from "../../api/endpoints/pods.api"; import { Pod } from "../../api/endpoints/pods.api";
import { podsStore } from "../+workloads-pods/pods.store"; import { podsStore } from "../+workloads-pods/pods.store";
import { apiManager } from "../../api/api-manager"; import { apiManager } from "../../api/api-manager";
import { autobind } from "../../../common/utils";
@autobind
export class EventStore extends KubeObjectStore<KubeEvent> { export class EventStore extends KubeObjectStore<KubeEvent> {
api = eventApi; api = eventApi;
limit = 1000; limit = 1000;

View File

@ -30,7 +30,7 @@ export class ExtensionInstallationStateStore {
}); });
} }
@action static reset() { static reset() {
logger.warn(`${Prefix}: resetting, may throw errors`); logger.warn(`${Prefix}: resetting, may throw errors`);
ExtensionInstallationStateStore.InstallingExtensions.clear(); ExtensionInstallationStateStore.InstallingExtensions.clear();
ExtensionInstallationStateStore.UninstallingExtensions.clear(); ExtensionInstallationStateStore.UninstallingExtensions.clear();
@ -42,7 +42,7 @@ export class ExtensionInstallationStateStore {
* @param extId the ID of the extension * @param extId the ID of the extension
* @throws if state is not IDLE * @throws if state is not IDLE
*/ */
@action static setInstalling(extId: string): void { static setInstalling(extId: string): void {
logger.debug(`${Prefix}: trying to set ${extId} as installing`); logger.debug(`${Prefix}: trying to set ${extId} as installing`);
const curState = ExtensionInstallationStateStore.getInstallationState(extId); const curState = ExtensionInstallationStateStore.getInstallationState(extId);
@ -76,7 +76,7 @@ export class ExtensionInstallationStateStore {
* determined. * determined.
* @returns a disposer which should be called to mark the end of the install phase * @returns a disposer which should be called to mark the end of the install phase
*/ */
@action static startPreInstall(): ExtendableDisposer { static startPreInstall(): ExtendableDisposer {
const preInstallStepId = uuid.v4(); const preInstallStepId = uuid.v4();
logger.debug(`${Prefix}: starting a new preinstall phase: ${preInstallStepId}`); logger.debug(`${Prefix}: starting a new preinstall phase: ${preInstallStepId}`);
@ -93,7 +93,7 @@ export class ExtensionInstallationStateStore {
* @param extId the ID of the extension * @param extId the ID of the extension
* @throws if state is not IDLE * @throws if state is not IDLE
*/ */
@action static setUninstalling(extId: string): void { static setUninstalling(extId: string): void {
logger.debug(`${Prefix}: trying to set ${extId} as uninstalling`); logger.debug(`${Prefix}: trying to set ${extId} as uninstalling`);
const curState = ExtensionInstallationStateStore.getInstallationState(extId); const curState = ExtensionInstallationStateStore.getInstallationState(extId);
@ -110,7 +110,7 @@ export class ExtensionInstallationStateStore {
* @param extId The ID of the extension * @param extId The ID of the extension
* @throws if state is not INSTALLING * @throws if state is not INSTALLING
*/ */
@action static clearInstalling(extId: string): void { static clearInstalling(extId: string): void {
logger.debug(`${Prefix}: trying to clear ${extId} as installing`); logger.debug(`${Prefix}: trying to clear ${extId} as installing`);
const curState = ExtensionInstallationStateStore.getInstallationState(extId); const curState = ExtensionInstallationStateStore.getInstallationState(extId);
@ -128,7 +128,7 @@ export class ExtensionInstallationStateStore {
* @param extId The ID of the extension * @param extId The ID of the extension
* @throws if state is not UNINSTALLING * @throws if state is not UNINSTALLING
*/ */
@action static clearUninstalling(extId: string): void { static clearUninstalling(extId: string): void {
logger.debug(`${Prefix}: trying to clear ${extId} as uninstalling`); logger.debug(`${Prefix}: trying to clear ${extId} as uninstalling`);
const curState = ExtensionInstallationStateStore.getInstallationState(extId); const curState = ExtensionInstallationStateStore.getInstallationState(extId);

View File

@ -519,7 +519,7 @@ export class Extensions extends React.Component {
); );
} }
@autobind() @autobind
renderExtension(extension: InstalledExtension) { renderExtension(extension: InstalledExtension) {
const { id, isEnabled, manifest } = extension; const { id, isEnabled, manifest } = extension;
const { name, description, version } = manifest; const { name, description, version } = manifest;

View File

@ -1,5 +1,5 @@
import { action, comparer, computed, IReactionDisposer, IReactionOptions, makeObservable, observable, reaction, } from "mobx"; import { action, comparer, computed, IReactionDisposer, IReactionOptions, makeObservable, observable, reaction, } from "mobx";
import { createStorage } from "../../utils"; import { autobind, createStorage } from "../../utils";
import { KubeObjectStore, KubeObjectStoreLoadingParams } from "../../kube-object.store"; import { KubeObjectStore, KubeObjectStoreLoadingParams } from "../../kube-object.store";
import { Namespace, namespacesApi } from "../../api/endpoints/namespaces.api"; import { Namespace, namespacesApi } from "../../api/endpoints/namespaces.api";
import { createPageParam } from "../../navigation"; import { createPageParam } from "../../navigation";
@ -27,6 +27,7 @@ export function getDummyNamespace(name: string) {
}); });
} }
@autobind
export class NamespaceStore extends KubeObjectStore<Namespace> { export class NamespaceStore extends KubeObjectStore<Namespace> {
api = namespacesApi; api = namespacesApi;

View File

@ -29,7 +29,7 @@ export class EndpointSubsetList extends React.Component<Props> {
return this.renderAddressTableRow(address); return this.renderAddressTableRow(address);
} }
@autobind() @autobind
getNotReadyAddressTableRow(ip: string) { getNotReadyAddressTableRow(ip: string) {
const { subset} = this.props; const { subset} = this.props;
const address = subset.getNotReadyAddresses().find(address => address.getId() == ip); const address = subset.getNotReadyAddresses().find(address => address.getId() == ip);
@ -37,7 +37,7 @@ export class EndpointSubsetList extends React.Component<Props> {
return this.renderAddressTableRow(address); return this.renderAddressTableRow(address);
} }
@autobind() @autobind
renderAddressTable(addresses: EndpointAddress[], virtual: boolean) { renderAddressTable(addresses: EndpointAddress[], virtual: boolean) {
return ( return (
<div> <div>
@ -63,7 +63,7 @@ export class EndpointSubsetList extends React.Component<Props> {
); );
} }
@autobind() @autobind
renderAddressTableRow(address: EndpointAddress) { renderAddressTableRow(address: EndpointAddress) {
const { endpoint } = this.props; const { endpoint } = this.props;

View File

@ -1,7 +1,9 @@
import { KubeObjectStore } from "../../kube-object.store"; import { KubeObjectStore } from "../../kube-object.store";
import { Endpoint, endpointApi } from "../../api/endpoints/endpoint.api"; import { Endpoint, endpointApi } from "../../api/endpoints/endpoint.api";
import { apiManager } from "../../api/api-manager"; import { apiManager } from "../../api/api-manager";
import { autobind } from "../../../common/utils";
@autobind
export class EndpointStore extends KubeObjectStore<Endpoint> { export class EndpointStore extends KubeObjectStore<Endpoint> {
api = endpointApi; api = endpointApi;
} }

View File

@ -2,7 +2,9 @@ import { makeObservable, observable } from "mobx";
import { KubeObjectStore } from "../../kube-object.store"; import { KubeObjectStore } from "../../kube-object.store";
import { IIngressMetrics, Ingress, ingressApi } from "../../api/endpoints"; import { IIngressMetrics, Ingress, ingressApi } from "../../api/endpoints";
import { apiManager } from "../../api/api-manager"; import { apiManager } from "../../api/api-manager";
import { autobind } from "../../../common/utils";
@autobind
export class IngressStore extends KubeObjectStore<Ingress> { export class IngressStore extends KubeObjectStore<Ingress> {
api = ingressApi; api = ingressApi;
@observable metrics: IIngressMetrics = null; @observable metrics: IIngressMetrics = null;

View File

@ -1,7 +1,9 @@
import { KubeObjectStore } from "../../kube-object.store"; import { KubeObjectStore } from "../../kube-object.store";
import { NetworkPolicy, networkPolicyApi } from "../../api/endpoints/network-policy.api"; import { NetworkPolicy, networkPolicyApi } from "../../api/endpoints/network-policy.api";
import { apiManager } from "../../api/api-manager"; import { apiManager } from "../../api/api-manager";
import { autobind } from "../../../common/utils";
@autobind
export class NetworkPolicyStore extends KubeObjectStore<NetworkPolicy> { export class NetworkPolicyStore extends KubeObjectStore<NetworkPolicy> {
api = networkPolicyApi; api = networkPolicyApi;
} }

View File

@ -1,7 +1,9 @@
import { KubeObjectStore } from "../../kube-object.store"; import { KubeObjectStore } from "../../kube-object.store";
import { Service, serviceApi } from "../../api/endpoints/service.api"; import { Service, serviceApi } from "../../api/endpoints/service.api";
import { apiManager } from "../../api/api-manager"; import { apiManager } from "../../api/api-manager";
import { autobind } from "../../../common/utils";
@autobind
export class ServiceStore extends KubeObjectStore<Service> { export class ServiceStore extends KubeObjectStore<Service> {
api = serviceApi; api = serviceApi;
} }

View File

@ -3,7 +3,9 @@ import { action, computed, makeObservable, observable } from "mobx";
import { clusterApi, IClusterMetrics, INodeMetrics, Node, nodesApi } from "../../api/endpoints"; import { clusterApi, IClusterMetrics, INodeMetrics, Node, nodesApi } from "../../api/endpoints";
import { KubeObjectStore } from "../../kube-object.store"; import { KubeObjectStore } from "../../kube-object.store";
import { apiManager } from "../../api/api-manager"; import { apiManager } from "../../api/api-manager";
import { autobind } from "../../../common/utils";
@autobind
export class NodesStore extends KubeObjectStore<Node> { export class NodesStore extends KubeObjectStore<Node> {
api = nodesApi; api = nodesApi;

View File

@ -1,7 +1,9 @@
import { PodSecurityPolicy, pspApi } from "../../api/endpoints"; import { PodSecurityPolicy, pspApi } from "../../api/endpoints";
import { KubeObjectStore } from "../../kube-object.store"; import { KubeObjectStore } from "../../kube-object.store";
import { apiManager } from "../../api/api-manager"; import { apiManager } from "../../api/api-manager";
import { autobind } from "../../../common/utils";
@autobind
export class PodSecurityPoliciesStore extends KubeObjectStore<PodSecurityPolicy> { export class PodSecurityPoliciesStore extends KubeObjectStore<PodSecurityPolicy> {
api = pspApi; api = pspApi;
} }

View File

@ -2,7 +2,9 @@ import { KubeObjectStore } from "../../kube-object.store";
import { StorageClass, storageClassApi } from "../../api/endpoints/storage-class.api"; import { StorageClass, storageClassApi } from "../../api/endpoints/storage-class.api";
import { apiManager } from "../../api/api-manager"; import { apiManager } from "../../api/api-manager";
import { volumesStore } from "../+storage-volumes/volumes.store"; import { volumesStore } from "../+storage-volumes/volumes.store";
import { autobind } from "../../../common/utils";
@autobind
export class StorageClassStore extends KubeObjectStore<StorageClass> { export class StorageClassStore extends KubeObjectStore<StorageClass> {
api = storageClassApi; api = storageClassApi;

View File

@ -2,7 +2,9 @@ import { action, makeObservable, observable } from "mobx";
import { KubeObjectStore } from "../../kube-object.store"; import { KubeObjectStore } from "../../kube-object.store";
import { IPvcMetrics, PersistentVolumeClaim, pvcApi } from "../../api/endpoints"; import { IPvcMetrics, PersistentVolumeClaim, pvcApi } from "../../api/endpoints";
import { apiManager } from "../../api/api-manager"; import { apiManager } from "../../api/api-manager";
import { autobind } from "../../../common/utils";
@autobind
export class VolumeClaimStore extends KubeObjectStore<PersistentVolumeClaim> { export class VolumeClaimStore extends KubeObjectStore<PersistentVolumeClaim> {
api = pvcApi; api = pvcApi;
@observable metrics: IPvcMetrics = null; @observable metrics: IPvcMetrics = null;

View File

@ -39,7 +39,7 @@ export class VolumeDetailsList extends React.Component<Props> {
makeObservable(this); makeObservable(this);
} }
@autobind() @autobind
getTableRow(uid: string) { getTableRow(uid: string) {
const { persistentVolumes } = this.props; const { persistentVolumes } = this.props;
const volume = persistentVolumes.find(volume => volume.getId() === uid); const volume = persistentVolumes.find(volume => volume.getId() === uid);

View File

@ -2,7 +2,9 @@ import { KubeObjectStore } from "../../kube-object.store";
import { PersistentVolume, persistentVolumeApi } from "../../api/endpoints/persistent-volume.api"; import { PersistentVolume, persistentVolumeApi } from "../../api/endpoints/persistent-volume.api";
import { apiManager } from "../../api/api-manager"; import { apiManager } from "../../api/api-manager";
import { StorageClass } from "../../api/endpoints/storage-class.api"; import { StorageClass } from "../../api/endpoints/storage-class.api";
import { autobind } from "../../../common/utils";
@autobind
export class PersistentVolumesStore extends KubeObjectStore<PersistentVolume> { export class PersistentVolumesStore extends KubeObjectStore<PersistentVolume> {
api = persistentVolumeApi; api = persistentVolumeApi;

View File

@ -47,7 +47,7 @@ export class RoleBindingDetails extends React.Component<Props> {
); );
} }
@autobind() @autobind
removeSelectedSubjects() { removeSelectedSubjects() {
const { object: roleBinding } = this.props; const { object: roleBinding } = this.props;
const { selectedSubjects } = this; const { selectedSubjects } = this;

View File

@ -3,7 +3,9 @@ import uniqBy from "lodash/uniqBy";
import { clusterRoleBindingApi, IRoleBindingSubject, RoleBinding, roleBindingApi } from "../../api/endpoints"; import { clusterRoleBindingApi, IRoleBindingSubject, RoleBinding, roleBindingApi } from "../../api/endpoints";
import { KubeObjectStore, KubeObjectStoreLoadingParams } from "../../kube-object.store"; import { KubeObjectStore, KubeObjectStoreLoadingParams } from "../../kube-object.store";
import { apiManager } from "../../api/api-manager"; import { apiManager } from "../../api/api-manager";
import { autobind } from "../../../common/utils";
@autobind
export class RoleBindingsStore extends KubeObjectStore<RoleBinding> { export class RoleBindingsStore extends KubeObjectStore<RoleBinding> {
api = clusterRoleBindingApi; api = clusterRoleBindingApi;

View File

@ -1,7 +1,9 @@
import { clusterRoleApi, Role, roleApi } from "../../api/endpoints"; import { clusterRoleApi, Role, roleApi } from "../../api/endpoints";
import { KubeObjectStore, KubeObjectStoreLoadingParams } from "../../kube-object.store"; import { KubeObjectStore, KubeObjectStoreLoadingParams } from "../../kube-object.store";
import { apiManager } from "../../api/api-manager"; import { apiManager } from "../../api/api-manager";
import { autobind } from "../../../common/utils";
@autobind
export class RolesStore extends KubeObjectStore<Role> { export class RolesStore extends KubeObjectStore<Role> {
api = clusterRoleApi; api = clusterRoleApi;

View File

@ -1,7 +1,9 @@
import { ServiceAccount, serviceAccountsApi } from "../../api/endpoints"; import { ServiceAccount, serviceAccountsApi } from "../../api/endpoints";
import { KubeObjectStore } from "../../kube-object.store"; import { KubeObjectStore } from "../../kube-object.store";
import { apiManager } from "../../api/api-manager"; import { apiManager } from "../../api/api-manager";
import { autobind } from "../../../common/utils";
@autobind
export class ServiceAccountsStore extends KubeObjectStore<ServiceAccount> { export class ServiceAccountsStore extends KubeObjectStore<ServiceAccount> {
api = serviceAccountsApi; api = serviceAccountsApi;

View File

@ -2,7 +2,9 @@ import { KubeObjectStore } from "../../kube-object.store";
import { CronJob, cronJobApi } from "../../api/endpoints/cron-job.api"; import { CronJob, cronJobApi } from "../../api/endpoints/cron-job.api";
import { jobStore } from "../+workloads-jobs/job.store"; import { jobStore } from "../+workloads-jobs/job.store";
import { apiManager } from "../../api/api-manager"; import { apiManager } from "../../api/api-manager";
import { autobind } from "../../../common/utils";
@autobind
export class CronJobStore extends KubeObjectStore<CronJob> { export class CronJobStore extends KubeObjectStore<CronJob> {
api = cronJobApi; api = cronJobApi;

View File

@ -3,7 +3,9 @@ import { KubeObjectStore } from "../../kube-object.store";
import { DaemonSet, daemonSetApi, IPodMetrics, Pod, podsApi, PodStatus } from "../../api/endpoints"; import { DaemonSet, daemonSetApi, IPodMetrics, Pod, podsApi, PodStatus } from "../../api/endpoints";
import { podsStore } from "../+workloads-pods/pods.store"; import { podsStore } from "../+workloads-pods/pods.store";
import { apiManager } from "../../api/api-manager"; import { apiManager } from "../../api/api-manager";
import { autobind } from "../../../common/utils";
@autobind
export class DaemonSetStore extends KubeObjectStore<DaemonSet> { export class DaemonSetStore extends KubeObjectStore<DaemonSet> {
api = daemonSetApi; api = daemonSetApi;

View File

@ -3,7 +3,9 @@ import { Deployment, deploymentApi, IPodMetrics, podsApi, PodStatus } from "../.
import { KubeObjectStore } from "../../kube-object.store"; import { KubeObjectStore } from "../../kube-object.store";
import { podsStore } from "../+workloads-pods/pods.store"; import { podsStore } from "../+workloads-pods/pods.store";
import { apiManager } from "../../api/api-manager"; import { apiManager } from "../../api/api-manager";
import { autobind } from "../../../common/utils";
@autobind
export class DeploymentStore extends KubeObjectStore<Deployment> { export class DeploymentStore extends KubeObjectStore<Deployment> {
api = deploymentApi; api = deploymentApi;
@observable metrics: IPodMetrics = null; @observable metrics: IPodMetrics = null;

View File

@ -3,7 +3,9 @@ import { Job, jobApi } from "../../api/endpoints/job.api";
import { CronJob, Pod, PodStatus } from "../../api/endpoints"; import { CronJob, Pod, PodStatus } from "../../api/endpoints";
import { podsStore } from "../+workloads-pods/pods.store"; import { podsStore } from "../+workloads-pods/pods.store";
import { apiManager } from "../../api/api-manager"; import { apiManager } from "../../api/api-manager";
import { autobind } from "../../../common/utils";
@autobind
export class JobStore extends KubeObjectStore<Job> { export class JobStore extends KubeObjectStore<Job> {
api = jobApi; api = jobApi;

View File

@ -29,7 +29,7 @@ export class OverviewStatuses extends React.Component {
makeObservable(this); makeObservable(this);
} }
@autobind() @autobind
renderWorkload(resource: KubeResource): React.ReactElement { renderWorkload(resource: KubeResource): React.ReactElement {
const store = workloadStores[resource]; const store = workloadStores[resource];
const items = store.getAllByNs(namespaceStore.contextNamespaces); const items = store.getAllByNs(namespaceStore.contextNamespaces);

View File

@ -103,7 +103,7 @@ export class PodDetailsList extends React.Component<Props> {
); );
} }
@autobind() @autobind
getTableRow(uid: string) { getTableRow(uid: string) {
const { pods } = this.props; const { pods } = this.props;
const pod = pods.find(pod => pod.getId() == uid); const pod = pods.find(pod => pod.getId() == uid);

View File

@ -56,7 +56,7 @@ export class PodDetails extends React.Component<Props> {
podsStore.reset(); podsStore.reset();
} }
@autobind() @autobind
async loadMetrics() { async loadMetrics() {
const { object: pod } = this.props; const { object: pod } = this.props;

View File

@ -1,11 +1,12 @@
import countBy from "lodash/countBy"; import countBy from "lodash/countBy";
import { action, makeObservable, observable } from "mobx"; import { action, makeObservable, observable } from "mobx";
import { KubeObjectStore } from "../../kube-object.store"; import { KubeObjectStore } from "../../kube-object.store";
import { cpuUnitsToNumber, unitsToBytes } from "../../utils"; import { autobind, cpuUnitsToNumber, unitsToBytes } from "../../utils";
import { IPodMetrics, Pod, PodMetrics, podMetricsApi, podsApi } from "../../api/endpoints"; import { IPodMetrics, Pod, PodMetrics, podMetricsApi, podsApi } from "../../api/endpoints";
import { apiManager } from "../../api/api-manager"; import { apiManager } from "../../api/api-manager";
import { WorkloadKubeObject } from "../../api/workload-kube-object"; import { WorkloadKubeObject } from "../../api/workload-kube-object";
@autobind
export class PodsStore extends KubeObjectStore<Pod> { export class PodsStore extends KubeObjectStore<Pod> {
api = podsApi; api = podsApi;

View File

@ -4,7 +4,9 @@ import { Deployment, IPodMetrics, podsApi, ReplicaSet, replicaSetApi } from "../
import { podsStore } from "../+workloads-pods/pods.store"; import { podsStore } from "../+workloads-pods/pods.store";
import { apiManager } from "../../api/api-manager"; import { apiManager } from "../../api/api-manager";
import { PodStatus } from "../../api/endpoints/pods.api"; import { PodStatus } from "../../api/endpoints/pods.api";
import { autobind } from "../../../common/utils";
@autobind
export class ReplicaSetStore extends KubeObjectStore<ReplicaSet> { export class ReplicaSetStore extends KubeObjectStore<ReplicaSet> {
api = replicaSetApi; api = replicaSetApi;
@observable metrics: IPodMetrics = null; @observable metrics: IPodMetrics = null;

View File

@ -3,7 +3,9 @@ import { KubeObjectStore } from "../../kube-object.store";
import { IPodMetrics, podsApi, PodStatus, StatefulSet, statefulSetApi } from "../../api/endpoints"; import { IPodMetrics, podsApi, PodStatus, StatefulSet, statefulSetApi } from "../../api/endpoints";
import { podsStore } from "../+workloads-pods/pods.store"; import { podsStore } from "../+workloads-pods/pods.store";
import { apiManager } from "../../api/api-manager"; import { apiManager } from "../../api/api-manager";
import { autobind } from "../../../common/utils";
@autobind
export class StatefulSetStore extends KubeObjectStore<StatefulSet> { export class StatefulSetStore extends KubeObjectStore<StatefulSet> {
api = statefulSetApi; api = statefulSetApi;
@observable metrics: IPodMetrics = null; @observable metrics: IPodMetrics = null;

View File

@ -130,7 +130,7 @@ export class AceEditor extends React.Component<Props, State> {
}); });
} }
@autobind() @autobind
onCursorPosChange() { onCursorPosChange() {
const { onCursorPosChange } = this.props; const { onCursorPosChange } = this.props;
@ -139,7 +139,7 @@ export class AceEditor extends React.Component<Props, State> {
} }
} }
@autobind() @autobind
onChange(delta: Ace.Delta) { onChange(delta: Ace.Delta) {
const { onChange } = this.props; const { onChange } = this.props;

View File

@ -71,7 +71,7 @@ export class Animate extends React.Component<AnimateProps> {
this.statusClassName.leave = false; this.statusClassName.leave = false;
} }
@autobind() @autobind
onTransitionEnd(evt: React.TransitionEvent) { onTransitionEnd(evt: React.TransitionEvent) {
const { enter, leave } = this.statusClassName; const { enter, leave } = this.statusClassName;
const { onTransitionEnd } = this.contentElem.props; const { onTransitionEnd } = this.contentElem.props;

View File

@ -15,7 +15,7 @@ export interface CheckboxProps<T = boolean> {
export class Checkbox extends React.PureComponent<CheckboxProps> { export class Checkbox extends React.PureComponent<CheckboxProps> {
private input: HTMLInputElement; private input: HTMLInputElement;
@autobind() @autobind
onChange(evt: React.ChangeEvent<HTMLInputElement>) { onChange(evt: React.ChangeEvent<HTMLInputElement>) {
if (this.props.onChange) { if (this.props.onChange) {
this.props.onChange(this.input.checked, evt); this.props.onChange(this.input.checked, evt);

View File

@ -33,7 +33,7 @@ export class Clipboard extends React.Component<CopyToClipboardProps> {
return React.Children.only(this.props.children) as React.ReactElement; return React.Children.only(this.props.children) as React.ReactElement;
} }
@autobind() @autobind
onClick(evt: React.MouseEvent) { onClick(evt: React.MouseEvent) {
if (this.rootReactElem.props.onClick) { if (this.rootReactElem.props.onClick) {
this.rootReactElem.props.onClick(evt); // pass event to children-root-element if any this.rootReactElem.props.onClick(evt); // pass event to children-root-element if any

View File

@ -12,7 +12,7 @@ interface Props {
@observer @observer
export class ClusterKubeconfig extends React.Component<Props> { export class ClusterKubeconfig extends React.Component<Props> {
@autobind() @autobind
openKubeconfig() { openKubeconfig() {
const { cluster } = this.props; const { cluster } = this.props;

View File

@ -18,7 +18,7 @@ export class RemoveClusterButton extends React.Component<Props> {
makeObservable(this); makeObservable(this);
} }
@autobind() @autobind
confirmRemoveCluster() { confirmRemoveCluster() {
const { cluster } = this.props; const { cluster } = this.props;

View File

@ -6,7 +6,9 @@ import filehound from "filehound";
import { watch } from "chokidar"; import { watch } from "chokidar";
import { DockTabStore } from "./dock-tab.store"; import { DockTabStore } from "./dock-tab.store";
import { dockStore, IDockTab, TabKind } from "./dock.store"; import { dockStore, IDockTab, TabKind } from "./dock.store";
import { autobind } from "../../../common/utils";
@autobind
export class CreateResourceStore extends DockTabStore<string> { export class CreateResourceStore extends DockTabStore<string> {
constructor() { constructor() {

View File

@ -1,5 +1,5 @@
import { autorun, observable, reaction } from "mobx"; import { autorun, observable, reaction } from "mobx";
import { createStorage, StorageHelper, toJS } from "../../utils"; import { autobind, createStorage, StorageHelper, toJS } from "../../utils";
import { dockStore, TabId } from "./dock.store"; import { dockStore, TabId } from "./dock.store";
export interface DockTabStoreOptions { export interface DockTabStoreOptions {
@ -9,6 +9,7 @@ export interface DockTabStoreOptions {
export type DockTabStorageState<T> = Record<TabId, T>; export type DockTabStorageState<T> = Record<TabId, T>;
@autobind
export class DockTabStore<T> { export class DockTabStore<T> {
protected storage?: StorageHelper<DockTabStorageState<T>>; protected storage?: StorageHelper<DockTabStorageState<T>>;
protected data = observable.map<TabId, T>(); protected data = observable.map<TabId, T>();

View File

@ -26,7 +26,7 @@ export class DockTab extends React.Component<DockTabProps> {
return this.props.value.id; return this.props.value.id;
} }
@autobind() @autobind
close() { close() {
dockStore.closeTab(this.tabId); dockStore.closeTab(this.tabId);
} }

View File

@ -1,6 +1,6 @@
import MD5 from "crypto-js/md5"; import MD5 from "crypto-js/md5";
import { action, computed, IReactionOptions, makeObservable, observable, reaction } from "mobx"; import { action, computed, IReactionOptions, makeObservable, observable, reaction } from "mobx";
import { createStorage, StorageHelper } from "../../utils"; import { autobind, createStorage, StorageHelper } from "../../utils";
import throttle from "lodash/throttle"; import throttle from "lodash/throttle";
export type TabId = string; export type TabId = string;
@ -28,7 +28,12 @@ export interface DockStorageState {
isOpen?: boolean; isOpen?: boolean;
} }
@autobind
export class DockStore implements DockStorageState { export class DockStore implements DockStorageState {
private storage: StorageHelper<DockStorageState>;
public readonly minHeight = 100;
@observable fullSize = false;
constructor() { constructor() {
makeObservable(this); makeObservable(this);
@ -42,10 +47,6 @@ export class DockStore implements DockStorageState {
this.bindEvents(); this.bindEvents();
} }
private storage: StorageHelper<DockStorageState>;
public readonly minHeight = 100;
@observable fullSize = false;
get isOpen(): boolean { get isOpen(): boolean {
return this.storage.get().isOpen; return this.storage.get().isOpen;
} }
@ -127,6 +128,7 @@ export class DockStore implements DockStorageState {
} }
} }
@action
close() { close() {
this.isOpen = false; this.isOpen = false;
} }
@ -142,7 +144,7 @@ export class DockStore implements DockStorageState {
this.fullSize = !this.fullSize; this.fullSize = !this.fullSize;
} }
getTabById(tabId: TabId) { getTabById(tabId: TabId): IDockTab | undefined {
return this.tabs.find(tab => tab.id === tabId); return this.tabs.find(tab => tab.id === tabId);
} }

View File

@ -1,4 +1,4 @@
import { noop } from "../../utils"; import { autobind, noop } from "../../utils";
import { DockTabStore } from "./dock-tab.store"; import { DockTabStore } from "./dock-tab.store";
import { autorun, IReactionDisposer } from "mobx"; import { autorun, IReactionDisposer } from "mobx";
import { dockStore, IDockTab, TabId, TabKind } from "./dock.store"; import { dockStore, IDockTab, TabId, TabKind } from "./dock.store";
@ -11,6 +11,7 @@ export interface EditingResource {
draft?: string; // edited draft in yaml draft?: string; // edited draft in yaml
} }
@autobind
export class EditResourceStore extends DockTabStore<EditingResource> { export class EditResourceStore extends DockTabStore<EditingResource> {
private watchers = new Map<TabId, IReactionDisposer>(); private watchers = new Map<TabId, IReactionDisposer>();

View File

@ -25,6 +25,7 @@ export class InstallChartStore extends DockTabStore<IChartInstallData> {
storageKey: "install_charts" storageKey: "install_charts"
}); });
makeObservable(this); makeObservable(this);
autorun(() => { autorun(() => {
const { selectedTab, isOpen } = dockStore; const { selectedTab, isOpen } = dockStore;

View File

@ -54,7 +54,7 @@ export class InstallChart extends Component<Props> {
return installChartStore.details.getData(this.tabId); return installChartStore.details.getData(this.tabId);
} }
@autobind() @autobind
viewRelease() { viewRelease() {
const { release } = this.releaseDetails; const { release } = this.releaseDetails;
@ -67,14 +67,14 @@ export class InstallChart extends Component<Props> {
dockStore.closeTab(this.tabId); dockStore.closeTab(this.tabId);
} }
@autobind() @autobind
save(data: Partial<IChartInstallData>) { save(data: Partial<IChartInstallData>) {
const chart = { ...this.chartData, ...data }; const chart = { ...this.chartData, ...data };
installChartStore.setData(this.tabId, chart); installChartStore.setData(this.tabId, chart);
} }
@autobind() @autobind
onVersionChange(option: SelectOption) { onVersionChange(option: SelectOption) {
const version = option.value; const version = option.value;
@ -82,18 +82,18 @@ export class InstallChart extends Component<Props> {
installChartStore.loadValues(this.tabId); installChartStore.loadValues(this.tabId);
} }
@autobind() @autobind
onValuesChange(values: string, error?: string) { onValuesChange(values: string, error?: string) {
this.error = error; this.error = error;
this.save({ values }); this.save({ values });
} }
@autobind() @autobind
onNamespaceChange(opt: SelectOption) { onNamespaceChange(opt: SelectOption) {
this.save({ namespace: opt.value }); this.save({ namespace: opt.value });
} }
@autobind() @autobind
onReleaseNameChange(name: string) { onReleaseNameChange(name: string) {
this.save({ releaseName: name }); this.save({ releaseName: name });
} }

View File

@ -1,6 +1,6 @@
import { autorun, computed, makeObservable, observable } from "mobx"; import { autorun, computed, makeObservable, observable } from "mobx";
import { IPodLogsQuery, Pod, podsApi } from "../../api/endpoints"; import { IPodLogsQuery, Pod, podsApi } from "../../api/endpoints";
import { interval } from "../../utils"; import { autobind, interval } from "../../utils";
import { dockStore, TabId } from "./dock.store"; import { dockStore, TabId } from "./dock.store";
import { isLogsTab, logTabStore } from "./log-tab.store"; import { isLogsTab, logTabStore } from "./log-tab.store";
@ -8,6 +8,7 @@ type PodLogLine = string;
const logLinesToLoad = 500; const logLinesToLoad = 500;
@autobind
export class LogStore { export class LogStore {
private refresher = interval(10, () => { private refresher = interval(10, () => {
const id = dockStore.selectedTabId; const id = dockStore.selectedTabId;

View File

@ -54,7 +54,7 @@ export class Logs extends React.Component<Props> {
* A function for various actions after search is happened * A function for various actions after search is happened
* @param query {string} A text from search field * @param query {string} A text from search field
*/ */
@autobind() @autobind
onSearch() { onSearch() {
this.toOverlay(); this.toOverlay();
} }
@ -62,7 +62,7 @@ export class Logs extends React.Component<Props> {
/** /**
* Scrolling to active overlay (search word highlight) * Scrolling to active overlay (search word highlight)
*/ */
@autobind() @autobind
toOverlay() { toOverlay() {
const { activeOverlayLine } = searchStore; const { activeOverlayLine } = searchStore;

View File

@ -28,7 +28,7 @@ export class TerminalTab extends React.Component<Props> {
return terminalStore.isDisconnected(this.tabId); return terminalStore.isDisconnected(this.tabId);
} }
@autobind() @autobind
reconnect() { reconnect() {
terminalStore.reconnect(this.tabId); terminalStore.reconnect(this.tabId);
} }

View File

@ -3,6 +3,7 @@ import { Terminal } from "./terminal";
import { TerminalApi } from "../../api/terminal-api"; import { TerminalApi } from "../../api/terminal-api";
import { dockStore, IDockTab, TabId, TabKind } from "./dock.store"; import { dockStore, IDockTab, TabId, TabKind } from "./dock.store";
import { WebSocketApiState } from "../../api/websocket-api"; import { WebSocketApiState } from "../../api/websocket-api";
import { autobind } from "../../../common/utils";
export interface ITerminalTab extends IDockTab { export interface ITerminalTab extends IDockTab {
node?: string; // activate node shell mode node?: string; // activate node shell mode
@ -20,6 +21,7 @@ export function createTerminalTab(tabParams: Partial<ITerminalTab> = {}) {
}); });
} }
@autobind
export class TerminalStore { export class TerminalStore {
protected terminals = new Map<TabId, Terminal>(); protected terminals = new Map<TabId, Terminal>();
protected connections = observable.map<TabId, TerminalApi>(); protected connections = observable.map<TabId, TerminalApi>();

View File

@ -35,7 +35,7 @@ export class Terminal {
public scrollPos = 0; public scrollPos = 0;
public disposers: Function[] = []; public disposers: Function[] = [];
@autobind() @autobind
protected setTheme(colors: Record<string, string>) { protected setTheme(colors: Record<string, string>) {
// Replacing keys stored in styles to format accepted by terminal // Replacing keys stored in styles to format accepted by terminal
// E.g. terminalBrightBlack -> brightBlack // E.g. terminalBrightBlack -> brightBlack

View File

@ -33,7 +33,7 @@ export class EditableList<T> extends React.Component<Props<T>> {
makeObservable(this); makeObservable(this);
} }
@autobind() @autobind
onSubmit(val: string) { onSubmit(val: string) {
const { add } = this.props; const { add } = this.props;

View File

@ -36,7 +36,7 @@ export class Icon extends React.PureComponent<IconProps> {
return interactive ?? !!(onClick || href || link); return interactive ?? !!(onClick || href || link);
} }
@autobind() @autobind
onClick(evt: React.MouseEvent) { onClick(evt: React.MouseEvent) {
if (this.props.disabled) { if (this.props.disabled) {
return; return;
@ -47,7 +47,7 @@ export class Icon extends React.PureComponent<IconProps> {
} }
} }
@autobind() @autobind
onKeyDown(evt: React.KeyboardEvent<any>) { onKeyDown(evt: React.KeyboardEvent<any>) {
switch (evt.nativeEvent.code) { switch (evt.nativeEvent.code) {
case "Space": case "Space":

View File

@ -24,17 +24,17 @@ export class DropFileInput<T extends HTMLElement = any> extends React.Component<
makeObservable(this); makeObservable(this);
} }
@autobind() @autobind
onDragEnter() { onDragEnter() {
this.dropAreaActive = true; this.dropAreaActive = true;
} }
@autobind() @autobind
onDragLeave() { onDragLeave() {
this.dropAreaActive = false; this.dropAreaActive = false;
} }
@autobind() @autobind
onDragOver(evt: React.DragEvent<T>) { onDragOver(evt: React.DragEvent<T>) {
if (this.props.onDragOver) { if (this.props.onDragOver) {
this.props.onDragOver(evt); this.props.onDragOver(evt);
@ -43,7 +43,7 @@ export class DropFileInput<T extends HTMLElement = any> extends React.Component<
evt.dataTransfer.dropEffect = "move"; evt.dataTransfer.dropEffect = "move";
} }
@autobind() @autobind
onDrop(evt: React.DragEvent<T>) { onDrop(evt: React.DragEvent<T>) {
if (this.props.onDrop) { if (this.props.onDrop) {
this.props.onDrop(evt); this.props.onDrop(evt);

Some files were not shown because too many files have changed in this diff Show More