diff --git a/src/common/ask-boolean/ask-boolean-answer-channel.injectable.ts b/src/common/ask-boolean/ask-boolean-answer-channel.injectable.ts deleted file mode 100644 index 9901c04e30..0000000000 --- a/src/common/ask-boolean/ask-boolean-answer-channel.injectable.ts +++ /dev/null @@ -1,21 +0,0 @@ -/** - * 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 { MessageChannel } from "../utils/channel/message-channel-injection-token"; -import { messageChannelInjectionToken } from "../utils/channel/message-channel-injection-token"; - -export type AskBooleanAnswerChannel = MessageChannel<{ id: string; value: boolean }>; - -const askBooleanAnswerChannelInjectable = getInjectable({ - id: "ask-boolean-answer-channel", - - instantiate: (): AskBooleanAnswerChannel => ({ - id: "ask-boolean-answer", - }), - - injectionToken: messageChannelInjectionToken, -}); - -export default askBooleanAnswerChannelInjectable; diff --git a/src/common/ask-boolean/ask-boolean-question-channel.injectable.ts b/src/common/ask-boolean/ask-boolean-question-channel.injectable.ts deleted file mode 100644 index 664337158f..0000000000 --- a/src/common/ask-boolean/ask-boolean-question-channel.injectable.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * 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 { MessageChannel } from "../utils/channel/message-channel-injection-token"; -import { messageChannelInjectionToken } from "../utils/channel/message-channel-injection-token"; - -// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -export type AskBooleanQuestionParameters = { id: string; title: string; question: string }; -export type AskBooleanQuestionChannel = MessageChannel; - -const askBooleanQuestionChannelInjectable = getInjectable({ - id: "ask-boolean-question-channel", - - instantiate: (): AskBooleanQuestionChannel => ({ - id: "ask-boolean-question", - }), - - injectionToken: messageChannelInjectionToken, -}); - -export default askBooleanQuestionChannelInjectable; diff --git a/src/renderer/ask-boolean/ask-boolean-question-channel-listener.injectable.tsx b/src/renderer/ask-boolean/ask-boolean-question-channel-listener.injectable.tsx deleted file mode 100644 index 5e9adff4cc..0000000000 --- a/src/renderer/ask-boolean/ask-boolean-question-channel-listener.injectable.tsx +++ /dev/null @@ -1,107 +0,0 @@ -/** - * 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 { AskBooleanQuestionChannel } from "../../common/ask-boolean/ask-boolean-question-channel.injectable"; -import askBooleanQuestionChannelInjectable from "../../common/ask-boolean/ask-boolean-question-channel.injectable"; -import showInfoNotificationInjectable from "../components/notifications/show-info-notification.injectable"; -import { Button } from "../components/button"; -import React from "react"; -import { messageToChannelInjectionToken } from "../../common/utils/channel/message-to-channel-injection-token"; -import askBooleanAnswerChannelInjectable from "../../common/ask-boolean/ask-boolean-answer-channel.injectable"; -import notificationsStoreInjectable from "../components/notifications/notifications-store.injectable"; -import type { MessageChannelListener } from "../../common/utils/channel/message-channel-listener-injection-token"; -import { messageChannelListenerInjectionToken } from "../../common/utils/channel/message-channel-listener-injection-token"; - -const askBooleanQuestionChannelListenerInjectable = getInjectable({ - id: "ask-boolean-question-channel-listener", - - instantiate: (di): MessageChannelListener => { - const questionChannel = di.inject(askBooleanQuestionChannelInjectable); - const showInfoNotification = di.inject(showInfoNotificationInjectable); - const messageToChannel = di.inject(messageToChannelInjectionToken); - const answerChannel = di.inject(askBooleanAnswerChannelInjectable); - const notificationsStore = di.inject(notificationsStoreInjectable); - - const sendAnswerFor = (id: string) => (value: boolean) => { - messageToChannel(answerChannel, { id, value }); - }; - - const closeNotification = (notificationId: string) => { - notificationsStore.remove(notificationId); - }; - - const sendAnswerAndCloseNotificationFor = (sendAnswer: (value: boolean) => void, notificationId: string) => (value: boolean) => () => { - sendAnswer(value); - closeNotification(notificationId); - }; - - return { - channel: questionChannel, - - handler: ({ id: questionId, title, question }) => { - const notificationId = `ask-boolean-for-${questionId}`; - - const sendAnswer = sendAnswerFor(questionId); - const sendAnswerAndCloseNotification = sendAnswerAndCloseNotificationFor(sendAnswer, notificationId); - - showInfoNotification( - , - - { - id: notificationId, - timeout: 0, - onClose: () => sendAnswer(false), - }, - ); - }, - }; - }, - - injectionToken: messageChannelListenerInjectionToken, -}); - -export default askBooleanQuestionChannelListenerInjectable; - -const AskBoolean = ({ - id, - title, - message, - onNo, - onYes, -}: { - id: string; - title: string; - message: string; - onNo: () => void; - onYes: () => void; -}) => ( -
- {title} -

{message}

- -
-
-
-);