1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Load model within getProps()

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2023-02-15 14:56:31 +03:00
parent 416ec1fdf8
commit 3bc817f596
2 changed files with 11 additions and 6 deletions

View File

@ -111,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: await di.inject(releaseDetailsModelInjectable, props.targetRelease),
...props,
}
},
}); });
const ResourceGroup = ({ const ResourceGroup = ({

View File

@ -31,7 +31,6 @@ import assert from "assert";
import activeThemeInjectable from "../../../../themes/active.injectable"; import activeThemeInjectable from "../../../../themes/active.injectable";
import type { ToHelmRelease } from "../../to-helm-release.injectable"; import type { ToHelmRelease } from "../../to-helm-release.injectable";
import toHelmReleaseInjectable from "../../to-helm-release.injectable"; import toHelmReleaseInjectable from "../../to-helm-release.injectable";
import uniqueId from "lodash/uniqueId";
const releaseDetailsModelInjectable = getInjectable({ const releaseDetailsModelInjectable = getInjectable({
id: "release-details-model", id: "release-details-model",
@ -57,7 +56,7 @@ const releaseDetailsModelInjectable = getInjectable({
}, },
lifecycle: lifecycleEnum.keyedSingleton({ lifecycle: lifecycleEnum.keyedSingleton({
getInstanceKey: (di, release: TargetHelmRelease) => `${release.namespace}/${release.name}-${uniqueId()}`, getInstanceKey: (di, release: TargetHelmRelease) => `${release.namespace}/${release.name}`,
}), }),
}); });