diff --git a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/ActivityFeed.spec.ts b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/ActivityFeed.spec.ts index 21fcd6282fb..ecbc948cf4a 100644 --- a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/ActivityFeed.spec.ts +++ b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/ActivityFeed.spec.ts @@ -186,7 +186,7 @@ test.describe('Activity feed', () => { test('Update Description Task on Columns', async ({ page }) => { const firstTaskValue: TaskDetails = { term: entity.entity.name, - assignee: `${user.data.firstName}.${user.data.lastName}`, + assignee: user.responseData.name, description: 'Column Description 1', columnName: entity.entity.columns[0].name, oldDescription: entity.entity.columns[0].description, diff --git a/openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/BlockMenu/BlockMenu.tsx b/openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/BlockMenu/BlockMenu.tsx index 1e47efcd91b..9f595fa62dc 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/BlockMenu/BlockMenu.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/BlockMenu/BlockMenu.tsx @@ -33,7 +33,7 @@ interface BlockMenuProps { export const BlockMenu = (props: BlockMenuProps) => { const { t } = useTranslation(); const { editor } = props; - const { view } = editor; + const { view, isEditable } = editor; const menuRef = useRef(null); const popup = useRef(null); @@ -127,7 +127,10 @@ export const BlockMenu = (props: BlockMenuProps) => { }, [editor]); useEffect(() => { - if (menuRef.current) { + /** + * Create a new tippy instance for the block menu if the editor is editable + */ + if (menuRef.current && isEditable) { menuRef.current.remove(); menuRef.current.style.visibility = 'visible'; @@ -150,7 +153,7 @@ export const BlockMenu = (props: BlockMenuProps) => { popup.current?.destroy(); popup.current = null; }; - }, []); + }, [isEditable]); useEffect(() => { document.addEventListener('click', handleClickDragHandle); diff --git a/openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/BubbleMenu/BubbleMenu.tsx b/openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/BubbleMenu/BubbleMenu.tsx index aab0809f3a6..c728ddb7ecd 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/BubbleMenu/BubbleMenu.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/BubbleMenu/BubbleMenu.tsx @@ -111,12 +111,14 @@ const BubbleMenu: FC = ({ editor, toggleLink }) => { // - the selection is empty // - the selection is a node selection (for drag handles) // - link is active + // - editor is not editable if ( editor.isActive('image') || empty || isNodeSelection(selection) || editor.isActive('link') || - editor.isActive('table') + editor.isActive('table') || + !editor.isEditable ) { return false; } diff --git a/openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/EditorSlots.tsx b/openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/EditorSlots.tsx index 7ecc0f78c1d..e3f56d35d12 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/EditorSlots.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/EditorSlots.tsx @@ -78,6 +78,11 @@ const EditorSlots = forwardRef( const handleLinkPopup = ( e: React.MouseEvent ) => { + // if editor is not editable, do not show the link popup + if (!editor?.isEditable) { + return; + } + let popup: Instance[] = []; let component: ReactRenderer; const target = e.target as HTMLElement; diff --git a/openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/Extensions/Callout/CalloutComponent.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/Extensions/Callout/CalloutComponent.test.tsx index a5a63bc77dd..06bb3f8b2fd 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/Extensions/Callout/CalloutComponent.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/Extensions/Callout/CalloutComponent.test.tsx @@ -32,6 +32,9 @@ const mockNodeViewProps = { node: mockNode, extension: mockExtension, updateAttributes: mockUpdateAttributes, + editor: { + isEditable: true, + }, } as unknown as NodeViewProps; describe('CalloutComponent', () => { @@ -70,4 +73,29 @@ describe('CalloutComponent', () => { expect(screen.getByTestId('callout-note')).toBeInTheDocument(); expect(screen.getByTestId('callout-danger')).toBeInTheDocument(); }); + + it('should not render the popover when callout button is clicked and editor is not editable', async () => { + const nodeViewProps = { + node: mockNode, + extension: mockExtension, + updateAttributes: mockUpdateAttributes, + editor: { + isEditable: false, + }, + } as unknown as NodeViewProps; + + await act(async () => { + render(); + }); + + const calloutButton = screen.getByTestId('callout-info-btn'); + + await act(async () => { + userEvent.click(calloutButton); + }); + + const popover = screen.queryByRole('tooltip'); + + expect(popover).not.toBeInTheDocument(); + }); }); diff --git a/openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/Extensions/Callout/CalloutComponent.tsx b/openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/Extensions/Callout/CalloutComponent.tsx index 71a463a46e4..4f20840c4b7 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/Extensions/Callout/CalloutComponent.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/Extensions/Callout/CalloutComponent.tsx @@ -45,12 +45,18 @@ const CalloutComponent: FC = ({ node, extension, updateAttributes, + editor, }) => { const { calloutType } = node.attrs; const [isPopupVisible, setIsPopupVisible] = useState(false); const CallOutIcon = CALLOUT_CONTENT[calloutType as keyof typeof CALLOUT_CONTENT]; + const handlePopoverVisibleChange = (visible: boolean) => { + // Only show the popover when the editor is in editable mode + setIsPopupVisible(visible && editor.isEditable); + }; + return (
= ({ placement="bottomRight" showArrow={false} trigger="click" - onOpenChange={setIsPopupVisible}> + onOpenChange={handlePopoverVisibleChange}>