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:
parent
4c627b8649
commit
35732e5a59
@ -108,12 +108,12 @@ export class SearchStore {
|
||||
return prev;
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
public setNextOverlayActive(): void {
|
||||
this.activeOverlayIndex = this.getNextOverlay(true);
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
public setPrevOverlayActive(): void {
|
||||
this.activeOverlayIndex = this.getPrevOverlay(true);
|
||||
}
|
||||
@ -139,7 +139,7 @@ export class SearchStore {
|
||||
* @param line Index of the line where overlay is located
|
||||
* @param occurrence Number of the overlay within one line
|
||||
*/
|
||||
@autobind()
|
||||
@autobind
|
||||
public isActiveOverlay(line: number, occurrence: number): boolean {
|
||||
const firstLineIndex = this.occurrences.findIndex(item => item === line);
|
||||
|
||||
|
||||
@ -1,46 +1,47 @@
|
||||
// Decorator for binding class methods
|
||||
// Can be applied to class or single method as @autobind()
|
||||
type Constructor<T = {}> = new (...args: any[]) => T;
|
||||
// Auto-binding class method(s) to proper "this"-context.
|
||||
// Useful when calling methods after object-destruction or when method copied to scope variable.
|
||||
|
||||
// FIXME-or-REMOVE: doesn't work as class-decorator with mobx-6 decorators, e.g. @action, @computed, etc.
|
||||
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);
|
||||
};
|
||||
}
|
||||
type Constructor<T> = new (...args: any[]) => object;
|
||||
|
||||
function bindClass<T extends Constructor>(constructor: T) {
|
||||
const proto = constructor.prototype;
|
||||
const descriptors = Object.getOwnPropertyDescriptors(proto);
|
||||
const skipMethod = (methodName: string) => {
|
||||
return methodName === "constructor"
|
||||
|| typeof descriptors[methodName].value !== "function";
|
||||
};
|
||||
export function autobind<T extends Constructor<any>>(target: T): T;
|
||||
export function autobind<T extends object>(target: T, prop?: PropertyKey, descriptor?: PropertyDescriptor): PropertyDescriptor;
|
||||
|
||||
Object.keys(descriptors).forEach(prop => {
|
||||
if (skipMethod(prop)) return;
|
||||
const boundDescriptor = bindMethod(proto, prop, descriptors[prop]);
|
||||
|
||||
Object.defineProperty(proto, prop, boundDescriptor);
|
||||
});
|
||||
}
|
||||
|
||||
function bindMethod(target: object, prop?: string, descriptor?: PropertyDescriptor) {
|
||||
if (!descriptor || typeof descriptor.value !== "function") {
|
||||
throw new Error(`@autobind() must be used on class or method only`);
|
||||
export function autobind(target: any, prop?: PropertyKey, descriptor?: PropertyDescriptor) {
|
||||
if (typeof target === "function") {
|
||||
return bindClass(target);
|
||||
}
|
||||
if (typeof descriptor === "object") {
|
||||
return bindMethod(target, prop, descriptor);
|
||||
}
|
||||
}
|
||||
|
||||
export function bindClass<T extends Constructor<T>>(target: T): T {
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
import type { KubeObjectStore } from "../kube-object.store";
|
||||
import { action, makeObservable, observable } from "mobx";
|
||||
import { KubeApi, parseKubeApi } from "./kube-api";
|
||||
import { autobind } from "../../common/utils";
|
||||
|
||||
@autobind
|
||||
export class ApiManager {
|
||||
private apis = observable.map<string, KubeApi>();
|
||||
private stores = observable.map<string, KubeObjectStore>();
|
||||
|
||||
@ -2,7 +2,7 @@ import { autobind } from "../../utils";
|
||||
import { Role } from "./role.api";
|
||||
import { KubeApi } from "../kube-api";
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
export class ClusterRole extends Role {
|
||||
static kind = "ClusterRole";
|
||||
static namespaced = false;
|
||||
|
||||
@ -5,7 +5,7 @@ import { KubeApi } from "../kube-api";
|
||||
|
||||
export type ConfigMapData = Record<string, string>;
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
export class ConfigMap extends KubeObject {
|
||||
static kind = "ConfigMap";
|
||||
static namespaced = true;
|
||||
|
||||
@ -37,7 +37,7 @@ export class CronJobApi extends KubeApi<CronJob> {
|
||||
}
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
export class CronJob extends KubeObject {
|
||||
static kind = "CronJob";
|
||||
static namespaced = true;
|
||||
|
||||
@ -4,7 +4,7 @@ import { IAffinity, WorkloadKubeObject } from "../workload-kube-object";
|
||||
import { autobind } from "../../utils";
|
||||
import { KubeApi } from "../kube-api";
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
export class DaemonSet extends WorkloadKubeObject {
|
||||
static kind = "DaemonSet";
|
||||
static namespaced = true;
|
||||
|
||||
@ -66,7 +66,7 @@ interface IContainerProbe {
|
||||
failureThreshold?: number;
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
export class Deployment extends WorkloadKubeObject {
|
||||
static kind = "Deployment";
|
||||
static namespaced = true;
|
||||
|
||||
@ -100,7 +100,7 @@ export class EndpointSubset implements IEndpointSubset {
|
||||
}
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
export class Endpoint extends KubeObject {
|
||||
static kind = "Endpoints";
|
||||
static namespaced = true;
|
||||
|
||||
@ -4,7 +4,7 @@ import { formatDuration } from "../../utils/formatDuration";
|
||||
import { autobind } from "../../utils";
|
||||
import { KubeApi } from "../kube-api";
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
export class KubeEvent extends KubeObject {
|
||||
static kind = "Event";
|
||||
static namespaced = true;
|
||||
|
||||
@ -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 })}`);
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
export class HelmChart {
|
||||
constructor(data: any) {
|
||||
Object.assign(this, data);
|
||||
|
||||
@ -134,7 +134,7 @@ export async function rollbackRelease(name: string, namespace: string, revision:
|
||||
});
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
export class HelmRelease implements ItemObject {
|
||||
constructor(data: any) {
|
||||
Object.assign(this, data);
|
||||
|
||||
@ -61,7 +61,7 @@ export const getBackendServiceNamePort = (backend: IIngressBackend) => {
|
||||
return { serviceName, servicePort };
|
||||
};
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
export class Ingress extends KubeObject {
|
||||
static kind = "Ingress";
|
||||
static namespaced = true;
|
||||
|
||||
@ -5,7 +5,7 @@ import { IPodContainer } from "./pods.api";
|
||||
import { KubeApi } from "../kube-api";
|
||||
import { JsonApiParams } from "../json-api";
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
export class Job extends WorkloadKubeObject {
|
||||
static kind = "Job";
|
||||
static namespaced = true;
|
||||
|
||||
@ -29,7 +29,7 @@ export interface LimitRangeItem extends LimitRangeParts {
|
||||
type: string
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
export class LimitRange extends KubeObject {
|
||||
static kind = "LimitRange";
|
||||
static namespaced = true;
|
||||
|
||||
@ -7,7 +7,7 @@ export enum NamespaceStatus {
|
||||
TERMINATING = "Terminating",
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
export class Namespace extends KubeObject {
|
||||
static kind = "Namespace";
|
||||
static namespaced = false;
|
||||
|
||||
@ -35,7 +35,7 @@ export interface IPolicyEgress {
|
||||
}[];
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
export class NetworkPolicy extends KubeObject {
|
||||
static kind = "NetworkPolicy";
|
||||
static namespaced = true;
|
||||
|
||||
@ -28,7 +28,7 @@ export interface INodeMetrics<T = IMetrics> {
|
||||
fsSize: T;
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
export class Node extends KubeObject {
|
||||
static kind = "Node";
|
||||
static namespaced = false;
|
||||
|
||||
@ -21,7 +21,7 @@ export interface IPvcMetrics<T = IMetrics> {
|
||||
diskCapacity: T;
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
export class PersistentVolumeClaim extends KubeObject {
|
||||
static kind = "PersistentVolumeClaim";
|
||||
static namespaced = true;
|
||||
|
||||
@ -3,7 +3,7 @@ import { unitsToBytes } from "../../utils/convertMemory";
|
||||
import { autobind } from "../../utils";
|
||||
import { KubeApi } from "../kube-api";
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
export class PersistentVolume extends KubeObject {
|
||||
static kind = "PersistentVolume";
|
||||
static namespaced = false;
|
||||
|
||||
@ -2,7 +2,7 @@ import { autobind } from "../../utils";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import { KubeApi } from "../kube-api";
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
export class PodDisruptionBudget extends KubeObject {
|
||||
static kind = "PodDisruptionBudget";
|
||||
static namespaced = true;
|
||||
|
||||
@ -181,7 +181,7 @@ export interface IPodContainerStatus {
|
||||
started?: boolean;
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
export class Pod extends WorkloadKubeObject {
|
||||
static kind = "Pod";
|
||||
static namespaced = true;
|
||||
|
||||
@ -2,7 +2,7 @@ import { autobind } from "../../utils";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import { KubeApi } from "../kube-api";
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
export class PodSecurityPolicy extends KubeObject {
|
||||
static kind = "PodSecurityPolicy";
|
||||
static namespaced = false;
|
||||
|
||||
@ -27,7 +27,7 @@ export class ReplicaSetApi extends KubeApi<ReplicaSet> {
|
||||
}
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
export class ReplicaSet extends WorkloadKubeObject {
|
||||
static kind = "ReplicaSet";
|
||||
static namespaced = true;
|
||||
|
||||
@ -9,7 +9,7 @@ export interface IRoleBindingSubject {
|
||||
apiGroup?: string;
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
export class RoleBinding extends KubeObject {
|
||||
static kind = "RoleBinding";
|
||||
static namespaced = true;
|
||||
|
||||
@ -19,7 +19,7 @@ export interface ISecretRef {
|
||||
name: string;
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
export class Secret extends KubeObject {
|
||||
static kind = "Secret";
|
||||
static namespaced = true;
|
||||
|
||||
@ -2,7 +2,7 @@ import { autobind } from "../../utils";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import { KubeApi } from "../kube-api";
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
export class ServiceAccount extends KubeObject {
|
||||
static kind = "ServiceAccount";
|
||||
static namespaced = true;
|
||||
|
||||
@ -29,7 +29,7 @@ export class ServicePort implements IServicePort {
|
||||
}
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
export class Service extends KubeObject {
|
||||
static kind = "Service";
|
||||
static namespaced = true;
|
||||
|
||||
@ -27,7 +27,7 @@ export class StatefulSetApi extends KubeApi<StatefulSet> {
|
||||
}
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
export class StatefulSet extends WorkloadKubeObject {
|
||||
static kind = "StatefulSet";
|
||||
static namespaced = true;
|
||||
|
||||
@ -2,7 +2,7 @@ import { autobind } from "../../utils";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import { KubeApi } from "../kube-api";
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
export class StorageClass extends KubeObject {
|
||||
static kind = "StorageClass";
|
||||
static namespaced = false;
|
||||
|
||||
@ -66,7 +66,7 @@ export class KubeStatus {
|
||||
|
||||
export type IKubeMetaField = keyof IKubeObjectMetadata;
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
export class KubeObject implements ItemObject {
|
||||
static readonly kind: string;
|
||||
static readonly namespaced: boolean;
|
||||
|
||||
@ -5,7 +5,7 @@ import type { KubeObjectStore } from "../kube-object.store";
|
||||
import type { ClusterContext } from "../components/context";
|
||||
import plimit from "p-limit";
|
||||
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 { isDebugging, isProduction } from "../../common/vars";
|
||||
|
||||
@ -27,6 +27,7 @@ export interface IKubeWatchLog {
|
||||
cssStyle?: string;
|
||||
}
|
||||
|
||||
@autobind
|
||||
export class KubeWatchApi {
|
||||
@observable context: ClusterContext = null;
|
||||
|
||||
|
||||
@ -85,7 +85,7 @@ export class TerminalApi extends WebSocketApi {
|
||||
this.onReady.removeAllListeners();
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
protected _onReady(data: string) {
|
||||
if (!data) return;
|
||||
this.isReady = true;
|
||||
|
||||
@ -51,7 +51,7 @@ export class HelmChartDetails extends Component<Props> {
|
||||
});
|
||||
});
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
async onVersionChange({ value: version }: SelectOption<string>) {
|
||||
this.selectedChart = this.chartVersions.find(chart => chart.version === version);
|
||||
this.readme = null;
|
||||
@ -68,7 +68,7 @@ export class HelmChartDetails extends Component<Props> {
|
||||
}
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
install() {
|
||||
createInstallChartTab(this.selectedChart);
|
||||
this.props.hideDetails();
|
||||
|
||||
@ -3,12 +3,14 @@ import { makeObservable, observable } from "mobx";
|
||||
import { getChartDetails, HelmChart, listCharts } from "../../api/endpoints/helm-charts.api";
|
||||
import { ItemStore } from "../../item.store";
|
||||
import flatten from "lodash/flatten";
|
||||
import { autobind } from "../../../common/utils";
|
||||
|
||||
export interface IChartVersion {
|
||||
repo: string;
|
||||
version: string;
|
||||
}
|
||||
|
||||
@autobind
|
||||
export class HelmChartStore extends ItemStore<HelmChart> {
|
||||
@observable versions = observable.map<string, IChartVersion[]>();
|
||||
|
||||
|
||||
@ -14,12 +14,12 @@ interface Props extends MenuActionsProps {
|
||||
}
|
||||
|
||||
export class HelmReleaseMenu extends React.Component<Props> {
|
||||
@autobind()
|
||||
@autobind
|
||||
remove() {
|
||||
return releaseStore.remove(this.props.release);
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
upgrade() {
|
||||
const { release, hideDetails } = this.props;
|
||||
|
||||
@ -27,7 +27,7 @@ export class HelmReleaseMenu extends React.Component<Props> {
|
||||
hideDetails && hideDetails();
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
rollback() {
|
||||
ReleaseRollbackDialog.open(this.props.release);
|
||||
}
|
||||
|
||||
@ -6,8 +6,9 @@ import { Secret } from "../../api/endpoints";
|
||||
import { secretsStore } from "../+config-secrets/secrets.store";
|
||||
import { namespaceStore } from "../+namespaces/namespace.store";
|
||||
import { Notifications } from "../notifications";
|
||||
import { toJS } from "../../../common/utils";
|
||||
import { autobind, toJS } from "../../../common/utils";
|
||||
|
||||
@autobind
|
||||
export class ReleaseStore extends ItemStore<HelmRelease> {
|
||||
releaseSecrets = observable.map<string, Secret>();
|
||||
|
||||
|
||||
@ -40,17 +40,17 @@ export class CatalogAddButton extends React.Component<CatalogAddButtonProps> {
|
||||
]);
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
onOpen() {
|
||||
this.isOpen = true;
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
onClose() {
|
||||
this.isOpen = false;
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
onButtonClick() {
|
||||
if (this.menuItems.length == 1) {
|
||||
this.menuItems[0].onClick();
|
||||
|
||||
@ -3,7 +3,9 @@ import { catalogEntityRegistry } from "../../api/catalog-entity-registry";
|
||||
import { CatalogEntity, CatalogEntityActionContext } from "../../api/catalog-entity";
|
||||
import { ItemObject, ItemStore } from "../../item.store";
|
||||
import { CatalogCategory } from "../../../common/catalog";
|
||||
import { autobind } from "../../../common/utils";
|
||||
|
||||
@autobind
|
||||
export class CatalogEntityItem implements ItemObject {
|
||||
constructor(public entity: CatalogEntity) {
|
||||
makeObservable(this);
|
||||
@ -63,6 +65,7 @@ export class CatalogEntityItem implements ItemObject {
|
||||
}
|
||||
}
|
||||
|
||||
@autobind
|
||||
export class CatalogEntityStore extends ItemStore<CatalogEntityItem> {
|
||||
@observable activeCategory?: CatalogCategory;
|
||||
|
||||
|
||||
@ -112,7 +112,7 @@ export class Catalog extends React.Component {
|
||||
);
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
renderItemMenu(item: CatalogEntityItem) {
|
||||
const menuItems = this.contextMenu.menuItems.filter((menuItem) => !menuItem.onlyVisibleForSource || menuItem.onlyVisibleForSource === item.entity.metadata.source);
|
||||
|
||||
|
||||
@ -87,7 +87,7 @@ export class ClusterIssues extends React.Component<Props> {
|
||||
return warnings;
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
getTableRow(uid: string) {
|
||||
const { warnings } = this;
|
||||
const warning = warnings.find(warn => warn.getId() == uid);
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { action, makeObservable, observable, reaction, when } from "mobx";
|
||||
import { KubeObjectStore } from "../../kube-object.store";
|
||||
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 { nodesStore } from "../+nodes/nodes.store";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
@ -21,6 +21,7 @@ export interface ClusterOverviewStorageState {
|
||||
metricNodeRole: MetricNodeRole,
|
||||
}
|
||||
|
||||
@autobind
|
||||
export class ClusterOverviewStore extends KubeObjectStore<Cluster> implements ClusterOverviewStorageState {
|
||||
api = clusterApi;
|
||||
|
||||
@ -30,13 +31,13 @@ export class ClusterOverviewStore extends KubeObjectStore<Cluster> implements Cl
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
makeObservable(this);
|
||||
|
||||
this.storage = createStorage<ClusterOverviewStorageState>("cluster_overview", {
|
||||
metricType: MetricType.CPU, // setup defaults
|
||||
metricNodeRole: MetricNodeRole.WORKER,
|
||||
});
|
||||
|
||||
makeObservable(this);
|
||||
this.init();
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
import { KubeObjectStore } from "../../kube-object.store";
|
||||
import { HorizontalPodAutoscaler, hpaApi } from "../../api/endpoints/hpa.api";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
import { autobind } from "../../../common/utils";
|
||||
|
||||
@autobind
|
||||
export class HPAStore extends KubeObjectStore<HorizontalPodAutoscaler> {
|
||||
api = hpaApi;
|
||||
}
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
import { KubeObjectStore } from "../../kube-object.store";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
import { LimitRange, limitRangeApi } from "../../api/endpoints/limit-range.api";
|
||||
import { autobind } from "../../../common/utils";
|
||||
|
||||
@autobind
|
||||
export class LimitRangesStore extends KubeObjectStore<LimitRange> {
|
||||
api = limitRangeApi;
|
||||
}
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
import { KubeObjectStore } from "../../kube-object.store";
|
||||
import { ConfigMap, configMapApi } from "../../api/endpoints/configmap.api";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
import { autobind } from "../../../common/utils";
|
||||
|
||||
@autobind
|
||||
export class ConfigMapsStore extends KubeObjectStore<ConfigMap> {
|
||||
api = configMapApi;
|
||||
}
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
import { KubeObjectStore } from "../../kube-object.store";
|
||||
import { pdbApi, PodDisruptionBudget } from "../../api/endpoints/poddisruptionbudget.api";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
import { autobind } from "../../../common/utils";
|
||||
|
||||
@autobind
|
||||
export class PodDisruptionBudgetsStore extends KubeObjectStore<PodDisruptionBudget> {
|
||||
api = pdbApi;
|
||||
}
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
import { KubeObjectStore } from "../../kube-object.store";
|
||||
import { ResourceQuota, resourceQuotaApi } from "../../api/endpoints/resource-quota.api";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
import { autobind } from "../../../common/utils";
|
||||
|
||||
@autobind
|
||||
export class ResourceQuotasStore extends KubeObjectStore<ResourceQuota> {
|
||||
api = resourceQuotaApi;
|
||||
}
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
import { KubeObjectStore } from "../../kube-object.store";
|
||||
import { Secret, secretsApi } from "../../api/endpoints";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
import { autobind } from "../../../common/utils";
|
||||
|
||||
@autobind
|
||||
export class SecretsStore extends KubeObjectStore<Secret> {
|
||||
api = secretsApi;
|
||||
}
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
import { KubeApi } from "../../api/kube-api";
|
||||
import { KubeObjectStore } from "../../kube-object.store";
|
||||
import { KubeObject } from "../../api/kube-object";
|
||||
import { autobind } from "../../../common/utils";
|
||||
|
||||
@autobind
|
||||
export class CRDResourceStore<T extends KubeObject = any> extends KubeObjectStore<T> {
|
||||
api: KubeApi;
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@ import { apiManager } from "../../api/api-manager";
|
||||
import { KubeApi } from "../../api/kube-api";
|
||||
import { CRDResourceStore } from "./crd-resource.store";
|
||||
import { KubeObject } from "../../api/kube-object";
|
||||
import { toJS } from "../../../common/utils";
|
||||
import { autobind, toJS } from "../../../common/utils";
|
||||
|
||||
function initStore(crd: CustomResourceDefinition) {
|
||||
const apiBase = crd.getResourceApiBase();
|
||||
@ -18,6 +18,7 @@ function initStore(crd: CustomResourceDefinition) {
|
||||
}
|
||||
}
|
||||
|
||||
@autobind
|
||||
export class CRDStore extends KubeObjectStore<CustomResourceDefinition> {
|
||||
api = crdApi;
|
||||
|
||||
|
||||
@ -6,7 +6,9 @@ import { KubeObject } from "../../api/kube-object";
|
||||
import { Pod } from "../../api/endpoints/pods.api";
|
||||
import { podsStore } from "../+workloads-pods/pods.store";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
import { autobind } from "../../../common/utils";
|
||||
|
||||
@autobind
|
||||
export class EventStore extends KubeObjectStore<KubeEvent> {
|
||||
api = eventApi;
|
||||
limit = 1000;
|
||||
|
||||
@ -30,7 +30,7 @@ export class ExtensionInstallationStateStore {
|
||||
});
|
||||
}
|
||||
|
||||
@action static reset() {
|
||||
static reset() {
|
||||
logger.warn(`${Prefix}: resetting, may throw errors`);
|
||||
ExtensionInstallationStateStore.InstallingExtensions.clear();
|
||||
ExtensionInstallationStateStore.UninstallingExtensions.clear();
|
||||
@ -42,7 +42,7 @@ export class ExtensionInstallationStateStore {
|
||||
* @param extId the ID of the extension
|
||||
* @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`);
|
||||
|
||||
const curState = ExtensionInstallationStateStore.getInstallationState(extId);
|
||||
@ -76,7 +76,7 @@ export class ExtensionInstallationStateStore {
|
||||
* determined.
|
||||
* @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();
|
||||
|
||||
logger.debug(`${Prefix}: starting a new preinstall phase: ${preInstallStepId}`);
|
||||
@ -93,7 +93,7 @@ export class ExtensionInstallationStateStore {
|
||||
* @param extId the ID of the extension
|
||||
* @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`);
|
||||
|
||||
const curState = ExtensionInstallationStateStore.getInstallationState(extId);
|
||||
@ -110,7 +110,7 @@ export class ExtensionInstallationStateStore {
|
||||
* @param extId The ID of the extension
|
||||
* @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`);
|
||||
|
||||
const curState = ExtensionInstallationStateStore.getInstallationState(extId);
|
||||
@ -128,7 +128,7 @@ export class ExtensionInstallationStateStore {
|
||||
* @param extId The ID of the extension
|
||||
* @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`);
|
||||
|
||||
const curState = ExtensionInstallationStateStore.getInstallationState(extId);
|
||||
|
||||
@ -519,7 +519,7 @@ export class Extensions extends React.Component {
|
||||
);
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
renderExtension(extension: InstalledExtension) {
|
||||
const { id, isEnabled, manifest } = extension;
|
||||
const { name, description, version } = manifest;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
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 { Namespace, namespacesApi } from "../../api/endpoints/namespaces.api";
|
||||
import { createPageParam } from "../../navigation";
|
||||
@ -27,6 +27,7 @@ export function getDummyNamespace(name: string) {
|
||||
});
|
||||
}
|
||||
|
||||
@autobind
|
||||
export class NamespaceStore extends KubeObjectStore<Namespace> {
|
||||
api = namespacesApi;
|
||||
|
||||
|
||||
@ -29,7 +29,7 @@ export class EndpointSubsetList extends React.Component<Props> {
|
||||
return this.renderAddressTableRow(address);
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
getNotReadyAddressTableRow(ip: string) {
|
||||
const { subset} = this.props;
|
||||
const address = subset.getNotReadyAddresses().find(address => address.getId() == ip);
|
||||
@ -37,7 +37,7 @@ export class EndpointSubsetList extends React.Component<Props> {
|
||||
return this.renderAddressTableRow(address);
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
renderAddressTable(addresses: EndpointAddress[], virtual: boolean) {
|
||||
return (
|
||||
<div>
|
||||
@ -63,7 +63,7 @@ export class EndpointSubsetList extends React.Component<Props> {
|
||||
);
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
renderAddressTableRow(address: EndpointAddress) {
|
||||
const { endpoint } = this.props;
|
||||
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
import { KubeObjectStore } from "../../kube-object.store";
|
||||
import { Endpoint, endpointApi } from "../../api/endpoints/endpoint.api";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
import { autobind } from "../../../common/utils";
|
||||
|
||||
@autobind
|
||||
export class EndpointStore extends KubeObjectStore<Endpoint> {
|
||||
api = endpointApi;
|
||||
}
|
||||
|
||||
@ -2,7 +2,9 @@ import { makeObservable, observable } from "mobx";
|
||||
import { KubeObjectStore } from "../../kube-object.store";
|
||||
import { IIngressMetrics, Ingress, ingressApi } from "../../api/endpoints";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
import { autobind } from "../../../common/utils";
|
||||
|
||||
@autobind
|
||||
export class IngressStore extends KubeObjectStore<Ingress> {
|
||||
api = ingressApi;
|
||||
@observable metrics: IIngressMetrics = null;
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
import { KubeObjectStore } from "../../kube-object.store";
|
||||
import { NetworkPolicy, networkPolicyApi } from "../../api/endpoints/network-policy.api";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
import { autobind } from "../../../common/utils";
|
||||
|
||||
@autobind
|
||||
export class NetworkPolicyStore extends KubeObjectStore<NetworkPolicy> {
|
||||
api = networkPolicyApi;
|
||||
}
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
import { KubeObjectStore } from "../../kube-object.store";
|
||||
import { Service, serviceApi } from "../../api/endpoints/service.api";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
import { autobind } from "../../../common/utils";
|
||||
|
||||
@autobind
|
||||
export class ServiceStore extends KubeObjectStore<Service> {
|
||||
api = serviceApi;
|
||||
}
|
||||
|
||||
@ -3,7 +3,9 @@ import { action, computed, makeObservable, observable } from "mobx";
|
||||
import { clusterApi, IClusterMetrics, INodeMetrics, Node, nodesApi } from "../../api/endpoints";
|
||||
import { KubeObjectStore } from "../../kube-object.store";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
import { autobind } from "../../../common/utils";
|
||||
|
||||
@autobind
|
||||
export class NodesStore extends KubeObjectStore<Node> {
|
||||
api = nodesApi;
|
||||
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
import { PodSecurityPolicy, pspApi } from "../../api/endpoints";
|
||||
import { KubeObjectStore } from "../../kube-object.store";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
import { autobind } from "../../../common/utils";
|
||||
|
||||
@autobind
|
||||
export class PodSecurityPoliciesStore extends KubeObjectStore<PodSecurityPolicy> {
|
||||
api = pspApi;
|
||||
}
|
||||
|
||||
@ -2,7 +2,9 @@ import { KubeObjectStore } from "../../kube-object.store";
|
||||
import { StorageClass, storageClassApi } from "../../api/endpoints/storage-class.api";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
import { volumesStore } from "../+storage-volumes/volumes.store";
|
||||
import { autobind } from "../../../common/utils";
|
||||
|
||||
@autobind
|
||||
export class StorageClassStore extends KubeObjectStore<StorageClass> {
|
||||
api = storageClassApi;
|
||||
|
||||
|
||||
@ -2,7 +2,9 @@ import { action, makeObservable, observable } from "mobx";
|
||||
import { KubeObjectStore } from "../../kube-object.store";
|
||||
import { IPvcMetrics, PersistentVolumeClaim, pvcApi } from "../../api/endpoints";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
import { autobind } from "../../../common/utils";
|
||||
|
||||
@autobind
|
||||
export class VolumeClaimStore extends KubeObjectStore<PersistentVolumeClaim> {
|
||||
api = pvcApi;
|
||||
@observable metrics: IPvcMetrics = null;
|
||||
|
||||
@ -39,7 +39,7 @@ export class VolumeDetailsList extends React.Component<Props> {
|
||||
makeObservable(this);
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
getTableRow(uid: string) {
|
||||
const { persistentVolumes } = this.props;
|
||||
const volume = persistentVolumes.find(volume => volume.getId() === uid);
|
||||
|
||||
@ -2,7 +2,9 @@ import { KubeObjectStore } from "../../kube-object.store";
|
||||
import { PersistentVolume, persistentVolumeApi } from "../../api/endpoints/persistent-volume.api";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
import { StorageClass } from "../../api/endpoints/storage-class.api";
|
||||
import { autobind } from "../../../common/utils";
|
||||
|
||||
@autobind
|
||||
export class PersistentVolumesStore extends KubeObjectStore<PersistentVolume> {
|
||||
api = persistentVolumeApi;
|
||||
|
||||
|
||||
@ -47,7 +47,7 @@ export class RoleBindingDetails extends React.Component<Props> {
|
||||
);
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
removeSelectedSubjects() {
|
||||
const { object: roleBinding } = this.props;
|
||||
const { selectedSubjects } = this;
|
||||
|
||||
@ -3,7 +3,9 @@ import uniqBy from "lodash/uniqBy";
|
||||
import { clusterRoleBindingApi, IRoleBindingSubject, RoleBinding, roleBindingApi } from "../../api/endpoints";
|
||||
import { KubeObjectStore, KubeObjectStoreLoadingParams } from "../../kube-object.store";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
import { autobind } from "../../../common/utils";
|
||||
|
||||
@autobind
|
||||
export class RoleBindingsStore extends KubeObjectStore<RoleBinding> {
|
||||
api = clusterRoleBindingApi;
|
||||
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
import { clusterRoleApi, Role, roleApi } from "../../api/endpoints";
|
||||
import { KubeObjectStore, KubeObjectStoreLoadingParams } from "../../kube-object.store";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
import { autobind } from "../../../common/utils";
|
||||
|
||||
@autobind
|
||||
export class RolesStore extends KubeObjectStore<Role> {
|
||||
api = clusterRoleApi;
|
||||
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
import { ServiceAccount, serviceAccountsApi } from "../../api/endpoints";
|
||||
import { KubeObjectStore } from "../../kube-object.store";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
import { autobind } from "../../../common/utils";
|
||||
|
||||
@autobind
|
||||
export class ServiceAccountsStore extends KubeObjectStore<ServiceAccount> {
|
||||
api = serviceAccountsApi;
|
||||
|
||||
|
||||
@ -2,7 +2,9 @@ import { KubeObjectStore } from "../../kube-object.store";
|
||||
import { CronJob, cronJobApi } from "../../api/endpoints/cron-job.api";
|
||||
import { jobStore } from "../+workloads-jobs/job.store";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
import { autobind } from "../../../common/utils";
|
||||
|
||||
@autobind
|
||||
export class CronJobStore extends KubeObjectStore<CronJob> {
|
||||
api = cronJobApi;
|
||||
|
||||
|
||||
@ -3,7 +3,9 @@ import { KubeObjectStore } from "../../kube-object.store";
|
||||
import { DaemonSet, daemonSetApi, IPodMetrics, Pod, podsApi, PodStatus } from "../../api/endpoints";
|
||||
import { podsStore } from "../+workloads-pods/pods.store";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
import { autobind } from "../../../common/utils";
|
||||
|
||||
@autobind
|
||||
export class DaemonSetStore extends KubeObjectStore<DaemonSet> {
|
||||
api = daemonSetApi;
|
||||
|
||||
|
||||
@ -3,7 +3,9 @@ import { Deployment, deploymentApi, IPodMetrics, podsApi, PodStatus } from "../.
|
||||
import { KubeObjectStore } from "../../kube-object.store";
|
||||
import { podsStore } from "../+workloads-pods/pods.store";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
import { autobind } from "../../../common/utils";
|
||||
|
||||
@autobind
|
||||
export class DeploymentStore extends KubeObjectStore<Deployment> {
|
||||
api = deploymentApi;
|
||||
@observable metrics: IPodMetrics = null;
|
||||
|
||||
@ -3,7 +3,9 @@ import { Job, jobApi } from "../../api/endpoints/job.api";
|
||||
import { CronJob, Pod, PodStatus } from "../../api/endpoints";
|
||||
import { podsStore } from "../+workloads-pods/pods.store";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
import { autobind } from "../../../common/utils";
|
||||
|
||||
@autobind
|
||||
export class JobStore extends KubeObjectStore<Job> {
|
||||
api = jobApi;
|
||||
|
||||
|
||||
@ -29,7 +29,7 @@ export class OverviewStatuses extends React.Component {
|
||||
makeObservable(this);
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
renderWorkload(resource: KubeResource): React.ReactElement {
|
||||
const store = workloadStores[resource];
|
||||
const items = store.getAllByNs(namespaceStore.contextNamespaces);
|
||||
|
||||
@ -103,7 +103,7 @@ export class PodDetailsList extends React.Component<Props> {
|
||||
);
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
getTableRow(uid: string) {
|
||||
const { pods } = this.props;
|
||||
const pod = pods.find(pod => pod.getId() == uid);
|
||||
|
||||
@ -56,7 +56,7 @@ export class PodDetails extends React.Component<Props> {
|
||||
podsStore.reset();
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
async loadMetrics() {
|
||||
const { object: pod } = this.props;
|
||||
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
import countBy from "lodash/countBy";
|
||||
import { action, makeObservable, observable } from "mobx";
|
||||
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 { apiManager } from "../../api/api-manager";
|
||||
import { WorkloadKubeObject } from "../../api/workload-kube-object";
|
||||
|
||||
@autobind
|
||||
export class PodsStore extends KubeObjectStore<Pod> {
|
||||
api = podsApi;
|
||||
|
||||
|
||||
@ -4,7 +4,9 @@ import { Deployment, IPodMetrics, podsApi, ReplicaSet, replicaSetApi } from "../
|
||||
import { podsStore } from "../+workloads-pods/pods.store";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
import { PodStatus } from "../../api/endpoints/pods.api";
|
||||
import { autobind } from "../../../common/utils";
|
||||
|
||||
@autobind
|
||||
export class ReplicaSetStore extends KubeObjectStore<ReplicaSet> {
|
||||
api = replicaSetApi;
|
||||
@observable metrics: IPodMetrics = null;
|
||||
|
||||
@ -3,7 +3,9 @@ import { KubeObjectStore } from "../../kube-object.store";
|
||||
import { IPodMetrics, podsApi, PodStatus, StatefulSet, statefulSetApi } from "../../api/endpoints";
|
||||
import { podsStore } from "../+workloads-pods/pods.store";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
import { autobind } from "../../../common/utils";
|
||||
|
||||
@autobind
|
||||
export class StatefulSetStore extends KubeObjectStore<StatefulSet> {
|
||||
api = statefulSetApi;
|
||||
@observable metrics: IPodMetrics = null;
|
||||
|
||||
@ -130,7 +130,7 @@ export class AceEditor extends React.Component<Props, State> {
|
||||
});
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
onCursorPosChange() {
|
||||
const { onCursorPosChange } = this.props;
|
||||
|
||||
@ -139,7 +139,7 @@ export class AceEditor extends React.Component<Props, State> {
|
||||
}
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
onChange(delta: Ace.Delta) {
|
||||
const { onChange } = this.props;
|
||||
|
||||
|
||||
@ -71,7 +71,7 @@ export class Animate extends React.Component<AnimateProps> {
|
||||
this.statusClassName.leave = false;
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
onTransitionEnd(evt: React.TransitionEvent) {
|
||||
const { enter, leave } = this.statusClassName;
|
||||
const { onTransitionEnd } = this.contentElem.props;
|
||||
|
||||
@ -15,7 +15,7 @@ export interface CheckboxProps<T = boolean> {
|
||||
export class Checkbox extends React.PureComponent<CheckboxProps> {
|
||||
private input: HTMLInputElement;
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
onChange(evt: React.ChangeEvent<HTMLInputElement>) {
|
||||
if (this.props.onChange) {
|
||||
this.props.onChange(this.input.checked, evt);
|
||||
|
||||
@ -33,7 +33,7 @@ export class Clipboard extends React.Component<CopyToClipboardProps> {
|
||||
return React.Children.only(this.props.children) as React.ReactElement;
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
onClick(evt: React.MouseEvent) {
|
||||
if (this.rootReactElem.props.onClick) {
|
||||
this.rootReactElem.props.onClick(evt); // pass event to children-root-element if any
|
||||
|
||||
@ -12,7 +12,7 @@ interface Props {
|
||||
@observer
|
||||
export class ClusterKubeconfig extends React.Component<Props> {
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
openKubeconfig() {
|
||||
const { cluster } = this.props;
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ export class RemoveClusterButton extends React.Component<Props> {
|
||||
makeObservable(this);
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
confirmRemoveCluster() {
|
||||
const { cluster } = this.props;
|
||||
|
||||
|
||||
@ -6,7 +6,9 @@ import filehound from "filehound";
|
||||
import { watch } from "chokidar";
|
||||
import { DockTabStore } from "./dock-tab.store";
|
||||
import { dockStore, IDockTab, TabKind } from "./dock.store";
|
||||
import { autobind } from "../../../common/utils";
|
||||
|
||||
@autobind
|
||||
export class CreateResourceStore extends DockTabStore<string> {
|
||||
|
||||
constructor() {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
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";
|
||||
|
||||
export interface DockTabStoreOptions {
|
||||
@ -9,6 +9,7 @@ export interface DockTabStoreOptions {
|
||||
|
||||
export type DockTabStorageState<T> = Record<TabId, T>;
|
||||
|
||||
@autobind
|
||||
export class DockTabStore<T> {
|
||||
protected storage?: StorageHelper<DockTabStorageState<T>>;
|
||||
protected data = observable.map<TabId, T>();
|
||||
|
||||
@ -26,7 +26,7 @@ export class DockTab extends React.Component<DockTabProps> {
|
||||
return this.props.value.id;
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
close() {
|
||||
dockStore.closeTab(this.tabId);
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import MD5 from "crypto-js/md5";
|
||||
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";
|
||||
|
||||
export type TabId = string;
|
||||
@ -28,7 +28,12 @@ export interface DockStorageState {
|
||||
isOpen?: boolean;
|
||||
}
|
||||
|
||||
@autobind
|
||||
export class DockStore implements DockStorageState {
|
||||
private storage: StorageHelper<DockStorageState>;
|
||||
public readonly minHeight = 100;
|
||||
@observable fullSize = false;
|
||||
|
||||
constructor() {
|
||||
makeObservable(this);
|
||||
|
||||
@ -42,10 +47,6 @@ export class DockStore implements DockStorageState {
|
||||
this.bindEvents();
|
||||
}
|
||||
|
||||
private storage: StorageHelper<DockStorageState>;
|
||||
public readonly minHeight = 100;
|
||||
@observable fullSize = false;
|
||||
|
||||
get isOpen(): boolean {
|
||||
return this.storage.get().isOpen;
|
||||
}
|
||||
@ -127,6 +128,7 @@ export class DockStore implements DockStorageState {
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
close() {
|
||||
this.isOpen = false;
|
||||
}
|
||||
@ -142,7 +144,7 @@ export class DockStore implements DockStorageState {
|
||||
this.fullSize = !this.fullSize;
|
||||
}
|
||||
|
||||
getTabById(tabId: TabId) {
|
||||
getTabById(tabId: TabId): IDockTab | undefined {
|
||||
return this.tabs.find(tab => tab.id === tabId);
|
||||
}
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { noop } from "../../utils";
|
||||
import { autobind, noop } from "../../utils";
|
||||
import { DockTabStore } from "./dock-tab.store";
|
||||
import { autorun, IReactionDisposer } from "mobx";
|
||||
import { dockStore, IDockTab, TabId, TabKind } from "./dock.store";
|
||||
@ -11,6 +11,7 @@ export interface EditingResource {
|
||||
draft?: string; // edited draft in yaml
|
||||
}
|
||||
|
||||
@autobind
|
||||
export class EditResourceStore extends DockTabStore<EditingResource> {
|
||||
private watchers = new Map<TabId, IReactionDisposer>();
|
||||
|
||||
|
||||
@ -25,6 +25,7 @@ export class InstallChartStore extends DockTabStore<IChartInstallData> {
|
||||
storageKey: "install_charts"
|
||||
});
|
||||
makeObservable(this);
|
||||
|
||||
autorun(() => {
|
||||
const { selectedTab, isOpen } = dockStore;
|
||||
|
||||
|
||||
@ -54,7 +54,7 @@ export class InstallChart extends Component<Props> {
|
||||
return installChartStore.details.getData(this.tabId);
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
viewRelease() {
|
||||
const { release } = this.releaseDetails;
|
||||
|
||||
@ -67,14 +67,14 @@ export class InstallChart extends Component<Props> {
|
||||
dockStore.closeTab(this.tabId);
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
save(data: Partial<IChartInstallData>) {
|
||||
const chart = { ...this.chartData, ...data };
|
||||
|
||||
installChartStore.setData(this.tabId, chart);
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
onVersionChange(option: SelectOption) {
|
||||
const version = option.value;
|
||||
|
||||
@ -82,18 +82,18 @@ export class InstallChart extends Component<Props> {
|
||||
installChartStore.loadValues(this.tabId);
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
onValuesChange(values: string, error?: string) {
|
||||
this.error = error;
|
||||
this.save({ values });
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
onNamespaceChange(opt: SelectOption) {
|
||||
this.save({ namespace: opt.value });
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
onReleaseNameChange(name: string) {
|
||||
this.save({ releaseName: name });
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { autorun, computed, makeObservable, observable } from "mobx";
|
||||
import { IPodLogsQuery, Pod, podsApi } from "../../api/endpoints";
|
||||
import { interval } from "../../utils";
|
||||
import { autobind, interval } from "../../utils";
|
||||
import { dockStore, TabId } from "./dock.store";
|
||||
import { isLogsTab, logTabStore } from "./log-tab.store";
|
||||
|
||||
@ -8,6 +8,7 @@ type PodLogLine = string;
|
||||
|
||||
const logLinesToLoad = 500;
|
||||
|
||||
@autobind
|
||||
export class LogStore {
|
||||
private refresher = interval(10, () => {
|
||||
const id = dockStore.selectedTabId;
|
||||
|
||||
@ -54,7 +54,7 @@ export class Logs extends React.Component<Props> {
|
||||
* A function for various actions after search is happened
|
||||
* @param query {string} A text from search field
|
||||
*/
|
||||
@autobind()
|
||||
@autobind
|
||||
onSearch() {
|
||||
this.toOverlay();
|
||||
}
|
||||
@ -62,7 +62,7 @@ export class Logs extends React.Component<Props> {
|
||||
/**
|
||||
* Scrolling to active overlay (search word highlight)
|
||||
*/
|
||||
@autobind()
|
||||
@autobind
|
||||
toOverlay() {
|
||||
const { activeOverlayLine } = searchStore;
|
||||
|
||||
|
||||
@ -28,7 +28,7 @@ export class TerminalTab extends React.Component<Props> {
|
||||
return terminalStore.isDisconnected(this.tabId);
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
reconnect() {
|
||||
terminalStore.reconnect(this.tabId);
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ import { Terminal } from "./terminal";
|
||||
import { TerminalApi } from "../../api/terminal-api";
|
||||
import { dockStore, IDockTab, TabId, TabKind } from "./dock.store";
|
||||
import { WebSocketApiState } from "../../api/websocket-api";
|
||||
import { autobind } from "../../../common/utils";
|
||||
|
||||
export interface ITerminalTab extends IDockTab {
|
||||
node?: string; // activate node shell mode
|
||||
@ -20,6 +21,7 @@ export function createTerminalTab(tabParams: Partial<ITerminalTab> = {}) {
|
||||
});
|
||||
}
|
||||
|
||||
@autobind
|
||||
export class TerminalStore {
|
||||
protected terminals = new Map<TabId, Terminal>();
|
||||
protected connections = observable.map<TabId, TerminalApi>();
|
||||
|
||||
@ -35,7 +35,7 @@ export class Terminal {
|
||||
public scrollPos = 0;
|
||||
public disposers: Function[] = [];
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
protected setTheme(colors: Record<string, string>) {
|
||||
// Replacing keys stored in styles to format accepted by terminal
|
||||
// E.g. terminalBrightBlack -> brightBlack
|
||||
|
||||
@ -33,7 +33,7 @@ export class EditableList<T> extends React.Component<Props<T>> {
|
||||
makeObservable(this);
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
onSubmit(val: string) {
|
||||
const { add } = this.props;
|
||||
|
||||
|
||||
@ -36,7 +36,7 @@ export class Icon extends React.PureComponent<IconProps> {
|
||||
return interactive ?? !!(onClick || href || link);
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
onClick(evt: React.MouseEvent) {
|
||||
if (this.props.disabled) {
|
||||
return;
|
||||
@ -47,7 +47,7 @@ export class Icon extends React.PureComponent<IconProps> {
|
||||
}
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
onKeyDown(evt: React.KeyboardEvent<any>) {
|
||||
switch (evt.nativeEvent.code) {
|
||||
case "Space":
|
||||
|
||||
@ -24,17 +24,17 @@ export class DropFileInput<T extends HTMLElement = any> extends React.Component<
|
||||
makeObservable(this);
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
onDragEnter() {
|
||||
this.dropAreaActive = true;
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
onDragLeave() {
|
||||
this.dropAreaActive = false;
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
onDragOver(evt: React.DragEvent<T>) {
|
||||
if (this.props.onDragOver) {
|
||||
this.props.onDragOver(evt);
|
||||
@ -43,7 +43,7 @@ export class DropFileInput<T extends HTMLElement = any> extends React.Component<
|
||||
evt.dataTransfer.dropEffect = "move";
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@autobind
|
||||
onDrop(evt: React.DragEvent<T>) {
|
||||
if (this.props.onDrop) {
|
||||
this.props.onDrop(evt);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user