mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Revert accidental breaking change in Extension API (#4904)
Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com> Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
parent
12a6bd8512
commit
81819dbbe9
@ -312,14 +312,14 @@ export abstract class KubeObjectStore<T extends KubeObject> extends ItemStore<T>
|
|||||||
return this.api.create(params, data);
|
return this.api.create(params, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
create = async (params: { name: string; namespace?: string }, data?: Partial<T>): Promise<T> => {
|
async create(params: { name: string; namespace?: string }, data?: Partial<T>): Promise<T> {
|
||||||
const newItem = await this.createItem(params, data);
|
const newItem = await this.createItem(params, data);
|
||||||
const items = this.sortItems([...this.items, newItem]);
|
const items = this.sortItems([...this.items, newItem]);
|
||||||
|
|
||||||
this.items.replace(items);
|
this.items.replace(items);
|
||||||
|
|
||||||
return newItem;
|
return newItem;
|
||||||
};
|
}
|
||||||
|
|
||||||
private postUpdate(rawItem: KubeJsonApiData): T {
|
private postUpdate(rawItem: KubeJsonApiData): T {
|
||||||
const newItem = new this.api.objectConstructor(rawItem);
|
const newItem = new this.api.objectConstructor(rawItem);
|
||||||
|
|||||||
@ -19,6 +19,7 @@ import namespaceStoreInjectable from "./namespace-store/namespace-store.injectab
|
|||||||
import type { AddNamespaceDialogModel } from "./add-namespace-dialog-model/add-namespace-dialog-model";
|
import type { AddNamespaceDialogModel } from "./add-namespace-dialog-model/add-namespace-dialog-model";
|
||||||
import addNamespaceDialogModelInjectable
|
import addNamespaceDialogModelInjectable
|
||||||
from "./add-namespace-dialog-model/add-namespace-dialog-model.injectable";
|
from "./add-namespace-dialog-model/add-namespace-dialog-model.injectable";
|
||||||
|
import type { NamespaceStore } from "./namespace-store/namespace.store";
|
||||||
|
|
||||||
interface Props extends DialogProps {
|
interface Props extends DialogProps {
|
||||||
onSuccess?(ns: Namespace): void;
|
onSuccess?(ns: Namespace): void;
|
||||||
@ -26,7 +27,7 @@ interface Props extends DialogProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface Dependencies {
|
interface Dependencies {
|
||||||
createNamespace: (params: { name: string }) => Promise<Namespace>;
|
namespaceStore: NamespaceStore;
|
||||||
model: AddNamespaceDialogModel;
|
model: AddNamespaceDialogModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,7 +49,7 @@ class NonInjectedAddNamespaceDialog extends React.Component<Props & Dependencies
|
|||||||
const { onSuccess, onError } = this.props;
|
const { onSuccess, onError } = this.props;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const created = await this.props.createNamespace({ name: namespace });
|
const created = await this.props.namespaceStore.create({ name: namespace });
|
||||||
|
|
||||||
onSuccess?.(created);
|
onSuccess?.(created);
|
||||||
this.props.model.close();
|
this.props.model.close();
|
||||||
@ -59,7 +60,7 @@ class NonInjectedAddNamespaceDialog extends React.Component<Props & Dependencies
|
|||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { model, createNamespace, ...dialogProps } = this.props;
|
const { model, namespaceStore, ...dialogProps } = this.props;
|
||||||
const { namespace } = this;
|
const { namespace } = this;
|
||||||
const header = <h5>Create Namespace</h5>;
|
const header = <h5>Create Namespace</h5>;
|
||||||
|
|
||||||
@ -97,7 +98,7 @@ export const AddNamespaceDialog = withInjectables<Dependencies, Props>(
|
|||||||
|
|
||||||
{
|
{
|
||||||
getProps: (di, props) => ({
|
getProps: (di, props) => ({
|
||||||
createNamespace: di.inject(namespaceStoreInjectable).create,
|
namespaceStore: di.inject(namespaceStoreInjectable),
|
||||||
model: di.inject(addNamespaceDialogModelInjectable),
|
model: di.inject(addNamespaceDialogModelInjectable),
|
||||||
|
|
||||||
...props,
|
...props,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user