mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Move model.load() to getProps()
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
aa2fcd2c6b
commit
bcf337c3b3
@ -5,7 +5,7 @@
|
||||
|
||||
import "./release-details.scss";
|
||||
|
||||
import React, { useEffect } from "react";
|
||||
import React from "react";
|
||||
|
||||
import { Link } from "react-router-dom";
|
||||
import { DrawerItem, DrawerTitle } from "../../drawer";
|
||||
@ -35,10 +35,6 @@ interface Dependencies {
|
||||
const NonInjectedReleaseDetailsContent = observer(({ model }: Dependencies & ReleaseDetailsContentProps) => {
|
||||
const loadingError = model.loadingError.get();
|
||||
|
||||
useEffect(() => {
|
||||
model.load();
|
||||
}, []);
|
||||
|
||||
if (loadingError) {
|
||||
return (
|
||||
<div data-testid="helm-release-detail-error">
|
||||
@ -115,10 +111,16 @@ const NonInjectedReleaseDetailsContent = observer(({ model }: Dependencies & Rel
|
||||
export const ReleaseDetailsContent = withInjectables<Dependencies, ReleaseDetailsContentProps>(NonInjectedReleaseDetailsContent, {
|
||||
getPlaceholder: () => <Spinner center data-testid="helm-release-detail-content-spinner" />,
|
||||
|
||||
getProps: async (di, props) => ({
|
||||
model: await di.inject(releaseDetailsModelInjectable, props.targetRelease),
|
||||
...props,
|
||||
}),
|
||||
getProps: async (di, props) => {
|
||||
const model = await di.inject(releaseDetailsModelInjectable, props.targetRelease);
|
||||
|
||||
await model.load();
|
||||
|
||||
return {
|
||||
model,
|
||||
...props,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
const ResourceGroup = ({
|
||||
|
||||
@ -28,7 +28,7 @@ const NonInjectedReleaseDetailsDrawerToolbar = observer(({
|
||||
model,
|
||||
navigateToHelmReleases,
|
||||
}: Dependencies & ReleaseDetailsDrawerProps) => (
|
||||
model.loadingError.get()
|
||||
model.loadingError.get() || !model.configuration.isLoaded.get()
|
||||
? null
|
||||
: (
|
||||
<HelmReleaseMenu
|
||||
|
||||
@ -50,8 +50,6 @@ const releaseDetailsModelInjectable = getInjectable({
|
||||
toHelmRelease: di.inject(toHelmReleaseInjectable),
|
||||
});
|
||||
|
||||
await model.load();
|
||||
|
||||
return model;
|
||||
},
|
||||
|
||||
@ -70,6 +68,7 @@ export interface OnlyUserSuppliedValuesAreShownToggle {
|
||||
export interface ConfigurationInput {
|
||||
readonly nonSavedValue: IObservableValue<string>;
|
||||
readonly isLoading: IObservableValue<boolean>;
|
||||
readonly isLoaded: IObservableValue<boolean>;
|
||||
readonly isSaving: IObservableValue<boolean>;
|
||||
onChange: (value: string) => void;
|
||||
save: () => Promise<void>;
|
||||
@ -101,6 +100,7 @@ export class ReleaseDetailsModel {
|
||||
readonly configuration: ConfigurationInput = {
|
||||
nonSavedValue: observable.box(""),
|
||||
isLoading: observable.box(false),
|
||||
isLoaded: observable.box(false),
|
||||
isSaving: observable.box(false),
|
||||
|
||||
onChange: action((value: string) => {
|
||||
@ -201,6 +201,7 @@ export class ReleaseDetailsModel {
|
||||
|
||||
runInAction(() => {
|
||||
this.configuration.isLoading.set(false);
|
||||
this.configuration.isLoaded.set(true);
|
||||
this.configuration.nonSavedValue.set(configuration);
|
||||
});
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user