mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
adding extension api for terminal environment variables
Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>
This commit is contained in:
parent
e8205a64b9
commit
1ac3d0a36b
@ -10,9 +10,11 @@ import type { CatalogEntity } from "../common/catalog";
|
||||
import type { IObservableArray } from "mobx";
|
||||
import type { MenuRegistration } from "../main/menu/menu-registration";
|
||||
import type { TrayMenuRegistration } from "../main/tray/tray-menu-registration";
|
||||
import type { ShellEnvVarRegistration } from "../main/shell-session/env-var/env-var-registration";
|
||||
export class LensMainExtension extends LensExtension {
|
||||
appMenus: MenuRegistration[] = [];
|
||||
trayMenus: TrayMenuRegistration[] = [];
|
||||
shellEnvVars: ShellEnvVarRegistration[] = [];
|
||||
|
||||
async navigate(pageId?: string, params?: Record<string, any>, frameId?: number) {
|
||||
return WindowManager.getInstance().navigateExtension(this.id, pageId, params, frameId);
|
||||
|
||||
10
src/main/shell-session/env-var/env-var-registration.ts
Normal file
10
src/main/shell-session/env-var/env-var-registration.ts
Normal file
@ -0,0 +1,10 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
export interface ShellEnvVarRegistration {
|
||||
title: string;
|
||||
env: Record<string, string>;
|
||||
}
|
||||
|
||||
19
src/main/shell-session/env-var/env-var.injectable.ts
Normal file
19
src/main/shell-session/env-var/env-var.injectable.ts
Normal file
@ -0,0 +1,19 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
|
||||
import mainExtensionsInjectable from "../../../extensions/main-extensions.injectable";
|
||||
import { getShellEnvVars } from "./get-shell-env-vars";
|
||||
|
||||
const shellEnvVarInjectable = getInjectable({
|
||||
instantiate: (di) =>
|
||||
getShellEnvVars({
|
||||
extensions: di.inject(mainExtensionsInjectable),
|
||||
}),
|
||||
|
||||
lifecycle: lifecycleEnum.singleton,
|
||||
});
|
||||
|
||||
export default shellEnvVarInjectable;
|
||||
18
src/main/shell-session/env-var/get-shell-env-vars.ts
Normal file
18
src/main/shell-session/env-var/get-shell-env-vars.ts
Normal file
@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import { computed, IComputedValue } from "mobx";
|
||||
import type { LensMainExtension } from "../../../extensions/lens-main-extension";
|
||||
|
||||
interface Dependencies {
|
||||
extensions: IComputedValue<LensMainExtension[]>;
|
||||
}
|
||||
|
||||
export const getShellEnvVars = ({ extensions }: Dependencies) => {
|
||||
return computed(() => (
|
||||
extensions.get()
|
||||
.flatMap((extension) => extension.shellEnvVars)
|
||||
));
|
||||
};
|
||||
Loading…
Reference in New Issue
Block a user