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",
"abort-controller": "^3.0.0",
"array-move": "^3.0.0",
"autobind-decorator": "^2.4.0",
"auto-bind": "^4.0.0",
"await-lock": "^2.1.0",
"byline": "^5.0.0",
"chalk": "^4.1.0",

View File

@ -15,6 +15,7 @@ Object.defineProperty(Mobx, "toJS", {
if (typeof data === "object" && !isObservable(data)) {
return toJS(observable.box(data).get());
}
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) {
ipcMain.handle(channel, (event: Electron.IpcMainInvokeEvent, ...args: any[]) => {
args = toJS(args); // unwrap possibly leaking observable values
return listener(event, ...args);
});
}

View File

@ -1,8 +1,16 @@
// Decorator for binding class methods to proper "this"-context.
// API: https://github.com/andreypopp/autobind-decorator
import bindMethodOrClass from "autobind-decorator"
// Automatically bind methods to their class instance
// API: https://github.com/sindresorhus/auto-bind
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>() {
return bindMethodOrClass;
export function autoBind<T extends object>(obj: T, opts?: Options): T {
if ("componentWillUnmount" in obj) {
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(
`PageRegistry: param's "${paramName}" initialization has failed:
paramInit.parse() and paramInit.stringify() are required for non string | string[] "defaultValue"`
)
);
}
paramInit.defaultValue = value;

View File

@ -1,16 +1,16 @@
import type { KubeObjectStore } from "../kube-object.store";
import { action, observable, makeObservable } from "mobx";
import { autobind } from "../utils";
import { autoBind } from "../utils";
import { KubeApi, parseKubeApi } from "./kube-api";
@autobind()
export class ApiManager {
private apis = observable.map<string, KubeApi>();
private stores = observable.map<string, KubeObjectStore>();
constructor() {
makeObservable(this);
autoBind(this);
}
getApi(pathOrCallback: string | ((api: KubeApi) => boolean)) {

View File

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

View File

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

View File

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

View File

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

View File

@ -1,8 +1,9 @@
import moment from "moment";
import { IAffinity, WorkloadKubeObject } from "../workload-kube-object";
import { autobind } from "../../utils";
import { autoBind } from "../../utils";
import { KubeApi } from "../kube-api";
import { KubeJsonApiData } from "../kube-json-api";
export class DeploymentApi extends KubeApi<Deployment> {
protected getScaleApiUrl(params: { namespace: string; name: string }) {
@ -66,12 +67,16 @@ interface IContainerProbe {
failureThreshold?: number;
}
@autobind()
export class Deployment extends WorkloadKubeObject {
static kind = "Deployment";
static namespaced = true;
static apiBase = "/apis/apps/v1/deployments";
constructor(data: KubeJsonApiData) {
super(data);
autoBind(this);
}
spec: {
replicas: number;
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 { KubeApi } from "../kube-api";
import { KubeJsonApiData } from "../kube-json-api";
export interface IEndpointPort {
name?: string;
@ -100,7 +101,6 @@ export class EndpointSubset implements IEndpointSubset {
}
}
@autobind()
export class Endpoint extends KubeObject {
static kind = "Endpoints";
static namespaced = true;
@ -108,6 +108,11 @@ export class Endpoint extends KubeObject {
subsets: IEndpointSubset[];
constructor(data: KubeJsonApiData) {
super(data);
autoBind(this);
}
getEndpointSubsets(): EndpointSubset[] {
const subsets = this.subsets || [];

View File

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

View File

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

View File

@ -1,6 +1,6 @@
import jsYaml from "js-yaml";
import { compile } from "path-to-regexp";
import { autobind, formatDuration } from "../../utils";
import { autoBind, formatDuration } from "../../utils";
import capitalize from "lodash/capitalize";
import { apiBase } from "../index";
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 {
constructor(data: any) {
Object.assign(this, data);
autoBind(this);
}
static create(data: any) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,8 +1,9 @@
import get from "lodash/get";
import { autobind } from "../../utils";
import { autoBind } from "../../utils";
import { WorkloadKubeObject } from "../workload-kube-object";
import { IPodContainer, Pod } from "./pods.api";
import { KubeApi } from "../kube-api";
import { KubeJsonApiData } from "../kube-json-api";
export class ReplicaSetApi extends KubeApi<ReplicaSet> {
protected getScaleApiUrl(params: { namespace: string; name: string }) {
@ -27,11 +28,16 @@ export class ReplicaSetApi extends KubeApi<ReplicaSet> {
}
}
@autobind()
export class ReplicaSet extends WorkloadKubeObject {
static kind = "ReplicaSet";
static namespaced = true;
static apiBase = "/apis/apps/v1/replicasets";
constructor(data: KubeJsonApiData) {
super(data);
autoBind(this);
}
spec: {
replicas?: number;
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 { KubeApi } from "../kube-api";
import { KubeJsonApiData } from "../kube-json-api";
export interface IRoleBindingSubject {
kind: string;
@ -9,12 +10,16 @@ export interface IRoleBindingSubject {
apiGroup?: string;
}
@autobind()
export class RoleBinding extends KubeObject {
static kind = "RoleBinding";
static namespaced = true;
static apiBase = "/apis/rbac.authorization.k8s.io/v1/rolebindings";
constructor(data: KubeJsonApiData) {
super(data);
autoBind(this);
}
subjects?: IRoleBindingSubject[];
roleRef: {
kind: string;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
import semver from "semver";
import { observable, makeObservable } from "mobx";
import { autobind } from "../../utils";
import { autoBind } from "../../utils";
import { getChartDetails, HelmChart, listCharts } from "../../api/endpoints/helm-charts.api";
import { ItemStore } from "../../item.store";
import flatten from "lodash/flatten";
@ -10,7 +10,6 @@ export interface IChartVersion {
version: string;
}
@autobind()
export class HelmChartStore extends ItemStore<HelmChart> {
@observable versions = observable.map<string, IChartVersion[]>();
@ -18,6 +17,7 @@ export class HelmChartStore extends ItemStore<HelmChart> {
super();
makeObservable(this);
autoBind(this);
}
async loadAll() {

View File

@ -1,6 +1,6 @@
import isEqual from "lodash/isEqual";
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 { ItemStore } from "../../item.store";
import { Secret } from "../../api/endpoints";
@ -8,13 +8,14 @@ import { secretsStore } from "../+config-secrets/secrets.store";
import { namespaceStore } from "../+namespaces/namespace.store";
import { Notifications } from "../notifications";
@autobind()
export class ReleaseStore extends ItemStore<HelmRelease> {
releaseSecrets = observable.map<string, Secret>();
constructor() {
super();
makeObservable(this);
autoBind(this);
when(() => secretsStore.isLoaded, () => {
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 { CatalogEntity, CatalogEntityActionContext } from "../../api/catalog-entity";
import { ItemObject, ItemStore } from "../../item.store";
import { autobind } from "../../utils";
import { autoBind } from "../../utils";
import { CatalogCategory } from "../../../common/catalog";
export class CatalogEntityItem implements ItemObject {
@ -65,7 +65,6 @@ export class CatalogEntityItem implements ItemObject {
}
}
@autobind()
export class CatalogEntityStore extends ItemStore<CatalogEntityItem> {
@observable activeCategory?: CatalogCategory;
@ -73,6 +72,7 @@ export class CatalogEntityStore extends ItemStore<CatalogEntityItem> {
super();
makeObservable(this);
autoBind(this);
}
@computed get entities() {

View File

@ -1,7 +1,7 @@
import { action, observable, reaction, when, makeObservable } from "mobx";
import { KubeObjectStore } from "../../kube-object.store";
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 { nodesStore } from "../+nodes/nodes.store";
import { apiManager } from "../../api/api-manager";
@ -21,7 +21,6 @@ export interface ClusterOverviewStorageState {
metricNodeRole: MetricNodeRole,
}
@autobind()
export class ClusterOverviewStore extends KubeObjectStore<Cluster> implements ClusterOverviewStorageState {
api = clusterApi;
@ -52,6 +51,8 @@ export class ClusterOverviewStore extends KubeObjectStore<Cluster> implements Cl
constructor() {
super();
makeObservable(this);
autoBind(this);
this.init();
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,10 +1,9 @@
import { observable, makeObservable } from "mobx";
import { KubeObjectStore } from "../../kube-object.store";
import { autobind } from "../../utils";
import { autoBind } from "../../utils";
import { IIngressMetrics, Ingress, ingressApi } from "../../api/endpoints";
import { apiManager } from "../../api/api-manager";
@autobind()
export class IngressStore extends KubeObjectStore<Ingress> {
api = ingressApi;
@observable metrics: IIngressMetrics = null;
@ -13,6 +12,7 @@ export class IngressStore extends KubeObjectStore<Ingress> {
super();
makeObservable(this);
autoBind(this);
}
async loadMetrics(ingress: Ingress) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,10 +1,9 @@
import { action, observable, makeObservable } from "mobx";
import { KubeObjectStore } from "../../kube-object.store";
import { autobind } from "../../utils";
import { autoBind } from "../../utils";
import { IPvcMetrics, PersistentVolumeClaim, pvcApi } from "../../api/endpoints";
import { apiManager } from "../../api/api-manager";
@autobind()
export class VolumeClaimStore extends KubeObjectStore<PersistentVolumeClaim> {
api = pvcApi;
@observable metrics: IPvcMetrics = null;
@ -13,6 +12,7 @@ export class VolumeClaimStore extends KubeObjectStore<PersistentVolumeClaim> {
super();
makeObservable(this);
autoBind(this);
}
@action

View File

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

View File

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

View File

@ -1,12 +1,16 @@
import { clusterRoleApi, Role, roleApi } from "../../api/endpoints";
import { autobind } from "../../utils";
import { autoBind } from "../../utils";
import { KubeObjectStore, KubeObjectStoreLoadingParams } from "../../kube-object.store";
import { apiManager } from "../../api/api-manager";
@autobind()
export class RolesStore extends KubeObjectStore<Role> {
api = clusterRoleApi;
constructor() {
super();
autoBind(this);
}
getSubscribeApis() {
return [roleApi, clusterRoleApi];
}

View File

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

View File

@ -1,13 +1,17 @@
import { KubeObjectStore } from "../../kube-object.store";
import { autobind } from "../../utils";
import { autoBind } from "../../utils";
import { CronJob, cronJobApi } from "../../api/endpoints/cron-job.api";
import { jobStore } from "../+workloads-jobs/job.store";
import { apiManager } from "../../api/api-manager";
@autobind()
export class CronJobStore extends KubeObjectStore<CronJob> {
api = cronJobApi;
constructor() {
super();
autoBind(this);
}
getStatuses(cronJobs?: CronJob[]) {
const status = { suspended: 0, scheduled: 0 };

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -4,17 +4,16 @@ import os from "os";
import groupBy from "lodash/groupBy";
import filehound from "filehound";
import { watch } from "chokidar";
import { autobind } from "../../utils";
import { autoBind } from "../../utils";
import { DockTabStore } from "./dock-tab.store";
import { dockStore, IDockTab, TabKind } from "./dock.store";
@autobind()
export class CreateResourceStore extends DockTabStore<string> {
constructor() {
super({
storageKey: "create_resource"
});
autoBind(this);
fs.ensureDirSync(this.userTemplatesFolder);
}

View File

@ -1,5 +1,5 @@
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";
export interface DockTabStoreOptions {
@ -9,12 +9,13 @@ 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>();
constructor(protected options: DockTabStoreOptions = {}) {
autoBind(this);
this.options = {
autoInit: true,
...this.options,

View File

@ -1,6 +1,6 @@
import MD5 from "crypto-js/md5";
import { action, computed, IReactionOptions, observable, reaction, makeObservable } from "mobx";
import { autobind, createStorage } from "../../utils";
import { autoBind, createStorage } from "../../utils";
import throttle from "lodash/throttle";
export type TabId = string;
@ -28,8 +28,13 @@ export interface DockStorageState {
isOpen?: boolean;
}
@autobind()
export class DockStore implements DockStorageState {
constructor() {
makeObservable(this);
autoBind(this);
this.init();
}
readonly minHeight = 100;
@observable fullSize = false;
@ -80,11 +85,6 @@ export class DockStore implements DockStorageState {
return this.tabs.find(tab => tab.id === this.selectedTabId);
}
constructor() {
makeObservable(this);
this.init();
}
private init() {
// adjust terminal height if window size changes
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 { autorun, IReactionDisposer } from "mobx";
import { dockStore, IDockTab, TabId, TabKind } from "./dock.store";
@ -11,7 +11,6 @@ export interface EditingResource {
draft?: string; // edited draft in yaml
}
@autobind()
export class EditResourceStore extends DockTabStore<EditingResource> {
private watchers = new Map<TabId, IReactionDisposer>();
@ -19,6 +18,7 @@ export class EditResourceStore extends DockTabStore<EditingResource> {
super({
storageKey: "edit_resource_store",
});
autoBind(this);
}
protected async init() {

View File

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

View File

@ -1,5 +1,5 @@
import { autorun, observable } from "mobx";
import { autobind } from "../../utils";
import { autoBind } from "../../utils";
import { Terminal } from "./terminal";
import { TerminalApi } from "../../api/terminal-api";
import { dockStore, IDockTab, TabId, TabKind } from "./dock.store";
@ -21,12 +21,13 @@ export function createTerminalTab(tabParams: Partial<ITerminalTab> = {}) {
});
}
@autobind()
export class TerminalStore {
protected terminals = new Map<TabId, Terminal>();
protected connections = observable.map<TabId, TerminalApi>();
constructor() {
autoBind(this);
// connect active tab
autorun(() => {
const { selectedTab, isOpen } = dockStore;

View File

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

View File

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

View File

@ -1,6 +1,6 @@
import React from "react";
import { action, observable, makeObservable } from "mobx";
import { autobind } from "../../utils";
import { autoBind } from "../../utils";
import uniqueId from "lodash/uniqueId";
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"
}
@autobind()
export class NotificationsStore {
public notifications = observable.array<Notification>([], { deep: false });
@ -29,6 +28,7 @@ export class NotificationsStore {
constructor() {
makeObservable(this);
autoBind(this);
}
getById(id: NotificationId): Notification | null {

View File

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

View File

@ -1,5 +1,5 @@
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 logger from "../main/logger";
@ -19,7 +19,6 @@ export interface Theme {
author?: string;
}
@autobind()
export class ThemeStore extends Singleton {
protected styles: HTMLStyleElement;
@ -54,6 +53,7 @@ export class ThemeStore extends Singleton {
super();
makeObservable(this);
autoBind(this);
// auto-apply active theme
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"
integrity sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==
autobind-decorator@^2.4.0:
version "2.4.0"
resolved "https://registry.yarnpkg.com/autobind-decorator/-/autobind-decorator-2.4.0.tgz#ea9e1c98708cf3b5b356f7cf9f10f265ff18239c"
integrity sha512-OGYhWUO72V6DafbF8PM8rm3EPbfuyMZcJhtm5/n26IDwO18pohE4eNazLoCGhPiXOCD0gEGmrbU3849QvM8bbw==
auto-bind@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/auto-bind/-/auto-bind-4.0.0.tgz#e3589fc6c2da8f7ca43ba9f84fa52a744fc997fb"
integrity sha512-Hdw8qdNiqdJ8LqT0iK0sVzkFbzg6fhnQqqfWhBDxcHZvU75+B+ayzTy8x+k5Ix0Y92XOhOUlx74ps+bA6BeYMQ==
await-lock@^2.1.0:
version "2.1.0"
@ -4428,7 +4428,7 @@ debug@^4.3.2:
dependencies:
ms "2.1.2"
debuglog@*, debuglog@^1.0.1:
debuglog@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/debuglog/-/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492"
integrity sha1-qiT/uaw9+aI1GDfPstJ5NgzXhJI=
@ -7090,7 +7090,7 @@ import-local@^3.0.2:
pkg-dir "^4.2.0"
resolve-cwd "^3.0.0"
imurmurhash@*, imurmurhash@^0.1.4:
imurmurhash@^0.1.4:
version "0.1.4"
resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea"
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"
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:
version "4.6.0"
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._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:
version "4.0.3"
resolved "https://registry.yarnpkg.com/lodash._createset/-/lodash._createset-4.0.3.tgz#0f4659fbb09d75194fa9e2b88a6644d363c9fe26"
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:
version "3.0.1"
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"
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:
version "4.7.0"
resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438"