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

Separate injection token as package

Signed-off-by: Sami Tiilikainen <97873007+samitiilikainen@users.noreply.github.com>
This commit is contained in:
Sami Tiilikainen 2023-04-13 09:13:17 +03:00
parent afff3f5c71
commit 91d3170398
22 changed files with 175 additions and 47 deletions

View File

@ -115,6 +115,7 @@
"@k8slens/metrics": "^6.5.0-alpha.3",
"@k8slens/node-fetch": "^6.5.0-alpha.3",
"@k8slens/react-application": "^1.0.0-alpha.2",
"@k8slens/list-layout": "^6.5.0-alpha.2",
"@kubernetes/client-node": "^0.18.1",
"@material-ui/styles": "^4.11.5",
"@sentry/electron": "^3.0.8",

View File

@ -5,8 +5,8 @@
import { getInjectable } from "@ogre-tools/injectable";
import React from "react";
import type { Pod } from "../../../../common/k8s-api/endpoints";
import type { KubeObjectListLayoutColumn } from "../../kube-object-list-layout/kube-object-list-layout-column-injection-token";
import { kubeObjectListLayoutColumnInjectionToken } from "../../kube-object-list-layout/kube-object-list-layout-column-injection-token";
import type { KubeObjectListLayoutColumn } from "@k8slens/list-layout";
import { kubeObjectListLayoutColumnInjectionToken } from "@k8slens/list-layout";
import { KubeObjectAge } from "../../kube-object/age";
export const podsAgeColumnInjectable = getInjectable({

View File

@ -7,8 +7,8 @@ import { getInjectable } from "@ogre-tools/injectable";
import startCase from "lodash/startCase";
import React from "react";
import type { ContainerStateValues, Pod } from "../../../../common/k8s-api/endpoints";
import type { KubeObjectListLayoutColumn } from "../../kube-object-list-layout/kube-object-list-layout-column-injection-token";
import { kubeObjectListLayoutColumnInjectionToken } from "../../kube-object-list-layout/kube-object-list-layout-column-injection-token";
import type { KubeObjectListLayoutColumn } from "@k8slens/list-layout";
import { kubeObjectListLayoutColumnInjectionToken } from "@k8slens/list-layout";
import { StatusBrick } from "../../status-brick";
function renderState(name: string, ready: boolean, key: string, data?: ContainerStateValues) {

View File

@ -6,8 +6,8 @@ import { getConvertedParts } from "@k8slens/utilities";
import { getInjectable } from "@ogre-tools/injectable";
import React from "react";
import type { Pod } from "../../../../common/k8s-api/endpoints";
import type { KubeObjectListLayoutColumn } from "../../kube-object-list-layout/kube-object-list-layout-column-injection-token";
import { kubeObjectListLayoutColumnInjectionToken } from "../../kube-object-list-layout/kube-object-list-layout-column-injection-token";
import type { KubeObjectListLayoutColumn } from "@k8slens/list-layout";
import { kubeObjectListLayoutColumnInjectionToken } from "@k8slens/list-layout";
import { Tooltip } from "../../tooltip";
export const podsNameColumnInjectable = getInjectable({

View File

@ -6,8 +6,8 @@ import { getInjectable } from "@ogre-tools/injectable";
import React from "react";
import { NamespaceSelectBadge } from "../../+namespaces/namespace-select-badge";
import type { Pod } from "../../../../common/k8s-api/endpoints";
import type { KubeObjectListLayoutColumn } from "../../kube-object-list-layout/kube-object-list-layout-column-injection-token";
import { kubeObjectListLayoutColumnInjectionToken } from "../../kube-object-list-layout/kube-object-list-layout-column-injection-token";
import type { KubeObjectListLayoutColumn } from "@k8slens/list-layout";
import { kubeObjectListLayoutColumnInjectionToken } from "@k8slens/list-layout";
export const podsNamespaceColumnInjectable = getInjectable({
id: "pods-namespace-column",

View File

@ -9,8 +9,8 @@ import nodeApiInjectable from "../../../../common/k8s-api/endpoints/node.api.inj
import type { Pod } from "../../../../common/k8s-api/endpoints";
import { Badge } from "../../badge";
import getDetailsUrlInjectable from "../../kube-detail-params/get-details-url.injectable";
import type { KubeObjectListLayoutColumn } from "../../kube-object-list-layout/kube-object-list-layout-column-injection-token";
import { kubeObjectListLayoutColumnInjectionToken } from "../../kube-object-list-layout/kube-object-list-layout-column-injection-token";
import type { KubeObjectListLayoutColumn } from "@k8slens/list-layout";
import { kubeObjectListLayoutColumnInjectionToken } from "@k8slens/list-layout";
import { stopPropagation } from "@k8slens/utilities";
export const podsNodeColumnInjectable = getInjectable({

View File

@ -10,8 +10,8 @@ import apiManagerInjectable from "../../../../common/k8s-api/api-manager/manager
import type { Pod } from "../../../../common/k8s-api/endpoints";
import { Badge } from "../../badge";
import getDetailsUrlInjectable from "../../kube-detail-params/get-details-url.injectable";
import type { KubeObjectListLayoutColumn } from "../../kube-object-list-layout/kube-object-list-layout-column-injection-token";
import { kubeObjectListLayoutColumnInjectionToken } from "../../kube-object-list-layout/kube-object-list-layout-column-injection-token";
import type { KubeObjectListLayoutColumn } from "@k8slens/list-layout";
import { kubeObjectListLayoutColumnInjectionToken } from "@k8slens/list-layout";
export const podsOwnersColumnInjectable = getInjectable({
id: "pods-owners-column",

View File

@ -4,8 +4,8 @@
*/
import { getInjectable } from "@ogre-tools/injectable";
import type { Pod } from "../../../../common/k8s-api/endpoints";
import type { KubeObjectListLayoutColumn } from "../../kube-object-list-layout/kube-object-list-layout-column-injection-token";
import { kubeObjectListLayoutColumnInjectionToken } from "../../kube-object-list-layout/kube-object-list-layout-column-injection-token";
import type { KubeObjectListLayoutColumn } from "@k8slens/list-layout";
import { kubeObjectListLayoutColumnInjectionToken } from "@k8slens/list-layout";
export const podsQosColumnInjectable = getInjectable({
id: "pods-qos-column",

View File

@ -4,8 +4,8 @@
*/
import { getInjectable } from "@ogre-tools/injectable";
import type { Pod } from "../../../../common/k8s-api/endpoints";
import type { KubeObjectListLayoutColumn } from "../../kube-object-list-layout/kube-object-list-layout-column-injection-token";
import { kubeObjectListLayoutColumnInjectionToken } from "../../kube-object-list-layout/kube-object-list-layout-column-injection-token";
import type { KubeObjectListLayoutColumn } from "@k8slens/list-layout";
import { kubeObjectListLayoutColumnInjectionToken } from "@k8slens/list-layout";
export const podsRestartsColumnInjectable = getInjectable({
id: "pods-restarts-column",

View File

@ -5,8 +5,8 @@
import { getInjectable } from "@ogre-tools/injectable";
import { kebabCase } from "lodash";
import type { Pod } from "../../../../common/k8s-api/endpoints";
import type { KubeObjectListLayoutColumn } from "../../kube-object-list-layout/kube-object-list-layout-column-injection-token";
import { kubeObjectListLayoutColumnInjectionToken } from "../../kube-object-list-layout/kube-object-list-layout-column-injection-token";
import type { KubeObjectListLayoutColumn } from "@k8slens/list-layout";
import { kubeObjectListLayoutColumnInjectionToken } from "@k8slens/list-layout";
export const podsStatusColumnInjectable = getInjectable({
id: "pods-status-column",

View File

@ -5,8 +5,8 @@
import { getInjectable } from "@ogre-tools/injectable";
import React from "react";
import type { Pod } from "../../../../common/k8s-api/endpoints";
import type { KubeObjectListLayoutColumn } from "../../kube-object-list-layout/kube-object-list-layout-column-injection-token";
import { kubeObjectListLayoutColumnInjectionToken } from "../../kube-object-list-layout/kube-object-list-layout-column-injection-token";
import type { KubeObjectListLayoutColumn } from "@k8slens/list-layout";
import { kubeObjectListLayoutColumnInjectionToken } from "@k8slens/list-layout";
import { KubeObjectStatusIcon } from "../../kube-object-status-icon";
export const podsQosColumnInjectable = getInjectable({

View File

@ -1,24 +0,0 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import type { ReactNode } from "react";
import type { SearchFilter } from "../item-object-list/list-layout";
import type { TableCellProps, TableSortCallback } from "../table";
import type { ItemObject } from "../../../common/item.store";
import { getInjectionToken } from "@ogre-tools/injectable";
export interface KubeObjectListLayoutColumn<Item extends ItemObject> {
id: string;
kind: string;
apiVersion: string;
priority: number;
sortingCallBack?: TableSortCallback<Item>;
searchFilter?: SearchFilter<Item>;
header: (TableCellProps | undefined | null);
content: (item: Item) => (ReactNode | TableCellProps);
}
export const kubeObjectListLayoutColumnInjectionToken = getInjectionToken<KubeObjectListLayoutColumn<any>>({
id: "kube-object-list-layout-column",
});

View File

@ -29,9 +29,9 @@ import type { ToggleKubeDetailsPane } from "../kube-detail-params/toggle-details
import kubeSelectedUrlParamInjectable from "../kube-detail-params/kube-selected-url.injectable";
import toggleKubeDetailsPaneInjectable from "../kube-detail-params/toggle-details.injectable";
import type { ClusterContext } from "../../cluster-frame-context/cluster-frame-context";
import type { KubeObjectListLayoutColumn } from "./kube-object-list-layout-column-injection-token";
import type { KubeObjectListLayoutColumn } from "@k8slens/list-layout";
import type { ItemObject } from "../../../common/item.store";
import { kubeObjectListLayoutColumnInjectionToken } from "./kube-object-list-layout-column-injection-token";
import { kubeObjectListLayoutColumnInjectionToken } from "@k8slens/list-layout";
import { sortBy } from "lodash";
export interface KubeObjectListLayoutProps<

View File

@ -10,7 +10,6 @@ import setStatusBarStatusInjectable from "./components/status-bar/set-status-bar
// @experimental
export type { Environments } from "../extensions/as-legacy-globals-for-extension-api/legacy-global-di-for-extension-api";
export { nodeEnvInjectionToken } from "../common/vars/node-env-injection-token";
export * from "./components/kube-object-list-layout/kube-object-list-layout-column-injection-token";
export { registerLensCore } from "./register-lens-core";
export {
React,

View File

@ -0,0 +1,6 @@
module.exports = {
extends: "@k8slens/eslint-config/eslint",
parserOptions: {
project: "./tsconfig.json",
},
};

View File

@ -0,0 +1 @@
"@k8slens/eslint-config/prettier"

View File

@ -0,0 +1 @@
export * from "./kube-object-list-layout-column-injection-token";

View File

@ -0,0 +1 @@
module.exports = require("@k8slens/jest").monorepoPackageConfig(__dirname).configForReact;

View File

@ -0,0 +1,97 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import type { ReactNode } from "react";
import type { SingleOrMany } from "@k8slens/utilities";
import { getInjectionToken } from "@ogre-tools/injectable";
export interface ItemObject {
getId(): string;
getName(): string;
}
export type TableSortBy = string;
export type TableOrderBy = "asc" | "desc";
export interface TableSortParams {
sortBy: TableSortBy;
orderBy: TableOrderBy;
}
export type TableSortCallback<Item> = (data: Item) => undefined | string | number | (string | number)[];
export type TableSortCallbacks<Item> = Record<string, TableSortCallback<Item>>;
export type SearchFilter<I extends ItemObject> = (item: I) => SingleOrMany<string | number | undefined | null>;
export interface TableCellProps extends React.DOMAttributes<HTMLDivElement> {
/**
* used for configuration visibility of columns
*/
id?: string;
/**
* Any css class names for this table cell. Only used if `title` is a "simple" react node
*/
className?: string;
/**
* The actual value of the cell
*/
title?: ReactNode;
/**
* content inside could be scrolled
*/
scrollable?: boolean;
/**
* render cell with a checkbox
*/
checkbox?: boolean;
/**
* mark checkbox as checked or not
*/
isChecked?: boolean;
/**
* column name, must be same as key in sortable object <Table sortable={}/>
*/
sortBy?: TableSortBy;
/**
* id of the column which follow same visibility rules
*/
showWithColumn?: string;
/**
* @internal
*/
_sorting?: Partial<TableSortParams>;
/**
* @internal
*/
_sort?(sortBy: TableSortBy): void;
/**
* @internal
* indicator, might come from parent <TableHead>, don't use this prop outside (!)
*/
_nowrap?: boolean;
}
export interface KubeObjectListLayoutColumn<Item extends ItemObject> {
id: string;
kind: string;
apiVersion: string;
priority: number;
sortingCallBack?: TableSortCallback<Item>;
searchFilter?: SearchFilter<Item>;
header: TableCellProps | undefined | null;
content: (item: Item) => ReactNode | TableCellProps;
}
export const kubeObjectListLayoutColumnInjectionToken = getInjectionToken<KubeObjectListLayoutColumn<any>>({
id: "kube-object-list-layout-column",
});

View File

@ -0,0 +1,41 @@
{
"name": "@k8slens/list-layout",
"private": false,
"version": "6.5.0-alpha.2",
"description": "Injection tokens for list layout",
"type": "commonjs",
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
},
"files": [
"dist"
],
"repository": {
"type": "git",
"url": "git+https://github.com/lensapp/lens.git"
},
"main": "dist/index.js",
"types": "dist/index.d.ts",
"author": {
"name": "OpenLens Authors",
"email": "info@k8slens.dev"
},
"license": "MIT",
"homepage": "https://github.com/lensapp/lens",
"scripts": {
"build": "webpack",
"clean": "rimraf dist/",
"dev": "webpack --mode=development --watch",
"test": "jest --coverage --runInBand",
"lint": "lens-lint",
"lint:fix": "lens-lint --fix"
},
"peerDependencies": {
"@ogre-tools/injectable": "^15.1.2",
"react": "^17.0.2"
},
"devDependencies": {
"@k8slens/eslint-config": "6.5.0-alpha.1"
}
}

View File

@ -0,0 +1,4 @@
{
"extends": "@k8slens/typescript/config/base.json",
"include": ["**/*.ts"]
}

View File

@ -0,0 +1 @@
module.exports = require("@k8slens/webpack").configForReact;