Canvas: Add edit option to context menu for elements with an edit mode (#55697)

pull/55708/head
Nathan Marrs 3 years ago committed by GitHub
parent f8bde4df09
commit 15de96286a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 19
      public/app/plugins/panel/canvas/CanvasContextMenu.tsx

@ -77,9 +77,28 @@ export const CanvasContextMenu = ({ scene }: Props) => {
/>
);
const editElementMenuItem = () => {
if (selectedElements?.length === 1) {
const onClickEditElementMenuItem = () => {
scene.editModeEnabled.next(true);
closeContextMenu();
};
const element = scene.findElementByTarget(selectedElements[0]);
return (
element &&
element.item.hasEditMode && (
<MenuItem label="Edit" onClick={onClickEditElementMenuItem} className={styles.menuItem} />
)
);
}
return null;
};
if (selectedElements && selectedElements.length >= 1) {
return (
<>
{editElementMenuItem()}
<MenuItem
label="Delete"
onClick={() => {

Loading…
Cancel
Save