-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make ClusterFrameManager fully injectable (#6590)
* Make ClusterFrameManager fully injectable Signed-off-by: Sebastian Malton <[email protected]> * Fix type errors Signed-off-by: Sebastian Malton <[email protected]> Signed-off-by: Sebastian Malton <[email protected]>
- Loading branch information
Showing
11 changed files
with
103 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* Copyright (c) OpenLens Authors. All rights reserved. | ||
* Licensed under MIT License. See LICENSE in root directory for more information. | ||
*/ | ||
|
||
import type { ClusterId } from "../cluster-types"; | ||
import type { MessageChannel } from "../utils/channel/message-channel-listener-injection-token"; | ||
|
||
export const clusterVisibilityChannel: MessageChannel<ClusterId | null> = { | ||
id: "cluster-visibility", | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* Copyright (c) OpenLens Authors. All rights reserved. | ||
* Licensed under MIT License. See LICENSE in root directory for more information. | ||
*/ | ||
import { clusterVisibilityChannel } from "../../common/cluster/visibility-channel"; | ||
import { getMessageChannelListenerInjectable } from "../../common/utils/channel/message-channel-listener-injection-token"; | ||
import visibleClusterInjectable from "./visible-cluster.injectable"; | ||
|
||
const clusterVisibilityHandlerInjectable = getMessageChannelListenerInjectable({ | ||
channel: clusterVisibilityChannel, | ||
id: "base", | ||
handler: (di) => { | ||
const visibleCluster = di.inject(visibleClusterInjectable); | ||
|
||
return (clusterId) => visibleCluster.set(clusterId); | ||
}, | ||
}); | ||
|
||
export default clusterVisibilityHandlerInjectable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* Copyright (c) OpenLens Authors. All rights reserved. | ||
* Licensed under MIT License. See LICENSE in root directory for more information. | ||
*/ | ||
import { getInjectable } from "@ogre-tools/injectable"; | ||
import { observable } from "mobx"; | ||
import type { ClusterId } from "../../common/cluster-types"; | ||
|
||
const visibleClusterInjectable = getInjectable({ | ||
id: "visible-cluster", | ||
instantiate: () => observable.box<ClusterId | null>(null), | ||
}); | ||
|
||
export default visibleClusterInjectable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/renderer/components/cluster-manager/emit-cluster-visibility.injectable.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* Copyright (c) OpenLens Authors. All rights reserved. | ||
* 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 { clusterVisibilityChannel } from "../../../common/cluster/visibility-channel"; | ||
|
||
export type EmitClusterVisibility = MessageChannelHandler<typeof clusterVisibilityChannel>; | ||
|
||
const emitClusterVisibilityInjectable = getInjectable({ | ||
id: "emit-cluster-visibility", | ||
instantiate: (di): EmitClusterVisibility => { | ||
const sendMessageToChannel = di.inject(sendMessageToChannelInjectionToken); | ||
|
||
return (id) => sendMessageToChannel(clusterVisibilityChannel, id); | ||
}, | ||
}); | ||
|
||
export default emitClusterVisibilityInjectable; |