mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Merge branch 'master' into prometheus-cluster-metadata
This commit is contained in:
commit
88a392ff0c
194 files changed
+4067
-10143
No files matched your search
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "extension-example",
|
||||
"name": "example-extension",
|
||||
"version": "1.0.0",
|
||||
"description": "Example extension",
|
||||
"main": "dist/main.js",
|
||||
|
||||
@@ -11,7 +11,7 @@ export class ExamplePage extends React.Component<{ extension: LensRendererExtens
|
||||
deactivate = () => {
|
||||
const { extension } = this.props;
|
||||
extension.disable();
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
const doodleStyle = {
|
||||
|
||||
@@ -6,13 +6,12 @@ export default class ExampleExtension extends LensRendererExtension {
|
||||
clusterPages = [
|
||||
{
|
||||
id: "example",
|
||||
routePath: "/extension-example",
|
||||
title: "Example Extension",
|
||||
components: {
|
||||
Page: () => <ExamplePage extension={this}/>,
|
||||
}
|
||||
}
|
||||
]
|
||||
];
|
||||
|
||||
clusterPageMenus = [
|
||||
{
|
||||
@@ -22,5 +21,5 @@ export default class ExampleExtension extends LensRendererExtension {
|
||||
Icon: ExampleIcon,
|
||||
}
|
||||
}
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -38,5 +38,5 @@ export default class EventResourceStatusRendererExtension extends LensRendererEx
|
||||
apiVersions: ["batch/v1"],
|
||||
resolve: (cronJob: K8sApi.CronJob) => resolveStatusForCronJobs(cronJob)
|
||||
},
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -6,8 +6,8 @@ export default class LicenseLensMainExtension extends LensMainExtension {
|
||||
parentId: "help",
|
||||
label: "License",
|
||||
async click() {
|
||||
Util.openExternal("https://k8slens.dev/licenses/eula.md");
|
||||
Util.openExternal("https://k8slens.dev/licenses/eula");
|
||||
}
|
||||
}
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -10,14 +10,14 @@ export default class ClusterMetricsFeatureExtension extends LensRendererExtensio
|
||||
Description: () => {
|
||||
return (
|
||||
<span>
|
||||
Enable timeseries data visualization (Prometheus stack) for your cluster.
|
||||
Install this only if you don't have existing Prometheus stack installed.
|
||||
You can see preview of manifests <a href="https://github.com/lensapp/lens/tree/master/extensions/lens-metrics/resources" target="_blank">here</a>.
|
||||
Enable timeseries data visualization (Prometheus stack) for your cluster.
|
||||
Install this only if you don't have existing Prometheus stack installed.
|
||||
You can see preview of manifests <a href="https://github.com/lensapp/lens/tree/master/extensions/lens-metrics/resources" target="_blank">here</a>.
|
||||
</span>
|
||||
);
|
||||
}
|
||||
},
|
||||
feature: new MetricsFeature()
|
||||
}
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -25,10 +25,10 @@ export interface MetricsConfiguration {
|
||||
}
|
||||
|
||||
export class MetricsFeature extends ClusterFeature.Feature {
|
||||
name = "metrics"
|
||||
latestVersion = "v2.17.2-lens1"
|
||||
name = "metrics";
|
||||
latestVersion = "v2.17.2-lens1";
|
||||
|
||||
config: MetricsConfiguration = {
|
||||
templateContext: MetricsConfiguration = {
|
||||
persistence: {
|
||||
enabled: false,
|
||||
storageClass: null,
|
||||
@@ -53,12 +53,12 @@ export class MetricsFeature extends ClusterFeature.Feature {
|
||||
// Check if there are storageclasses
|
||||
const storageClassApi = K8sApi.forCluster(cluster, K8sApi.StorageClass);
|
||||
const scs = await storageClassApi.list();
|
||||
this.config.persistence.enabled = scs.some(sc => (
|
||||
this.templateContext.persistence.enabled = scs.some(sc => (
|
||||
sc.metadata?.annotations?.['storageclass.kubernetes.io/is-default-class'] === 'true' ||
|
||||
sc.metadata?.annotations?.['storageclass.beta.kubernetes.io/is-default-class'] === 'true'
|
||||
));
|
||||
|
||||
super.applyResources(cluster, super.renderTemplates(path.join(__dirname, "../resources/")));
|
||||
super.applyResources(cluster, path.join(__dirname, "../resources/"));
|
||||
}
|
||||
|
||||
async upgrade(cluster: Store.Cluster): Promise<void> {
|
||||
|
||||
@@ -11,5 +11,5 @@ export default class NodeMenuRendererExtension extends LensRendererExtension {
|
||||
MenuItem: (props: NodeMenuProps) => <NodeMenu {...props} />
|
||||
}
|
||||
}
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -19,5 +19,5 @@ export default class PodMenuRendererExtension extends LensRendererExtension {
|
||||
MenuItem: (props: PodLogsMenuProps) => <PodLogsMenu {...props} />
|
||||
}
|
||||
}
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
import { LensMainExtension } from "@k8slens/extensions";
|
||||
|
||||
export default class SupportPageMainExtension extends LensMainExtension {
|
||||
appMenus = [
|
||||
{
|
||||
parentId: "help",
|
||||
label: "Support",
|
||||
click: () => {
|
||||
this.navigate();
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
-8520
File diff suppressed because it is too large.
Load diff
@@ -1,29 +0,0 @@
|
||||
{
|
||||
"name": "lens-support-page",
|
||||
"version": "0.1.0",
|
||||
"description": "Lens support page",
|
||||
"main": "dist/main.js",
|
||||
"renderer": "dist/renderer.js",
|
||||
"scripts": {
|
||||
"build": "webpack -p",
|
||||
"dev": "webpack --watch",
|
||||
"test": "jest --passWithNoTests --env=jsdom src $@"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"@k8slens/extensions": "file:../../src/extensions/npm/extensions",
|
||||
"@types/react": "^16.9.53",
|
||||
"@types/react-router": "^5.1.8",
|
||||
"@types/webpack": "^4.41.17",
|
||||
"css-loader": "^5.0.0",
|
||||
"jest": "^26.6.3",
|
||||
"mobx": "^5.15.5",
|
||||
"react": "^16.13.1",
|
||||
"sass-loader": "^10.0.4",
|
||||
"style-loader": "^2.0.0",
|
||||
"ts-loader": "^8.0.4",
|
||||
"ts-node": "^9.0.0",
|
||||
"typescript": "^4.0.3",
|
||||
"webpack": "^4.44.2"
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
import React from "react";
|
||||
import { Component, Interface, LensRendererExtension } from "@k8slens/extensions";
|
||||
import { SupportPage } from "./src/support";
|
||||
|
||||
export default class SupportPageRendererExtension extends LensRendererExtension {
|
||||
globalPages: Interface.PageRegistration[] = [
|
||||
{
|
||||
components: {
|
||||
Page: SupportPage,
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
statusBarItems: Interface.StatusBarRegistration[] = [
|
||||
{
|
||||
item: (
|
||||
<div className="SupportPageIcon flex align-center" onClick={() => this.navigate()}>
|
||||
<Component.Icon interactive material="help" smallest/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
.SupportPage {
|
||||
a[target=_blank] {
|
||||
text-decoration: none;
|
||||
border-bottom: 1px solid;
|
||||
|
||||
&:after {
|
||||
content: "launch";
|
||||
font: small "Material Icons";
|
||||
vertical-align: middle;
|
||||
margin-left: 2px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.SupportPageIcon {
|
||||
color: white;
|
||||
font-size: var(--font-size-small);
|
||||
padding-right: calc(var(--padding) / 2);
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
// TODO: support localization / figure out how to extract / consume i18n strings
|
||||
|
||||
import "./support.scss";
|
||||
import React from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import { App, Component } from "@k8slens/extensions";
|
||||
|
||||
@observer
|
||||
export class SupportPage extends React.Component {
|
||||
render() {
|
||||
const { PageLayout } = Component;
|
||||
const { slackUrl, issuesTrackerUrl } = App;
|
||||
return (
|
||||
<PageLayout showOnTop className="SupportPage" header={<h2>Support</h2>}>
|
||||
<h2>Community Slack Channel</h2>
|
||||
<p>
|
||||
Ask a question, see what's being discussed, join the conversation <a href={slackUrl} target="_blank">here</a>
|
||||
</p>
|
||||
|
||||
<h2>Report an Issue</h2>
|
||||
<p>
|
||||
Review existing issues or open a new one <a href={issuesTrackerUrl} target="_blank">here</a>
|
||||
</p>
|
||||
|
||||
{/*<h2><Trans>Commercial Support</Trans></h2>*/}
|
||||
</PageLayout>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"outDir": "dist",
|
||||
"baseUrl": ".",
|
||||
"module": "CommonJS",
|
||||
"target": "ES2017",
|
||||
"lib": ["ESNext", "DOM", "DOM.Iterable"],
|
||||
"moduleResolution": "Node",
|
||||
"sourceMap": false,
|
||||
"declaration": false,
|
||||
"strict": false,
|
||||
"noImplicitAny": true,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"experimentalDecorators": true,
|
||||
"jsx": "react",
|
||||
"paths": {
|
||||
"*": [
|
||||
"node_modules/*",
|
||||
"../../types/*"
|
||||
]
|
||||
}
|
||||
},
|
||||
"include": [
|
||||
"renderer.tsx",
|
||||
"src/**/*"
|
||||
]
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
import path from "path";
|
||||
|
||||
const outputPath = path.resolve(__dirname, 'dist');
|
||||
|
||||
const lensExternals = {
|
||||
"@k8slens/extensions": "var global.LensExtensions",
|
||||
"react": "var global.React",
|
||||
"mobx": "var global.Mobx",
|
||||
"mobx-react": "var global.MobxReact",
|
||||
};
|
||||
|
||||
export default [
|
||||
{
|
||||
entry: './main.ts',
|
||||
context: __dirname,
|
||||
target: "electron-main",
|
||||
mode: "production",
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.tsx?$/,
|
||||
use: 'ts-loader',
|
||||
exclude: /node_modules/,
|
||||
},
|
||||
],
|
||||
},
|
||||
externals: [
|
||||
lensExternals,
|
||||
],
|
||||
resolve: {
|
||||
extensions: ['.tsx', '.ts', '.js'],
|
||||
},
|
||||
output: {
|
||||
libraryTarget: "commonjs2",
|
||||
globalObject: "this",
|
||||
filename: 'main.js',
|
||||
path: outputPath,
|
||||
},
|
||||
},
|
||||
{
|
||||
entry: './renderer.tsx',
|
||||
context: __dirname,
|
||||
target: "electron-renderer",
|
||||
mode: "production",
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.tsx?$/,
|
||||
use: 'ts-loader',
|
||||
exclude: /node_modules/,
|
||||
},
|
||||
{
|
||||
test: /\.s?css$/,
|
||||
use: [
|
||||
"style-loader",
|
||||
"css-loader",
|
||||
"sass-loader",
|
||||
]
|
||||
}
|
||||
],
|
||||
},
|
||||
externals: [
|
||||
lensExternals,
|
||||
],
|
||||
resolve: {
|
||||
extensions: ['.tsx', '.ts', '.js'],
|
||||
},
|
||||
output: {
|
||||
libraryTarget: "commonjs2",
|
||||
globalObject: "this",
|
||||
filename: 'renderer.js',
|
||||
path: outputPath,
|
||||
},
|
||||
},
|
||||
];
|
||||
@@ -8,6 +8,7 @@ export default class TelemetryMainExtension extends LensMainExtension {
|
||||
console.log("telemetry main extension activated");
|
||||
tracker.start();
|
||||
tracker.reportPeriodically();
|
||||
tracker.watchExtensions();
|
||||
await telemetryPreferencesStore.loadExtension(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { toJS } from "mobx";
|
||||
|
||||
export type TelemetryPreferencesModel = {
|
||||
enabled: boolean;
|
||||
}
|
||||
};
|
||||
|
||||
export class TelemetryPreferencesStore extends Store.ExtensionStore<TelemetryPreferencesModel> {
|
||||
enabled = true;
|
||||
|
||||
@@ -3,23 +3,26 @@ import ua from "universal-analytics";
|
||||
import Analytics from "analytics-node";
|
||||
import { machineIdSync } from "node-machine-id";
|
||||
import { telemetryPreferencesStore } from "./telemetry-preferences-store";
|
||||
import { reaction, IReactionDisposer } from "mobx";
|
||||
import { comparer } from "mobx";
|
||||
|
||||
export class Tracker extends Util.Singleton {
|
||||
static readonly GA_ID = "UA-159377374-1"
|
||||
static readonly SEGMENT_KEY = "YENwswyhlOgz8P7EFKUtIZ2MfON7Yxqb"
|
||||
protected eventHandlers: Array<(ev: EventBus.AppEvent ) => void> = []
|
||||
protected started = false
|
||||
protected visitor: ua.Visitor
|
||||
protected analytics: Analytics
|
||||
static readonly GA_ID = "UA-159377374-1";
|
||||
static readonly SEGMENT_KEY = "YENwswyhlOgz8P7EFKUtIZ2MfON7Yxqb";
|
||||
protected eventHandlers: Array<(ev: EventBus.AppEvent ) => void> = [];
|
||||
protected started = false;
|
||||
protected visitor: ua.Visitor;
|
||||
protected analytics: Analytics;
|
||||
protected machineId: string = null;
|
||||
protected ip: string = null;
|
||||
protected appVersion: string;
|
||||
protected locale: string;
|
||||
protected userAgent: string;
|
||||
protected anonymousId: string;
|
||||
protected os: string
|
||||
protected os: string;
|
||||
protected disposers: IReactionDisposer[];
|
||||
|
||||
protected reportInterval: NodeJS.Timeout
|
||||
protected reportInterval: NodeJS.Timeout;
|
||||
|
||||
private constructor() {
|
||||
super();
|
||||
@@ -35,6 +38,7 @@ export class Tracker extends Util.Singleton {
|
||||
this.analytics = new Analytics(Tracker.SEGMENT_KEY, { flushAt: 1 });
|
||||
this.visitor.set("dl", "https://telemetry.k8slens.dev");
|
||||
this.visitor.set("ua", this.userAgent);
|
||||
this.disposers = [];
|
||||
}
|
||||
|
||||
start() {
|
||||
@@ -49,6 +53,21 @@ export class Tracker extends Util.Singleton {
|
||||
EventBus.appEventBus.addListener(handler);
|
||||
}
|
||||
|
||||
watchExtensions() {
|
||||
let previousExtensions = App.getEnabledExtensions();
|
||||
this.disposers.push(reaction(() => App.getEnabledExtensions(), (currentExtensions) => {
|
||||
const removedExtensions = previousExtensions.filter(x => !currentExtensions.includes(x));
|
||||
removedExtensions.forEach(ext => {
|
||||
this.event("extension", "disable", { extension: ext });
|
||||
});
|
||||
const newExtensions = currentExtensions.filter(x => !previousExtensions.includes(x));
|
||||
newExtensions.forEach(ext => {
|
||||
this.event("extension", "enable", { extension: ext });
|
||||
});
|
||||
previousExtensions = currentExtensions;
|
||||
}, { equals: comparer.structural }));
|
||||
}
|
||||
|
||||
reportPeriodically() {
|
||||
this.reportInterval = setInterval(() => {
|
||||
this.reportData();
|
||||
@@ -66,6 +85,9 @@ export class Tracker extends Util.Singleton {
|
||||
if (this.reportInterval) {
|
||||
clearInterval(this.reportInterval);
|
||||
}
|
||||
this.disposers.forEach(disposer => {
|
||||
disposer();
|
||||
});
|
||||
}
|
||||
|
||||
protected async isTelemetryAllowed(): Promise<boolean> {
|
||||
@@ -79,7 +101,8 @@ export class Tracker extends Util.Singleton {
|
||||
appVersion: App.version,
|
||||
os: this.os,
|
||||
clustersCount: clustersList.length,
|
||||
workspacesCount: Store.workspaceStore.enabledWorkspacesList.length
|
||||
workspacesCount: Store.workspaceStore.enabledWorkspacesList.length,
|
||||
extensions: App.getEnabledExtensions()
|
||||
});
|
||||
|
||||
clustersList.forEach((cluster) => {
|
||||
|
||||
Reference in new issue
Block a user