mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
mobx-6 migration -- part 3 (more fixes)
Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
parent
ae1b840df7
commit
02aa3217c3
@ -2,9 +2,7 @@
|
|||||||
// API: https://github.com/andreypopp/autobind-decorator
|
// API: https://github.com/andreypopp/autobind-decorator
|
||||||
import bindMethodOrClass from "autobind-decorator"
|
import bindMethodOrClass from "autobind-decorator"
|
||||||
|
|
||||||
// TODO: unwrap, replace usages of @autobind() to @autobind
|
// TODO: unwrap, replace calls @autobind() to @autobind
|
||||||
export function autobind<T extends object>() {
|
export function autobind<T extends object>() {
|
||||||
return function (target: { new(...args: any[]): T } | object, prop?: string, descriptor?: PropertyDescriptor) {
|
return bindMethodOrClass;
|
||||||
return bindMethodOrClass(target, prop, descriptor) as any;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
// Extensions API -> Commands
|
// Extensions API -> Commands
|
||||||
|
|
||||||
import { BaseRegistry } from "./base-registry";
|
import { BaseRegistry } from "./base-registry";
|
||||||
import { action, observable, makeObservable } from "mobx";
|
import { makeObservable, observable } from "mobx";
|
||||||
import { LensExtension } from "../lens-extension";
|
import { LensExtension } from "../lens-extension";
|
||||||
import { CatalogEntity } from "../../common/catalog";
|
import { CatalogEntity } from "../../common/catalog";
|
||||||
|
|
||||||
@ -26,7 +26,6 @@ export class CommandRegistry extends BaseRegistry<CommandRegistration> {
|
|||||||
makeObservable(this);
|
makeObservable(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
|
||||||
add(items: CommandRegistration | CommandRegistration[], extension?: LensExtension) {
|
add(items: CommandRegistration | CommandRegistration[], extension?: LensExtension) {
|
||||||
const itemArray = [items].flat();
|
const itemArray = [items].flat();
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,6 @@
|
|||||||
import type { IconProps } from "../../renderer/components/icon";
|
import type { IconProps } from "../../renderer/components/icon";
|
||||||
import type React from "react";
|
import type React from "react";
|
||||||
import type { PageTarget, RegisteredPage } from "./page-registry";
|
import type { PageTarget, RegisteredPage } from "./page-registry";
|
||||||
import { action, makeObservable } from "mobx";
|
|
||||||
import { BaseRegistry } from "./base-registry";
|
import { BaseRegistry } from "./base-registry";
|
||||||
import { LensExtension } from "../lens-extension";
|
import { LensExtension } from "../lens-extension";
|
||||||
|
|
||||||
@ -22,13 +21,6 @@ export interface PageMenuComponents {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class PageMenuRegistry<T extends PageMenuRegistration> extends BaseRegistry<T> {
|
export class PageMenuRegistry<T extends PageMenuRegistration> extends BaseRegistry<T> {
|
||||||
constructor() {
|
|
||||||
super();
|
|
||||||
|
|
||||||
makeObservable(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@action
|
|
||||||
add(items: T[], ext: LensExtension) {
|
add(items: T[], ext: LensExtension) {
|
||||||
const normalizedItems = items.map(menuItem => {
|
const normalizedItems = items.map(menuItem => {
|
||||||
menuItem.target = {
|
menuItem.target = {
|
||||||
|
|||||||
@ -12,11 +12,6 @@ interface Props {
|
|||||||
|
|
||||||
@observer
|
@observer
|
||||||
export class RemoveClusterButton extends React.Component<Props> {
|
export class RemoveClusterButton extends React.Component<Props> {
|
||||||
constructor(props: Props) {
|
|
||||||
super(props);
|
|
||||||
makeObservable(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@autobind()
|
@autobind()
|
||||||
confirmRemoveCluster() {
|
confirmRemoveCluster() {
|
||||||
const { cluster } = this.props;
|
const { cluster } = this.props;
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
// Manage observable param from document's location.search
|
// Manage observable param from document's location.search
|
||||||
import type { ObservableHistory } from "mobx-observable-history";
|
import type { ObservableHistory } from "mobx-observable-history";
|
||||||
import { action, computed, makeObservable } from "mobx";
|
import { action, makeObservable } from "mobx";
|
||||||
|
|
||||||
export interface PageParamInit<V = any> {
|
export interface PageParamInit<V = any> {
|
||||||
name: string;
|
name: string;
|
||||||
@ -81,7 +81,7 @@ export class PageParam<V = any> {
|
|||||||
/**
|
/**
|
||||||
* Get stringified raw value(s) from `document.location.search`
|
* Get stringified raw value(s) from `document.location.search`
|
||||||
*/
|
*/
|
||||||
@computed getRaw(): string | string[] {
|
getRaw(): string | string[] {
|
||||||
const values: string[] = this.history.searchParams.getAll(this.name);
|
const values: string[] = this.history.searchParams.getAll(this.name);
|
||||||
|
|
||||||
return this.isMulti ? values : values[0];
|
return this.isMulti ? values : values[0];
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user