forked from kocyigitkim/lens-app-viewer
-
Notifications
You must be signed in to change notification settings - Fork 1
/
renderer.tsx
120 lines (116 loc) · 2.89 KB
/
renderer.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
import { Renderer } from "@k8slens/extensions";
import React from "react";
import fs from "fs";
import { SettingsEditor } from "./SettingsEditor";
import { Helper } from "./Helper";
import AppViewerPage from "./src/AppViewerPage";
import { AiTwotoneAppstore } from "react-icons/ai";
console.warn('Bootstrap CSS Injected!!!');
Helper.registerStylesheetFromNodeModule("bootstrap",
//"bootstrap/dist/css/bootstrap.min.css",
"bootstrap-dark-5/dist/css/bootstrap-dark.css"
);
const RegisterServiceButton = (
props: Renderer.Component.KubeObjectDetailsProps<Renderer.K8sApi.Service>
) => (
<div
style={{
marginTop: 10,
backgroundColor: "var(--layoutBackground)",
borderRadius: 6,
padding: 10,
boxShadow:'0px 5px 10px var(--boxShadow)',
color: 'var(--textColorSecondary) !important',
border: '1px solid rgba(0,0,0,0.1)'
}}
>
<div>
<div style={{ marginBottom: 15 }}>
<h5
style={{
display: "inline-block",
fontWeight: "bold",
padding: 10,
color: 'var(--textColorSecondary) !important'
}}
>
App Viewer
</h5>
</div>
<span
style={{
fontStyle: "italic",
padding: 10,
marginBottom: 5,
}}
>
You can add these ports to App viewer
</span>
</div>
<div
style={{
display: "flex",
flexDirection: "row",
justifyContent: "flex-end",
flexWrap: "wrap",
marginTop: 10,
}}
>
{props.object.getPorts().map((port: any) => (
<Renderer.Component.Button
style={{ margin: 5 }}
onClick={() => {
var editor: SettingsEditor = new SettingsEditor();
var cluster: any = editor.data.getCluster(
Helper.getCurrentClusterId()
);
cluster.name = Helper.getCurrentClusterName();
cluster.registerService(props.object, port);
editor.save();
}}
>
{port.port}:{port.targetPort}
</Renderer.Component.Button>
))}
</div>
</div>
);
export default class UIExtension extends Renderer.LensExtension {
constructor(a: any) {
super(a);
}
clusterPages = [
{
id: "appviewer",
components: {
Page: (props: any) => (
<AppViewerPage extension={this} pageProps={props} />
),
MenuIcon: AiTwotoneAppstore,
},
},
];
clusterPageMenus = [
{
target: { pageId: "appviewer" },
title: "App Viewer",
components: {
Icon: () => (
<AiTwotoneAppstore
style={{ marginLeft: 2.5 }}
size={24}
></AiTwotoneAppstore>
),
},
},
];
kubeObjectDetailItems = [
{
kind: "Service",
apiVersions: ["v1"],
components: {
Details: RegisterServiceButton,
},
},
];
}