mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Revert 2844 (#2980)
* Revert "review comments" This reverts commit97f2ecd88d. * Revert "Switch to I, remove type parameter default" This reverts commita3073cc99b. * Revert "Improve Table typing and remove annotations on callbacks" This reverts commitdefb0ea0dd.
This commit is contained in:
1 parent
97f2ecd88d
commit
60a19143b4
55 files changed
+471
-479
No files matched your search
@@ -32,7 +32,6 @@ import type { CustomResourceDefinition } from "../../api/endpoints/crd.api";
|
||||
import { Select, SelectOption } from "../select";
|
||||
import { createPageParam } from "../../navigation";
|
||||
import { Icon } from "../icon";
|
||||
import type { TableSortCallbacks } from "../table";
|
||||
|
||||
export const crdGroupsUrlParam = createPageParam<string[]>({
|
||||
name: "groups",
|
||||
@@ -79,11 +78,11 @@ export class CrdList extends React.Component {
|
||||
|
||||
render() {
|
||||
const { items, selectedGroups } = this;
|
||||
const sortingCallbacks: TableSortCallbacks<CustomResourceDefinition> = {
|
||||
[columnId.kind]: crd => crd.getResourceKind(),
|
||||
[columnId.group]: crd => crd.getGroup(),
|
||||
[columnId.version]: crd => crd.getVersion(),
|
||||
[columnId.scope]: crd => crd.getScope(),
|
||||
const sortingCallbacks = {
|
||||
[columnId.kind]: (crd: CustomResourceDefinition) => crd.getResourceKind(),
|
||||
[columnId.group]: (crd: CustomResourceDefinition) => crd.getGroup(),
|
||||
[columnId.version]: (crd: CustomResourceDefinition) => crd.getVersion(),
|
||||
[columnId.scope]: (crd: CustomResourceDefinition) => crd.getScope(),
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -134,7 +133,7 @@ export class CrdList extends React.Component {
|
||||
{ title: "Scope", className: "scope", sortBy: columnId.scope, id: columnId.scope },
|
||||
{ title: "Age", className: "age", sortBy: columnId.age, id: columnId.age },
|
||||
]}
|
||||
renderTableContents={crd => [
|
||||
renderTableContents={(crd: CustomResourceDefinition) => [
|
||||
<Link key="link" to={crd.getResourceUrl()} onClick={stopPropagation}>
|
||||
{crd.getResourceTitle()}
|
||||
</Link>,
|
||||
|
||||
@@ -23,10 +23,10 @@ import type { KubeApi } from "../../api/kube-api";
|
||||
import { KubeObjectStore } from "../../kube-object.store";
|
||||
import type { KubeObject } from "../../api/kube-object";
|
||||
|
||||
export class CRDResourceStore<K extends KubeObject> extends KubeObjectStore<K> {
|
||||
api: KubeApi<K>;
|
||||
export class CRDResourceStore<T extends KubeObject = any> extends KubeObjectStore<T> {
|
||||
api: KubeApi;
|
||||
|
||||
constructor(api: KubeApi<K>) {
|
||||
constructor(api: KubeApi<T>) {
|
||||
super();
|
||||
this.api = api;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ import type { KubeObject } from "../../api/kube-object";
|
||||
import type { ICRDRouteParams } from "./crd.route";
|
||||
import { autorun, computed, makeObservable } from "mobx";
|
||||
import { crdStore } from "./crd.store";
|
||||
import type { TableSortCallbacks } from "../table";
|
||||
import type { TableSortCallback } from "../table";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
import { parseJsonPath } from "../../utils/jsonPath";
|
||||
|
||||
@@ -80,14 +80,14 @@ export class CrdResources extends React.Component<Props> {
|
||||
if (!crd) return null;
|
||||
const isNamespaced = crd.isNamespaced();
|
||||
const extraColumns = crd.getPrinterColumns(false); // Cols with priority bigger than 0 are shown in details
|
||||
const sortingCallbacks: TableSortCallbacks<KubeObject> = {
|
||||
[columnId.name]: item => item.getName(),
|
||||
[columnId.namespace]: item => item.getNs(),
|
||||
[columnId.age]: item => item.getTimeDiffFromNow(),
|
||||
const sortingCallbacks: { [sortBy: string]: TableSortCallback } = {
|
||||
[columnId.name]: (item: KubeObject) => item.getName(),
|
||||
[columnId.namespace]: (item: KubeObject) => item.getNs(),
|
||||
[columnId.age]: (item: KubeObject) => item.getTimeDiffFromNow(),
|
||||
};
|
||||
|
||||
extraColumns.forEach(column => {
|
||||
sortingCallbacks[column.name] = item => jsonPath.value(item, parseJsonPath(column.jsonPath.slice(1)));
|
||||
sortingCallbacks[column.name] = (item: KubeObject) => jsonPath.value(item, parseJsonPath(column.jsonPath.slice(1)));
|
||||
});
|
||||
|
||||
return (
|
||||
@@ -98,7 +98,7 @@ export class CrdResources extends React.Component<Props> {
|
||||
store={store}
|
||||
sortingCallbacks={sortingCallbacks}
|
||||
searchFilters={[
|
||||
item => item.getSearchFields(),
|
||||
(item: KubeObject) => item.getSearchFields(),
|
||||
]}
|
||||
renderHeaderTitle={crd.getResourceTitle()}
|
||||
renderTableHeader={[
|
||||
@@ -116,7 +116,7 @@ export class CrdResources extends React.Component<Props> {
|
||||
}),
|
||||
{ title: "Age", className: "age", sortBy: columnId.age, id: columnId.age },
|
||||
]}
|
||||
renderTableContents={crdInstance => [
|
||||
renderTableContents={(crdInstance: KubeObject) => [
|
||||
crdInstance.getName(),
|
||||
isNamespaced && crdInstance.getNs(),
|
||||
...extraColumns.map((column) => {
|
||||
|
||||
@@ -26,18 +26,13 @@ import { crdApi, CustomResourceDefinition } from "../../api/endpoints/crd.api";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
import { KubeApi } from "../../api/kube-api";
|
||||
import { CRDResourceStore } from "./crd-resource.store";
|
||||
import { KubeObject } from "../../api/kube-object";
|
||||
import type { KubeObject } from "../../api/kube-object";
|
||||
|
||||
function initStore(crd: CustomResourceDefinition) {
|
||||
const apiBase = crd.getResourceApiBase();
|
||||
const kind = crd.getResourceKind();
|
||||
const isNamespaced = crd.isNamespaced();
|
||||
const api = apiManager.getApi(apiBase) ?? new KubeApi({
|
||||
objectConstructor: KubeObject,
|
||||
apiBase,
|
||||
kind,
|
||||
isNamespaced,
|
||||
});
|
||||
const api = apiManager.getApi(apiBase) || new KubeApi({ apiBase, kind, isNamespaced });
|
||||
|
||||
if (!apiManager.getStore(api)) {
|
||||
apiManager.registerStore(new CRDResourceStore(api));
|
||||
|
||||
Reference in new issue
Block a user