mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Respect id prop
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
db91458a52
commit
74e844ac56
@ -5,21 +5,21 @@
|
|||||||
|
|
||||||
import styles from "./styles.module.scss";
|
import styles from "./styles.module.scss";
|
||||||
|
|
||||||
|
import type { HTMLAttributes} from "react";
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import { Menu, MenuItem } from "../menu";
|
import { Menu, MenuItem } from "../menu";
|
||||||
import uniqueId from "lodash/uniqueId";
|
|
||||||
import { noop } from "lodash";
|
import { noop } from "lodash";
|
||||||
import { cssNames } from "../../utils";
|
import { cssNames } from "../../utils";
|
||||||
import type { IconProps } from "../icon";
|
import type { IconProps } from "../icon";
|
||||||
import { Icon } from "../icon";
|
import { Icon } from "../icon";
|
||||||
|
|
||||||
interface UpdateButtonProps {
|
interface UpdateButtonProps extends HTMLAttributes<HTMLButtonElement> {
|
||||||
warningLevel?: "light" | "medium" | "high";
|
warningLevel?: "light" | "medium" | "high";
|
||||||
update: () => void;
|
update: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function UpdateButton({ warningLevel, update }: UpdateButtonProps) {
|
export function UpdateButton({ warningLevel, update, id }: UpdateButtonProps) {
|
||||||
const id = uniqueId("update_button_");
|
const buttonId = id ?? "update-lens-button";
|
||||||
const menuIconProps: IconProps = { material: "update", small: true };
|
const menuIconProps: IconProps = { material: "update", small: true };
|
||||||
const [opened, setOpened] = useState(false);
|
const [opened, setOpened] = useState(false);
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ export function UpdateButton({ warningLevel, update }: UpdateButtonProps) {
|
|||||||
<>
|
<>
|
||||||
<button
|
<button
|
||||||
data-testid="update-button"
|
data-testid="update-button"
|
||||||
id="update-lens-button"
|
id={buttonId}
|
||||||
className={cssNames(styles.updateButton, {
|
className={cssNames(styles.updateButton, {
|
||||||
[styles.warningHigh]: warningLevel === "high",
|
[styles.warningHigh]: warningLevel === "high",
|
||||||
[styles.warningMedium]: warningLevel === "medium",
|
[styles.warningMedium]: warningLevel === "medium",
|
||||||
@ -55,7 +55,7 @@ export function UpdateButton({ warningLevel, update }: UpdateButtonProps) {
|
|||||||
</button>
|
</button>
|
||||||
<Menu
|
<Menu
|
||||||
usePortal
|
usePortal
|
||||||
htmlFor="update-lens-button"
|
htmlFor={buttonId}
|
||||||
isOpen={opened}
|
isOpen={opened}
|
||||||
close={toggle}
|
close={toggle}
|
||||||
open={noop}
|
open={noop}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user