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 "./release-details.scss";
|
||||||
|
|
||||||
import React, { useEffect } from "react";
|
import React from "react";
|
||||||
|
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import { DrawerItem, DrawerTitle } from "../../drawer";
|
import { DrawerItem, DrawerTitle } from "../../drawer";
|
||||||
@ -35,10 +35,6 @@ interface Dependencies {
|
|||||||
const NonInjectedReleaseDetailsContent = observer(({ model }: Dependencies & ReleaseDetailsContentProps) => {
|
const NonInjectedReleaseDetailsContent = observer(({ model }: Dependencies & ReleaseDetailsContentProps) => {
|
||||||
const loadingError = model.loadingError.get();
|
const loadingError = model.loadingError.get();
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
model.load();
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
if (loadingError) {
|
if (loadingError) {
|
||||||
return (
|
return (
|
||||||
<div data-testid="helm-release-detail-error">
|
<div data-testid="helm-release-detail-error">
|
||||||
@ -115,10 +111,16 @@ const NonInjectedReleaseDetailsContent = observer(({ model }: Dependencies & Rel
|
|||||||
export const ReleaseDetailsContent = withInjectables<Dependencies, ReleaseDetailsContentProps>(NonInjectedReleaseDetailsContent, {
|
export const ReleaseDetailsContent = withInjectables<Dependencies, ReleaseDetailsContentProps>(NonInjectedReleaseDetailsContent, {
|
||||||
getPlaceholder: () => <Spinner center data-testid="helm-release-detail-content-spinner" />,
|
getPlaceholder: () => <Spinner center data-testid="helm-release-detail-content-spinner" />,
|
||||||
|
|
||||||
getProps: async (di, props) => ({
|
getProps: async (di, props) => {
|
||||||
model: await di.inject(releaseDetailsModelInjectable, props.targetRelease),
|
const model = await di.inject(releaseDetailsModelInjectable, props.targetRelease);
|
||||||
...props,
|
|
||||||
}),
|
await model.load();
|
||||||
|
|
||||||
|
return {
|
||||||
|
model,
|
||||||
|
...props,
|
||||||
|
};
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const ResourceGroup = ({
|
const ResourceGroup = ({
|
||||||
|
|||||||
@ -28,7 +28,7 @@ const NonInjectedReleaseDetailsDrawerToolbar = observer(({
|
|||||||
model,
|
model,
|
||||||
navigateToHelmReleases,
|
navigateToHelmReleases,
|
||||||
}: Dependencies & ReleaseDetailsDrawerProps) => (
|
}: Dependencies & ReleaseDetailsDrawerProps) => (
|
||||||
model.loadingError.get()
|
model.loadingError.get() || !model.configuration.isLoaded.get()
|
||||||
? null
|
? null
|
||||||
: (
|
: (
|
||||||
<HelmReleaseMenu
|
<HelmReleaseMenu
|
||||||
|
|||||||
@ -50,8 +50,6 @@ const releaseDetailsModelInjectable = getInjectable({
|
|||||||
toHelmRelease: di.inject(toHelmReleaseInjectable),
|
toHelmRelease: di.inject(toHelmReleaseInjectable),
|
||||||
});
|
});
|
||||||
|
|
||||||
await model.load();
|
|
||||||
|
|
||||||
return model;
|
return model;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -70,6 +68,7 @@ export interface OnlyUserSuppliedValuesAreShownToggle {
|
|||||||
export interface ConfigurationInput {
|
export interface ConfigurationInput {
|
||||||
readonly nonSavedValue: IObservableValue<string>;
|
readonly nonSavedValue: IObservableValue<string>;
|
||||||
readonly isLoading: IObservableValue<boolean>;
|
readonly isLoading: IObservableValue<boolean>;
|
||||||
|
readonly isLoaded: IObservableValue<boolean>;
|
||||||
readonly isSaving: IObservableValue<boolean>;
|
readonly isSaving: IObservableValue<boolean>;
|
||||||
onChange: (value: string) => void;
|
onChange: (value: string) => void;
|
||||||
save: () => Promise<void>;
|
save: () => Promise<void>;
|
||||||
@ -101,6 +100,7 @@ export class ReleaseDetailsModel {
|
|||||||
readonly configuration: ConfigurationInput = {
|
readonly configuration: ConfigurationInput = {
|
||||||
nonSavedValue: observable.box(""),
|
nonSavedValue: observable.box(""),
|
||||||
isLoading: observable.box(false),
|
isLoading: observable.box(false),
|
||||||
|
isLoaded: observable.box(false),
|
||||||
isSaving: observable.box(false),
|
isSaving: observable.box(false),
|
||||||
|
|
||||||
onChange: action((value: string) => {
|
onChange: action((value: string) => {
|
||||||
@ -201,6 +201,7 @@ export class ReleaseDetailsModel {
|
|||||||
|
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
this.configuration.isLoading.set(false);
|
this.configuration.isLoading.set(false);
|
||||||
|
this.configuration.isLoaded.set(true);
|
||||||
this.configuration.nonSavedValue.set(configuration);
|
this.configuration.nonSavedValue.set(configuration);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user