From 1fd3487f3f609735af0989b6290be4d26a8fe8c6 Mon Sep 17 00:00:00 2001 From: Alex Andreev Date: Tue, 24 May 2022 15:16:25 +0300 Subject: [PATCH] Give an UpdateButton injectables Signed-off-by: Alex Andreev --- .../update-button/update-button.tsx | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/renderer/components/update-button/update-button.tsx b/src/renderer/components/update-button/update-button.tsx index 6da453de3d..723c75aef7 100644 --- a/src/renderer/components/update-button/update-button.tsx +++ b/src/renderer/components/update-button/update-button.tsx @@ -11,13 +11,18 @@ import { Menu, MenuItem } from "../menu"; import { cssNames } from "../../utils"; import type { IconProps } from "../icon"; import { Icon } from "../icon"; +import { withInjectables } from "@ogre-tools/injectable-react"; +import appUpdateWarningInjectable from "../../app-freshness/app-update-warning.injectable"; interface UpdateButtonProps extends HTMLAttributes { - warningLevel?: "light" | "medium" | "high"; update: () => void; } -export function UpdateButton({ warningLevel, update, id }: UpdateButtonProps) { +interface Dependencies { + warningLevel?: "light" | "medium" | "high" | ""; +} + +export function NonInjectedUpdateButton({ warningLevel, update, id }: UpdateButtonProps & Dependencies) { const buttonId = id ?? "update-lens-button"; const menuIconProps: IconProps = { material: "update", small: true }; const [opened, setOpened] = useState(false); @@ -62,3 +67,14 @@ export function UpdateButton({ warningLevel, update, id }: UpdateButtonProps) { ); } + +export const UpdateButton = withInjectables(NonInjectedUpdateButton, { + getProps: (di, props) => { + const store = di.inject(appUpdateWarningInjectable); + + return { + ...props, + warningLevel: store.warningLevel, + }; + }, +});