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

License extension (#1174)

* License menu item should come from an extension #1141

Signed-off-by: Roman <ixrock@gmail.com>

* fix: expose `Util.openExternal` via extensions-api

Signed-off-by: Roman <ixrock@gmail.com>

* move LICENSE back to root

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman 2020-11-02 13:03:00 +02:00 committed by GitHub
parent da862db0b9
commit 32ca885596
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 3691 additions and 9 deletions

View File

@ -0,0 +1,5 @@
install-deps:
npm install
build: install-deps
npm run build

View File

@ -0,0 +1,13 @@
import { LensMainExtension, Util } from "@k8slens/extensions";
export default class LicenseLensMainExtension extends LensMainExtension {
appMenus = [
{
parentId: "help",
label: "License",
async click() {
Util.openExternal("https://k8slens.dev/licenses/eula.md")
}
}
]
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,21 @@
{
"name": "lens-license",
"version": "0.1.0",
"description": "License menu item",
"main": "dist/main.js",
"scripts": {
"build": "webpack -p",
"dev": "webpack --watch"
},
"dependencies": {},
"devDependencies": {
"@types/webpack": "^4.41.17",
"@k8slens/extensions": "file:../../src/extensions/npm/extensions",
"mobx": "^5.15.5",
"react": "^16.13.1",
"ts-loader": "^8.0.4",
"ts-node": "^9.0.0",
"typescript": "^4.0.3",
"webpack": "^4.44.2"
}
}

View File

@ -0,0 +1,19 @@
{
"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"
}
}

View File

@ -0,0 +1,34 @@
import path from "path"
const outputPath = path.resolve(__dirname, 'dist');
export default [
{
entry: './main.ts',
context: __dirname,
target: "electron-main",
mode: "production",
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
],
},
externals: {
"@k8slens/extensions": "var global.LensExtensions",
"mobx": "var global.Mobx",
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
},
output: {
libraryTarget: "commonjs2",
globalObject: "this",
filename: 'main.js',
path: outputPath,
},
},
];

View File

@ -185,6 +185,7 @@
"pod-menu",
"node-menu",
"metrics-cluster-feature",
"license-menu-item",
"support-page"
]
},

View File

@ -11,4 +11,4 @@ export * from "./getRandId"
export * from "./splitArray"
export * from "./saveToAppFiles"
export * from "./singleton"
export * from "./cloneJson"
export * from "./openExternal"

View File

@ -0,0 +1,6 @@
// Opens a link in external browser
import { shell } from "electron"
export function openExternal(url: string) {
return shell.openExternal(url);
}

View File

@ -1,3 +1,3 @@
export { Singleton } from "../../common/utils"
export { Singleton, openExternal } from "../../common/utils"
export { prevDefault, stopPropagation } from "../../renderer/utils/prevDefault"
export { cssNames } from "../../renderer/utils/cssNames"

View File

@ -1,4 +1,4 @@
import { app, BrowserWindow, dialog, Menu, MenuItem, MenuItemConstructorOptions, shell, webContents } from "electron"
import { app, BrowserWindow, dialog, Menu, MenuItem, MenuItemConstructorOptions, webContents } from "electron"
import { autorun } from "mobx";
import { WindowManager } from "./window-manager";
import { appName, isMac, isWindows } from "../common/vars";
@ -185,12 +185,6 @@ export function buildMenu(windowManager: WindowManager) {
navigate(whatsNewURL())
},
},
{
label: "License",
click: async () => {
shell.openExternal('https://k8slens.dev/licenses/eula.md');
},
},
...ignoreOnMac([
{
label: "About Lens",