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

mobx-6 migration -- remove @autobind as class-decorator

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman 2021-05-06 17:07:57 +03:00
parent ecc3aa0820
commit 884f8ae523
80 changed files with 316 additions and 223 deletions

View File

@ -183,7 +183,7 @@
"@kubernetes/client-node": "^0.12.0", "@kubernetes/client-node": "^0.12.0",
"abort-controller": "^3.0.0", "abort-controller": "^3.0.0",
"array-move": "^3.0.0", "array-move": "^3.0.0",
"autobind-decorator": "^2.4.0", "auto-bind": "^4.0.0",
"await-lock": "^2.1.0", "await-lock": "^2.1.0",
"byline": "^5.0.0", "byline": "^5.0.0",
"chalk": "^4.1.0", "chalk": "^4.1.0",

View File

@ -15,6 +15,7 @@ Object.defineProperty(Mobx, "toJS", {
if (typeof data === "object" && !isObservable(data)) { if (typeof data === "object" && !isObservable(data)) {
return toJS(observable.box(data).get()); return toJS(observable.box(data).get());
} }
return toJS(data); return toJS(data);
} }
}); });

View File

@ -12,6 +12,7 @@ const subFramesChannel = "ipc:get-sub-frames";
export function handleRequest(channel: string, listener: (event: Electron.IpcMainInvokeEvent, ...args: any[]) => any) { export function handleRequest(channel: string, listener: (event: Electron.IpcMainInvokeEvent, ...args: any[]) => any) {
ipcMain.handle(channel, (event: Electron.IpcMainInvokeEvent, ...args: any[]) => { ipcMain.handle(channel, (event: Electron.IpcMainInvokeEvent, ...args: any[]) => {
args = toJS(args); // unwrap possibly leaking observable values args = toJS(args); // unwrap possibly leaking observable values
return listener(event, ...args); return listener(event, ...args);
}); });
} }

View File

@ -1,8 +1,16 @@
// Decorator for binding class methods to proper "this"-context. // Automatically bind methods to their class instance
// API: https://github.com/andreypopp/autobind-decorator // API: https://github.com/sindresorhus/auto-bind
import bindMethodOrClass from "autobind-decorator" import autoBindClass, { Options } from "auto-bind";
import autoBindReactClass from "auto-bind/react";
// TODO: unwrap, replace calls @autobind() to @autobind export function autoBind<T extends object>(obj: T, opts?: Options): T {
export function autobind<T extends object>() { if ("componentWillUnmount" in obj) {
return bindMethodOrClass; return autoBindReactClass(obj as any, opts);
}
return autoBindClass(obj, opts);
}
export function autobind(): any {
return (): void => undefined; // noop
} }

View File

@ -117,7 +117,7 @@ export class PageRegistry extends BaseRegistry<PageRegistration, RegisteredPage>
throw new Error( throw new Error(
`PageRegistry: param's "${paramName}" initialization has failed: `PageRegistry: param's "${paramName}" initialization has failed:
paramInit.parse() and paramInit.stringify() are required for non string | string[] "defaultValue"` paramInit.parse() and paramInit.stringify() are required for non string | string[] "defaultValue"`
) );
} }
paramInit.defaultValue = value; paramInit.defaultValue = value;

View File

