mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Add cluster UI block injection token and current implementation as a Feature
Signed-off-by: Juho Heikka <juho.heikka@gmail.com>
This commit is contained in:
parent
af1808dbb3
commit
66f3cc8bcf
@ -112,6 +112,8 @@
|
|||||||
"@astronautlabs/jsonpath": "^1.1.0",
|
"@astronautlabs/jsonpath": "^1.1.0",
|
||||||
"@hapi/call": "^9.0.1",
|
"@hapi/call": "^9.0.1",
|
||||||
"@hapi/subtext": "^7.1.0",
|
"@hapi/subtext": "^7.1.0",
|
||||||
|
"@k8slens/cluster-settings": "^6.5.0-alpha.1",
|
||||||
|
"@k8slens/metrics": "^6.5.0-alpha.1",
|
||||||
"@k8slens/node-fetch": "^6.5.0-alpha.1",
|
"@k8slens/node-fetch": "^6.5.0-alpha.1",
|
||||||
"@k8slens/react-application": "^1.0.0-alpha.0",
|
"@k8slens/react-application": "^1.0.0-alpha.0",
|
||||||
"@kubernetes/client-node": "^0.18.1",
|
"@kubernetes/client-node": "^0.18.1",
|
||||||
|
|||||||
42
packages/core/src/features/metrics/metrics-feature.ts
Normal file
42
packages/core/src/features/metrics/metrics-feature.ts
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
import { getFeature } from "@k8slens/feature-core";
|
||||||
|
import { clusterOverviewUIBlockInjectionToken } from "@k8slens/metrics";
|
||||||
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
|
import { ClusterMetrics } from "../../renderer/components/+cluster/cluster-metrics";
|
||||||
|
import { ClusterPieCharts } from "../../renderer/components/+cluster/cluster-pie-charts";
|
||||||
|
|
||||||
|
const clusterPieChartsClusterOverviewInjectable = getInjectable({
|
||||||
|
id: "cluster-pie-charts-cluster-overview",
|
||||||
|
|
||||||
|
instantiate: () => ({
|
||||||
|
id: "cluster-pie-charts-cluster-overview",
|
||||||
|
Component: ClusterPieCharts,
|
||||||
|
orderNumber: 2,
|
||||||
|
}),
|
||||||
|
|
||||||
|
injectionToken: clusterOverviewUIBlockInjectionToken,
|
||||||
|
});
|
||||||
|
|
||||||
|
const clusterMetricsOverviewBlockInjectable = getInjectable({
|
||||||
|
id: "cluster-metrics-overview-block",
|
||||||
|
|
||||||
|
instantiate: () => ({
|
||||||
|
id: "cluster-metrics-overview-block",
|
||||||
|
Component: ClusterMetrics,
|
||||||
|
orderNumber: 1,
|
||||||
|
}),
|
||||||
|
|
||||||
|
injectionToken: clusterOverviewUIBlockInjectionToken,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const metricsFeature = getFeature({
|
||||||
|
id: "core-metrics-feature",
|
||||||
|
|
||||||
|
register: (di) => {
|
||||||
|
di.register(clusterPieChartsClusterOverviewInjectable);
|
||||||
|
di.register(clusterMetricsOverviewBlockInjectable);
|
||||||
|
},
|
||||||
|
});
|
||||||
@ -15,9 +15,7 @@ import { interval } from "@k8slens/utilities";
|
|||||||
import { TabLayout } from "../layout/tab-layout";
|
import { TabLayout } from "../layout/tab-layout";
|
||||||
import { Spinner } from "../spinner";
|
import { Spinner } from "../spinner";
|
||||||
import { ClusterIssues } from "./cluster-issues";
|
import { ClusterIssues } from "./cluster-issues";
|
||||||
import { ClusterMetrics } from "./cluster-metrics";
|
|
||||||
import type { ClusterOverviewStore } from "./cluster-overview-store/cluster-overview-store";
|
import type { ClusterOverviewStore } from "./cluster-overview-store/cluster-overview-store";
|
||||||
import { ClusterPieCharts } from "./cluster-pie-charts";
|
|
||||||
import { ClusterMetricsResourceType } from "../../../common/cluster-types";
|
import { ClusterMetricsResourceType } from "../../../common/cluster-types";
|
||||||
import type { EventStore } from "../+events/store";
|
import type { EventStore } from "../+events/store";
|
||||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||||
@ -28,6 +26,9 @@ import podStoreInjectable from "../+workloads-pods/store.injectable";
|
|||||||
import eventStoreInjectable from "../+events/store.injectable";
|
import eventStoreInjectable from "../+events/store.injectable";
|
||||||
import nodeStoreInjectable from "../+nodes/store.injectable";
|
import nodeStoreInjectable from "../+nodes/store.injectable";
|
||||||
import enabledMetricsInjectable from "../../api/catalog/entity/metrics-enabled.injectable";
|
import enabledMetricsInjectable from "../../api/catalog/entity/metrics-enabled.injectable";
|
||||||
|
import type { ClusterOverviewUIBlock } from "@k8slens/metrics";
|
||||||
|
import { clusterOverviewUIBlockInjectionToken } from "@k8slens/metrics";
|
||||||
|
import { orderByOrderNumber } from "../../../common/utils/composable-responsibilities/orderable/orderable";
|
||||||
|
|
||||||
interface Dependencies {
|
interface Dependencies {
|
||||||
subscribeStores: SubscribeStores;
|
subscribeStores: SubscribeStores;
|
||||||
@ -36,6 +37,7 @@ interface Dependencies {
|
|||||||
eventStore: EventStore;
|
eventStore: EventStore;
|
||||||
nodeStore: NodeStore;
|
nodeStore: NodeStore;
|
||||||
clusterMetricsAreVisible: IComputedValue<boolean>;
|
clusterMetricsAreVisible: IComputedValue<boolean>;
|
||||||
|
uiBlocks: ClusterOverviewUIBlock[];
|
||||||
}
|
}
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
@ -76,8 +78,9 @@ class NonInjectedClusterOverview extends React.Component<Dependencies> {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ClusterMetrics/>
|
{orderByOrderNumber(this.props.uiBlocks).map((block) => (
|
||||||
<ClusterPieCharts/>
|
<block.Component key={block.id} />
|
||||||
|
))}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -118,5 +121,6 @@ export const ClusterOverview = withInjectables<Dependencies>(NonInjectedClusterO
|
|||||||
podStore: di.inject(podStoreInjectable),
|
podStore: di.inject(podStoreInjectable),
|
||||||
eventStore: di.inject(eventStoreInjectable),
|
eventStore: di.inject(eventStoreInjectable),
|
||||||
nodeStore: di.inject(nodeStoreInjectable),
|
nodeStore: di.inject(nodeStoreInjectable),
|
||||||
|
uiBlocks: di.injectMany(clusterOverviewUIBlockInjectionToken),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|||||||
@ -20,3 +20,4 @@ export * as ReactRouter from "react-router";
|
|||||||
export * as ReactRouterDom from "react-router-dom";
|
export * as ReactRouterDom from "react-router-dom";
|
||||||
export * as rendererExtensionApi from "../extensions/renderer-api";
|
export * as rendererExtensionApi from "../extensions/renderer-api";
|
||||||
export * as commonExtensionApi from "../extensions/common-api";
|
export * as commonExtensionApi from "../extensions/common-api";
|
||||||
|
export { metricsFeature } from "../features/metrics/metrics-feature";
|
||||||
|
|||||||
6
packages/metrics/.eslintrc.js
Normal file
6
packages/metrics/.eslintrc.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
module.exports = {
|
||||||
|
extends: "@k8slens/eslint-config/eslint",
|
||||||
|
parserOptions: {
|
||||||
|
project: "./tsconfig.json",
|
||||||
|
},
|
||||||
|
};
|
||||||
1
packages/metrics/.prettierrc
Normal file
1
packages/metrics/.prettierrc
Normal file
@ -0,0 +1 @@
|
|||||||
|
"@k8slens/eslint-config/prettier"
|
||||||
17
packages/metrics/index.ts
Normal file
17
packages/metrics/index.ts
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import type React from "react";
|
||||||
|
import { getInjectionToken } from "@ogre-tools/injectable";
|
||||||
|
|
||||||
|
export type ClusterOverviewUIBlock = {
|
||||||
|
id: string;
|
||||||
|
Component: React.ElementType;
|
||||||
|
orderNumber: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const clusterOverviewUIBlockInjectionToken = getInjectionToken<ClusterOverviewUIBlock>({
|
||||||
|
id: "cluster-overview-ui-block-injection-token",
|
||||||
|
});
|
||||||
1
packages/metrics/jest.config.js
Normal file
1
packages/metrics/jest.config.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
module.exports = require("@k8slens/jest").monorepoPackageConfig(__dirname).configForReact;
|
||||||
41
packages/metrics/package.json
Normal file
41
packages/metrics/package.json
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
{
|
||||||
|
"name": "@k8slens/metrics",
|
||||||
|
"private": false,
|
||||||
|
"version": "6.5.0-alpha.1",
|
||||||
|
"description": "Code that is common to all Features and those registering them.",
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
}
|
||||||
4
packages/metrics/tsconfig.json
Normal file
4
packages/metrics/tsconfig.json
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"extends": "@k8slens/typescript/config/base.json",
|
||||||
|
"include": ["**/*.ts"]
|
||||||
|
}
|
||||||
1
packages/metrics/webpack.config.js
Normal file
1
packages/metrics/webpack.config.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
module.exports = require("@k8slens/webpack").configForReact;
|
||||||
@ -4,6 +4,7 @@ import {
|
|||||||
rendererExtensionApi as Renderer,
|
rendererExtensionApi as Renderer,
|
||||||
commonExtensionApi as Common,
|
commonExtensionApi as Common,
|
||||||
registerLensCore,
|
registerLensCore,
|
||||||
|
metricsFeature
|
||||||
} from "@k8slens/core/renderer";
|
} from "@k8slens/core/renderer";
|
||||||
import { autoRegister } from "@ogre-tools/injectable-extension-for-auto-registration";
|
import { autoRegister } from "@ogre-tools/injectable-extension-for-auto-registration";
|
||||||
import { registerFeature } from "@k8slens/feature-core";
|
import { registerFeature } from "@k8slens/feature-core";
|
||||||
@ -32,7 +33,8 @@ runInAction(() => {
|
|||||||
applicationFeature,
|
applicationFeature,
|
||||||
messagingFeatureForRenderer,
|
messagingFeatureForRenderer,
|
||||||
keyboardShortcutsFeature,
|
keyboardShortcutsFeature,
|
||||||
reactApplicationFeature
|
reactApplicationFeature,
|
||||||
|
metricsFeature
|
||||||
);
|
);
|
||||||
|
|
||||||
autoRegister({
|
autoRegister({
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user