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

chore: Fix type errors from CustomResources

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2023-06-01 10:33:18 -04:00
parent cadc7e0a30
commit 544d9e2686
2 changed files with 87 additions and 95 deletions

View File

@ -2,11 +2,12 @@
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getFrontEndRouteInjectable } from "../../../../front-end-route-injection-token";
import { getFrontEndRouteInjectable } from "../../../front-end-route-injection-token";
const customResourcesRouteInjectable = getFrontEndRouteInjectable({
id: "custom-resources-route",
path: "/crd/:group?/:name?",
path: "/crd/:group/:name",
clusterFrame: true,
});

View File

@ -8,7 +8,6 @@ import "./view.scss";
import React from "react";
import { observer } from "mobx-react";
import { KubeObjectListLayout } from "../kube-object-list-layout";
import { computed } from "mobx";
import type { ApiManager } from "../../../common/k8s-api/api-manager";
import { formatJSONValue, safeJSONPathValue } from "@k8slens/utilities";
import { TabLayout } from "../layout/tab-layout-2";
@ -37,21 +36,14 @@ export interface CustomResourcesProps {
params: ParametersFromRouteInjectable<typeof customResourcesRouteInjectable>;
}
@observer
class NonInjectedCustomResources extends React.Component<Dependencies & CustomResourcesProps> {
readonly crd = computed(() => {
if (this.props.params.group && this.props.params.name) {
return this.props.customResourceDefinitionStore.getByGroup(this.props.params.group, this.props.params.name);
}
return undefined;
});
readonly store = computed(() => this.props.apiManager.getStore(this.crd.get()?.getResourceApiBase()));
render() {
const crd = this.crd.get();
const store = this.store.get();
const NonInjectedCustomResources = observer((props: Dependencies & CustomResourcesProps) => {
const {
apiManager,
customResourceDefinitionStore,
params,
} = props;
const crd = customResourceDefinitionStore.getByGroup(params.group, params.name);
const store = apiManager.getStore(crd?.getResourceApiBase());
if (!crd || !store) {
return null;
@ -129,8 +121,7 @@ class NonInjectedCustomResources extends React.Component<Dependencies & CustomRe
/>
</TabLayout>
);
}
}
});
export const CustomResources = withInjectables<Dependencies, CustomResourcesProps>(NonInjectedCustomResources, {
getProps: (di, props) => ({