@ -1,16 +1,16 @@
import type { KubeObjectStore } from "../kube-object.store"; import type { KubeObjectStore } from "../kube-object.store";
import { action, observable, makeObservable } from "mobx"; import { action, observable, makeObservable } from "mobx";
import { autobind } from "../utils"; import { autoBind } from "../utils";
import { KubeApi, parseKubeApi } from "./kube-api"; import { KubeApi, parseKubeApi } from "./kube-api";
@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>();
constructor() { constructor() {
makeObservable(this); makeObservable(this);
autoBind(this);
} }
getApi(pathOrCallback: string | ((api: KubeApi) => boolean)) { getApi(pathOrCallback: string | ((api: KubeApi) => boolean)) {

View File

@ -1,8 +1,6 @@
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()
export class ClusterRole extends Role { export class ClusterRole extends Role {
static kind = "ClusterRole"; static kind = "ClusterRole";
static namespaced = false; static namespaced = false;

View File

@ -1,9 +1,7 @@
import { KubeObject } from "../kube-object"; import { KubeObject } from "../kube-object";
import { KubeJsonApiData } from "../kube-json-api"; import { KubeJsonApiData } from "../kube-json-api";
import { autobind } from "../../utils";
import { KubeApi } from "../kube-api"; import { KubeApi } from "../kube-api";
@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

@ -2,8 +2,9 @@ import moment from "moment";
import { KubeObject } from "../kube-object"; import { KubeObject } from "../kube-object";
import { IPodContainer } from "./pods.api"; import { IPodContainer } from "./pods.api";
import { formatDuration } from "../../utils/formatDuration"; import { formatDuration } from "../../utils/formatDuration";
import { autobind } from "../../utils"; import { autoBind } from "../../utils";
import { KubeApi } from "../kube-api"; import { KubeApi } from "../kube-api";
import { KubeJsonApiData } from "../kube-json-api";
export class CronJobApi extends KubeApi<CronJob> { export class CronJobApi extends KubeApi<CronJob> {
suspend(params: { namespace: string; name: string }) { suspend(params: { namespace: string; name: string }) {
@ -37,28 +38,16 @@ export class CronJobApi extends KubeApi<CronJob> {
} }
} }
@autobind()
export class CronJob extends KubeObject { export class CronJob extends KubeObject {
static kind = "CronJob"; static kind = "CronJob";
static namespaced = true; static namespaced = true;
static apiBase = "/apis/batch/v1beta1/cronjobs"; static apiBase = "/apis/batch/v1beta1/cronjobs";
kind: string; constructor(data: KubeJsonApiData) {
apiVersion: string; super(data);
metadata: { autoBind(this);
name: string; }
namespace: string;
selfLink: string;
uid: string;
resourceVersion: string;
creationTimestamp: string;
labels: {
[key: string]: string;
};
annotations: {
[key: string]: string;
};
};
spec: { spec: {
schedule: string; schedule: string;
concurrencyPolicy: string; concurrencyPolicy: string;

View File

@ -1,15 +1,20 @@
import get from "lodash/get"; import get from "lodash/get";
import { IPodContainer } from "./pods.api"; import { IPodContainer } from "./pods.api";
import { IAffinity, WorkloadKubeObject } from "../workload-kube-object"; 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";
import { KubeJsonApiData } from "../kube-json-api";
@autobind()
export class DaemonSet extends WorkloadKubeObject { export class DaemonSet extends WorkloadKubeObject {
static kind = "DaemonSet"; static kind = "DaemonSet";
static namespaced = true; static namespaced = true;
static apiBase = "/apis/apps/v1/daemonsets"; static apiBase = "/apis/apps/v1/daemonsets";
constructor(data: KubeJsonApiData) {
super(data);
autoBind(this);
}
spec: { spec: {
selector: { selector: {
matchLabels: { matchLabels: {

View File

@ -1,8 +1,9 @@
import moment from "moment"; import moment from "moment";
import { IAffinity, WorkloadKubeObject } from "../workload-kube-object"; 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";
import { KubeJsonApiData } from "../kube-json-api";
export class DeploymentApi extends KubeApi<Deployment> { export class DeploymentApi extends KubeApi<Deployment> {
protected getScaleApiUrl(params: { namespace: string; name: string }) { protected getScaleApiUrl(params: { namespace: string; name: string }) {
@ -66,12 +67,16 @@ interface IContainerProbe {
failureThreshold?: number; failureThreshold?: number;
} }
@autobind()
export class Deployment extends WorkloadKubeObject { export class Deployment extends WorkloadKubeObject {
static kind = "Deployment"; static kind = "Deployment";
static namespaced = true; static namespaced = true;
static apiBase = "/apis/apps/v1/deployments"; static apiBase = "/apis/apps/v1/deployments";
constructor(data: KubeJsonApiData) {
super(data);
autoBind(this);
}
spec: { spec: {
replicas: number; replicas: number;
selector: { matchLabels: { [app: string]: string } }; selector: { matchLabels: { [app: string]: string } };

View File

@ -1,6 +1,7 @@
import { autobind } from "../../utils"; import { autoBind } from "../../utils";
import { KubeObject } from "../kube-object"; import { KubeObject } from "../kube-object";
import { KubeApi } from "../kube-api"; import { KubeApi } from "../kube-api";
import { KubeJsonApiData } from "../kube-json-api";
export interface IEndpointPort { export interface IEndpointPort {
name?: string; name?: string;
@ -100,7 +101,6 @@ export class EndpointSubset implements IEndpointSubset {
} }
} }
@autobind()
export class Endpoint extends KubeObject { export class Endpoint extends KubeObject {
static kind = "Endpoints"; static kind = "Endpoints";
static namespaced = true; static namespaced = true;
@ -108,6 +108,11 @@ export class Endpoint extends KubeObject {
subsets: IEndpointSubset[]; subsets: IEndpointSubset[];
constructor(data: KubeJsonApiData) {
super(data);
autoBind(this);
}
getEndpointSubsets(): EndpointSubset[] { getEndpointSubsets(): EndpointSubset[] {
const subsets = this.subsets || []; const subsets = this.subsets || [];

View File

@ -1,15 +1,20 @@
import moment from "moment"; import moment from "moment";
import { KubeObject } from "../kube-object"; import { KubeObject } from "../kube-object";
import { formatDuration } from "../../utils/formatDuration"; import { formatDuration } from "../../utils/formatDuration";
import { autobind } from "../../utils"; import { autoBind } from "../../utils";
import { KubeApi } from "../kube-api"; import { KubeApi } from "../kube-api";
import { KubeJsonApiData } from "../kube-json-api";
@autobind()
export class KubeEvent extends KubeObject { export class KubeEvent extends KubeObject {
static kind = "Event"; static kind = "Event";
static namespaced = true; static namespaced = true;
static apiBase = "/api/v1/events"; static apiBase = "/api/v1/events";
constructor(data: KubeJsonApiData) {
super(data);
autoBind(this);
}
involvedObject: { involvedObject: {
kind: string; kind: string;
namespace: string; namespace: string;

View File

@ -1,7 +1,7 @@
import { compile } from "path-to-regexp"; import { compile } from "path-to-regexp";
import { apiBase } from "../index"; import { apiBase } from "../index";
import { stringify } from "querystring"; import { stringify } from "querystring";
import { autobind } from "../../utils"; import { autoBind } from "../../utils";
export type RepoHelmChartList = Record<string, HelmChart[]>; export type RepoHelmChartList = Record<string, HelmChart[]>;
export type HelmChartList = Record<string, RepoHelmChartList>; export type HelmChartList = Record<string, RepoHelmChartList>;
@ -62,10 +62,10 @@ 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()
export class HelmChart { export class HelmChart {
constructor(data: any) { constructor(data: any) {
Object.assign(this, data); Object.assign(this, data);
autoBind(this);
} }
static create(data: any) { static create(data: any) {

View File

@ -1,6 +1,6 @@
import jsYaml from "js-yaml"; import jsYaml from "js-yaml";
import { compile } from "path-to-regexp"; import { compile } from "path-to-regexp";
import { autobind, formatDuration } from "../../utils"; import { autoBind, formatDuration } from "../../utils";
import capitalize from "lodash/capitalize"; import capitalize from "lodash/capitalize";
import { apiBase } from "../index"; import { apiBase } from "../index";
import { helmChartStore } from "../../components/+apps-helm-charts/helm-chart.store"; import { helmChartStore } from "../../components/+apps-helm-charts/helm-chart.store";
@ -134,10 +134,10 @@ export async function rollbackRelease(name: string, namespace: string, revision:
}); });
} }
@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);
autoBind(this);
} }
static create(data: any) { static create(data: any) {

View File

@ -1,7 +1,8 @@
import { KubeObject } from "../kube-object"; import { KubeObject } from "../kube-object";
import { autobind } from "../../utils"; import { autoBind } from "../../utils";
import { IMetrics, metricsApi } from "./metrics.api"; import { IMetrics, metricsApi } from "./metrics.api";
import { KubeApi } from "../kube-api"; import { KubeApi } from "../kube-api";
import { KubeJsonApiData } from "../kube-json-api";
export class IngressApi extends KubeApi<Ingress> { export class IngressApi extends KubeApi<Ingress> {
getMetrics(ingress: string, namespace: string): Promise<IIngressMetrics> { getMetrics(ingress: string, namespace: string): Promise<IIngressMetrics> {
@ -61,12 +62,16 @@ export const getBackendServiceNamePort = (backend: IIngressBackend) => {
return { serviceName, servicePort }; return { serviceName, servicePort };
}; };
@autobind()
export class Ingress extends KubeObject { export class Ingress extends KubeObject {
static kind = "Ingress"; static kind = "Ingress";
static namespaced = true; static namespaced = true;
static apiBase = "/apis/networking.k8s.io/v1/ingresses"; static apiBase = "/apis/networking.k8s.io/v1/ingresses";
constructor(data: KubeJsonApiData) {
super(data);
autoBind(this);
}
spec: { spec: {
tls: { tls: {
secretName: string; secretName: string;

View File

@ -1,16 +1,21 @@
import get from "lodash/get"; import get from "lodash/get";
import { autobind } from "../../utils"; import { autoBind } from "../../utils";
import { IAffinity, WorkloadKubeObject } from "../workload-kube-object"; import { IAffinity, WorkloadKubeObject } from "../workload-kube-object";
import { IPodContainer } from "./pods.api"; 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";
import { KubeJsonApiData } from "../kube-json-api";
@autobind()
export class Job extends WorkloadKubeObject { export class Job extends WorkloadKubeObject {
static kind = "Job"; static kind = "Job";
static namespaced = true; static namespaced = true;
static apiBase = "/apis/batch/v1/jobs"; static apiBase = "/apis/batch/v1/jobs";
constructor(data: KubeJsonApiData) {
super(data);
autoBind(this);
}
spec: { spec: {
parallelism?: number; parallelism?: number;
completions?: number; completions?: number;

View File

@ -1,6 +1,7 @@
import { KubeObject } from "../kube-object"; import { KubeObject } from "../kube-object";
import { KubeApi } from "../kube-api"; import { KubeApi } from "../kube-api";
import { autobind } from "../../utils"; import { autoBind } from "../../utils";
import { KubeJsonApiData } from "../kube-json-api";
export enum LimitType { export enum LimitType {
CONTAINER = "Container", CONTAINER = "Container",
@ -29,12 +30,16 @@ export interface LimitRangeItem extends LimitRangeParts {
type: string type: string
} }
@autobind()
export class LimitRange extends KubeObject { export class LimitRange extends KubeObject {
static kind = "LimitRange"; static kind = "LimitRange";
static namespaced = true; static namespaced = true;
static apiBase = "/api/v1/limitranges"; static apiBase = "/api/v1/limitranges";
constructor(data: KubeJsonApiData) {
super(data);
autoBind(this);
}
spec: { spec: {
limits: LimitRangeItem[]; limits: LimitRangeItem[];
}; };

View File

@ -1,18 +1,23 @@
import { KubeApi } from "../kube-api"; import { KubeApi } from "../kube-api";
import { KubeObject } from "../kube-object"; import { KubeObject } from "../kube-object";
import { autobind } from "../../utils"; import { autoBind } from "../../utils";
import { KubeJsonApiData } from "../kube-json-api";
export enum NamespaceStatus { export enum NamespaceStatus {
ACTIVE = "Active", ACTIVE = "Active",
TERMINATING = "Terminating", TERMINATING = "Terminating",
} }
@autobind()
export class Namespace extends KubeObject { export class Namespace extends KubeObject {
static kind = "Namespace"; static kind = "Namespace";
static namespaced = false; static namespaced = false;
static apiBase = "/api/v1/namespaces"; static apiBase = "/api/v1/namespaces";
constructor(data: KubeJsonApiData) {
super(data);
autoBind(this);
}
status?: { status?: {
phase: string; phase: string;
}; };

View File

@ -1,6 +1,7 @@
import { KubeObject } from "../kube-object"; import { KubeObject } from "../kube-object";
import { autobind } from "../../utils"; import { autoBind } from "../../utils";
import { KubeApi } from "../kube-api"; import { KubeApi } from "../kube-api";
import { KubeJsonApiData } from "../kube-json-api";
export interface IPolicyIpBlock { export interface IPolicyIpBlock {
cidr: string; cidr: string;
@ -35,12 +36,16 @@ export interface IPolicyEgress {
}[]; }[];
} }
@autobind()
export class NetworkPolicy extends KubeObject { export class NetworkPolicy extends KubeObject {
static kind = "NetworkPolicy"; static kind = "NetworkPolicy";
static namespaced = true; static namespaced = true;
static apiBase = "/apis/networking.k8s.io/v1/networkpolicies"; static apiBase = "/apis/networking.k8s.io/v1/networkpolicies";
constructor(data: KubeJsonApiData) {
super(data);
autoBind(this);
}
spec: { spec: {
podSelector: { podSelector: {
matchLabels: { matchLabels: {

View File

@ -1,7 +1,8 @@
import { KubeObject } from "../kube-object"; import { KubeObject } from "../kube-object";
import { autobind, cpuUnitsToNumber, unitsToBytes } from "../../utils"; import { autoBind, cpuUnitsToNumber, unitsToBytes } from "../../utils";
import { IMetrics, metricsApi } from "./metrics.api"; import { IMetrics, metricsApi } from "./metrics.api";
import { KubeApi } from "../kube-api"; import { KubeApi } from "../kube-api";
import { KubeJsonApiData } from "../kube-json-api";
export class NodesApi extends KubeApi<Node> { export class NodesApi extends KubeApi<Node> {
getMetrics(): Promise<INodeMetrics> { getMetrics(): Promise<INodeMetrics> {
@ -28,12 +29,16 @@ export interface INodeMetrics<T = IMetrics> {
fsSize: T; fsSize: T;
} }
@autobind()
export class Node extends KubeObject { export class Node extends KubeObject {
static kind = "Node"; static kind = "Node";
static namespaced = false; static namespaced = false;
static apiBase = "/api/v1/nodes"; static apiBase = "/api/v1/nodes";
constructor(data: KubeJsonApiData) {
super(data);
autoBind(this);
}
spec: { spec: {
podCIDR: string; podCIDR: string;
externalID: string; externalID: string;

View File

@ -1,8 +1,9 @@
import { KubeObject } from "../kube-object"; import { KubeObject } from "../kube-object";
import { autobind } from "../../utils"; import { autoBind } from "../../utils";
import { IMetrics, metricsApi } from "./metrics.api"; import { IMetrics, metricsApi } from "./metrics.api";
import { Pod } from "./pods.api"; import { Pod } from "./pods.api";
import { KubeApi } from "../kube-api"; import { KubeApi } from "../kube-api";
import { KubeJsonApiData } from "../kube-json-api";
export class PersistentVolumeClaimsApi extends KubeApi<PersistentVolumeClaim> { export class PersistentVolumeClaimsApi extends KubeApi<PersistentVolumeClaim> {
getMetrics(pvcName: string, namespace: string): Promise<IPvcMetrics> { getMetrics(pvcName: string, namespace: string): Promise<IPvcMetrics> {
@ -21,12 +22,16 @@ export interface IPvcMetrics<T = IMetrics> {
diskCapacity: T; diskCapacity: T;
} }
@autobind()
export class PersistentVolumeClaim extends KubeObject { export class PersistentVolumeClaim extends KubeObject {
static kind = "PersistentVolumeClaim"; static kind = "PersistentVolumeClaim";
static namespaced = true; static namespaced = true;
static apiBase = "/api/v1/persistentvolumeclaims"; static apiBase = "/api/v1/persistentvolumeclaims";
constructor(data: KubeJsonApiData) {
super(data);
autoBind(this);
}
spec: { spec: {
accessModes: string[]; accessModes: string[];
storageClassName: string; storageClassName: string;

View File

@ -1,14 +1,19 @@
import { KubeObject } from "../kube-object"; import { KubeObject } from "../kube-object";
import { unitsToBytes } from "../../utils/convertMemory"; import { unitsToBytes } from "../../utils/convertMemory";
import { autobind } from "../../utils"; import { autoBind } from "../../utils";
import { KubeApi } from "../kube-api"; import { KubeApi } from "../kube-api";
import { KubeJsonApiData } from "../kube-json-api";
@autobind()
export class PersistentVolume extends KubeObject { export class PersistentVolume extends KubeObject {
static kind = "PersistentVolume"; static kind = "PersistentVolume";
static namespaced = false; static namespaced = false;
static apiBase = "/api/v1/persistentvolumes"; static apiBase = "/api/v1/persistentvolumes";
constructor(data: KubeJsonApiData) {
super(data);
autoBind(this);
}
spec: { spec: {
capacity: { capacity: {
storage: string; // 8Gi storage: string; // 8Gi

View File

@ -1,13 +1,18 @@
import { autobind } from "../../utils"; import { autoBind } from "../../utils";
import { KubeObject } from "../kube-object"; import { KubeObject } from "../kube-object";
import { KubeApi } from "../kube-api"; import { KubeApi } from "../kube-api";
import { KubeJsonApiData } from "../kube-json-api";
@autobind()
export class PodDisruptionBudget extends KubeObject { export class PodDisruptionBudget extends KubeObject {
static kind = "PodDisruptionBudget"; static kind = "PodDisruptionBudget";
static namespaced = true; static namespaced = true;
static apiBase = "/apis/policy/v1beta1/poddisruptionbudgets"; static apiBase = "/apis/policy/v1beta1/poddisruptionbudgets";
constructor(data: KubeJsonApiData) {
super(data);
autoBind(this);
}
spec: { spec: {
minAvailable: string; minAvailable: string;
maxUnavailable: string; maxUnavailable: string;

View File

@ -1,7 +1,8 @@
import { IAffinity, WorkloadKubeObject } from "../workload-kube-object"; import { IAffinity, WorkloadKubeObject } from "../workload-kube-object";
import { autobind } from "../../utils"; import { autoBind } from "../../utils";
import { IMetrics, metricsApi } from "./metrics.api"; import { IMetrics, metricsApi } from "./metrics.api";
import { KubeApi } from "../kube-api"; import { KubeApi } from "../kube-api";
import { KubeJsonApiData } from "../kube-json-api";
export class PodsApi extends KubeApi<Pod> { export class PodsApi extends KubeApi<Pod> {
async getLogs(params: { namespace: string; name: string }, query?: IPodLogsQuery): Promise<string> { async getLogs(params: { namespace: string; name: string }, query?: IPodLogsQuery): Promise<string> {
@ -181,12 +182,16 @@ export interface IPodContainerStatus {
started?: boolean; started?: boolean;
} }
@autobind()
export class Pod extends WorkloadKubeObject { export class Pod extends WorkloadKubeObject {
static kind = "Pod"; static kind = "Pod";
static namespaced = true; static namespaced = true;
static apiBase = "/api/v1/pods"; static apiBase = "/api/v1/pods";
constructor(data: KubeJsonApiData) {
super(data);
autoBind(this);
}
spec: { spec: {
volumes?: { volumes?: {
name: string; name: string;

View File

@ -1,13 +1,18 @@
import { autobind } from "../../utils"; import { autoBind } from "../../utils";
import { KubeObject } from "../kube-object"; import { KubeObject } from "../kube-object";
import { KubeApi } from "../kube-api"; import { KubeApi } from "../kube-api";
import { KubeJsonApiData } from "../kube-json-api";
@autobind()
export class PodSecurityPolicy extends KubeObject { export class PodSecurityPolicy extends KubeObject {
static kind = "PodSecurityPolicy"; static kind = "PodSecurityPolicy";
static namespaced = false; static namespaced = false;
static apiBase = "/apis/policy/v1beta1/podsecuritypolicies"; static apiBase = "/apis/policy/v1beta1/podsecuritypolicies";
constructor(data: KubeJsonApiData) {
super(data);
autoBind(this);
}
spec: { spec: {
allowPrivilegeEscalation?: boolean; allowPrivilegeEscalation?: boolean;
allowedCSIDrivers?: { allowedCSIDrivers?: {

View File

@ -1,8 +1,9 @@
import get from "lodash/get"; import get from "lodash/get";
import { autobind } from "../../utils"; import { autoBind } from "../../utils";
import { WorkloadKubeObject } from "../workload-kube-object"; import { WorkloadKubeObject } from "../workload-kube-object";
import { IPodContainer, Pod } from "./pods.api"; import { IPodContainer, Pod } from "./pods.api";
import { KubeApi } from "../kube-api"; import { KubeApi } from "../kube-api";
import { KubeJsonApiData } from "../kube-json-api";
export class ReplicaSetApi extends KubeApi<ReplicaSet> { export class ReplicaSetApi extends KubeApi<ReplicaSet> {
protected getScaleApiUrl(params: { namespace: string; name: string }) { protected getScaleApiUrl(params: { namespace: string; name: string }) {
@ -27,11 +28,16 @@ export class ReplicaSetApi extends KubeApi<ReplicaSet> {
} }
} }
@autobind()
export class ReplicaSet extends WorkloadKubeObject { export class ReplicaSet extends WorkloadKubeObject {
static kind = "ReplicaSet"; static kind = "ReplicaSet";
static namespaced = true; static namespaced = true;
static apiBase = "/apis/apps/v1/replicasets"; static apiBase = "/apis/apps/v1/replicasets";
constructor(data: KubeJsonApiData) {
super(data);
autoBind(this);
}
spec: { spec: {
replicas?: number; replicas?: number;
selector: { matchLabels: { [app: string]: string } }; selector: { matchLabels: { [app: string]: string } };

View File

@ -1,6 +1,7 @@
import { autobind } from "../../utils"; import { autoBind } from "../../utils";
import { KubeObject } from "../kube-object"; import { KubeObject } from "../kube-object";
import { KubeApi } from "../kube-api"; import { KubeApi } from "../kube-api";
import { KubeJsonApiData } from "../kube-json-api";
export interface IRoleBindingSubject { export interface IRoleBindingSubject {
kind: string; kind: string;
@ -9,12 +10,16 @@ export interface IRoleBindingSubject {
apiGroup?: string; apiGroup?: string;
} }
@autobind()
export class RoleBinding extends KubeObject { export class RoleBinding extends KubeObject {
static kind = "RoleBinding"; static kind = "RoleBinding";
static namespaced = true; static namespaced = true;
static apiBase = "/apis/rbac.authorization.k8s.io/v1/rolebindings"; static apiBase = "/apis/rbac.authorization.k8s.io/v1/rolebindings";
constructor(data: KubeJsonApiData) {
super(data);
autoBind(this);
}
subjects?: IRoleBindingSubject[]; subjects?: IRoleBindingSubject[];
roleRef: { roleRef: {
kind: string; kind: string;

View File

@ -1,6 +1,6 @@
import { KubeObject } from "../kube-object"; import { KubeObject } from "../kube-object";
import { KubeJsonApiData } from "../kube-json-api"; import { KubeJsonApiData } from "../kube-json-api";
import { autobind } from "../../utils"; import { autoBind } from "../../utils";
import { KubeApi } from "../kube-api"; import { KubeApi } from "../kube-api";
export enum SecretType { export enum SecretType {
@ -19,22 +19,21 @@ export interface ISecretRef {
name: string; name: string;
} }
@autobind()
export class Secret extends KubeObject { export class Secret extends KubeObject {
static kind = "Secret"; static kind = "Secret";
static namespaced = true; static namespaced = true;
static apiBase = "/api/v1/secrets"; static apiBase = "/api/v1/secrets";
constructor(data: KubeJsonApiData) {
super(data);
autoBind(this);
}
type: SecretType; type: SecretType;
data: { data: {
[prop: string]: string; [prop: string]: string;
token?: string; token?: string;
}; } = {};
constructor(data: KubeJsonApiData) {
super(data);
this.data = this.data || {};
}
getKeys(): string[] { getKeys(): string[] {
return Object.keys(this.data); return Object.keys(this.data);

View File

@ -1,13 +1,18 @@
import { autobind } from "../../utils"; import { autoBind } from "../../utils";
import { KubeObject } from "../kube-object"; import { KubeObject } from "../kube-object";
import { KubeApi } from "../kube-api"; import { KubeApi } from "../kube-api";
import { KubeJsonApiData } from "../kube-json-api";
@autobind()
export class ServiceAccount extends KubeObject { export class ServiceAccount extends KubeObject {
static kind = "ServiceAccount"; static kind = "ServiceAccount";
static namespaced = true; static namespaced = true;
static apiBase = "/api/v1/serviceaccounts"; static apiBase = "/api/v1/serviceaccounts";
constructor(data: KubeJsonApiData) {
super(data);
autoBind(this);
}
secrets?: { secrets?: {
name: string; name: string;
}[]; }[];

View File

@ -1,6 +1,7 @@
import { autobind } from "../../utils"; import { autoBind } from "../../utils";
import { KubeObject } from "../kube-object"; import { KubeObject } from "../kube-object";
import { KubeApi } from "../kube-api"; import { KubeApi } from "../kube-api";
import { KubeJsonApiData } from "../kube-json-api";
export interface IServicePort { export interface IServicePort {
name?: string; name?: string;
@ -29,12 +30,16 @@ export class ServicePort implements IServicePort {
} }
} }
@autobind()
export class Service extends KubeObject { export class Service extends KubeObject {
static kind = "Service"; static kind = "Service";
static namespaced = true; static namespaced = true;
static apiBase = "/api/v1/services"; static apiBase = "/api/v1/services";
constructor(data: KubeJsonApiData) {
super(data);
autoBind(this);
}
spec: { spec: {
type: string; type: string;
clusterIP: string; clusterIP: string;

View File

@ -1,8 +1,9 @@
import get from "lodash/get"; import get from "lodash/get";
import { IPodContainer } from "./pods.api"; import { IPodContainer } from "./pods.api";
import { IAffinity, WorkloadKubeObject } from "../workload-kube-object"; 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";
import { KubeJsonApiData } from "../kube-json-api";
export class StatefulSetApi extends KubeApi<StatefulSet> { export class StatefulSetApi extends KubeApi<StatefulSet> {
protected getScaleApiUrl(params: { namespace: string; name: string }) { protected getScaleApiUrl(params: { namespace: string; name: string }) {
@ -27,12 +28,16 @@ export class StatefulSetApi extends KubeApi<StatefulSet> {
} }
} }
@autobind()
export class StatefulSet extends WorkloadKubeObject { export class StatefulSet extends WorkloadKubeObject {
static kind = "StatefulSet"; static kind = "StatefulSet";
static namespaced = true; static namespaced = true;
static apiBase = "/apis/apps/v1/statefulsets"; static apiBase = "/apis/apps/v1/statefulsets";
constructor(data: KubeJsonApiData) {
super(data);
autoBind(this);
}
spec: { spec: {
serviceName: string; serviceName: string;
replicas: number; replicas: number;

View File

@ -1,13 +1,18 @@
import { autobind } from "../../utils"; import { autoBind } from "../../utils";
import { KubeObject } from "../kube-object"; import { KubeObject } from "../kube-object";
import { KubeApi } from "../kube-api"; import { KubeApi } from "../kube-api";
import { KubeJsonApiData } from "../kube-json-api";
@autobind()
export class StorageClass extends KubeObject { export class StorageClass extends KubeObject {
static kind = "StorageClass"; static kind = "StorageClass";
static namespaced = false; static namespaced = false;
static apiBase = "/apis/storage.k8s.io/v1/storageclasses"; static apiBase = "/apis/storage.k8s.io/v1/storageclasses";
constructor(data: KubeJsonApiData) {
super(data);
autoBind(this);
}
provisioner: string; // e.g. "storage.k8s.io/v1" provisioner: string; // e.g. "storage.k8s.io/v1"
mountOptions?: string[]; mountOptions?: string[];
volumeBindingMode: string; volumeBindingMode: string;

View File

@ -2,7 +2,7 @@
import moment from "moment"; import moment from "moment";
import { KubeJsonApiData, KubeJsonApiDataList, KubeJsonApiListMetadata, KubeJsonApiMetadata } from "./kube-json-api"; import { KubeJsonApiData, KubeJsonApiDataList, KubeJsonApiListMetadata, KubeJsonApiMetadata } from "./kube-json-api";
import { autobind, formatDuration } from "../utils"; import { autoBind, formatDuration } from "../utils";
import { ItemObject } from "../item.store"; import { ItemObject } from "../item.store";
import { apiKube } from "./index"; import { apiKube } from "./index";
import { JsonApiParams } from "./json-api"; import { JsonApiParams } from "./json-api";
@ -66,7 +66,6 @@ export class KubeStatus {
export type IKubeMetaField = keyof IKubeObjectMetadata; export type IKubeMetaField = keyof IKubeObjectMetadata;
@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;
@ -139,6 +138,7 @@ export class KubeObject implements ItemObject {
constructor(data: KubeJsonApiData) { constructor(data: KubeJsonApiData) {
Object.assign(this, data); Object.assign(this, data);
autoBind(this);
} }
apiVersion: string; apiVersion: string;

View File

@ -6,7 +6,7 @@ import type { ClusterContext } from "../components/context";
import plimit from "p-limit"; import plimit from "p-limit";
import { comparer, IReactionDisposer, observable, reaction, when, makeObservable } from "mobx"; import { comparer, IReactionDisposer, observable, reaction, when, makeObservable } from "mobx";
import { autobind, noop } from "../utils"; import { autoBind, noop } from "../utils";
import { KubeApi } from "./kube-api"; import { KubeApi } from "./kube-api";
import { KubeJsonApiData } from "./kube-json-api"; import { KubeJsonApiData } from "./kube-json-api";
import { isDebugging, isProduction } from "../../common/vars"; import { isDebugging, isProduction } from "../../common/vars";
@ -29,7 +29,6 @@ export interface IKubeWatchLog {
cssStyle?: string; cssStyle?: string;
} }
@autobind()
export class KubeWatchApi { export class KubeWatchApi {
@observable context: ClusterContext = null; @observable context: ClusterContext = null;
@ -37,6 +36,7 @@ export class KubeWatchApi {
constructor() { constructor() {
makeObservable(this); makeObservable(this);
autoBind(this);
} }
isAllowedApi(api: KubeApi): boolean { isAllowedApi(api: KubeApi): boolean {

View File

@ -1,6 +1,6 @@
import semver from "semver"; import semver from "semver";
import { observable, makeObservable } from "mobx"; import { observable, makeObservable } from "mobx";
import { autobind } from "../../utils"; import { autoBind } from "../../utils";
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";
@ -10,7 +10,6 @@ export interface IChartVersion {
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[]>();
@ -18,6 +17,7 @@ export class HelmChartStore extends ItemStore<HelmChart> {
super(); super();
makeObservable(this); makeObservable(this);
autoBind(this);
} }
async loadAll() { async loadAll() {

View File

@ -1,6 +1,6 @@
import isEqual from "lodash/isEqual"; import isEqual from "lodash/isEqual";
import { action, observable, reaction, when, makeObservable } from "mobx"; import { action, observable, reaction, when, makeObservable } from "mobx";
import { autobind } from "../../utils"; import { autoBind } from "../../utils";
import { createRelease, deleteRelease, HelmRelease, IReleaseCreatePayload, IReleaseUpdatePayload, listReleases, rollbackRelease, updateRelease } from "../../api/endpoints/helm-releases.api"; import { createRelease, deleteRelease, HelmRelease, IReleaseCreatePayload, IReleaseUpdatePayload, listReleases, rollbackRelease, updateRelease } from "../../api/endpoints/helm-releases.api";
import { ItemStore } from "../../item.store"; import { ItemStore } from "../../item.store";
import { Secret } from "../../api/endpoints"; import { Secret } from "../../api/endpoints";
@ -8,13 +8,14 @@ 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";
@autobind()
export class ReleaseStore extends ItemStore<HelmRelease> { export class ReleaseStore extends ItemStore<HelmRelease> {
releaseSecrets = observable.map<string, Secret>(); releaseSecrets = observable.map<string, Secret>();
constructor() { constructor() {
super(); super();
makeObservable(this); makeObservable(this);
autoBind(this);
when(() => secretsStore.isLoaded, () => { when(() => secretsStore.isLoaded, () => {
this.releaseSecrets.replace(this.getReleaseSecrets()); this.releaseSecrets.replace(this.getReleaseSecrets());
}); });

View File

@ -2,7 +2,7 @@ import { action, computed, IReactionDisposer, observable, reaction, makeObservab
import { catalogEntityRegistry } from "../../api/catalog-entity-registry"; 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 { autobind } from "../../utils"; import { autoBind } from "../../utils";
import { CatalogCategory } from "../../../common/catalog"; import { CatalogCategory } from "../../../common/catalog";
export class CatalogEntityItem implements ItemObject { export class CatalogEntityItem implements ItemObject {
@ -65,7 +65,6 @@ export class CatalogEntityItem implements ItemObject {
} }
} }
@autobind()
export class CatalogEntityStore extends ItemStore<CatalogEntityItem> { export class CatalogEntityStore extends ItemStore<CatalogEntityItem> {
@observable activeCategory?: CatalogCategory; @observable activeCategory?: CatalogCategory;
@ -73,6 +72,7 @@ export class CatalogEntityStore extends ItemStore<CatalogEntityItem> {
super(); super();
makeObservable(this); makeObservable(this);
autoBind(this);
} }
@computed get entities() { @computed get entities() {

View File

@ -1,7 +1,7 @@
import { action, observable, reaction, when, makeObservable } from "mobx"; import { action, observable, reaction, when, makeObservable } 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 { autobind, createStorage } from "../../utils"; import { autoBind, createStorage } 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,7 +21,6 @@ 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;
@ -52,6 +51,8 @@ export class ClusterOverviewStore extends KubeObjectStore<Cluster> implements Cl
constructor() { constructor() {
super(); super();
makeObservable(this); makeObservable(this);
autoBind(this);
this.init(); this.init();
} }

View File

@ -1,9 +1,7 @@
import { autobind } from "../../utils";
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";
@autobind()
export class HPAStore extends KubeObjectStore<HorizontalPodAutoscaler> { export class HPAStore extends KubeObjectStore<HorizontalPodAutoscaler> {
api = hpaApi; api = hpaApi;
} }

View File

@ -1,9 +1,7 @@
import { autobind } from "../../../common/utils/autobind";
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";
@autobind()
export class LimitRangesStore extends KubeObjectStore<LimitRange> { export class LimitRangesStore extends KubeObjectStore<LimitRange> {
api = limitRangeApi; api = limitRangeApi;
} }

View File

@ -1,9 +1,7 @@
import { KubeObjectStore } from "../../kube-object.store"; import { KubeObjectStore } from "../../kube-object.store";
import { autobind } from "../../utils";
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";
@autobind()
export class ConfigMapsStore extends KubeObjectStore<ConfigMap> { export class ConfigMapsStore extends KubeObjectStore<ConfigMap> {
api = configMapApi; api = configMapApi;
} }

View File

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

View File

@ -1,9 +1,7 @@
import { KubeObjectStore } from "../../kube-object.store"; import { KubeObjectStore } from "../../kube-object.store";
import { autobind } from "../../utils";
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";
@autobind()
export class ResourceQuotasStore extends KubeObjectStore<ResourceQuota> { export class ResourceQuotasStore extends KubeObjectStore<ResourceQuota> {
api = resourceQuotaApi; api = resourceQuotaApi;
} }

View File

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

View File

@ -1,9 +1,7 @@
import { autobind } from "../../utils";
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";
@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

@ -1,6 +1,6 @@
import { computed, reaction, makeObservable } from "mobx"; import { computed, reaction, makeObservable } from "mobx";
import { KubeObjectStore } from "../../kube-object.store"; import { KubeObjectStore } from "../../kube-object.store";
import { autobind } from "../../utils"; import { autoBind } from "../../utils";
import { crdApi, CustomResourceDefinition } from "../../api/endpoints/crd.api"; import { crdApi, CustomResourceDefinition } from "../../api/endpoints/crd.api";
import { apiManager } from "../../api/api-manager"; import { apiManager } from "../../api/api-manager";
import { KubeApi } from "../../api/kube-api"; import { KubeApi } from "../../api/kube-api";
@ -18,7 +18,6 @@ function initStore(crd: CustomResourceDefinition) {
} }
} }
@autobind()
export class CRDStore extends KubeObjectStore<CustomResourceDefinition> { export class CRDStore extends KubeObjectStore<CustomResourceDefinition> {
api = crdApi; api = crdApi;
@ -26,6 +25,7 @@ export class CRDStore extends KubeObjectStore<CustomResourceDefinition> {
super(); super();
makeObservable(this); makeObservable(this);
autoBind(this);
// auto-init stores for crd-s // auto-init stores for crd-s
reaction(() => this.items.toJSON(), items => items.forEach(initStore)); reaction(() => this.items.toJSON(), items => items.forEach(initStore));

View File

@ -1,19 +1,23 @@
import groupBy from "lodash/groupBy"; import groupBy from "lodash/groupBy";
import compact from "lodash/compact"; import compact from "lodash/compact";
import { KubeObjectStore } from "../../kube-object.store"; import { KubeObjectStore } from "../../kube-object.store";
import { autobind } from "../../utils"; import { autoBind } from "../../utils";
import { eventApi, KubeEvent } from "../../api/endpoints/events.api"; import { eventApi, KubeEvent } from "../../api/endpoints/events.api";
import { KubeObject } from "../../api/kube-object"; 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";
@autobind()
export class EventStore extends KubeObjectStore<KubeEvent> { export class EventStore extends KubeObjectStore<KubeEvent> {
api = eventApi; api = eventApi;
limit = 1000; limit = 1000;
saveLimit = 50000; saveLimit = 50000;
constructor() {
super();
autoBind(this);
}
protected bindWatchEventsUpdater() { protected bindWatchEventsUpdater() {
return super.bindWatchEventsUpdater(5000); return super.bindWatchEventsUpdater(5000);
} }

View File

@ -8,7 +8,7 @@ import {
reaction, reaction,
makeObservable, makeObservable,
} from "mobx"; } from "mobx";
import { autobind, 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";
@ -34,7 +34,6 @@ export function getDummyNamespace(name: string) {
}); });
} }
@autobind()
export class NamespaceStore extends KubeObjectStore<Namespace> { export class NamespaceStore extends KubeObjectStore<Namespace> {
api = namespacesApi; api = namespacesApi;
@ -43,6 +42,8 @@ export class NamespaceStore extends KubeObjectStore<Namespace> {
constructor() { constructor() {
super(); super();
makeObservable(this); makeObservable(this);
autoBind(this);
this.init(); this.init();
} }

View File

@ -1,9 +1,7 @@
import { KubeObjectStore } from "../../kube-object.store"; import { KubeObjectStore } from "../../kube-object.store";
import { autobind } from "../../utils";
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";
@autobind()
export class EndpointStore extends KubeObjectStore<Endpoint> { export class EndpointStore extends KubeObjectStore<Endpoint> {
api = endpointApi; api = endpointApi;
} }

View File

@ -1,10 +1,9 @@
import { observable, makeObservable } from "mobx"; import { observable, makeObservable } from "mobx";
import { KubeObjectStore } from "../../kube-object.store"; import { KubeObjectStore } from "../../kube-object.store";
import { autobind } from "../../utils"; import { autoBind } from "../../utils";
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";
@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;
@ -13,6 +12,7 @@ export class IngressStore extends KubeObjectStore<Ingress> {
super(); super();
makeObservable(this); makeObservable(this);
autoBind(this);
} }
async loadMetrics(ingress: Ingress) { async loadMetrics(ingress: Ingress) {

View File

@ -1,9 +1,7 @@
import { KubeObjectStore } from "../../kube-object.store"; import { KubeObjectStore } from "../../kube-object.store";
import { autobind } from "../../utils";
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";
@autobind()
export class NetworkPolicyStore extends KubeObjectStore<NetworkPolicy> { export class NetworkPolicyStore extends KubeObjectStore<NetworkPolicy> {
api = networkPolicyApi; api = networkPolicyApi;
} }

View File

@ -1,9 +1,7 @@
import { KubeObjectStore } from "../../kube-object.store"; import { KubeObjectStore } from "../../kube-object.store";
import { autobind } from "../../utils";
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";
@autobind()
export class ServiceStore extends KubeObjectStore<Service> { export class ServiceStore extends KubeObjectStore<Service> {
api = serviceApi; api = serviceApi;
} }

View File

@ -1,11 +1,10 @@
import { sum } from "lodash"; import { sum } from "lodash";
import { action, computed, observable, makeObservable } from "mobx"; import { action, computed, observable, makeObservable } from "mobx";
import { clusterApi, IClusterMetrics, INodeMetrics, Node, nodesApi } from "../../api/endpoints"; import { clusterApi, IClusterMetrics, INodeMetrics, Node, nodesApi } from "../../api/endpoints";
import { autobind } from "../../utils"; import { autoBind } from "../../utils";
import { KubeObjectStore } from "../../kube-object.store"; import { KubeObjectStore } from "../../kube-object.store";
import { apiManager } from "../../api/api-manager"; import { apiManager } from "../../api/api-manager";
@autobind()
export class NodesStore extends KubeObjectStore<Node> { export class NodesStore extends KubeObjectStore<Node> {
api = nodesApi; api = nodesApi;
@ -18,6 +17,7 @@ export class NodesStore extends KubeObjectStore<Node> {
super(); super();
makeObservable(this); makeObservable(this);
autoBind(this);
} }
@action @action

View File

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

View File

@ -1,13 +1,17 @@
import { KubeObjectStore } from "../../kube-object.store"; import { KubeObjectStore } from "../../kube-object.store";
import { autobind } from "../../utils"; import { autoBind } from "../../utils";
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";
@autobind()
export class StorageClassStore extends KubeObjectStore<StorageClass> { export class StorageClassStore extends KubeObjectStore<StorageClass> {
api = storageClassApi; api = storageClassApi;
constructor() {
super();
autoBind(this);
}
getPersistentVolumes(storageClass: StorageClass) { getPersistentVolumes(storageClass: StorageClass) {
return volumesStore.getByStorageClass(storageClass); return volumesStore.getByStorageClass(storageClass);
} }

View File

@ -1,10 +1,9 @@
import { action, observable, makeObservable } from "mobx"; import { action, observable, makeObservable } from "mobx";
import { KubeObjectStore } from "../../kube-object.store"; import { KubeObjectStore } from "../../kube-object.store";
import { autobind } from "../../utils"; import { autoBind } from "../../utils";
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";
@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;
@ -13,6 +12,7 @@ export class VolumeClaimStore extends KubeObjectStore<PersistentVolumeClaim> {
super(); super();
makeObservable(this); makeObservable(this);
autoBind(this);
} }
@action @action

View File

@ -1,13 +1,17 @@
import { KubeObjectStore } from "../../kube-object.store"; import { KubeObjectStore } from "../../kube-object.store";
import { autobind } from "../../utils"; import { autoBind } from "../../utils";
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";
@autobind()
export class PersistentVolumesStore extends KubeObjectStore<PersistentVolume> { export class PersistentVolumesStore extends KubeObjectStore<PersistentVolume> {
api = persistentVolumeApi; api = persistentVolumeApi;
constructor() {
super();
autoBind(this);
}
getByStorageClass(storageClass: StorageClass): PersistentVolume[] { getByStorageClass(storageClass: StorageClass): PersistentVolume[] {
return this.items.filter(volume => return this.items.filter(volume =>
volume.getStorageClassName() === storageClass.getName() volume.getStorageClassName() === storageClass.getName()

View File

@ -2,13 +2,17 @@ import difference from "lodash/difference";
import uniqBy from "lodash/uniqBy"; 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 { autobind } from "../../utils"; import { autoBind } from "../../utils";
import { apiManager } from "../../api/api-manager"; import { apiManager } from "../../api/api-manager";
@autobind()
export class RoleBindingsStore extends KubeObjectStore<RoleBinding> { export class RoleBindingsStore extends KubeObjectStore<RoleBinding> {
api = clusterRoleBindingApi; api = clusterRoleBindingApi;
constructor() {
super();
autoBind(this);
}
getSubscribeApis() { getSubscribeApis() {
return [clusterRoleBindingApi, roleBindingApi]; return [clusterRoleBindingApi, roleBindingApi];
} }

View File

@ -1,12 +1,16 @@
import { clusterRoleApi, Role, roleApi } from "../../api/endpoints"; import { clusterRoleApi, Role, roleApi } from "../../api/endpoints";
import { autobind } from "../../utils"; import { autoBind } from "../../utils";
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";
@autobind()
export class RolesStore extends KubeObjectStore<Role> { export class RolesStore extends KubeObjectStore<Role> {
api = clusterRoleApi; api = clusterRoleApi;
constructor() {
super();
autoBind(this);
}
getSubscribeApis() { getSubscribeApis() {
return [roleApi, clusterRoleApi]; return [roleApi, clusterRoleApi];
} }

View File

@ -1,12 +1,16 @@
import { autobind } from "../../utils"; import { autoBind } from "../../utils";
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";
@autobind()
export class ServiceAccountsStore extends KubeObjectStore<ServiceAccount> { export class ServiceAccountsStore extends KubeObjectStore<ServiceAccount> {
api = serviceAccountsApi; api = serviceAccountsApi;
constructor() {
super();
autoBind(this);
}
protected async createItem(params: { name: string; namespace?: string }) { protected async createItem(params: { name: string; namespace?: string }) {
await super.createItem(params); await super.createItem(params);

View File

@ -1,13 +1,17 @@
import { KubeObjectStore } from "../../kube-object.store"; import { KubeObjectStore } from "../../kube-object.store";
import { autobind } from "../../utils"; import { autoBind } from "../../utils";
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";
@autobind()
export class CronJobStore extends KubeObjectStore<CronJob> { export class CronJobStore extends KubeObjectStore<CronJob> {
api = cronJobApi; api = cronJobApi;
constructor() {
super();
autoBind(this);
}
getStatuses(cronJobs?: CronJob[]) { getStatuses(cronJobs?: CronJob[]) {
const status = { suspended: 0, scheduled: 0 }; const status = { suspended: 0, scheduled: 0 };

View File

@ -1,11 +1,10 @@
import { observable, makeObservable } from "mobx"; import { observable, makeObservable } from "mobx";
import { KubeObjectStore } from "../../kube-object.store"; import { KubeObjectStore } from "../../kube-object.store";
import { autobind } from "../../utils"; import { autoBind } from "../../utils";
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";
@autobind()
export class DaemonSetStore extends KubeObjectStore<DaemonSet> { export class DaemonSetStore extends KubeObjectStore<DaemonSet> {
api = daemonSetApi; api = daemonSetApi;
@ -15,6 +14,7 @@ export class DaemonSetStore extends KubeObjectStore<DaemonSet> {
super(); super();
makeObservable(this); makeObservable(this);
autoBind(this);
} }
async loadMetrics(daemonSet: DaemonSet) { async loadMetrics(daemonSet: DaemonSet) {

View File

@ -1,11 +1,10 @@
import { observable, makeObservable } from "mobx"; import { observable, makeObservable } from "mobx";
import { Deployment, deploymentApi, IPodMetrics, podsApi, PodStatus } from "../../api/endpoints"; import { Deployment, deploymentApi, IPodMetrics, podsApi, PodStatus } from "../../api/endpoints";
import { KubeObjectStore } from "../../kube-object.store"; import { KubeObjectStore } from "../../kube-object.store";
import { autobind } from "../../utils"; import { autoBind } from "../../utils";
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";
@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;
@ -14,6 +13,7 @@ export class DeploymentStore extends KubeObjectStore<Deployment> {
super(); super();
makeObservable(this); makeObservable(this);
autoBind(this);
} }
protected sortItems(items: Deployment[]) { protected sortItems(items: Deployment[]) {

View File

@ -1,14 +1,18 @@
import { KubeObjectStore } from "../../kube-object.store"; import { KubeObjectStore } from "../../kube-object.store";
import { autobind } from "../../utils"; import { autoBind } from "../../utils";
import { Job, jobApi } from "../../api/endpoints/job.api"; 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";
@autobind()
export class JobStore extends KubeObjectStore<Job> { export class JobStore extends KubeObjectStore<Job> {
api = jobApi; api = jobApi;
constructor() {
super();
autoBind(this);
}
getChildPods(job: Job): Pod[] { getChildPods(job: Job): Pod[] {
return podsStore.getPodsByOwnerId(job.getId()); return podsStore.getPodsByOwnerId(job.getId());
} }

View File

@ -1,12 +1,11 @@
import countBy from "lodash/countBy"; import countBy from "lodash/countBy";
import { action, observable, makeObservable } from "mobx"; import { action, observable, makeObservable } from "mobx";
import { KubeObjectStore } from "../../kube-object.store"; import { KubeObjectStore } from "../../kube-object.store";
import { autobind, 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;
@ -17,6 +16,7 @@ export class PodsStore extends KubeObjectStore<Pod> {
super(); super();
makeObservable(this); makeObservable(this);
autoBind(this);
} }
@action @action

View File

@ -1,12 +1,11 @@
import { observable, makeObservable } from "mobx"; import { observable, makeObservable } from "mobx";
import { autobind } from "../../utils"; import { autoBind } from "../../utils";
import { KubeObjectStore } from "../../kube-object.store"; import { KubeObjectStore } from "../../kube-object.store";
import { Deployment, IPodMetrics, podsApi, ReplicaSet, replicaSetApi } from "../../api/endpoints"; import { Deployment, IPodMetrics, podsApi, ReplicaSet, replicaSetApi } 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 { PodStatus } from "../../api/endpoints/pods.api"; import { PodStatus } from "../../api/endpoints/pods.api";
@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;
@ -15,6 +14,7 @@ export class ReplicaSetStore extends KubeObjectStore<ReplicaSet> {
super(); super();
makeObservable(this); makeObservable(this);
autoBind(this);
} }
async loadMetrics(replicaSet: ReplicaSet) { async loadMetrics(replicaSet: ReplicaSet) {

View File

@ -1,11 +1,10 @@
import { observable, makeObservable } from "mobx"; import { observable, makeObservable } from "mobx";
import { autobind } from "../../utils"; import { autoBind } from "../../utils";
import { KubeObjectStore } from "../../kube-object.store"; 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";
@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;
@ -14,8 +13,10 @@ export class StatefulSetStore extends KubeObjectStore<StatefulSet> {
super(); super();
makeObservable(this); makeObservable(this);
autoBind(this);
} }
async loadMetrics(statefulSet: StatefulSet) { async loadMetrics(statefulSet: StatefulSet) {
const pods = this.getChildPods(statefulSet); const pods = this.getChildPods(statefulSet);

View File

@ -4,17 +4,16 @@ import os from "os";
import groupBy from "lodash/groupBy"; import groupBy from "lodash/groupBy";
import filehound from "filehound"; import filehound from "filehound";
import { watch } from "chokidar"; import { watch } from "chokidar";
import { autobind } from "../../utils"; import { autoBind } from "../../utils";
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";
@autobind()
export class CreateResourceStore extends DockTabStore<string> { export class CreateResourceStore extends DockTabStore<string> {
constructor() { constructor() {
super({ super({
storageKey: "create_resource" storageKey: "create_resource"
}); });
autoBind(this);
fs.ensureDirSync(this.userTemplatesFolder); fs.ensureDirSync(this.userTemplatesFolder);
} }

View File

@ -1,5 +1,5 @@
import { autorun, observable, reaction, toJS } from "mobx"; import { autorun, observable, reaction, toJS } from "mobx";
import { autobind, createStorage, StorageHelper } from "../../utils"; import { autoBind, createStorage, StorageHelper } from "../../utils";
import { dockStore, TabId } from "./dock.store"; import { dockStore, TabId } from "./dock.store";
export interface DockTabStoreOptions { export interface DockTabStoreOptions {
@ -9,12 +9,13 @@ 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>();
constructor(protected options: DockTabStoreOptions = {}) { constructor(protected options: DockTabStoreOptions = {}) {
autoBind(this);
this.options = { this.options = {
autoInit: true, autoInit: true,
...this.options, ...this.options,

View File

@ -1,6 +1,6 @@
import MD5 from "crypto-js/md5"; import MD5 from "crypto-js/md5";
import { action, computed, IReactionOptions, observable, reaction, makeObservable } from "mobx"; import { action, computed, IReactionOptions, observable, reaction, makeObservable } from "mobx";
import { autobind, createStorage } from "../../utils"; import { autoBind, createStorage } from "../../utils";
import throttle from "lodash/throttle"; import throttle from "lodash/throttle";
export type TabId = string; export type TabId = string;
@ -28,8 +28,13 @@ export interface DockStorageState {
isOpen?: boolean; isOpen?: boolean;
} }
@autobind()
export class DockStore implements DockStorageState { export class DockStore implements DockStorageState {
constructor() {
makeObservable(this);
autoBind(this);
this.init();
}
readonly minHeight = 100; readonly minHeight = 100;
@observable fullSize = false; @observable fullSize = false;
@ -80,11 +85,6 @@ export class DockStore implements DockStorageState {
return this.tabs.find(tab => tab.id === this.selectedTabId); return this.tabs.find(tab => tab.id === this.selectedTabId);
} }
constructor() {
makeObservable(this);
this.init();
}
private init() { private init() {
// adjust terminal height if window size changes // adjust terminal height if window size changes
window.addEventListener("resize", throttle(this.adjustHeight, 250)); window.addEventListener("resize", throttle(this.adjustHeight, 250));

View File

@ -1,4 +1,4 @@
import { autobind, 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,7 +11,6 @@ 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>();
@ -19,6 +18,7 @@ export class EditResourceStore extends DockTabStore<EditingResource> {
super({ super({
storageKey: "edit_resource_store", storageKey: "edit_resource_store",
}); });
autoBind(this);
} }
protected async init() { protected async init() {

View File

@ -1,7 +1,7 @@
import { autorun, computed, observable, makeObservable } from "mobx"; import { autorun, computed, observable, makeObservable } from "mobx";
import { IPodLogsQuery, Pod, podsApi } from "../../api/endpoints"; import { IPodLogsQuery, Pod, podsApi } from "../../api/endpoints";
import { autobind, 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";
@ -9,7 +9,6 @@ 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;
@ -22,6 +21,8 @@ export class LogStore {
constructor() { constructor() {
makeObservable(this); makeObservable(this);
autoBind(this);
autorun(() => { autorun(() => {
const { selectedTab, isOpen } = dockStore; const { selectedTab, isOpen } = dockStore;

View File

@ -1,5 +1,5 @@
import { autorun, observable } from "mobx"; import { autorun, observable } from "mobx";
import { autobind } from "../../utils"; import { autoBind } from "../../utils";
import { Terminal } from "./terminal"; 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";
@ -21,12 +21,13 @@ 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>();
constructor() { constructor() {
autoBind(this);
// connect active tab // connect active tab
autorun(() => { autorun(() => {
const { selectedTab, isOpen } = dockStore; const { selectedTab, isOpen } = dockStore;

View File

@ -1,5 +1,5 @@
import { computed, observable, reaction, makeObservable } from "mobx"; import { computed, observable, reaction, makeObservable } from "mobx";
import { autobind } from "../../utils"; import { autoBind } from "../../utils";
import { searchUrlParam } from "../input/search-input-url"; import { searchUrlParam } from "../input/search-input-url";
export enum FilterType { export enum FilterType {
@ -12,7 +12,6 @@ export interface Filter {
value: string; value: string;
} }
@autobind()
export class PageFiltersStore { export class PageFiltersStore {
protected filters = observable.array<Filter>([], { deep: false }); protected filters = observable.array<Filter>([], { deep: false });
protected isDisabled = observable.map<FilterType, boolean>(); protected isDisabled = observable.map<FilterType, boolean>();
@ -23,6 +22,8 @@ export class PageFiltersStore {
constructor() { constructor() {
makeObservable(this); makeObservable(this);
autoBind(this);
this.syncWithGlobalSearch(); this.syncWithGlobalSearch();
} }

View File

@ -2,7 +2,7 @@ import "./menu.scss";
import React, { Fragment, ReactElement, ReactNode } from "react"; import React, { Fragment, ReactElement, ReactNode } from "react";
import { createPortal } from "react-dom"; import { createPortal } from "react-dom";
import { autobind, cssNames, noop } from "../../utils"; import { autoBind, cssNames, noop } from "../../utils";
import { Animate } from "../animate"; import { Animate } from "../animate";
import { Icon, IconProps } from "../icon"; import { Icon, IconProps } from "../icon";
@ -47,14 +47,17 @@ const defaultPropsMenu: Partial<MenuProps> = {
toggleEvent: "click" toggleEvent: "click"
}; };
@autobind()
export class Menu extends React.Component<MenuProps, State> { export class Menu extends React.Component<MenuProps, State> {
static defaultProps = defaultPropsMenu as object; static defaultProps = defaultPropsMenu as object;
constructor(props: MenuProps) {
super(props);
autoBind(this);
}
public opener: HTMLElement; public opener: HTMLElement;
public elem: HTMLUListElement; public elem: HTMLUListElement;
protected items: { [index: number]: MenuItem } = {}; protected items: { [index: number]: MenuItem } = {};
public state: State = {}; public state: State = {};
get isOpen() { get isOpen() {
@ -319,7 +322,6 @@ const defaultPropsMenuItem: Partial<MenuItemProps> = {
onClick: noop, onClick: noop,
}; };
@autobind()
export class MenuItem extends React.Component<MenuItemProps> { export class MenuItem extends React.Component<MenuItemProps> {
static defaultProps = defaultPropsMenuItem as object; static defaultProps = defaultPropsMenuItem as object;
static contextType = MenuContext; static contextType = MenuContext;
@ -327,6 +329,11 @@ export class MenuItem extends React.Component<MenuItemProps> {
public context: MenuContextValue; public context: MenuContextValue;
public elem: HTMLElement; public elem: HTMLElement;
constructor(props: MenuItemProps) {
super(props);
autoBind(this);
}
get isFocusable() { get isFocusable() {
const { disabled, spacer } = this.props; const { disabled, spacer } = this.props;

View File

@ -1,6 +1,6 @@
import React from "react"; import React from "react";
import { action, observable, makeObservable } from "mobx"; import { action, observable, makeObservable } from "mobx";
import { autobind } from "../../utils"; import { autoBind } from "../../utils";
import uniqueId from "lodash/uniqueId"; import uniqueId from "lodash/uniqueId";
import { JsonApiErrorParsed } from "../../api/json-api"; import { JsonApiErrorParsed } from "../../api/json-api";
@ -21,7 +21,6 @@ export interface Notification {
onClose?(): void; // additonal logic on when the notification times out or is closed by the "x" onClose?(): void; // additonal logic on when the notification times out or is closed by the "x"
} }
@autobind()
export class NotificationsStore { export class NotificationsStore {
public notifications = observable.array<Notification>([], { deep: false }); public notifications = observable.array<Notification>([], { deep: false });
@ -29,6 +28,7 @@ export class NotificationsStore {
constructor() { constructor() {
makeObservable(this); makeObservable(this);
autoBind(this);
} }
getById(id: NotificationId): Notification | null { getById(id: NotificationId): Notification | null {

View File

@ -103,6 +103,7 @@ export class PageParam<V = any> {
this.stringify(value).forEach(value => { this.stringify(value).forEach(value => {
searchParams.append(this.name, value); searchParams.append(this.name, value);
}); });
return `${withPrefix ? "?" : ""}${searchParams}`; return `${withPrefix ? "?" : ""}${searchParams}`;
} }

View File

@ -1,5 +1,5 @@
import { computed, observable, reaction, makeObservable } from "mobx"; import { computed, observable, reaction, makeObservable } from "mobx";
import { autobind, Singleton } from "./utils"; import { autoBind, autobind, Singleton } from "./utils";
import { UserStore } from "../common/user-store"; import { UserStore } from "../common/user-store";
import logger from "../main/logger"; import logger from "../main/logger";
@ -19,7 +19,6 @@ export interface Theme {
author?: string; author?: string;
} }
@autobind()
export class ThemeStore extends Singleton { export class ThemeStore extends Singleton {
protected styles: HTMLStyleElement; protected styles: HTMLStyleElement;
@ -54,6 +53,7 @@ export class ThemeStore extends Singleton {
super(); super();
makeObservable(this); makeObservable(this);
autoBind(this);
// auto-apply active theme // auto-apply active theme
reaction(() => this.activeThemeId, async themeId => { reaction(() => this.activeThemeId, async themeId => {

View File

@ -2708,10 +2708,10 @@ atob@^2.1.2:
resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9" resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9"
integrity sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg== integrity sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==
autobind-decorator@^2.4.0: auto-bind@^4.0.0:
version "2.4.0" version "4.0.0"
resolved "https://registry.yarnpkg.com/autobind-decorator/-/autobind-decorator-2.4.0.tgz#ea9e1c98708cf3b5b356f7cf9f10f265ff18239c" resolved "https://registry.yarnpkg.com/auto-bind/-/auto-bind-4.0.0.tgz#e3589fc6c2da8f7ca43ba9f84fa52a744fc997fb"
integrity sha512-OGYhWUO72V6DafbF8PM8rm3EPbfuyMZcJhtm5/n26IDwO18pohE4eNazLoCGhPiXOCD0gEGmrbU3849QvM8bbw== integrity sha512-Hdw8qdNiqdJ8LqT0iK0sVzkFbzg6fhnQqqfWhBDxcHZvU75+B+ayzTy8x+k5Ix0Y92XOhOUlx74ps+bA6BeYMQ==
await-lock@^2.1.0: await-lock@^2.1.0:
version "2.1.0" version "2.1.0"
@ -4428,7 +4428,7 @@ debug@^4.3.2:
dependencies: dependencies:
ms "2.1.2" ms "2.1.2"
debuglog@*, debuglog@^1.0.1: debuglog@^1.0.1:
version "1.0.1" version "1.0.1"
resolved "https://registry.yarnpkg.com/debuglog/-/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492" resolved "https://registry.yarnpkg.com/debuglog/-/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492"
integrity sha1-qiT/uaw9+aI1GDfPstJ5NgzXhJI= integrity sha1-qiT/uaw9+aI1GDfPstJ5NgzXhJI=
@ -7090,7 +7090,7 @@ import-local@^3.0.2:
pkg-dir "^4.2.0" pkg-dir "^4.2.0"
resolve-cwd "^3.0.0" resolve-cwd "^3.0.0"
imurmurhash@*, imurmurhash@^0.1.4: imurmurhash@^0.1.4:
version "0.1.4" version "0.1.4"
resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea"
integrity sha1-khi5srkoojixPcT7a21XbyMUU+o= integrity sha1-khi5srkoojixPcT7a21XbyMUU+o=
@ -8911,11 +8911,6 @@ lodash-es@^4.17.20:
resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.21.tgz#43e626c46e6591b7750beb2b50117390c609e3ee" resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.21.tgz#43e626c46e6591b7750beb2b50117390c609e3ee"
integrity sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw== integrity sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==
lodash._baseindexof@*:
version "3.1.0"
resolved "https://registry.yarnpkg.com/lodash._baseindexof/-/lodash._baseindexof-3.1.0.tgz#fe52b53a1c6761e42618d654e4a25789ed61822c"
integrity sha1-/lK1OhxnYeQmGNZU5KJXie1hgiw=
lodash._baseuniq@~4.6.0: lodash._baseuniq@~4.6.0:
version "4.6.0" version "4.6.0"
resolved "https://registry.yarnpkg.com/lodash._baseuniq/-/lodash._baseuniq-4.6.0.tgz#0ebb44e456814af7905c6212fa2c9b2d51b841e8" resolved "https://registry.yarnpkg.com/lodash._baseuniq/-/lodash._baseuniq-4.6.0.tgz#0ebb44e456814af7905c6212fa2c9b2d51b841e8"
@ -8924,33 +8919,11 @@ lodash._baseuniq@~4.6.0:
lodash._createset "~4.0.0" lodash._createset "~4.0.0"
lodash._root "~3.0.0" lodash._root "~3.0.0"
lodash._bindcallback@*:
version "3.0.1"
resolved "https://registry.yarnpkg.com/lodash._bindcallback/-/lodash._bindcallback-3.0.1.tgz#e531c27644cf8b57a99e17ed95b35c748789392e"
integrity sha1-5THCdkTPi1epnhftlbNcdIeJOS4=
lodash._cacheindexof@*:
version "3.0.2"
resolved "https://registry.yarnpkg.com/lodash._cacheindexof/-/lodash._cacheindexof-3.0.2.tgz#3dc69ac82498d2ee5e3ce56091bafd2adc7bde92"
integrity sha1-PcaayCSY0u5ePOVgkbr9Ktx73pI=
lodash._createcache@*:
version "3.1.2"
resolved "https://registry.yarnpkg.com/lodash._createcache/-/lodash._createcache-3.1.2.tgz#56d6a064017625e79ebca6b8018e17440bdcf093"
integrity sha1-VtagZAF2JeeevKa4AY4XRAvc8JM=
dependencies:
lodash._getnative "^3.0.0"
lodash._createset@~4.0.0: lodash._createset@~4.0.0:
version "4.0.3" version "4.0.3"
resolved "https://registry.yarnpkg.com/lodash._createset/-/lodash._createset-4.0.3.tgz#0f4659fbb09d75194fa9e2b88a6644d363c9fe26" resolved "https://registry.yarnpkg.com/lodash._createset/-/lodash._createset-4.0.3.tgz#0f4659fbb09d75194fa9e2b88a6644d363c9fe26"
integrity sha1-D0ZZ+7CddRlPqeK4imZE02PJ/iY= integrity sha1-D0ZZ+7CddRlPqeK4imZE02PJ/iY=
lodash._getnative@*, lodash._getnative@^3.0.0:
version "3.9.1"
resolved "https://registry.yarnpkg.com/lodash._getnative/-/lodash._getnative-3.9.1.tgz#570bc7dede46d61cdcde687d65d3eecbaa3aaff5"
integrity sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U=
lodash._root@~3.0.0: lodash._root@~3.0.0:
version "3.0.1" version "3.0.1"
resolved "https://registry.yarnpkg.com/lodash._root/-/lodash._root-3.0.1.tgz#fba1c4524c19ee9a5f8136b4609f017cf4ded692" resolved "https://registry.yarnpkg.com/lodash._root/-/lodash._root-3.0.1.tgz#fba1c4524c19ee9a5f8136b4609f017cf4ded692"
@ -8971,11 +8944,6 @@ lodash.memoize@4.x:
resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe" resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe"
integrity sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4= integrity sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4=
lodash.restparam@*:
version "3.6.1"
resolved "https://registry.yarnpkg.com/lodash.restparam/-/lodash.restparam-3.6.1.tgz#936a4e309ef330a7645ed4145986c85ae5b20805"
integrity sha1-k2pOMJ7zMKdkXtQUWYbIWuWyCAU=
lodash.sortby@^4.7.0: lodash.sortby@^4.7.0:
version "4.7.0" version "4.7.0"
resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438" resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438"