mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Switch to using messaging and startable stoppable from NPM package (#7368)
* Add custom jest resolver to fix requiring "uuid" module Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Update dependencies Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Introduce test utils for rendering and running with thrown mobx reactions Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Extract startable-stoppable to NPM package Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Extract messaging to NPM package Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com> Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Switch to using startable-stoppable from NPM package Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Switch to using messaging from the Feature Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Remove old implementation of messaging Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Make setupping app paths happen earlier in renderer Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Fix typo Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Add kludge to make testing-library work properly from test-utils package Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Fix code style Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Add lint:fix -root script Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Fix unrelated failing unit tests Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Turn of no-floating-promises from typescript linting for being broken Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Make linting not happen for dist -directories Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Make linting failures appear as failure Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Stop running prettier twice It already gets ran as eslint-plugin. Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Make CI run unit tests for all packages by consolidating name of NPM script Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com> Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Add missing unit tests for coverage Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com> Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Skip coverage for test utils Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com> Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Remove check for coverage in packages which are not ready for it Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Stop collecting coverage from index.ts files them being indirections to the implementation Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com> Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Implement sending message to channel in main Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Add missing feature dependencies Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Add dummy implementations for requesting in main from renderer Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Re-enable communicating from main to cluster frames Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Ignore trivial files from coverage Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Update package-lock Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Extract message-bridge to separate NPM package to prevent dev dependencies being in the production bundle Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Extract computed channel to own NPM package for clear dependencies Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Consolidate electron related stuff to a directory Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Add missing publish configurations Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Ignore test implementation from coverage being not interesting Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> --------- Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
1 parent
df49ff9b96
commit
0f1f030a06
261 files changed
+4447
-1795
No files matched your search
+1
-1
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { autorun } from "mobx";
|
||||
import { getStartableStoppable } from "../../../common/utils/get-startable-stoppable";
|
||||
import { getStartableStoppable } from "@k8slens/startable-stoppable";
|
||||
import populateApplicationMenuInjectable from "./populate-application-menu.injectable";
|
||||
import applicationMenuItemCompositeInjectable from "./application-menu-item-composite.injectable";
|
||||
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { getStartableStoppable } from "../../../../../common/utils/get-startable-stoppable";
|
||||
import { getStartableStoppable } from "@k8slens/startable-stoppable";
|
||||
import processCheckingForUpdatesInjectable from "../../../main/process-checking-for-updates.injectable";
|
||||
import withOrphanPromiseInjectable from "../../../../../common/utils/with-orphan-promise/with-orphan-promise.injectable";
|
||||
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import type { MessageChannel } from "../../../common/utils/channel/message-channel-listener-injection-token";
|
||||
import type { MessageChannel } from "@k8slens/messaging";
|
||||
|
||||
export type RestartAndInstallUpdateChannel = MessageChannel<void>;
|
||||
|
||||
|
||||
+2
-2
@@ -3,13 +3,13 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { restartAndInstallUpdateChannel } from "../../common/restart-and-install-update-channel";
|
||||
import { getMessageChannelListenerInjectable } from "../../../../common/utils/channel/message-channel-listener-injection-token";
|
||||
import { getMessageChannelListenerInjectable } from "@k8slens/messaging";
|
||||
import quitAndInstallUpdateInjectable from "../quit-and-install-update.injectable";
|
||||
|
||||
const restartAndInstallUpdateListenerInjectable = getMessageChannelListenerInjectable({
|
||||
id: "restart",
|
||||
channel: restartAndInstallUpdateChannel,
|
||||
handler: (di) => di.inject(quitAndInstallUpdateInjectable),
|
||||
getHandler: (di) => di.inject(quitAndInstallUpdateInjectable),
|
||||
});
|
||||
|
||||
export default restartAndInstallUpdateListenerInjectable;
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { autorun } from "mobx";
|
||||
import { getStartableStoppable } from "../../../../common/utils/get-startable-stoppable";
|
||||
import { getStartableStoppable } from "@k8slens/startable-stoppable";
|
||||
import setUpdateOnQuitInjectable from "../../../../main/electron-app/features/set-update-on-quit.injectable";
|
||||
import selectedUpdateChannelInjectable from "../../common/selected-update-channel/selected-update-channel.injectable";
|
||||
import type { ReleaseChannel, UpdateChannel } from "../../common/update-channels";
|
||||
|
||||
+2
-2
@@ -4,13 +4,13 @@
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { restartAndInstallUpdateChannel } from "../common/restart-and-install-update-channel";
|
||||
import messageToChannelInjectable from "../../../renderer/utils/channel/message-to-channel.injectable";
|
||||
import { sendMessageToChannelInjectionToken } from "@k8slens/messaging";
|
||||
|
||||
const restartAndInstallUpdateInjectable = getInjectable({
|
||||
id: "restart-and-install-update",
|
||||
|
||||
instantiate: (di) => {
|
||||
const messageToChannel = di.inject(messageToChannelInjectable);
|
||||
const messageToChannel = di.inject(sendMessageToChannelInjectionToken);
|
||||
|
||||
return () => {
|
||||
messageToChannel(restartAndInstallUpdateChannel);
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import { getRequestChannel } from "../../../common/utils/channel/get-request-channel";
|
||||
import { getRequestChannel } from "@k8slens/messaging";
|
||||
|
||||
export const casChannel = getRequestChannel<void, string[]>("certificate-authorities");
|
||||
+1
@@ -8,6 +8,7 @@ import { casChannel } from "../common/channel";
|
||||
import certificateAuthoritiesChannelListenerInjectable from "./channel-handler.injectable";
|
||||
|
||||
export default getGlobalOverride(certificateAuthoritiesChannelListenerInjectable, () => ({
|
||||
id: "certificate-authorities-channel-listener",
|
||||
channel: casChannel,
|
||||
handler: () => [],
|
||||
}));
|
||||
+3
-2
@@ -2,14 +2,15 @@
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getRequestChannelListenerInjectable } from "../../../main/utils/channel/channel-listeners/listener-tokens";
|
||||
import { getRequestChannelListenerInjectable } from "@k8slens/messaging";
|
||||
import { casChannel } from "../common/channel";
|
||||
import { globalAgent } from "https";
|
||||
import { isString } from "@k8slens/utilities";
|
||||
|
||||
const certificateAuthoritiesChannelListenerInjectable = getRequestChannelListenerInjectable({
|
||||
id: "certificate-authorities-channel-listener",
|
||||
channel: casChannel,
|
||||
handler: () => () => {
|
||||
getHandler: () => () => {
|
||||
if (Array.isArray(globalAgent.options.ca)) {
|
||||
return globalAgent.options.ca.filter(isString);
|
||||
}
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { requestFromChannelInjectionToken } from "../../../common/utils/channel/request-from-channel-injection-token";
|
||||
import { requestFromChannelInjectionToken } from "@k8slens/messaging";
|
||||
import { casChannel } from "../common/channel";
|
||||
import { requestSystemCAsInjectionToken } from "../common/request-system-cas-token";
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
import type { ClusterId } from "../../../../common/cluster-types";
|
||||
import { getRequestChannel } from "../../../../common/utils/channel/get-request-channel";
|
||||
import { getRequestChannel } from "@k8slens/messaging";
|
||||
|
||||
export interface ActivateCluster {
|
||||
clusterId: ClusterId;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
import { getInjectionToken } from "@ogre-tools/injectable";
|
||||
import type { ChannelRequester } from "../../../../common/utils/channel/request-from-channel-injection-token";
|
||||
import type { ChannelRequester } from "@k8slens/messaging";
|
||||
import type { activateClusterChannel, deactivateClusterChannel } from "./channels";
|
||||
|
||||
export type RequestClusterActivation = ChannelRequester<typeof activateClusterChannel>;
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getRequestChannelListenerInjectable } from "../../../../main/utils/channel/channel-listeners/listener-tokens";
|
||||
import { getRequestChannelListenerInjectable } from "@k8slens/messaging";
|
||||
import { activateClusterChannel } from "../common/channels";
|
||||
import requestClusterActivationInjectable from "./request-activation.injectable";
|
||||
|
||||
const activateClusterRequestChannelListenerInjectable = getRequestChannelListenerInjectable({
|
||||
id: "activate-cluster-request-channel-listener",
|
||||
channel: activateClusterChannel,
|
||||
handler: (di) => di.inject(requestClusterActivationInjectable),
|
||||
getHandler: (di) => di.inject(requestClusterActivationInjectable),
|
||||
});
|
||||
|
||||
export default activateClusterRequestChannelListenerInjectable;
|
||||
+3
-2
@@ -2,13 +2,14 @@
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getRequestChannelListenerInjectable } from "../../../../main/utils/channel/channel-listeners/listener-tokens";
|
||||
import { getRequestChannelListenerInjectable } from "@k8slens/messaging";
|
||||
import { deactivateClusterChannel } from "../common/channels";
|
||||
import requestClusterDeactivationInjectable from "./request-deactivation.injectable";
|
||||
|
||||
const clusterDeactivationRequestChannelListenerInjectable = getRequestChannelListenerInjectable({
|
||||
id: "cluster-deactivation-request-channel-listener",
|
||||
channel: deactivateClusterChannel,
|
||||
handler: (di) => di.inject(requestClusterDeactivationInjectable),
|
||||
getHandler: (di) => di.inject(requestClusterDeactivationInjectable),
|
||||
});
|
||||
|
||||
export default clusterDeactivationRequestChannelListenerInjectable;
|
||||
+2
-2
@@ -3,14 +3,14 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import requestFromChannelInjectable from "../../../../renderer/utils/channel/request-from-channel.injectable";
|
||||
import { requestFromChannelInjectionToken } from "@k8slens/messaging";
|
||||
import { activateClusterChannel } from "../common/channels";
|
||||
import { requestClusterActivationInjectionToken } from "../common/request-token";
|
||||
|
||||
const requestClusterActivationInjectable = getInjectable({
|
||||
id: "request-cluster-activation",
|
||||
instantiate: (di) => {
|
||||
const requestFromChannel = di.inject(requestFromChannelInjectable);
|
||||
const requestFromChannel = di.inject(requestFromChannelInjectionToken);
|
||||
|
||||
return (req) => requestFromChannel(activateClusterChannel, req);
|
||||
},
|
||||
|
||||
+2
-2
@@ -3,14 +3,14 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import requestFromChannelInjectable from "../../../../renderer/utils/channel/request-from-channel.injectable";
|
||||
import { requestFromChannelInjectionToken } from "@k8slens/messaging";
|
||||
import { deactivateClusterChannel } from "../common/channels";
|
||||
import { requestClusterDeactivationInjectionToken } from "../common/request-token";
|
||||
|
||||
const requestClusterDeactivationInjectable = getInjectable({
|
||||
id: "request-cluster-deactivation",
|
||||
instantiate: (di) => {
|
||||
const requestFromChannel = di.inject(requestFromChannelInjectable);
|
||||
const requestFromChannel = di.inject(requestFromChannelInjectionToken);
|
||||
|
||||
return (clusterId) => requestFromChannel(deactivateClusterChannel, clusterId);
|
||||
},
|
||||
|
||||
+4
-6
@@ -3,10 +3,8 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import type { ClusterId } from "../../../../common/cluster-types";
|
||||
import type { RequestChannel } from "../../../../common/utils/channel/request-channel-listener-injection-token";
|
||||
import { getRequestChannel } from "@k8slens/messaging";
|
||||
|
||||
export type ClearClusterAsDeletingChannel = RequestChannel<ClusterId, void>;
|
||||
|
||||
export const clearClusterAsDeletingChannel: ClearClusterAsDeletingChannel = {
|
||||
id: "clear-cluster-as-deleting",
|
||||
};
|
||||
export const clearClusterAsDeletingChannel = getRequestChannel<ClusterId, void>(
|
||||
"clear-cluster-as-deleting",
|
||||
);
|
||||
@@ -3,10 +3,11 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import type { ClusterId } from "../../../../common/cluster-types";
|
||||
import type { RequestChannel } from "../../../../common/utils/channel/request-channel-listener-injection-token";
|
||||
import type { RequestChannel } from "@k8slens/messaging";
|
||||
import { getRequestChannel } from "@k8slens/messaging";
|
||||
|
||||
export type DeleteClusterChannel = RequestChannel<ClusterId, void>;
|
||||
|
||||
export const deleteClusterChannel: DeleteClusterChannel = {
|
||||
id: "delete-cluster",
|
||||
};
|
||||
export const deleteClusterChannel = getRequestChannel<ClusterId, void>(
|
||||
"delete-cluster",
|
||||
);
|
||||
@@ -3,10 +3,8 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import type { ClusterId } from "../../../../common/cluster-types";
|
||||
import type { RequestChannel } from "../../../../common/utils/channel/request-channel-listener-injection-token";
|
||||
import { getRequestChannel } from "@k8slens/messaging";
|
||||
|
||||
export type SetClusterAsDeletingChannel = RequestChannel<ClusterId, void>;
|
||||
|
||||
export const setClusterAsDeletingChannel: SetClusterAsDeletingChannel = {
|
||||
id: "set-cluster-as-deleting",
|
||||
};
|
||||
export const setClusterAsDeletingChannel = getRequestChannel<ClusterId, void>(
|
||||
"set-cluster-as-deleting",
|
||||
);
|
||||
+3
-2
@@ -3,12 +3,13 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import clustersThatAreBeingDeletedInjectable from "../../../../main/cluster/are-being-deleted.injectable";
|
||||
import { getRequestChannelListenerInjectable } from "../../../../main/utils/channel/channel-listeners/listener-tokens";
|
||||
import { getRequestChannelListenerInjectable } from "@k8slens/messaging";
|
||||
import { clearClusterAsDeletingChannel } from "../common/clear-as-deleting-channel";
|
||||
|
||||
const clearClusterAsDeletingChannelListenerInjectable = getRequestChannelListenerInjectable({
|
||||
id: "clear-cluster-as-deleting-channel-listener",
|
||||
channel: clearClusterAsDeletingChannel,
|
||||
handler: (di) => {
|
||||
getHandler: (di) => {
|
||||
const clustersThatAreBeingDeleted = di.inject(clustersThatAreBeingDeletedInjectable);
|
||||
|
||||
return (clusterId) => {
|
||||
|
||||
+3
-2
@@ -10,12 +10,13 @@ import removePathInjectable from "../../../../common/fs/remove.injectable";
|
||||
import joinPathsInjectable from "../../../../common/path/join-paths.injectable";
|
||||
import clusterConnectionInjectable from "../../../../main/cluster/cluster-connection.injectable";
|
||||
import { noop } from "@k8slens/utilities";
|
||||
import { getRequestChannelListenerInjectable } from "../../../../main/utils/channel/channel-listeners/listener-tokens";
|
||||
import { getRequestChannelListenerInjectable } from "@k8slens/messaging";
|
||||
import { deleteClusterChannel } from "../common/delete-channel";
|
||||
|
||||
const deleteClusterChannelListenerInjectable = getRequestChannelListenerInjectable({
|
||||
id: "delete-cluster-channel-listener",
|
||||
channel: deleteClusterChannel,
|
||||
handler: (di) => {
|
||||
getHandler: (di) => {
|
||||
const emitAppEvent = di.inject(emitAppEventInjectable);
|
||||
const clusterStore = di.inject(clusterStoreInjectable);
|
||||
const clusterFrames = di.inject(clusterFramesInjectable);
|
||||
|
||||
+3
-2
@@ -3,12 +3,13 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import clustersThatAreBeingDeletedInjectable from "../../../../main/cluster/are-being-deleted.injectable";
|
||||
import { getRequestChannelListenerInjectable } from "../../../../main/utils/channel/channel-listeners/listener-tokens";
|
||||
import { getRequestChannelListenerInjectable } from "@k8slens/messaging";
|
||||
import { setClusterAsDeletingChannel } from "../common/set-as-deleting-channel";
|
||||
|
||||
const setClusterAsDeletingChannelHandlerInjectable = getRequestChannelListenerInjectable({
|
||||
id: "set-cluster-as-deleting-channel-handler",
|
||||
channel: setClusterAsDeletingChannel,
|
||||
handler: (di) => {
|
||||
getHandler: (di) => {
|
||||
const clustersThatAreBeingDeleted = di.inject(clustersThatAreBeingDeletedInjectable);
|
||||
|
||||
return (clusterId) => {
|
||||
|
||||
+2
-2
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import type { ClusterId } from "../../../../common/cluster-types";
|
||||
import requestFromChannelInjectable from "../../../../renderer/utils/channel/request-from-channel.injectable";
|
||||
import { requestFromChannelInjectionToken } from "@k8slens/messaging";
|
||||
import { clearClusterAsDeletingChannel } from "../common/clear-as-deleting-channel";
|
||||
|
||||
export type RequestClearClusterAsDeleting = (clusterId: ClusterId) => Promise<void>;
|
||||
@@ -12,7 +12,7 @@ export type RequestClearClusterAsDeleting = (clusterId: ClusterId) => Promise<vo
|
||||
const requestClearClusterAsDeletingInjectable = getInjectable({
|
||||
id: "request-clear-cluster-as-deleting",
|
||||
instantiate: (di): RequestClearClusterAsDeleting => {
|
||||
const requestChannel = di.inject(requestFromChannelInjectable);
|
||||
const requestChannel = di.inject(requestFromChannelInjectionToken);
|
||||
|
||||
return (clusterId) => requestChannel(clearClusterAsDeletingChannel, clusterId);
|
||||
},
|
||||
|
||||
+2
-2
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import type { ClusterId } from "../../../../common/cluster-types";
|
||||
import requestFromChannelInjectable from "../../../../renderer/utils/channel/request-from-channel.injectable";
|
||||
import { requestFromChannelInjectionToken } from "@k8slens/messaging";
|
||||
import { deleteClusterChannel } from "../common/delete-channel";
|
||||
|
||||
export type RequestDeleteCluster = (clusterId: ClusterId) => Promise<void>;
|
||||
@@ -12,7 +12,7 @@ export type RequestDeleteCluster = (clusterId: ClusterId) => Promise<void>;
|
||||
const requestDeleteClusterInjectable = getInjectable({
|
||||
id: "request-delete-cluster",
|
||||
instantiate: (di): RequestDeleteCluster => {
|
||||
const requestChannel = di.inject(requestFromChannelInjectable);
|
||||
const requestChannel = di.inject(requestFromChannelInjectionToken);
|
||||
|
||||
return (clusterId) => requestChannel(deleteClusterChannel, clusterId);
|
||||
},
|
||||
|
||||
+2
-2
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import type { ClusterId } from "../../../../common/cluster-types";
|
||||
import requestFromChannelInjectable from "../../../../renderer/utils/channel/request-from-channel.injectable";
|
||||
import { requestFromChannelInjectionToken } from "@k8slens/messaging";
|
||||
import { setClusterAsDeletingChannel } from "../common/set-as-deleting-channel";
|
||||
|
||||
export type RequestSetClusterAsDeleting = (clusterId: ClusterId) => Promise<void>;
|
||||
@@ -12,7 +12,7 @@ export type RequestSetClusterAsDeleting = (clusterId: ClusterId) => Promise<void
|
||||
const requestSetClusterAsDeletingInjectable = getInjectable({
|
||||
id: "request-set-cluster-as-deleting",
|
||||
instantiate: (di): RequestSetClusterAsDeleting => {
|
||||
const requestChannel = di.inject(requestFromChannelInjectable);
|
||||
const requestChannel = di.inject(requestFromChannelInjectionToken);
|
||||
|
||||
return (clusterId) => requestChannel(setClusterAsDeletingChannel, clusterId);
|
||||
},
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
*/
|
||||
|
||||
import type { ClusterId, ClusterState } from "../../../../common/cluster-types";
|
||||
import type { MessageChannel } from "../../../../common/utils/channel/message-channel-listener-injection-token";
|
||||
import type { RequestChannel } from "../../../../common/utils/channel/request-channel-listener-injection-token";
|
||||
import type { MessageChannel, RequestChannel } from "@k8slens/messaging";
|
||||
|
||||
export interface ClusterStateSync {
|
||||
clusterId: ClusterId;
|
||||
|
||||
@@ -3,18 +3,16 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import type { MessageChannelHandler } from "../../../../common/utils/channel/message-channel-listener-injection-token";
|
||||
import { sendMessageToChannelInjectionToken } from "../../../../common/utils/channel/message-to-channel-injection-token";
|
||||
import { sendMessageToChannelInjectionToken } from "@k8slens/messaging";
|
||||
import type { ClusterStateSync } from "../common/channels";
|
||||
import { clusterStateSyncChannel } from "../common/channels";
|
||||
|
||||
export type EmitClusterStateUpdate = MessageChannelHandler<typeof clusterStateSyncChannel>;
|
||||
|
||||
const emitClusterStateUpdateInjectable = getInjectable({
|
||||
id: "emit-cluster-state-update",
|
||||
instantiate: (di): EmitClusterStateUpdate => {
|
||||
instantiate: (di) => {
|
||||
const sendMessageToChannel = di.inject(sendMessageToChannelInjectionToken);
|
||||
|
||||
return (message) => sendMessageToChannel(clusterStateSyncChannel, message);
|
||||
return (message: ClusterStateSync) => sendMessageToChannel(clusterStateSyncChannel, message);
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -3,12 +3,13 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import clusterStoreInjectable from "../../../../common/cluster-store/cluster-store.injectable";
|
||||
import { getRequestChannelListenerInjectable } from "../../../../main/utils/channel/channel-listeners/listener-tokens";
|
||||
import { getRequestChannelListenerInjectable } from "@k8slens/messaging";
|
||||
import { initialClusterStatesChannel } from "../common/channels";
|
||||
|
||||
const handleInitialClusterStateSyncInjectable = getRequestChannelListenerInjectable({
|
||||
id: "handle-initial-cluster-state-sync",
|
||||
channel: initialClusterStatesChannel,
|
||||
handler: (di) => {
|
||||
getHandler: (di) => {
|
||||
const clusterStore = di.inject(clusterStoreInjectable);
|
||||
|
||||
return () => clusterStore.clustersList.map(cluster => ({
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import getClusterByIdInjectable from "../../../../common/cluster-store/get-by-id.injectable";
|
||||
import { getMessageChannelListenerInjectable } from "../../../../common/utils/channel/message-channel-listener-injection-token";
|
||||
import { getMessageChannelListenerInjectable } from "@k8slens/messaging";
|
||||
import { clusterStateSyncChannel } from "../common/channels";
|
||||
|
||||
const clusterStateListenerInjectable = getMessageChannelListenerInjectable({
|
||||
channel: clusterStateSyncChannel,
|
||||
id: "main",
|
||||
handler: (di) => {
|
||||
getHandler: (di) => {
|
||||
const getClusterById = di.inject(getClusterByIdInjectable);
|
||||
|
||||
return ({ clusterId, state }) => getClusterById(clusterId)?.setState(state);
|
||||
|
||||
+3
-3
@@ -3,8 +3,8 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import type { RequestChannelHandler } from "../../../../main/utils/channel/channel-listeners/listener-tokens";
|
||||
import requestFromChannelInjectable from "../../../../renderer/utils/channel/request-from-channel.injectable";
|
||||
import type { RequestChannelHandler } from "@k8slens/messaging";
|
||||
import { requestFromChannelInjectionToken } from "@k8slens/messaging";
|
||||
import { initialClusterStatesChannel } from "../common/channels";
|
||||
|
||||
export type RequestInitialClusterStates = RequestChannelHandler<typeof initialClusterStatesChannel>;
|
||||
@@ -12,7 +12,7 @@ export type RequestInitialClusterStates = RequestChannelHandler<typeof initialCl
|
||||
const requestInitialClusterStatesInjectable = getInjectable({
|
||||
id: "request-initial-cluster-states",
|
||||
instantiate: (di): RequestInitialClusterStates => {
|
||||
const requestFromChannel = di.inject(requestFromChannelInjectable);
|
||||
const requestFromChannel = di.inject(requestFromChannelInjectionToken);
|
||||
|
||||
return () => requestFromChannel(initialClusterStatesChannel);
|
||||
},
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { MessageChannel } from "../../../../common/utils/channel/message-channel-listener-injection-token";
|
||||
import type { MessageChannel } from "@k8slens/messaging";
|
||||
|
||||
export interface NavigateForExtensionArgs {
|
||||
extId: string;
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getMessageChannelListenerInjectable } from "../../../../common/utils/channel/message-channel-listener-injection-token";
|
||||
import { getMessageChannelListenerInjectable } from "@k8slens/messaging";
|
||||
import extensionLoaderInjectable from "../../../../extensions/extension-loader/extension-loader.injectable";
|
||||
import type { LensRendererExtension } from "../../../../extensions/lens-renderer-extension";
|
||||
import { navigateForExtensionChannel } from "../common/channel";
|
||||
|
||||
const navigateForExtensionListenerInjectable = getMessageChannelListenerInjectable({
|
||||
channel: navigateForExtensionChannel,
|
||||
id: "main",
|
||||
handler: (di) => {
|
||||
id: "renderer",
|
||||
getHandler: (di) => {
|
||||
const extensionLoader = di.inject(extensionLoaderInjectable);
|
||||
|
||||
return ({ extId, pageId, params }) => {
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { asyncComputed } from "@ogre-tools/injectable-react";
|
||||
import { getActiveHelmRepositoriesChannel } from "../../../../../common/helm/get-active-helm-repositories-channel";
|
||||
import { requestFromChannelInjectionToken } from "../../../../../common/utils/channel/request-from-channel-injection-token";
|
||||
import { requestFromChannelInjectionToken } from "@k8slens/messaging";
|
||||
import showErrorNotificationInjectable from "../../../../../renderer/components/notifications/show-error-notification.injectable";
|
||||
import helmRepositoriesErrorStateInjectable from "./helm-repositories-error-state.injectable";
|
||||
import { runInAction } from "mobx";
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import type { HelmRepo } from "../../../../../../../common/helm/helm-repo";
|
||||
import { requestFromChannelInjectionToken } from "../../../../../../../common/utils/channel/request-from-channel-injection-token";
|
||||
import { requestFromChannelInjectionToken } from "@k8slens/messaging";
|
||||
import activeHelmRepositoriesInjectable from "../../active-helm-repositories.injectable";
|
||||
import showErrorNotificationInjectable from "../../../../../../../renderer/components/notifications/show-error-notification.injectable";
|
||||
import showSuccessNotificationInjectable from "../../../../../../../renderer/components/notifications/show-success-notification.injectable";
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import type { HelmRepo } from "../../../../../common/helm/helm-repo";
|
||||
import { requestFromChannelInjectionToken } from "../../../../../common/utils/channel/request-from-channel-injection-token";
|
||||
import { requestFromChannelInjectionToken } from "@k8slens/messaging";
|
||||
import activeHelmRepositoriesInjectable from "./active-helm-repositories.injectable";
|
||||
import { removeHelmRepositoryChannel } from "../../../../../common/helm/remove-helm-repository-channel";
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { MessageChannel } from "../../../../common/utils/channel/message-channel-listener-injection-token";
|
||||
import type { MessageChannel } from "@k8slens/messaging";
|
||||
|
||||
export type ReloadPageChannel = MessageChannel<void>;
|
||||
|
||||
|
||||
+1
@@ -8,6 +8,7 @@ import { reloadPageChannel } from "../common/channel";
|
||||
import reloadPageChannelListenerInjectable from "./register-listener.injectable";
|
||||
|
||||
export default getGlobalOverride(reloadPageChannelListenerInjectable, () => ({
|
||||
id: "reload-page-channel-listener",
|
||||
channel: reloadPageChannel,
|
||||
handler: () => {},
|
||||
}));
|
||||
+2
-2
@@ -2,13 +2,13 @@
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getMessageChannelListenerInjectable } from "../../../../common/utils/channel/message-channel-listener-injection-token";
|
||||
import { getMessageChannelListenerInjectable } from "@k8slens/messaging";
|
||||
import { reloadPageChannel } from "../common/channel";
|
||||
|
||||
const reloadPageChannelListenerInjectable = getMessageChannelListenerInjectable({
|
||||
id: "handler",
|
||||
channel: reloadPageChannel,
|
||||
handler: () => () => location.reload(),
|
||||
getHandler: () => () => location.reload(),
|
||||
causesSideEffects: true,
|
||||
});
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
import type { OpenDialogOptions } from "electron";
|
||||
import type { RequestChannel } from "../../../common/utils/channel/request-channel-listener-injection-token";
|
||||
import type { RequestChannel } from "@k8slens/messaging";
|
||||
|
||||
export type PathPickingResponse = {
|
||||
canceled: true;
|
||||
|
||||
@@ -4,12 +4,13 @@
|
||||
*/
|
||||
|
||||
import askUserForFilePathsInjectable from "../../../main/ipc/ask-user-for-file-paths.injectable";
|
||||
import { getRequestChannelListenerInjectable } from "../../../main/utils/channel/channel-listeners/listener-tokens";
|
||||
import { getRequestChannelListenerInjectable } from "@k8slens/messaging";
|
||||
import { openPathPickingDialogChannel } from "../common/channel";
|
||||
|
||||
const openPathPickingDialogListener = getRequestChannelListenerInjectable({
|
||||
id: "open-path-picking-dialog",
|
||||
channel: openPathPickingDialogChannel,
|
||||
handler: (di) => di.inject(askUserForFilePathsInjectable),
|
||||
getHandler: (di) => di.inject(askUserForFilePathsInjectable),
|
||||
});
|
||||
|
||||
export default openPathPickingDialogListener;
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import type { PathPickOpts } from "../../../renderer/components/path-picker";
|
||||
import requestFromChannelInjectable from "../../../renderer/utils/channel/request-from-channel.injectable";
|
||||
import { requestFromChannelInjectionToken } from "@k8slens/messaging";
|
||||
import { openPathPickingDialogChannel } from "../common/channel";
|
||||
|
||||
export type OpenPathPickingDialog = (options: PathPickOpts) => Promise<void>;
|
||||
@@ -12,7 +12,7 @@ export type OpenPathPickingDialog = (options: PathPickOpts) => Promise<void>;
|
||||
const openPathPickingDialogInjectable = getInjectable({
|
||||
id: "open-path-picking-dialog",
|
||||
instantiate: (di): OpenPathPickingDialog => {
|
||||
const requestFromChannel = di.inject(requestFromChannelInjectable);
|
||||
const requestFromChannel = di.inject(requestFromChannelInjectionToken);
|
||||
|
||||
return async (options) => {
|
||||
const { onPick, onCancel, ...dialogOptions } = options;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { MessageChannel } from "../../../common/utils/channel/message-channel-listener-injection-token";
|
||||
import type { MessageChannel } from "@k8slens/messaging";
|
||||
|
||||
export const shellSyncFailedChannel: MessageChannel<string> = {
|
||||
id: "shell-sync-failed-channel",
|
||||
|
||||
@@ -3,16 +3,15 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import type { MessageChannelSender } from "../../../common/utils/channel/message-to-channel-injection-token";
|
||||
import { sendMessageToChannelInjectionToken } from "../../../common/utils/channel/message-to-channel-injection-token";
|
||||
import { sendMessageToChannelInjectionToken } from "@k8slens/messaging";
|
||||
import { shellSyncFailedChannel } from "../common/failure-channel";
|
||||
|
||||
const emitShellSyncFailedInjectable = getInjectable({
|
||||
id: "emit-shell-sync-failed",
|
||||
instantiate: (di): MessageChannelSender<typeof shellSyncFailedChannel> => {
|
||||
instantiate: (di) => {
|
||||
const sendMessageToChannel = di.inject(sendMessageToChannelInjectionToken);
|
||||
|
||||
return (error) => sendMessageToChannel(shellSyncFailedChannel, error);
|
||||
return (error: string) => sendMessageToChannel(shellSyncFailedChannel, error);
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getMessageChannelListenerInjectable } from "../../../common/utils/channel/message-channel-listener-injection-token";
|
||||
import { getMessageChannelListenerInjectable } from "@k8slens/messaging";
|
||||
import showErrorNotificationInjectable from "../../../renderer/components/notifications/show-error-notification.injectable";
|
||||
import { shellSyncFailedChannel } from "../common/failure-channel";
|
||||
|
||||
const shellSyncFailureListenerInjectable = getMessageChannelListenerInjectable({
|
||||
id: "notification",
|
||||
channel: shellSyncFailedChannel,
|
||||
handler: (di) => {
|
||||
getHandler: (di) => {
|
||||
const showErrorNotification = di.inject(showErrorNotificationInjectable);
|
||||
|
||||
return (errorMessage) => showErrorNotification(`Failed to sync shell environment: ${errorMessage}`);
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { MessageChannel } from "../../../../common/utils/channel/message-channel-listener-injection-token";
|
||||
import type { RequestChannel } from "../../../../common/utils/channel/request-channel-listener-injection-token";
|
||||
import type { MessageChannel, RequestChannel } from "@k8slens/messaging";
|
||||
|
||||
export type SystemThemeType = "dark" | "light";
|
||||
|
||||
|
||||
@@ -3,18 +3,16 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import type { MessageChannelHandler } from "../../../../common/utils/channel/message-channel-listener-injection-token";
|
||||
import { sendMessageToChannelInjectionToken } from "../../../../common/utils/channel/message-to-channel-injection-token";
|
||||
import { sendMessageToChannelInjectionToken } from "@k8slens/messaging";
|
||||
import type { SystemThemeType } from "../common/channels";
|
||||
import { systemThemeTypeUpdateChannel } from "../common/channels";
|
||||
|
||||
export type EmitSystemThemeTypeUpdate = MessageChannelHandler<typeof systemThemeTypeUpdateChannel>;
|
||||
|
||||
const emitSystemThemeTypeUpdateInjectable = getInjectable({
|
||||
id: "emit-system-theme-type-update",
|
||||
instantiate: (di): EmitSystemThemeTypeUpdate => {
|
||||
instantiate: (di) => {
|
||||
const sendMessageToChannel = di.inject(sendMessageToChannelInjectionToken);
|
||||
|
||||
return (type) => sendMessageToChannel(systemThemeTypeUpdateChannel, type);
|
||||
return (type: SystemThemeType) => sendMessageToChannel(systemThemeTypeUpdateChannel, type);
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -4,12 +4,13 @@
|
||||
*/
|
||||
|
||||
import operatingSystemThemeInjectable from "../../../../main/theme/operating-system-theme.injectable";
|
||||
import { getRequestChannelListenerInjectable } from "../../../../main/utils/channel/channel-listeners/listener-tokens";
|
||||
import { getRequestChannelListenerInjectable } from "@k8slens/messaging";
|
||||
import { initialSystemThemeTypeChannel } from "../common/channels";
|
||||
|
||||
const initialSystemThemeTypeHandler = getRequestChannelListenerInjectable({
|
||||
id: "initial-system-theme-type-listener",
|
||||
channel: initialSystemThemeTypeChannel,
|
||||
handler: (di) => {
|
||||
getHandler: (di) => {
|
||||
const operatingSystemTheme = di.inject(operatingSystemThemeInjectable);
|
||||
|
||||
return () => operatingSystemTheme.get();
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import type { RequestChannelHandler } from "../../../../main/utils/channel/channel-listeners/listener-tokens";
|
||||
import requestFromChannelInjectable from "../../../../renderer/utils/channel/request-from-channel.injectable";
|
||||
import type { RequestChannelHandler } from "@k8slens/messaging";
|
||||
import { requestFromChannelInjectionToken } from "@k8slens/messaging";
|
||||
import { initialSystemThemeTypeChannel } from "../common/channels";
|
||||
|
||||
export type RequestInitialSystemThemeType = RequestChannelHandler<typeof initialSystemThemeTypeChannel>;
|
||||
@@ -12,7 +12,7 @@ export type RequestInitialSystemThemeType = RequestChannelHandler<typeof initial
|
||||
const requestInitialSystemThemeTypeInjectable = getInjectable({
|
||||
id: "request-initial-system-theme-type",
|
||||
instantiate: (di): RequestInitialSystemThemeType => {
|
||||
const requestFromChannel = di.inject(requestFromChannelInjectable);
|
||||
const requestFromChannel = di.inject(requestFromChannelInjectionToken);
|
||||
|
||||
return () => requestFromChannel(initialSystemThemeTypeChannel);
|
||||
},
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getMessageChannelListenerInjectable } from "../../../../common/utils/channel/message-channel-listener-injection-token";
|
||||
import { getMessageChannelListenerInjectable } from "@k8slens/messaging";
|
||||
import systemThemeConfigurationInjectable from "../../../../renderer/themes/system-theme.injectable";
|
||||
import { systemThemeTypeUpdateChannel } from "../common/channels";
|
||||
|
||||
const systemThemeTypeUpdateListenerInjectable = getMessageChannelListenerInjectable({
|
||||
channel: systemThemeTypeUpdateChannel,
|
||||
id: "main",
|
||||
handler: (di) => {
|
||||
getHandler: (di) => {
|
||||
const systemThemeConfiguration = di.inject(systemThemeConfigurationInjectable);
|
||||
|
||||
return (type) => systemThemeConfiguration.set(type);
|
||||
|
||||
Reference in new issue
Block a user