mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Make UpdateButton warning prop observable
by using computed() structure Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
4e9d81dbea
commit
cd2d2f97e4
@ -13,13 +13,14 @@ import type { IconProps } from "../icon";
|
|||||||
import { Icon } from "../icon";
|
import { Icon } from "../icon";
|
||||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
import updateWarningLevelInjectable from "../../../main/application-update/update-warning-level/update-warning-level.injectable";
|
import updateWarningLevelInjectable from "../../../common/application-update/update-warning-level.injectable";
|
||||||
|
import { computed, IComputedValue } from "mobx";
|
||||||
|
|
||||||
interface UpdateButtonProps extends HTMLAttributes<HTMLButtonElement> {
|
interface UpdateButtonProps extends HTMLAttributes<HTMLButtonElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Dependencies {
|
interface Dependencies {
|
||||||
warningLevel: "light" | "medium" | "high" | "";
|
warningLevel: IComputedValue<"light" | "medium" | "high" | "">;
|
||||||
update: () => void;
|
update: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,7 +33,7 @@ export const NonInjectedUpdateButton = observer(({ warningLevel, update, id }: U
|
|||||||
setOpened(!opened);
|
setOpened(!opened);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!warningLevel) {
|
if (!warningLevel.get()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,11 +41,11 @@ export const NonInjectedUpdateButton = observer(({ warningLevel, update, id }: U
|
|||||||
<>
|
<>
|
||||||
<button
|
<button
|
||||||
data-testid="update-button"
|
data-testid="update-button"
|
||||||
data-warning-level={warningLevel}
|
data-warning-level={warningLevel.get()}
|
||||||
id={buttonId}
|
id={buttonId}
|
||||||
className={cssNames(styles.updateButton, {
|
className={cssNames(styles.updateButton, {
|
||||||
[styles.warningHigh]: warningLevel === "high",
|
[styles.warningHigh]: warningLevel.get() === "high",
|
||||||
[styles.warningMedium]: warningLevel === "medium",
|
[styles.warningMedium]: warningLevel.get() === "medium",
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
Update
|
Update
|
||||||
@ -78,7 +79,7 @@ export const UpdateButton = withInjectables<Dependencies, UpdateButtonProps>(Non
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
...props,
|
...props,
|
||||||
warningLevel: warnignLevel.value.get(),
|
warningLevel: computed(() => warnignLevel.value.get()),
|
||||||
update,
|
update,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user