mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Give an UpdateButton injectables
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
acb119af94
commit
1fd3487f3f
@ -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<HTMLButtonElement> {
|
||||
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<Dependencies, UpdateButtonProps>(NonInjectedUpdateButton, {
|
||||
getProps: (di, props) => {
|
||||
const store = di.inject(appUpdateWarningInjectable);
|
||||
|
||||
return {
|
||||
...props,
|
||||
warningLevel: store.warningLevel,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user