From efc6c9c05ad6b39c2a514d928e55678fa0609ef1 Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Wed, 22 Jun 2022 12:58:09 -0400 Subject: [PATCH] Fix compile error Signed-off-by: Sebastian Malton --- .../components/+helm-charts/helm-chart-details.tsx | 2 +- .../components/notifications/notifications.store.tsx | 4 ---- src/renderer/components/notifications/notifications.tsx | 6 +++++- .../notifications/show-checked-error.injectable.ts | 9 +++++++-- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/renderer/components/+helm-charts/helm-chart-details.tsx b/src/renderer/components/+helm-charts/helm-chart-details.tsx index 6b5a6a2564..e33f2836ae 100644 --- a/src/renderer/components/+helm-charts/helm-chart-details.tsx +++ b/src/renderer/components/+helm-charts/helm-chart-details.tsx @@ -19,7 +19,7 @@ import { Badge } from "../badge"; import { Tooltip, withStyles } from "@material-ui/core"; import { withInjectables } from "@ogre-tools/injectable-react"; import createInstallChartTabInjectable from "../dock/install-chart/create-install-chart-tab.injectable"; -import type { ShowCheckedErrorNotification } from "../notifications"; +import type { ShowCheckedErrorNotification } from "../notifications/show-checked-error.injectable"; import type { SingleValue } from "react-select"; import AbortController from "abort-controller"; import showCheckedErrorNotificationInjectable from "../notifications/show-checked-error.injectable"; diff --git a/src/renderer/components/notifications/notifications.store.tsx b/src/renderer/components/notifications/notifications.store.tsx index 7720398a69..89061ef4ca 100644 --- a/src/renderer/components/notifications/notifications.store.tsx +++ b/src/renderer/components/notifications/notifications.store.tsx @@ -5,7 +5,6 @@ import type React from "react"; import { action, observable, makeObservable } from "mobx"; -import type { Disposer } from "../../utils"; import { autoBind } from "../../utils"; import uniqueId from "lodash/uniqueId"; import type { JsonApiErrorParsed } from "../../../common/k8s-api/json-api"; @@ -20,9 +19,6 @@ export enum NotificationStatus { INFO = "info", } -export type ShowNotification = (message: NotificationMessage, opts?: CreateNotificationOptions) => Disposer; -export type ShowCheckedErrorNotification = (message: unknown, fallback: string, opts?: CreateNotificationOptions) => Disposer; - export interface CreateNotificationOptions { id?: NotificationId; timeout?: number; diff --git a/src/renderer/components/notifications/notifications.tsx b/src/renderer/components/notifications/notifications.tsx index 4a6d73d7a5..aa26a94b18 100644 --- a/src/renderer/components/notifications/notifications.tsx +++ b/src/renderer/components/notifications/notifications.tsx @@ -9,19 +9,23 @@ import React from "react"; import { reaction } from "mobx"; import { disposeOnUnmount, observer } from "mobx-react"; import { JsonApiErrorParsed } from "../../../common/k8s-api/json-api"; +import type { Disposer } from "../../utils"; import { cssNames, prevDefault } from "../../utils"; -import type { Notification, NotificationsStore, ShowCheckedErrorNotification, ShowNotification } from "./notifications.store"; +import type { CreateNotificationOptions, Notification, NotificationMessage, NotificationsStore } from "./notifications.store"; import { Animate } from "../animate"; import { Icon } from "../icon"; import { withInjectables } from "@ogre-tools/injectable-react"; import notificationsStoreInjectable from "./notifications-store.injectable"; import { asLegacyGlobalFunctionForExtensionApi } from "../../../extensions/as-legacy-globals-for-extension-api/as-legacy-global-function-for-extension-api"; import showSuccessNotificationInjectable from "./show-success-notification.injectable"; +import type { ShowCheckedErrorNotification } from "./show-checked-error.injectable"; import showCheckedErrorNotificationInjectable from "./show-checked-error.injectable"; import showErrorNotificationInjectable from "./show-error-notification.injectable"; import showInfoNotificationInjectable from "./show-info-notification.injectable"; import showShortInfoNotificationInjectable from "./show-short-info.injectable"; +export type ShowNotification = (message: NotificationMessage, opts?: CreateNotificationOptions) => Disposer; + interface Dependencies { store: NotificationsStore; } diff --git a/src/renderer/components/notifications/show-checked-error.injectable.ts b/src/renderer/components/notifications/show-checked-error.injectable.ts index 27dbec3dc9..af8dab59e9 100644 --- a/src/renderer/components/notifications/show-checked-error.injectable.ts +++ b/src/renderer/components/notifications/show-checked-error.injectable.ts @@ -4,20 +4,25 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import { JsonApiErrorParsed } from "../../../common/k8s-api/json-api"; -import type { ShowCheckedErrorNotification } from "./notifications.store"; +import loggerInjectable from "../../../common/logger.injectable"; +import type { Disposer } from "../../utils"; +import type { CreateNotificationOptions } from "./notifications.store"; import showErrorNotificationInjectable from "./show-error-notification.injectable"; +export type ShowCheckedErrorNotification = (message: unknown, fallback: string, opts?: CreateNotificationOptions) => Disposer; + const showCheckedErrorNotificationInjectable = getInjectable({ id: "show-checked-error-notififcation", instantiate: (di): ShowCheckedErrorNotification => { const showErrorNotification = di.inject(showErrorNotificationInjectable); + const logger = di.inject(loggerInjectable); return (message, fallback, opts) => { if (typeof message === "string" || message instanceof Error || message instanceof JsonApiErrorParsed) { return showErrorNotification(message, opts); } - console.warn("Unknown notification error message, falling back to default", message); + logger.warn("[NOTIFICATIONS]: Unknown notification error message, falling back to default", message); return showErrorNotification(fallback, opts); };