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

Add table and add-remove buttons injection tokens

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2023-06-01 11:00:21 +03:00
parent 9a2d585e62
commit 007a0174f0

56
packages/table/index.ts Normal file
View File

@ -0,0 +1,56 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import type { KubeObject } from "@k8slens/kube-object";
import type {
BaseKubeObjectListLayoutColumn,
GeneralKubeObjectListLayoutColumn,
SpecificKubeListLayoutColumn,
} from "@k8slens/list-layout";
import { getInjectionToken } from "@ogre-tools/injectable";
import type { IComputedValue, IObservableValue } from "mobx";
type Column = (
| BaseKubeObjectListLayoutColumn<KubeObject>
| SpecificKubeListLayoutColumn<KubeObject>
| GeneralKubeObjectListLayoutColumn
);
export interface TableComponentProps {
tableId?: string;
columns?: Column[];
save?: (state: object) => void;
load?: (tableId: string) => object;
initialState?: {
dataItems: IComputedValue<any[]>;
headingColumns: object[];
customizeRows?: (row: object) => object;
getRowId?: (dataItem: any) => string | number | symbol;
searchBox?: IComputedValue<string> | IObservableValue<string>;
}
}
export interface TableComponent {
Component: React.ComponentType<TableComponentProps>;
}
export interface AddRemoveButtonsProps extends React.HTMLAttributes<any> {
onAdd?: () => void;
onRemove?: () => void;
addTooltip?: React.ReactNode;
removeTooltip?: React.ReactNode;
}
export interface AddOrRemoveButtons {
Component: React.ComponentType<AddRemoveButtonsProps>;
}
export const tableComponentInjectionToken = getInjectionToken<TableComponent>({
id: "table-component-injection-token",
});
export const addOrRemoveButtonsInjectionToken = getInjectionToken<TableComponent>({
id: "add-or-remove-buttons-injection-token",
});