diff --git a/docs/decisions/2026-11-13-react-aria-controlled-props-are-cleared-with-null-not-undefined.md b/docs/decisions/2026-11-13-react-aria-controlled-props-are-cleared-with-null-not-undefined.md index b4f44dc57b4e..784dc572eaee 100644 --- a/docs/decisions/2026-11-13-react-aria-controlled-props-are-cleared-with-null-not-undefined.md +++ b/docs/decisions/2026-11-13-react-aria-controlled-props-are-cleared-with-null-not-undefined.md @@ -1,7 +1,7 @@ # React Aria controlled props are cleared with null, not undefined - **Status:** Accepted -- **Revisions:** v1 2026-11-13 (initial) +- **Revisions:** v1 2026-11-13 (initial) · v2 2026-11-17 (example component removed) - **Deciders:** Chirag Madlani - **Guard:** ESLint `openmetadata-ui-patterns/no-undefined-controlled-prop` (error) - **Related:** #37771, #37772 @@ -25,6 +25,10 @@ passes nothing, from its first render to its last. ## Consequences The lint rule catches a literal `undefined` fallback in a JSX prop. It cannot see a variable whose type merely includes `undefined` (`useState()` passed straight through); review those, and prefer -initialising such state to `null`. A component that deliberately flips — `CopyToClipboardButton` -forcing its tooltip open after a copy while leaving hover to React Aria — disables the rule on that -line with the reason beside it. +initialising such state to `null`. A component that deliberately flips — a tooltip forced open +after an action while hover is left to React Aria — disables the rule on that line with the reason +beside it. + +## Amendment +v2 2026-11-17: the original example, `CopyToClipboardButton`, was removed by +ADR:2026-11-17-copy-actions-use-the-shared-copy-button; the rule and its exception are unchanged. diff --git a/docs/decisions/2026-11-17-copy-actions-use-the-shared-copy-button.md b/docs/decisions/2026-11-17-copy-actions-use-the-shared-copy-button.md new file mode 100644 index 000000000000..5647b16b4508 --- /dev/null +++ b/docs/decisions/2026-11-17-copy-actions-use-the-shared-copy-button.md @@ -0,0 +1,34 @@ +# Copy-to-clipboard actions use the shared CopyButton + +- **Status:** Accepted +- **Revisions:** v1 2026-11-17 (initial) +- **Deciders:** Rohit Jain +- **Guard:** `CopyButton.test.tsx` (success state, accessible name, click does not reach a parent + row, labeled variant); reviewer for new call sites +- **Related:** open-metadata/OpenMetadata#37953 + +## Context +The UI had three copy components (`CopyLinkButton` in Context Center, `common/CopyLinkButton` for +field links, `common/CopyToClipboardButton`) and about thirty hand-rolled `ButtonUtility icon={Copy01}` ++ `useClipboard` blocks. Each gave different feedback — a toast, a tooltip swap, an icon swap, or +nothing — and some copy buttons inside clickable rows also triggered the row. + +## Decision +- Every copy-to-clipboard action renders `components/common/CopyButton/CopyButton`: icon-only by + default, or a text button with `label`. Duplicate/clone actions that merely reuse the `Copy01` + glyph, and dropdown menu items, are not copy buttons and stay as they are. +- Success is shown by the button itself: icon-only turns into a green circle with a check and a ring + pulse, and its tooltip reads "Copied"; the labeled variant turns green and its text reads "Copied". + A copy action does not also raise a success toast. +- The copied state resets after 1200 ms — long enough to read the check, short enough to copy again. +- `CopyButton` stops propagation and prevents default on click, so copying inside a clickable row, + card or form never activates it. +- Callers pass layout classes only; the copied colours are applied after the caller's `className` + so they always win. + +## Consequences +Copy feedback looks and behaves the same everywhere, and a new copy action is one element. A failed +copy (clipboard API and `execCommand` both refused) leaves the button idle without a message; add an +error path to `useClipboard` if that turns out to matter. Revisit if a surface needs a copy action +whose feedback must outlive the 1200 ms state (for example a one-time secret that must be +acknowledged). diff --git a/openmetadata-ui/src/main/resources/ui/src/components/APIEndpoint/APIEndpointSchema/APIEndpointSchema.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/APIEndpoint/APIEndpointSchema/APIEndpointSchema.test.tsx index 9fa84048166b..da4c1a2053c9 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/APIEndpoint/APIEndpointSchema/APIEndpointSchema.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/APIEndpoint/APIEndpointSchema/APIEndpointSchema.test.tsx @@ -100,7 +100,7 @@ jest.mock('../../Database/TableTags/TableTags.component', () => )) ); -jest.mock('../../common/CopyLinkButton/CopyLinkButton', () => +jest.mock('../../common/CopyButton/CopyButton', () => jest.fn(() =>
) ); jest.mock('../../common/ToggleExpandButton/ToggleExpandButton', () => diff --git a/openmetadata-ui/src/main/resources/ui/src/components/APIEndpoint/APIEndpointSchema/APIEndpointSchema.tsx b/openmetadata-ui/src/main/resources/ui/src/components/APIEndpoint/APIEndpointSchema/APIEndpointSchema.tsx index 2e1076c3c477..2191d6bbe949 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/APIEndpoint/APIEndpointSchema/APIEndpointSchema.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/APIEndpoint/APIEndpointSchema/APIEndpointSchema.tsx @@ -64,6 +64,7 @@ import { useTreeTagFilter } from '../../../hooks/useTreeTagFilter'; import { getEntityName } from '../../../utils/EntityNameUtils'; import { getColumnSorter } from '../../../utils/EntitySortUtils'; import { getDerivedPermissionFlags } from '../../../utils/PermissionDerivation'; +import { getEntityDetailsUrl } from '../../../utils/RouterUtils'; import { getVersionedSchema } from '../../../utils/SchemaVersionUtils'; import { columnFilterIcon } from '../../../utils/TableColumn.util'; import { @@ -76,7 +77,7 @@ import { import { getAllTags } from '../../../utils/TableTags/TableTags.utils'; import { getTableExpandableConfig } from '../../../utils/TableUtils'; import withSuspenseFallback from '../../AppRouter/withSuspenseFallback'; -import CopyLinkButton from '../../common/CopyLinkButton/CopyLinkButton'; +import CopyButton from '../../common/CopyButton/CopyButton'; import { EntityAttachmentProvider } from '../../common/EntityDescription/EntityAttachmentProvider/EntityAttachmentProvider'; import RichTextEditorPreviewerV1 from '../../common/RichTextEditor/RichTextEditorPreviewerV1'; import Table from '../../common/Table/TableV2'; @@ -321,9 +322,15 @@ const APIEndpointSchema: FC = ({ {!isVersionView && record.fullyQualifiedName && ( - )}
diff --git a/openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/Extensions/CodeBlock/CodeBlockComponent.tsx b/openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/Extensions/CodeBlock/CodeBlockComponent.tsx index c96955bc7445..6a62564355e5 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/Extensions/CodeBlock/CodeBlockComponent.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/Extensions/CodeBlock/CodeBlockComponent.tsx @@ -10,39 +10,23 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { ButtonUtility, Tooltip } from '@openmetadata/ui-core-components'; -import { Copy01 } from '@openmetadata/ui-core-components/icons'; import { NodeViewContent, NodeViewProps, NodeViewWrapper } from '@tiptap/react'; -import { FC, useCallback, useState } from 'react'; +import { FC } from 'react'; import { useTranslation } from 'react-i18next'; -import { useClipboard } from '../../../../hooks/useClipBoard'; +import CopyButton from '../../../common/CopyButton/CopyButton'; const CodeBlockComponent: FC = ({ node }) => { const { t } = useTranslation(); - const { onCopyToClipBoard, hasCopied } = useClipboard('', 2000); - const [isTooltipOpen, setIsTooltipOpen] = useState(false); - - const handleCopy = useCallback(async () => { - await onCopyToClipBoard(node.textContent); - }, [node, onCopyToClipBoard]); return ( - + as="code" /> - - - - - + ); }; diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Container/ContainerDataModel/ContainerDataModel.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Container/ContainerDataModel/ContainerDataModel.test.tsx index 3843830e0a1c..d4422528d8e1 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Container/ContainerDataModel/ContainerDataModel.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Container/ContainerDataModel/ContainerDataModel.test.tsx @@ -177,6 +177,11 @@ jest.mock('../../../utils/RouterUtils', () => ({ getEntityDetailsPath: jest .fn() .mockImplementation((_entityType, fqn) => `/container/${fqn}`), + getEntityDetailsUrl: jest + .fn() + .mockImplementation( + (_entityType, fqn) => `http://localhost/container/${fqn}` + ), })); jest.mock( diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Container/ContainerDataModel/ContainerDataModel.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Container/ContainerDataModel/ContainerDataModel.tsx index 96e0d82e7a82..654217aa9cef 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Container/ContainerDataModel/ContainerDataModel.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Container/ContainerDataModel/ContainerDataModel.tsx @@ -47,6 +47,7 @@ import { updateContainerColumnTags, } from '../../../utils/ContainerDetailPureUtils'; import { getEntityName } from '../../../utils/EntityNameUtils'; +import { getEntityDetailsUrl } from '../../../utils/RouterUtils'; import { columnFilterIcon } from '../../../utils/TableColumn.util'; import { getHighlightedRowClassName, @@ -55,7 +56,7 @@ import { import { getAllTags } from '../../../utils/TableTags/TableTags.utils'; import { getTableExpandableConfig } from '../../../utils/TableUtils'; import withSuspenseFallback from '../../AppRouter/withSuspenseFallback'; -import CopyLinkButton from '../../common/CopyLinkButton/CopyLinkButton'; +import CopyButton from '../../common/CopyButton/CopyButton'; import NoDataPlaceholder from '../../common/EmptyPlaceholder/NoDataPlaceholder'; import { EntityAttachmentProvider } from '../../common/EntityDescription/EntityAttachmentProvider/EntityAttachmentProvider'; import { ColumnsType } from '../../common/Table/Table.interface'; @@ -207,10 +208,15 @@ const ContainerDataModel: FC = ({ {record.fullyQualifiedName && ( - )} diff --git a/openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/ArticleDetailHeader/ArticleDetailHeader.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/ArticleDetailHeader/ArticleDetailHeader.component.tsx index 35713f505739..de33f7e1e551 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/ArticleDetailHeader/ArticleDetailHeader.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/ArticleDetailHeader/ArticleDetailHeader.component.tsx @@ -29,7 +29,6 @@ import { } from '@openmetadata/ui-core-components'; import { Conversation, - Copy01, DotsVertical, Edit01, ExpandPanel, @@ -81,11 +80,11 @@ import { getKnowledgePageName } from '../../../utils/KnowledgePagePureUtils'; import { updateKnowledgeCenterRecentViewed } from '../../../utils/KnowledgePageUtils'; import { getDerivedPermissionFlags } from '../../../utils/PermissionDerivation'; import { showErrorToast } from '../../../utils/ToastUtils'; +import CopyButton from '../../common/CopyButton/CopyButton'; import DomainSelectableList from '../../common/DomainSelectableList/DomainSelectableList.component'; import HeaderBreadcrumb from '../../common/HeaderBreadcrumb/HeaderBreadcrumb.component'; import { HeaderVersionButton } from '../../common/HeaderVersionButton/HeaderVersionButton.component'; import { UserTeamSelectableList } from '../../common/UserTeamSelectableList/UserTeamSelectableList.component'; -import CopyLinkButton from '../../CopyLinkButton/CopyLinkButton.component'; import { ArticleDetailHeaderProps } from './ArticleDetailHeader.interface'; const TOOLTIP_TRIGGER_CLASS = 'tw:leading-0'; @@ -547,9 +546,7 @@ const ArticleDetailHeader: FC = ({ tooltip={isFollowing ? t('label.un-follow') : t('label.follow')} onClick={handleFollowClick} /> - - - + {permissions?.Delete && ( diff --git a/openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/DocumentsView/DocumentPreviewPanel.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/DocumentsView/DocumentPreviewPanel.component.tsx index 214ff5bc3061..3939f67281bb 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/DocumentsView/DocumentPreviewPanel.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/DocumentsView/DocumentPreviewPanel.component.tsx @@ -18,7 +18,7 @@ import { FileIcon, Typography, } from '@openmetadata/ui-core-components'; -import { Copy01, XClose } from '@openmetadata/ui-core-components/icons'; +import { XClose } from '@openmetadata/ui-core-components/icons'; import { FC, useMemo } from 'react'; import { useTranslation } from 'react-i18next'; import { CONTEXT_FILE_ENTITY_TYPE } from '../../../constants/ContextCenter.constants'; @@ -31,7 +31,7 @@ import { formatBytes } from '../../../utils/ContextCenterPureUtils'; import { getShortRelativeTime } from '../../../utils/date-time/DateTimeUtils'; import { getFileExtractionAction } from '../../../utils/discovery/context-center/memoryExtraction.utils'; import { getEntityName } from '../../../utils/EntityNameUtils'; -import CopyLinkButton from '../../CopyLinkButton/CopyLinkButton.component'; +import CopyButton from '../../common/CopyButton/CopyButton'; import MemoryExtractionButton from '../../discovery/context-center/MemoryExtractionButton/MemoryExtractionButton'; import DocumentStatusBadge from '../DocumentStatusBadge/DocumentStatusBadge.component'; import ExtractedMemoriesCard from '../ExtractedMemoriesCard/ExtractedMemoriesCard.component'; @@ -100,9 +100,7 @@ const DocumentPreviewPanel: FC = ({ - - + ({ ), })); -jest.mock('../../CopyLinkButton/CopyLinkButton.component', () => - jest.fn(({ url }: { url: string }) => ( - )) diff --git a/openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/DocumentsView/DocumentsView.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/DocumentsView/DocumentsView.component.tsx index c98ca4e140f6..e3bc39e694ce 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/DocumentsView/DocumentsView.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/DocumentsView/DocumentsView.component.tsx @@ -26,7 +26,6 @@ import { import { Check, ChevronRight, - Copy01, Documents, DotsVertical, Download01, @@ -63,13 +62,13 @@ import { getShortRelativeTime } from '../../../utils/date-time/DateTimeUtils'; import { getFileExtractionAction } from '../../../utils/discovery/context-center/memoryExtraction.utils'; import { getEntityName } from '../../../utils/EntityNameUtils'; import { showErrorToast, showSuccessToast } from '../../../utils/ToastUtils'; +import CopyButton from '../../common/CopyButton/CopyButton'; import NoDataPlaceholder from '../../common/EmptyPlaceholder/NoDataPlaceholder'; import NoSearchResultsPlaceholder from '../../common/EmptyPlaceholder/NoSearchResultsPlaceholder'; import { PreviewRendererId } from '../../common/FilePreviewer/FilePreviewer.types'; import { resolveRenderer } from '../../common/FilePreviewer/FilePreviewer.utils'; import UserPopOverCard from '../../common/PopOverCard/UserPopOverCard'; import { UserSelectableList } from '../../common/UserSelectableList/UserSelectableList.component'; -import CopyLinkButton from '../../CopyLinkButton/CopyLinkButton.component'; import MemoryExtractionMenuItem from '../../discovery/context-center/MemoryExtractionMenuItem/MemoryExtractionMenuItem'; import DocumentStatusBadge from '../DocumentStatusBadge/DocumentStatusBadge.component'; import { @@ -795,9 +794,7 @@ const FileRow: FC = ({ tooltip={t('label.download')} onClick={() => onDownload?.(file)} /> - - + = ({ return ( e.stopPropagation()}> - - + {canActOnMemory && canEdit && onEditMemory && ( ({ getContextMemoryVersions: jest.fn(), })); -jest.mock('../../CopyLinkButton/CopyLinkButton.component', () => +jest.mock('../../common/CopyButton/CopyButton', () => jest.fn(() => - + diff --git a/openmetadata-ui/src/main/resources/ui/src/components/CopyLinkButton/CopyLinkButton.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/CopyLinkButton/CopyLinkButton.component.tsx deleted file mode 100644 index 2ad34d7d0646..000000000000 --- a/openmetadata-ui/src/main/resources/ui/src/components/CopyLinkButton/CopyLinkButton.component.tsx +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2026 Collate. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { - ButtonUtility, - ButtonUtilityProps, - Tooltip, - TooltipTrigger, -} from '@openmetadata/ui-core-components'; -import { Check } from '@openmetadata/ui-core-components/icons'; -import classNames from 'classnames'; -import { FC, ReactNode } from 'react'; -import { useTranslation } from 'react-i18next'; -import { useClipboard } from '../../hooks/useClipBoard'; - -interface CopyLinkButtonProps { - children: ReactNode; - url: string; - tooltip?: string; - className?: string; - size?: NonNullable; - testId?: string; -} - -const CopyLinkButton: FC = ({ - children, - className, - url, - tooltip, - size = 'lg', - testId = 'copy-link-btn', -}) => { - const { t } = useTranslation(); - const { onCopyToClipBoard, hasCopied } = useClipboard(url, 1200); - const resolvedTooltip = - tooltip ?? t('label.copy-item', { item: t('label.link') }); - - return ( - - - - - - ); -}; - -export default CopyLinkButton; diff --git a/openmetadata-ui/src/main/resources/ui/src/components/CopyLinkButton/CopyLinkButton.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/CopyLinkButton/CopyLinkButton.test.tsx deleted file mode 100644 index 890fb486ddcf..000000000000 --- a/openmetadata-ui/src/main/resources/ui/src/components/CopyLinkButton/CopyLinkButton.test.tsx +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright 2026 Collate. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { fireEvent, render, screen } from '@testing-library/react'; -import CopyLinkButton from './CopyLinkButton.component'; - -const mockOnCopyToClipBoard = jest.fn(); - -jest.mock('../../hooks/useClipBoard', () => ({ - useClipboard: jest.fn().mockImplementation(() => ({ - onCopyToClipBoard: mockOnCopyToClipBoard, - hasCopied: false, - })), -})); - -jest.mock('@openmetadata/ui-core-components', () => ({ - ButtonUtility: jest - .fn() - .mockImplementation( - ({ icon, onClick, className, 'data-testid': testId }) => ( - - ) - ), - Tooltip: jest.fn().mockImplementation(({ children }) => <>{children}), - TooltipTrigger: jest - .fn() - .mockImplementation(({ children }) => <>{children}), -})); - -jest.mock('@openmetadata/ui-core-components/icons', () => ({ - Check: jest.fn().mockImplementation(() => ), -})); - -const renderComponent = (props = {}) => - render( - - - - ); - -describe('CopyLinkButton', () => { - beforeEach(() => { - jest.clearAllMocks(); - }); - - it('renders the button with the children icon in idle state', () => { - renderComponent(); - - expect(screen.getByTestId('copy-link-btn')).toBeInTheDocument(); - expect(screen.getByTestId('link-icon')).toBeInTheDocument(); - expect(screen.queryByTestId('check-icon')).not.toBeInTheDocument(); - }); - - it('calls onCopyToClipBoard when the button is clicked', () => { - renderComponent(); - - fireEvent.click(screen.getByTestId('copy-link-btn')); - - expect(mockOnCopyToClipBoard).toHaveBeenCalledTimes(1); - }); - - it('shows the check icon and hides children when hasCopied is true', () => { - const { useClipboard } = require('../../hooks/useClipBoard'); - useClipboard.mockReturnValueOnce({ - onCopyToClipBoard: mockOnCopyToClipBoard, - hasCopied: true, - }); - - renderComponent(); - - expect(screen.getByTestId('check-icon')).toBeInTheDocument(); - expect(screen.queryByTestId('link-icon')).not.toBeInTheDocument(); - }); - - it('applies the success class when hasCopied is true', () => { - const { useClipboard } = require('../../hooks/useClipBoard'); - useClipboard.mockReturnValueOnce({ - onCopyToClipBoard: mockOnCopyToClipBoard, - hasCopied: true, - }); - - renderComponent(); - - expect(screen.getByTestId('copy-link-btn').className).toContain( - 'tw:bg-success-solid' - ); - }); - - it('applies the round class in idle state', () => { - renderComponent(); - - expect(screen.getByTestId('copy-link-btn').className).toContain( - 'tw:rounded-md' - ); - }); - - it('passes the url to useClipboard', () => { - const { useClipboard } = require('../../hooks/useClipBoard'); - const url = 'https://example.com/page?memory=my-memory'; - - renderComponent({ url }); - - expect(useClipboard).toHaveBeenCalledWith(url, 1200); - }); - - it('uses the custom tooltip prop when provided', () => { - const { useClipboard } = require('../../hooks/useClipBoard'); - const { Tooltip } = require('@openmetadata/ui-core-components'); - useClipboard.mockReturnValue({ - onCopyToClipBoard: mockOnCopyToClipBoard, - hasCopied: false, - }); - - renderComponent({ tooltip: 'Custom tooltip text' }); - - expect(Tooltip).toHaveBeenCalledWith( - expect.objectContaining({ title: 'Custom tooltip text' }), - expect.anything() - ); - }); - - it('disables the tooltip when hasCopied is true', () => { - const { useClipboard } = require('../../hooks/useClipBoard'); - const { Tooltip } = require('@openmetadata/ui-core-components'); - useClipboard.mockReturnValueOnce({ - onCopyToClipBoard: mockOnCopyToClipBoard, - hasCopied: true, - }); - - renderComponent(); - - expect(Tooltip).toHaveBeenCalledWith( - expect.objectContaining({ isDisabled: true }), - expect.anything() - ); - }); -}); diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Database/SchemaEditor/CodeEditor.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Database/SchemaEditor/CodeEditor.tsx index 73685b9023c8..289bc39722cc 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Database/SchemaEditor/CodeEditor.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Database/SchemaEditor/CodeEditor.tsx @@ -11,16 +11,15 @@ * limitations under the License. */ -import { ButtonUtility, Card } from '@openmetadata/ui-core-components'; -import { Copy01 } from '@openmetadata/ui-core-components/icons'; +import { Card } from '@openmetadata/ui-core-components'; import CodeMirror from '@uiw/react-codemirror'; import classNames from 'classnames'; import { useTranslation } from 'react-i18next'; import { JSON_TAB_SIZE } from '../../../constants/constants'; import { CSMode } from '../../../enums/codemirror.enum'; -import { useClipboard } from '../../../hooks/useClipBoard'; import { useCodeMirrorEditor } from '../../../hooks/useCodeMirrorEditor'; import { CodeMirrorOptions } from '../../../interface/codemirror.interface'; +import CopyButton from '../../common/CopyButton/CopyButton'; import './schema-editor.less'; import { SchemaEditorProps } from './SchemaEditor.interface'; @@ -71,7 +70,6 @@ const CodeEditor = ({ extensions, onChange, }); - const { onCopyToClipBoard, hasCopied } = useClipboard(internalValue); return ( {showCopyButton && (
- onCopyToClipBoard(internalValue)} +
)} diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Database/SchemaEditor/SchemaEditor.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Database/SchemaEditor/SchemaEditor.tsx index 2fb04f289ae5..2c9facabf746 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Database/SchemaEditor/SchemaEditor.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Database/SchemaEditor/SchemaEditor.tsx @@ -11,16 +11,14 @@ * limitations under the License. */ -import { ButtonUtility } from '@openmetadata/ui-core-components'; -import { Copy01 } from '@openmetadata/ui-core-components/icons'; import CodeMirror from '@uiw/react-codemirror'; import classNames from 'classnames'; import { useTranslation } from 'react-i18next'; import { JSON_TAB_SIZE } from '../../../constants/constants'; import { CSMode } from '../../../enums/codemirror.enum'; -import { useClipboard } from '../../../hooks/useClipBoard'; import { useCodeMirrorEditor } from '../../../hooks/useCodeMirrorEditor'; import { CodeMirrorOptions } from '../../../interface/codemirror.interface'; +import CopyButton from '../../common/CopyButton/CopyButton'; import './schema-editor.less'; import { SchemaEditorProps } from './SchemaEditor.interface'; @@ -71,7 +69,6 @@ const SchemaEditor = ({ extensions, onChange, }); - const { onCopyToClipBoard, hasCopied } = useClipboard(internalValue); return (
{showCopyButton && (
- onCopyToClipBoard(internalValue)} +
)} diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Database/SchemaTable/SchemaTable.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Database/SchemaTable/SchemaTable.component.tsx index 4b8530603198..c6d288827222 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Database/SchemaTable/SchemaTable.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Database/SchemaTable/SchemaTable.component.tsx @@ -94,6 +94,7 @@ import { } from '../../../utils/EntitySearchUtils'; import { getEntityColumnFQN } from '../../../utils/FeedUtilsPure'; import { getDerivedPermissionFlags } from '../../../utils/PermissionDerivation'; +import { getEntityDetailsUrl } from '../../../utils/RouterUtils'; import { columnFilterIcon } from '../../../utils/TableColumn.util'; import { findColumnByEntityLink, @@ -110,7 +111,7 @@ import { } from '../../../utils/TableUtils'; import { showErrorToast } from '../../../utils/ToastUtils'; import withSuspenseFallback from '../../AppRouter/withSuspenseFallback'; -import CopyLinkButton from '../../common/CopyLinkButton/CopyLinkButton'; +import CopyButton from '../../common/CopyButton/CopyButton'; import NoSearchResultsPlaceholder from '../../common/EmptyPlaceholder/NoSearchResultsPlaceholder'; import { EntityAttachmentProvider } from '../../common/EntityDescription/EntityAttachmentProvider/EntityAttachmentProvider'; import { PagingHandlerParams } from '../../common/NextPrevious/NextPrevious.interface'; @@ -794,10 +795,15 @@ const SchemaTable = () => { /> )} {record.fullyQualifiedName && ( - )}
diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Database/SchemaTable/SchemaTable.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Database/SchemaTable/SchemaTable.test.tsx index 1764eea9e47a..65a2d5213db2 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Database/SchemaTable/SchemaTable.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Database/SchemaTable/SchemaTable.test.tsx @@ -418,6 +418,9 @@ jest.mock('../../../utils/RouterUtils', () => ({ getEntityDetailsPath: jest .fn() .mockImplementation((_entityType, fqn) => `/table/${fqn}`), + getEntityDetailsUrl: jest + .fn() + .mockImplementation((_entityType, fqn) => `http://localhost/table/${fqn}`), })); jest.mock('../../../utils/TableColumn.util', () => ({ diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Database/TableQueries/QueryCard.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Database/TableQueries/QueryCard.tsx index 8b3fa7c59f44..60888439bcd6 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Database/TableQueries/QueryCard.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Database/TableQueries/QueryCard.tsx @@ -19,11 +19,7 @@ import { Grid, Typography, } from '@openmetadata/ui-core-components'; -import { - Copy01, - Maximize01, - Minimize01, -} from '@openmetadata/ui-core-components/icons'; +import { Maximize01, Minimize01 } from '@openmetadata/ui-core-components/icons'; import classNames from 'classnames'; import { isUndefined, split } from 'lodash'; import Qs from 'qs'; @@ -38,7 +34,6 @@ import { import { CSMode } from '../../../enums/codemirror.enum'; import { EntityTabs, EntityType } from '../../../enums/entity.enum'; import { EntityReference } from '../../../generated/type/entityReference'; -import { useClipboard } from '../../../hooks/useClipBoard'; import useCustomLocation from '../../../hooks/useCustomLocation/useCustomLocation'; import { useFqn } from '../../../hooks/useFqn'; import { getLayoutGutter } from '../../../utils/common/layout.utils'; @@ -50,6 +45,7 @@ import { parseSearchParams } from '../../../utils/Query/QueryUtils'; import queryClassBase from '../../../utils/QueryClassBase'; import { getEntityDetailsPath, getQueryPath } from '../../../utils/RouterUtils'; import withSuspenseFallback from '../../AppRouter/withSuspenseFallback'; +import CopyButton from '../../common/CopyButton/CopyButton'; import QueryCardExtraOption from './QueryCardExtraOption/QueryCardExtraOption.component'; import QueryUsedByOtherTable from './QueryUsedByOtherTable/QueryUsedByOtherTable.component'; import './table-queries.style.less'; @@ -75,7 +71,6 @@ const QueryCard: FC = ({ const { fqn: datasetFQN } = useFqn(); const location = useCustomLocation(); const navigate = useNavigate(); - const { onCopyToClipBoard } = useClipboard(query.query); const searchFilter = useMemo( () => parseSearchParams(location.search), [location.search] @@ -266,12 +261,10 @@ const QueryCard: FC = ({ onClick={handleExpandClick} {...getExpandButtonProps()} /> - onCopyToClipBoard()} + value={query.query ?? ''} /> diff --git a/openmetadata-ui/src/main/resources/ui/src/components/DriveService/Worksheet/WorksheetColumnsTable/WorksheetColumnsTable.tsx b/openmetadata-ui/src/main/resources/ui/src/components/DriveService/Worksheet/WorksheetColumnsTable/WorksheetColumnsTable.tsx index 2960ca00afcf..aed04eae00fc 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/DriveService/Worksheet/WorksheetColumnsTable/WorksheetColumnsTable.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/DriveService/Worksheet/WorksheetColumnsTable/WorksheetColumnsTable.tsx @@ -39,6 +39,7 @@ import { TagLabel } from '../../../../generated/type/tagLabel'; import { useTreeTagFilter } from '../../../../hooks/useTreeTagFilter'; import { getEntityName } from '../../../../utils/EntityNameUtils'; import { getDerivedPermissionFlags } from '../../../../utils/PermissionDerivation'; +import { getEntityDetailsUrl } from '../../../../utils/RouterUtils'; import { columnFilterIcon } from '../../../../utils/TableColumn.util'; import { pruneEmptyChildren, @@ -51,7 +52,7 @@ import { prepareConstraintIcon, } from '../../../../utils/TableUtils'; import withSuspenseFallback from '../../../AppRouter/withSuspenseFallback'; -import CopyLinkButton from '../../../common/CopyLinkButton/CopyLinkButton'; +import CopyButton from '../../../common/CopyButton/CopyButton'; import NoDataPlaceholder from '../../../common/EmptyPlaceholder/NoDataPlaceholder'; import { EntityAttachmentProvider } from '../../../common/EntityDescription/EntityAttachmentProvider/EntityAttachmentProvider'; import { ColumnsType } from '../../../common/Table/Table.interface'; @@ -198,9 +199,15 @@ function WorksheetColumnsTable() { {name} {record.fullyQualifiedName && ( - )} diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityHeaderTitle/EntityHeaderTitle.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityHeaderTitle/EntityHeaderTitle.component.tsx index c136f9342e6b..d958a5317a8f 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityHeaderTitle/EntityHeaderTitle.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityHeaderTitle/EntityHeaderTitle.component.tsx @@ -13,12 +13,10 @@ import { Badge, Button, - ButtonUtility, Tooltip, Typography, } from '@openmetadata/ui-core-components'; import { - Copy01, ExclamationCircleFilled, LinkExternal01, Star01, @@ -26,14 +24,14 @@ import { } from '@openmetadata/ui-core-components/icons'; import classNames from 'classnames'; import { isEmpty } from 'lodash'; -import { MouseEvent, useMemo, useState } from 'react'; +import { useMemo } from 'react'; import { useTranslation } from 'react-i18next'; import { Link } from 'react-router-dom'; import { EntityType } from '../../../enums/entity.enum'; -import { useClipboard } from '../../../hooks/useClipBoard'; import { getEntityName } from '../../../utils/EntityNameUtils'; import { renderHighlightedText } from '../../../utils/EntitySearchUtils'; import entityUtilClassBase from '../../../utils/EntityUtilClassBase'; +import CopyButton from '../../common/CopyButton/CopyButton'; import './entity-header-title.less'; import { EntityHeaderTitleProps } from './EntityHeaderTitle.interface'; @@ -81,19 +79,6 @@ const EntityHeaderTitle = ({ entityUrl, }: EntityHeaderTitleProps) => { const { t } = useTranslation(); - const [copyTooltip, setCopyTooltip] = useState(); - const { onCopyToClipBoard } = useClipboard( - entityUrl ?? globalThis.location.href - ); - - const handleShareButtonClick = async (e: MouseEvent) => { - e.preventDefault(); - e.stopPropagation(); - await onCopyToClipBoard(); - setCopyTooltip(t('message.link-copy-to-clipboard')); - setTimeout(() => setCopyTooltip(''), 2000); - }; - const formattedEntityType = useMemo( () => entityUtilClassBase.getFormattedEntityType(entityType as EntityType), [entityType] @@ -256,16 +241,11 @@ const EntityHeaderTitle = ({ )} - {(isEmpty(displayName) || !showName) && suffix} {renderFollowButton()} diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityPageTitle/EntityPageTitle.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityPageTitle/EntityPageTitle.tsx index 4e4207db7282..417b8cdff1be 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityPageTitle/EntityPageTitle.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityPageTitle/EntityPageTitle.tsx @@ -10,19 +10,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { - Badge, - Box, - ButtonUtility, - Typography, -} from '@openmetadata/ui-core-components'; -import { Copy01 } from '@openmetadata/ui-core-components/icons'; +import { Badge, Box, Typography } from '@openmetadata/ui-core-components'; import classNames from 'classnames'; import { isEmpty } from 'lodash'; import { ReactNode } from 'react'; import { useTranslation } from 'react-i18next'; -import { useClipboard } from '../../../hooks/useClipBoard'; import { renderHighlightedText } from '../../../utils/EntitySearchUtils'; +import CopyButton from '../../common/CopyButton/CopyButton'; export interface EntityPageTitleProps { name: string; @@ -46,7 +40,6 @@ export const EntityPageTitle = ({ testId, }: EntityPageTitleProps) => { const { t } = useTranslation(); - const { onCopyToClipBoard, hasCopied } = useClipboard('', 2000); const hasDisplayName = !isEmpty(displayName); // Version views pass getTextDiff HTML; render its diff spans as elements. const displayNameNode = renderHighlightedText(displayName); @@ -101,16 +94,10 @@ export const EntityPageTitle = ({ {t('label.deleted')} )} - onCopyToClipBoard(globalThis.location.href)} + {actions} diff --git a/openmetadata-ui/src/main/resources/ui/src/components/ServiceAgents/components/RunStepRow.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/ServiceAgents/components/RunStepRow.component.tsx index e60b9a0be8fe..3bf2fbc79884 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/ServiceAgents/components/RunStepRow.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/ServiceAgents/components/RunStepRow.component.tsx @@ -15,12 +15,11 @@ import { Badge, Box } from '@openmetadata/ui-core-components'; import { Alert, ChevronRight, - Copy01, Lightbulb03, } from '@openmetadata/ui-core-components/icons'; import { FC, useState } from 'react'; import { useTranslation } from 'react-i18next'; -import { useClipboard } from '../../../hooks/useClipBoard'; +import CopyButton from '../../common/CopyButton/CopyButton'; import { RunAttention, RunStep } from '../AgentsPage.interface'; import { fmtNum } from '../utils/agents.utils'; import RunGlyph from './RunGlyph.component'; @@ -84,10 +83,8 @@ const RawLogSection: FC<{ stackLines: string[] }> = ({ stackLines }) => { const AttentionCard: FC = ({ att }) => { const { t } = useTranslation(); + // Only the raw logs go to the clipboard — the title, message and hint are already on screen. const stackLines = att.stackTrace ? att.stackTrace.split('\n') : []; - // Only the raw logs go to the clipboard — the title, message and hint are already on screen, and - // pasting them into a ticket or a terminal alongside the log body is noise. - const { hasCopied, onCopyToClipBoard } = useClipboard(att.stackTrace ?? ''); const isError = att.severity === 'error'; const { surfaceClass, dividerClass, accentClass, accentIconClass } = getAttentionClasses(isError); @@ -108,13 +105,12 @@ const AttentionCard: FC = ({ att }) => { {stackLines.length > 0 && ( - + )}
diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Settings/Applications/AppLogsViewer/AppLogsViewer.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Settings/Applications/AppLogsViewer/AppLogsViewer.test.tsx index 347f9d14a0da..77bb52b43026 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Settings/Applications/AppLogsViewer/AppLogsViewer.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Settings/Applications/AppLogsViewer/AppLogsViewer.test.tsx @@ -47,8 +47,8 @@ jest.mock('../../../../utils/StringUtils', () => ({ formatJsonString: jest.fn().mockReturnValue('logs'), })); -jest.mock('../../../common/CopyToClipboardButton/CopyToClipboardButton', () => - jest.fn().mockReturnValue(<>CopyToClipboardButton) +jest.mock('../../../common/CopyButton/CopyButton', () => + jest.fn().mockReturnValue(<>CopyButton) ); jest.mock('../../../../utils/ApplicationUtils', () => ({ diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Settings/Applications/AppLogsViewer/ReindexFailures.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Settings/Applications/AppLogsViewer/ReindexFailures.component.tsx index 27e9ada443eb..56feac923cf3 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Settings/Applications/AppLogsViewer/ReindexFailures.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Settings/Applications/AppLogsViewer/ReindexFailures.component.tsx @@ -35,7 +35,7 @@ import { getRdfReindexFailures } from '../../../../rest/rdfAPI'; import { getReindexFailures } from '../../../../rest/searchAPI'; import { formatDateTimeWithTimezone } from '../../../../utils/date-time/DateTimeUtils'; import { showErrorToast } from '../../../../utils/ToastUtils'; -import CopyToClipboardButton from '../../../common/CopyToClipboardButton/CopyToClipboardButton'; +import CopyButton from '../../../common/CopyButton/CopyButton'; import { ColumnsType } from '../../../common/Table/Table.interface'; import Table from '../../../common/Table/TableV2'; import { @@ -75,7 +75,13 @@ const ErrorMessage = ({ text }: { text: string }) => { )} - + ); }; @@ -189,7 +195,15 @@ const ReindexFailures = ({ render: (text: string) => ( {text || '-'} - {text && } + {text && ( + + )} ), }, diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Settings/Bot/BotDetails/AuthMechanism.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Settings/Bot/BotDetails/AuthMechanism.tsx index 31490af345c0..31900dae420d 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Settings/Bot/BotDetails/AuthMechanism.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Settings/Bot/BotDetails/AuthMechanism.tsx @@ -14,12 +14,11 @@ import { Box, Button, - ButtonUtility, Divider, PasswordInput, Typography, } from '@openmetadata/ui-core-components'; -import { Alert, Copy01 } from '@openmetadata/ui-core-components/icons'; +import { Alert } from '@openmetadata/ui-core-components/icons'; import classNames from 'classnames'; import { FC, useMemo } from 'react'; import { useTranslation } from 'react-i18next'; @@ -30,7 +29,7 @@ import { getTokenExpiry, getTokenIssuedAtMs, } from '../../../../utils/BotsUtils'; -import CopyToClipboardButton from '../../../common/CopyToClipboardButton/CopyToClipboardButton'; +import CopyButton from '../../../common/CopyButton/CopyButton'; import UserPopOverCard from '../../../common/PopOverCard/UserPopOverCard'; import './auth-mechanism.less'; @@ -127,16 +126,14 @@ const AuthMechanism: FC = ({ placeholder="Generate new token..." value={JWTToken} /> - {!isSCIMBot ? ( - - ) : ( - navigator.clipboard.writeText(JWTToken)} - /> - )} + {!isSCIMBot && (

diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Settings/Users/CreateUser/CreateUser.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Settings/Users/CreateUser/CreateUser.component.tsx index 75e7c7e2b72f..6f2a1e2417f6 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Settings/Users/CreateUser/CreateUser.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Settings/Users/CreateUser/CreateUser.component.tsx @@ -29,11 +29,7 @@ import { SelectItemType, Toggle, } from '@openmetadata/ui-core-components'; -import { - Copy01, - Plus, - RefreshCw01, -} from '@openmetadata/ui-core-components/icons'; +import { Plus, RefreshCw01 } from '@openmetadata/ui-core-components/icons'; import { AxiosError } from 'axios'; import { compact, debounce, isUndefined, trim } from 'lodash'; import { useCallback, useEffect, useMemo, useState } from 'react'; @@ -62,7 +58,8 @@ import { getAllPersonas } from '../../../../rest/PersonaAPI'; import { searchRoles } from '../../../../rest/rolesAPIV1'; import { getJWTTokenExpiryOptions } from '../../../../utils/BotsUtils'; import { getEntityName } from '../../../../utils/EntityNameUtils'; -import { showErrorToast, showSuccessToast } from '../../../../utils/ToastUtils'; +import { showErrorToast } from '../../../../utils/ToastUtils'; +import CopyButton from '../../../common/CopyButton/CopyButton'; import { DomainLabel } from '../../../common/DomainLabel/DomainLabel.component'; import DomainSelectableList from '../../../common/DomainSelectableList/DomainSelectableList.component'; import InlineAlert from '../../../common/InlineAlert/InlineAlert'; @@ -255,14 +252,6 @@ const CreateUser = ({ } }, []); - const handleCopyPassword = async () => { - if (!generatedPassword) { - return; - } - await navigator.clipboard.writeText(generatedPassword); - showSuccessToast(t('message.copied-to-clipboard')); - }; - const fetchRoleOptions = useCallback( async (searchText = '') => { try { @@ -452,13 +441,14 @@ const CreateUser = ({ tooltip={String(t('label.regenerate'))} onClick={generateRandomPassword} /> - } diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Topic/TopicSchema/TopicSchema.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Topic/TopicSchema/TopicSchema.test.tsx index 4c16caccedba..f87663d3cbb4 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Topic/TopicSchema/TopicSchema.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Topic/TopicSchema/TopicSchema.test.tsx @@ -200,6 +200,9 @@ jest.mock('../../../utils/RouterUtils', () => ({ getEntityDetailsPath: jest .fn() .mockImplementation((_entityType, fqn) => `/topic/${fqn}`), + getEntityDetailsUrl: jest + .fn() + .mockImplementation((_entityType, fqn) => `http://localhost/topic/${fqn}`), })); describe('Topic Schema', () => { diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Topic/TopicSchema/TopicSchema.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Topic/TopicSchema/TopicSchema.tsx index 0375d7aed2c8..0fe386f726d6 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Topic/TopicSchema/TopicSchema.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Topic/TopicSchema/TopicSchema.tsx @@ -68,6 +68,7 @@ import { getLayoutGutter } from '../../../utils/common/layout.utils'; import { getEntityName } from '../../../utils/EntityNameUtils'; import { getColumnSorter } from '../../../utils/EntitySortUtils'; import { getDerivedPermissionFlags } from '../../../utils/PermissionDerivation'; +import { getEntityDetailsUrl } from '../../../utils/RouterUtils'; import { getVersionedSchema } from '../../../utils/SchemaVersionUtils'; import { columnFilterIcon } from '../../../utils/TableColumn.util'; import { @@ -86,7 +87,7 @@ import { getAllTags } from '../../../utils/TableTags/TableTags.utils'; import { getTableExpandableConfig } from '../../../utils/TableUtils'; import { showErrorToast } from '../../../utils/ToastUtils'; import withSuspenseFallback from '../../AppRouter/withSuspenseFallback'; -import CopyLinkButton from '../../common/CopyLinkButton/CopyLinkButton'; +import CopyButton from '../../common/CopyButton/CopyButton'; import NoDataPlaceholder from '../../common/EmptyPlaceholder/NoDataPlaceholder'; import { EntityAttachmentProvider } from '../../common/EntityDescription/EntityAttachmentProvider/EntityAttachmentProvider'; import { PagingHandlerParams } from '../../common/NextPrevious/NextPrevious.interface'; @@ -480,9 +481,15 @@ const TopicSchemaFields: FC = ({ {!isVersionView && record.fullyQualifiedName && ( - )}

diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/CopyButton/CopyButton.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/CopyButton/CopyButton.test.tsx new file mode 100644 index 000000000000..797c3ce7f25f --- /dev/null +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/CopyButton/CopyButton.test.tsx @@ -0,0 +1,171 @@ +/* + * Copyright 2026 Collate. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { act, fireEvent, render, screen } from '@testing-library/react'; +import CopyButton from './CopyButton'; + +const mockWriteText = jest.fn().mockResolvedValue(undefined); + +beforeAll(() => { + Object.defineProperty(window, 'isSecureContext', { + value: true, + configurable: true, + }); + Object.defineProperty(navigator, 'clipboard', { + value: { writeText: mockWriteText }, + configurable: true, + }); +}); + +jest.mock('@openmetadata/ui-core-components', () => ({ + Button: jest + .fn() + .mockImplementation( + ({ + children, + className, + iconLeading: Icon, + isDisabled, + onClick, + 'data-testid': testId, + }) => ( + + ) + ), + ButtonUtility: jest + .fn() + .mockImplementation( + ({ + icon: Icon, + className, + isDisabled, + onClick, + tooltip, + 'data-testid': testId, + }) => ( + + ) + ), +})); + +jest.mock('@openmetadata/ui-core-components/icons', () => ({ + Check: () => , + Copy01: () => , +})); + +const clickAndSettle = async (testId: string) => { + await act(async () => { + fireEvent.click(screen.getByTestId(testId)); + }); +}; + +describe('CopyButton', () => { + beforeEach(() => { + jest.clearAllMocks(); + }); + + it('copies the value and swaps to the success state', async () => { + render(); + + expect(screen.getByTestId('copy-icon')).toBeInTheDocument(); + expect(screen.getByTestId('copy-link-btn').className).toContain( + 'tw:rounded-md' + ); + + await clickAndSettle('copy-link-btn'); + + expect(mockWriteText).toHaveBeenCalledWith('https://example.com/memory'); + expect(screen.getByTestId('check-icon')).toBeInTheDocument(); + expect(screen.queryByTestId('copy-icon')).not.toBeInTheDocument(); + expect(screen.getByTestId('copy-link-btn').className).toContain( + 'tw:bg-success-solid' + ); + expect(screen.getByTestId('copy-link-btn').className).toContain( + 'tw:rounded-full' + ); + expect(screen.getByTestId('copy-link-btn')).toHaveAttribute( + 'aria-label', + 'label.copied' + ); + }); + + it('uses the given test id and tooltip as the accessible name', () => { + render( + + ); + + expect(screen.getByTestId('copy-secret')).toHaveAttribute( + 'aria-label', + 'Copy token' + ); + }); + + it('does not let the click reach a clickable parent row', async () => { + const onRowClick = jest.fn(); + render( + // A clickable table row; the a11y rules do not apply to this test fixture. + // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions +
+ +
+ ); + + await clickAndSettle('copy-link-btn'); + + expect(mockWriteText).toHaveBeenCalledWith('row-link'); + expect(onRowClick).not.toHaveBeenCalled(); + }); + + it('calls onCopy after a successful copy', async () => { + const onCopy = jest.fn(); + render(); + + await clickAndSettle('copy-link-btn'); + + expect(onCopy).toHaveBeenCalledTimes(1); + }); + + it('renders the labeled variant and flips the label to Copied', async () => { + render(); + + expect(screen.getByTestId('copy-token')).toHaveTextContent('Copy'); + + await clickAndSettle('copy-token'); + + expect(mockWriteText).toHaveBeenCalledWith('jwt'); + expect(screen.getByTestId('copy-token')).toHaveTextContent('label.copied'); + expect(screen.getByTestId('check-icon')).toBeInTheDocument(); + expect(screen.getByTestId('copy-token').className).toContain( + 'tw:bg-success-solid' + ); + }); + + it('passes isDisabled through so an empty value cannot be copied', () => { + render(); + + expect(screen.getByTestId('copy-log')).toBeDisabled(); + }); +}); diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/CopyButton/CopyButton.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/CopyButton/CopyButton.tsx new file mode 100644 index 000000000000..879bb8c641ac --- /dev/null +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/CopyButton/CopyButton.tsx @@ -0,0 +1,148 @@ +/* + * Copyright 2026 Collate. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { + Button, + ButtonProps, + ButtonUtility, + ButtonUtilityProps, +} from '@openmetadata/ui-core-components'; +import { Check, Copy01 } from '@openmetadata/ui-core-components/icons'; +import classNames from 'classnames'; +import { FC, MouseEvent } from 'react'; +import type { Placement } from 'react-aria'; +import { useTranslation } from 'react-i18next'; +import { useClipboard } from '../../../hooks/useClipBoard'; + +const COPIED_RESET_MS = 1200; + +const SUCCESS_CLASSES = [ + 'tw:bg-success-solid', + 'tw:text-fg-white', + 'tw:after:outline-0', + 'tw:shadow-none', + 'tw:hover:bg-success-solid', + 'tw:dark:hover:bg-success-solid', + 'tw:hover:text-fg-white', + 'tw:*:data-icon:text-fg-white', + 'tw:hover:*:data-icon:text-fg-white', +].join(' '); + +interface CopyButtonProps { + value: string; + // Renders a text button instead of the icon-only one; the text flips to "Copied" on success. + label?: string; + tooltip?: string; + tooltipPlacement?: Placement; + className?: string; + size?: NonNullable; + labelSize?: NonNullable; + color?: NonNullable; + labelColor?: NonNullable; + testId?: string; + isDisabled?: boolean; + onCopy?: () => void; +} + +const RingPulse = () => ( + )} {enableCopy && ( - + )} {isLive && ( = (props) => { status || resolvedTotalLines !== undefined || runId || lastRun ); - const { hasCopied, onCopyToClipBoard } = useClipboard(resolvedLogs); - const query = searchText.trim().toLowerCase(); const filteredLogs = useMemo(() => { @@ -637,6 +609,7 @@ const LogViewerModal: FunctionComponent = (props) => {
= (props) => { handleJumpToEnd={handleJumpToEnd} handleToggleFullScreen={handleToggleFullScreen} handleToggleWrap={handleToggleWrap} - hasCopied={hasCopied} isFullScreen={isFullScreen} isLive={isLive} isReconnecting={isReconnecting} @@ -655,7 +627,6 @@ const LogViewerModal: FunctionComponent = (props) => { toggleFollow={toggleFollow} wrap={wrap} onClose={onClose} - onCopyToClipBoard={() => onCopyToClipBoard(resolvedLogs)} onDownload={onDownload} onSearchChange={handleSearchChange} /> diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/LogViewerModal/log-viewer-modal.less b/openmetadata-ui/src/main/resources/ui/src/components/common/LogViewerModal/log-viewer-modal.less index 223ddf5cc2a8..683a6f5e41b4 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/LogViewerModal/log-viewer-modal.less +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/LogViewerModal/log-viewer-modal.less @@ -166,30 +166,6 @@ white-space: nowrap; } - .lvm-copy-button { - display: inline-flex; - align-items: center; - gap: 6px; - height: 32px; - padding: 0 12px; - border: 1px solid var(--lvm-border-strong); - border-radius: 8px; - background-color: var(--lvm-chip-bg); - color: var(--lvm-chip-text); - font-family: inherit; - font-size: 12.5px; - cursor: pointer; - - &:hover { - background-color: var(--lvm-surface-2); - } - } - - .lvm-copy-icon { - width: 15px; - height: 15px; - } - .lvm-icon-button { display: inline-flex; align-items: center; diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/QueryViewer/QueryViewer.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/QueryViewer/QueryViewer.component.tsx index 2a920f257e68..88f85e011d34 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/QueryViewer/QueryViewer.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/QueryViewer/QueryViewer.component.tsx @@ -10,16 +10,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { Badge, ButtonUtility, Card } from '@openmetadata/ui-core-components'; -import { Copy01 } from '@openmetadata/ui-core-components/icons'; +import { Badge, Card } from '@openmetadata/ui-core-components'; import classNames from 'classnames'; import { isEmpty, split } from 'lodash'; import { lazy, useMemo } from 'react'; import { useTranslation } from 'react-i18next'; import { CSMode } from '../../../enums/codemirror.enum'; -import { useClipboard } from '../../../hooks/useClipBoard'; import { getSchemaEditorValue } from '../../../utils/SchemaEditor.utils'; import withSuspenseFallback from '../../AppRouter/withSuspenseFallback'; +import CopyButton from '../CopyButton/CopyButton'; import NoDataPlaceholder from '../EmptyPlaceholder/NoDataPlaceholder'; import './query-viewer.style.less'; @@ -57,8 +56,6 @@ const QueryViewer = ({ }; }, [sqlQuery, hasQuery]); - const { onCopyToClipBoard } = useClipboard(formattedQuery); - return ( {(title || hasQuery) && ( @@ -80,13 +77,11 @@ const QueryViewer = ({ size="sm"> {queryLine} - onCopyToClipBoard()} + value={formattedQuery} /> ) : null diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/QueryViewer/QueryViewer.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/QueryViewer/QueryViewer.test.tsx index d6b18f7a0e12..a22e6bfdb65e 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/QueryViewer/QueryViewer.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/QueryViewer/QueryViewer.test.tsx @@ -81,6 +81,10 @@ describe('QueryViewer Component', () => { expect(screen.getByTestId('schema-editor').textContent).toBe( formattedConfig ); - expect(useClipboard).toHaveBeenLastCalledWith(formattedConfig); + expect(useClipboard).toHaveBeenLastCalledWith( + formattedConfig, + 1200, + undefined + ); }); }); diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/ServiceDocPanel/ServiceDocPanel.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/ServiceDocPanel/ServiceDocPanel.test.tsx index 1000e0a40da4..4f4ed242b4f5 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/ServiceDocPanel/ServiceDocPanel.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/ServiceDocPanel/ServiceDocPanel.test.tsx @@ -1642,15 +1642,6 @@ describe('CodeBlockComponent', () => { expect(screen.getByTestId('code-block-copy-icon')).toBeInTheDocument(); }); - it('should set data-copied to false initially', () => { - const { container } = render(); - - expect(container.querySelector('.code-copy-button')).toHaveAttribute( - 'data-copied', - 'false' - ); - }); - it('should copy node text content to clipboard on click', async () => { render(); @@ -1661,21 +1652,20 @@ describe('CodeBlockComponent', () => { }); }); - it('should set data-copied to true after clicking copy', async () => { - const { container } = render(); + it('should show the copied state after clicking copy', async () => { + render(); fireEvent.click(screen.getByTestId('code-block-copy-icon')); await waitFor(() => { - expect(container.querySelector('.code-copy-button')).toHaveAttribute( - 'data-copied', - 'true' + expect(screen.getByTestId('code-block-copy-icon').className).toContain( + 'tw:bg-success-solid' ); }); }); it('should remain in copied state after rapid clicks', async () => { - const { container } = render(); + render(); fireEvent.click(screen.getByTestId('code-block-copy-icon')); @@ -1689,9 +1679,8 @@ describe('CodeBlockComponent', () => { expect(mockWriteText).toHaveBeenCalledTimes(2); }); - expect(container.querySelector('.code-copy-button')).toHaveAttribute( - 'data-copied', - 'true' + expect(screen.getByTestId('code-block-copy-icon').className).toContain( + 'tw:bg-success-solid' ); }); }); diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/ServiceDocPanel/service-doc-panel.less b/openmetadata-ui/src/main/resources/ui/src/components/common/ServiceDocPanel/service-doc-panel.less index 5476c03e650c..a66ffffe92e6 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/ServiceDocPanel/service-doc-panel.less +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/ServiceDocPanel/service-doc-panel.less @@ -122,28 +122,6 @@ display: none; } } - - .code-copy-button { - position: absolute; - top: 6px; - right: 6px; - opacity: 0; - transition: opacity var(--om-duration-200); - background: @markdown-bg-color; - border-radius: var(--om-radius-sm); - - &[data-copied='true'] { - opacity: 0.4; - } - } - - &:hover .code-copy-button { - opacity: 0.6; - - &:hover { - opacity: 1; - } - } } blockquote { diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/TestConnection/ConnectionStepCard/ConnectionStepCard.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/TestConnection/ConnectionStepCard/ConnectionStepCard.tsx index 544d1e0b3f3b..6135dbb19668 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/TestConnection/ConnectionStepCard/ConnectionStepCard.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/TestConnection/ConnectionStepCard/ConnectionStepCard.tsx @@ -16,7 +16,6 @@ import { AccordionItem, AccordionPanel, Box, - ButtonUtility, Divider, Tooltip, Typography, @@ -25,7 +24,6 @@ import { AlertCircle, CheckCircle02, ChevronRight, - Copy01, InfoCircle, XCircle, } from '@openmetadata/ui-core-components/icons'; @@ -34,8 +32,8 @@ import { isUndefined } from 'lodash'; import { useTranslation } from 'react-i18next'; import { TestConnectionStepResult } from '../../../../generated/entity/automations/workflow'; import { TestConnectionStep } from '../../../../generated/entity/services/connections/testConnectionDefinition'; -import { useClipboard } from '../../../../hooks/useClipBoard'; import { requiredField } from '../../../../utils/EntityDisplayPureUtils'; +import CopyButton from '../../CopyButton/CopyButton'; import './connection-step-card.less'; interface ConnectionStepCardProp { @@ -159,8 +157,6 @@ const ConnectionStepCard = ({ testConnectionStepResult?.errorLog ?? t('label.no-entity', { entity: t('label.log-plural') }); - const { onCopyToClipBoard } = useClipboard(logs ?? ''); - return (
{t('label.show-log-plural')} - onCopyToClipBoard()} + value={logs ?? ''} /> diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/TestConnection/TestConnectionModal/TestConnectionModal.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/TestConnection/TestConnectionModal/TestConnectionModal.tsx index f890df0deb87..425b401320fa 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/TestConnection/TestConnectionModal/TestConnectionModal.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/TestConnection/TestConnectionModal/TestConnectionModal.tsx @@ -33,7 +33,6 @@ import { TestConnectionStepResult, } from '../../../../generated/entity/automations/workflow'; import { TestConnectionStep } from '../../../../generated/entity/services/connections/testConnectionDefinition'; -import { useClipboard } from '../../../../hooks/useClipBoard'; import { formatDuration } from '../../../../utils/date-time/DateTimeUtils'; import { getServiceLogo } from '../../../../utils/EntityDisplayUtils'; import { @@ -318,7 +317,6 @@ const TestConnectionModal = ({ [testConnectionStepResult] ); - const { onCopyToClipBoard } = useClipboard(rawLog); const rawLogLineCount = getRawLogLineCount(rawLog); const serviceLogo = useMemo( @@ -509,7 +507,6 @@ const TestConnectionModal = ({ t={t} onCancel={onCancel} onConfirm={onConfirm} - onCopyToClipBoard={() => onCopyToClipBoard()} onTestConnection={onTestConnection} />
diff --git a/openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/Profile/components/AccessTokenRow.tsx b/openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/Profile/components/AccessTokenRow.tsx index 3cc24f08ddfc..65d3caa45074 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/Profile/components/AccessTokenRow.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/Profile/components/AccessTokenRow.tsx @@ -24,7 +24,6 @@ import { Typography, } from '@openmetadata/ui-core-components'; import { - Copy01, Eye, EyeOff, Key01, @@ -57,6 +56,7 @@ import { showErrorToast, showSuccessToast, } from '../../../../../utils/ToastUtils'; +import CopyButton from '../../../../common/CopyButton/CopyButton'; import NoDataPlaceholder from '../../../../common/EmptyPlaceholder/NoDataPlaceholder'; const AI_PROFILE_TOKEN_NAME = 'ai-profile-token'; @@ -171,7 +171,6 @@ const AccessTokenDetails = ({ reveal, setReveal, canReveal, - handleCopy, isLoading, isLimitReached, handleRegenerate, @@ -185,7 +184,6 @@ const AccessTokenDetails = ({ reveal: boolean; setReveal: Dispatch>; canReveal: boolean; - handleCopy: () => void; isLoading: boolean; isLimitReached: boolean; handleRegenerate: () => void; @@ -243,15 +241,12 @@ const AccessTokenDetails = ({ tooltip={t('label.show')} onClick={() => setReveal(!reveal)} /> - + @@ -421,23 +416,6 @@ const AccessTokenRow: React.FC = () => { } }; - const handleCopy = async () => { - if (!token?.jwtToken) { - return; - } - if (!navigator.clipboard?.writeText) { - showErrorToast(t('message.clipboard-not-available') as string); - - return; - } - try { - await navigator.clipboard.writeText(token.jwtToken); - showSuccessToast(t('label.copied')); - } catch (error) { - showErrorToast(error as AxiosError); - } - }; - if (isFetching) { return ; } @@ -470,7 +448,6 @@ const AccessTokenRow: React.FC = () => { = ({ onSetHeaderTitleSuffix, }) => { const { t } = useTranslation(); - const { onCopyToClipBoard, hasCopied } = useClipboard(window.location.href); const { isAdminUser } = useAuth(); const { canDelete, @@ -660,17 +658,11 @@ const AccessControlPolicyDetail: FC = ({ setIsRenameOpen(true); }} /> - onCopyToClipBoard()} + value={window.location.href} /> ); @@ -709,8 +701,6 @@ const AccessControlPolicyDetail: FC = ({ handleSaveRename, handleAfterDeletePolicy, t, - hasCopied, - onCopyToClipBoard, onSetHeaderActions, onSetHeaderTitleInput, onSetHeaderTitleSuffix, diff --git a/openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/Profile/tabs/access-control/AccessControlRoleDetail.tsx b/openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/Profile/tabs/access-control/AccessControlRoleDetail.tsx index 1be8ffcb6c24..3736dc79b74e 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/Profile/tabs/access-control/AccessControlRoleDetail.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/Profile/tabs/access-control/AccessControlRoleDetail.tsx @@ -27,7 +27,6 @@ import { Typography, } from '@openmetadata/ui-core-components'; import { - Copy01, Edit01 as Edit, Policy as PolicyIcon, Teams, @@ -57,7 +56,6 @@ import { Policy } from '../../../../../../generated/entity/policies/policy'; import { Role } from '../../../../../../generated/entity/teams/role'; import { EntityReference } from '../../../../../../generated/entity/type'; import { useAuth } from '../../../../../../hooks/authHooks'; -import { useClipboard } from '../../../../../../hooks/useClipBoard'; import { useSettingsHash } from '../../../../../../hooks/useSettingsHash'; import { getPolicies, @@ -77,6 +75,7 @@ import { showErrorToast, showSuccessToast, } from '../../../../../../utils/ToastUtils'; +import CopyButton from '../../../../../common/CopyButton/CopyButton'; import DeleteEntityPopover from '../../../../../common/DeleteWidget/DeleteEntityPopover'; import NoDataPlaceholder from '../../../../../common/EmptyPlaceholder/NoDataPlaceholder'; import Loader from '../../../../../common/Loader/Loader'; @@ -415,7 +414,6 @@ const AccessControlRoleDetail: React.FC = ({ onSetHeaderTitleSuffix, }) => { const { t } = useTranslation(); - const { onCopyToClipBoard, hasCopied } = useClipboard(window.location.href); const { isAdminUser } = useAuth(); const { getEntityPermissionByFqn } = usePermissionProvider(); const { contains } = useFilter({ sensitivity: 'base' }); @@ -541,17 +539,11 @@ const AccessControlRoleDetail: React.FC = ({ setIsRenameOpen(true); }} /> - onCopyToClipBoard()} + value={window.location.href} /> ); @@ -590,8 +582,6 @@ const AccessControlRoleDetail: React.FC = ({ handleSaveRename, handleAfterDeleteRole, t, - hasCopied, - onCopyToClipBoard, onSetHeaderActions, onSetHeaderTitleInput, onSetHeaderTitleSuffix, diff --git a/openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/Profile/tabs/bots/BotTokenSection.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/Profile/tabs/bots/BotTokenSection.test.tsx index 53d41c6a95d8..d0d26508dba7 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/Profile/tabs/bots/BotTokenSection.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/Profile/tabs/bots/BotTokenSection.test.tsx @@ -11,7 +11,13 @@ * limitations under the License. */ -import { fireEvent, render, screen, waitFor } from '@testing-library/react'; +import { + act, + fireEvent, + render, + screen, + waitFor, +} from '@testing-library/react'; import React from 'react'; import { User } from '../../../../../../generated/entity/teams/user'; import { @@ -68,12 +74,14 @@ jest.mock('@openmetadata/ui-core-components', () => ({ ), Button: ({ children, + onClick, onPress, 'data-testid': testId, isDisabled, isLoading, }: { children: React.ReactNode; + onClick?: (e: React.MouseEvent) => void; onPress?: () => void; 'data-testid'?: string; isDisabled?: boolean; @@ -84,7 +92,7 @@ jest.mock('@openmetadata/ui-core-components', () => ({ data-testid={testId} disabled={isDisabled} type="button" - onClick={onPress}> + onClick={onClick ?? onPress}> {children} ), @@ -150,7 +158,11 @@ describe('BotTokenSection', () => { beforeEach(() => { jest.clearAllMocks(); Object.assign(navigator, { - clipboard: { writeText: jest.fn() }, + clipboard: { writeText: jest.fn().mockResolvedValue(undefined) }, + }); + Object.defineProperty(window, 'isSecureContext', { + configurable: true, + value: true, }); }); @@ -231,7 +243,7 @@ describe('BotTokenSection', () => { expect(screen.getByTestId('token-created-on')).toBeInTheDocument(); }); - it('should copy the token to the clipboard', () => { + it('should copy the token to the clipboard', async () => { render( { /> ); - fireEvent.click(screen.getByTestId('copy-token')); + await act(async () => { + fireEvent.click(screen.getByTestId('copy-token')); + }); expect(navigator.clipboard.writeText).toHaveBeenCalledWith( 'mock-jwt-token-value' diff --git a/openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/Profile/tabs/bots/BotTokenSection.tsx b/openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/Profile/tabs/bots/BotTokenSection.tsx index 95cb92925a7a..f2d0912be2e8 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/Profile/tabs/bots/BotTokenSection.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/Profile/tabs/bots/BotTokenSection.tsx @@ -20,7 +20,7 @@ import { Select, Typography, } from '@openmetadata/ui-core-components'; -import { Alert, Copy01 } from '@openmetadata/ui-core-components/icons'; +import { Alert } from '@openmetadata/ui-core-components/icons'; import { AxiosError } from 'axios'; import React, { useCallback, useMemo, useState } from 'react'; import { useTranslation } from 'react-i18next'; @@ -37,10 +37,8 @@ import { getTokenIssuedAtMs, } from '../../../../../../utils/BotsUtils'; import { formatDateTimeLong } from '../../../../../../utils/date-time/DateTimeUtils'; -import { - showErrorToast, - showSuccessToast, -} from '../../../../../../utils/ToastUtils'; +import { showErrorToast } from '../../../../../../utils/ToastUtils'; +import CopyButton from '../../../../../common/CopyButton/CopyButton'; import { TOKEN_EXPIRY_OPTIONS } from './BotToken.constants'; interface BotTokenSectionProps { @@ -94,13 +92,6 @@ const BotTokenSection: React.FC = ({ [t] ); - const handleCopy = useCallback(() => { - if (jwtToken) { - void navigator.clipboard.writeText(jwtToken); - showSuccessToast(t('message.copied-to-clipboard')); - } - }, [jwtToken, t]); - const handleGenerate = useCallback(async () => { setIsUpdating(true); @@ -205,14 +196,12 @@ const BotTokenSection: React.FC = ({ type="password" value={jwtToken} /> - + = ({ } }, []); - const handleCopyPassword = async () => { - if (!generatedPassword) { - return; - } - await navigator.clipboard.writeText(generatedPassword); - showSuccessToast(t('message.copied-to-clipboard')); - }; - const fetchTeams = useCallback(async () => { try { const { data } = await getTeamsHierarchy(); @@ -520,13 +512,13 @@ const MembersCreateUserForm: React.FC = ({ tooltip={String(t('label.regenerate'))} onClick={generateRandomPassword} /> - } diff --git a/openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/Profile/tabs/personas/PersonaDetail.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/Profile/tabs/personas/PersonaDetail.test.tsx index 4511b51f1e51..7ae16376fd8b 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/Profile/tabs/personas/PersonaDetail.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/Profile/tabs/personas/PersonaDetail.test.tsx @@ -157,6 +157,7 @@ jest.mock( ); jest.mock('@openmetadata/ui-core-components/icons', () => ({ + Check: () => , CheckCircle: () => , Copy01: () => , Edit01: () => , @@ -694,7 +695,7 @@ describe('PersonaDetail', () => { ); expect(screen.getByTestId('copy-persona-link')).toHaveAttribute( 'aria-label', - 'message.link-copy-to-clipboard' + 'label.copied' ); }); diff --git a/openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/Profile/tabs/personas/PersonaDetail.tsx b/openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/Profile/tabs/personas/PersonaDetail.tsx index 316a18c8254c..f816bf1d1a43 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/Profile/tabs/personas/PersonaDetail.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/Profile/tabs/personas/PersonaDetail.tsx @@ -22,7 +22,6 @@ import { } from '@openmetadata/ui-core-components'; import { CheckCircle, - Copy01, Edit01 as Edit, Trash01 as Delete, } from '@openmetadata/ui-core-components/icons'; @@ -42,7 +41,6 @@ import { EntityType } from '../../../../../../enums/entity.enum'; import { ResourceEntity } from '../../../../../../enums/permissions.enum'; import { Persona } from '../../../../../../generated/entity/teams/persona'; import { EntityReference } from '../../../../../../generated/entity/type'; -import { useClipboard } from '../../../../../../hooks/useClipBoard'; import { useEntityPermissions } from '../../../../../../hooks/useEntityPermissions/useEntityPermissions'; import { getPersonaByName, @@ -53,6 +51,7 @@ import { showErrorToast, showSuccessToast, } from '../../../../../../utils/ToastUtils'; +import CopyButton from '../../../../../common/CopyButton/CopyButton'; import DeleteEntityPopover from '../../../../../common/DeleteWidget/DeleteEntityPopover'; import Loader from '../../../../../common/Loader/Loader'; import RichTextEditor from '../../../../../common/RichTextEditor/RichTextEditor'; @@ -116,11 +115,9 @@ const PersonaDetail: FC = ({ } = useEntityPermissions(ResourceEntity.PERSONA, fqn); // Deep link that reopens this persona in the personal-space modal. - const { onCopyToClipBoard, hasCopied } = useClipboard( - `${globalThis.location.origin}${ - globalThis.location.pathname - }#personas/${viewToSubPath({ type: 'detail', fqn, name: fqn })}` - ); + const personaLink = `${globalThis.location.origin}${ + globalThis.location.pathname + }#personas/${viewToSubPath({ type: 'detail', fqn, name: fqn })}`; const fetchPersona = useCallback(async () => { const requestId = ++fetchRequestIdRef.current; @@ -280,16 +277,12 @@ const PersonaDetail: FC = ({ return ( - onCopyToClipBoard()} + value={personaLink} /> = ({ /> ); - }, [ - isRenameOpen, - persona, - canEditDescription, - hasCopied, - onCopyToClipBoard, - t, - ]); + }, [isRenameOpen, persona, canEditDescription, personaLink, t]); const actionsNode = useMemo(() => { if (isRenameOpen || !persona) { diff --git a/openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/Profile/tabs/platform-settings/HealthCheckCard.tsx b/openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/Profile/tabs/platform-settings/HealthCheckCard.tsx index 57197809dd6b..ab4fe5dacc66 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/Profile/tabs/platform-settings/HealthCheckCard.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/Profile/tabs/platform-settings/HealthCheckCard.tsx @@ -22,7 +22,6 @@ import { CheckCircle, ChevronDown, ChevronUp, - Copy01, InfoCircle, XCircle, } from '@openmetadata/ui-core-components/icons'; @@ -31,7 +30,7 @@ import { startCase } from 'lodash'; import { useState } from 'react'; import { useTranslation } from 'react-i18next'; import { StepValidation } from '../../../../../../generated/system/validationResponse'; -import { useClipboard } from '../../../../../../hooks/useClipBoard'; +import CopyButton from '../../../../../common/CopyButton/CopyButton'; const STATUS_STYLES = { passed: { @@ -55,7 +54,6 @@ const STATUS_STYLES = { const HealthCheckLogs = ({ logs }: { logs: string }) => { const { t } = useTranslation(); const [isOpen, setIsOpen] = useState(false); - const { onCopyToClipBoard } = useClipboard(logs); return ( <> @@ -84,14 +82,12 @@ const HealthCheckLogs = ({ logs }: { logs: string }) => { weight="medium"> {t('label.log-plural')} - +
             {logs}
diff --git a/openmetadata-ui/src/main/resources/ui/src/components/observability/TestCaseDetail/TestCaseDetail.tsx b/openmetadata-ui/src/main/resources/ui/src/components/observability/TestCaseDetail/TestCaseDetail.tsx
index 36327950341f..aaa289fd1fb6 100644
--- a/openmetadata-ui/src/main/resources/ui/src/components/observability/TestCaseDetail/TestCaseDetail.tsx
+++ b/openmetadata-ui/src/main/resources/ui/src/components/observability/TestCaseDetail/TestCaseDetail.tsx
@@ -26,12 +26,11 @@ import {
 import { useQuery } from '@tanstack/react-query';
 import classNames from 'classnames';
 import { isUndefined, toString } from 'lodash';
-import { useCallback, useMemo } from 'react';
+import { useMemo } from 'react';
 import { useTranslation } from 'react-i18next';
 import { useNavigate } from 'react-router-dom';
 import { EntityType } from '../../../enums/entity.enum';
 import { ServiceCategory } from '../../../enums/service.enum';
-import { useClipboard } from '../../../hooks/useClipBoard';
 import useCustomLocation from '../../../hooks/useCustomLocation/useCustomLocation';
 import { TestCasePageTabs } from '../../../pages/IncidentManager/IncidentManager.interface';
 import { TEST_CASE_NEXT_RUN_QUERY_KEY } from '../../../pages/IncidentManager/IncidentManagerDetailPage/IncidentManagerDetailPage.constants';
@@ -288,12 +287,6 @@ const TestCaseDetail = ({ isVersionPage = false }: TestCaseDetailProps) => {
     return buildCrumbs();
   }, [t, testCase, isDimensionPage, dimensionKey, originBreadcrumb]);
 
-  const { onCopyToClipBoard, hasCopied } = useClipboard('', 2000);
-
-  const handleCopyEntityUrl = useCallback(async () => {
-    await onCopyToClipBoard(globalThis.location.href);
-  }, [onCopyToClipBoard]);
-
   if (isLoading) {
     return ;
   }
@@ -398,9 +391,7 @@ const TestCaseDetail = ({ isVersionPage = false }: TestCaseDetailProps) => {
                   
                 
                 
diff --git a/openmetadata-ui/src/main/resources/ui/src/components/observability/TestSuiteDetail/TestSuiteDetail.tsx b/openmetadata-ui/src/main/resources/ui/src/components/observability/TestSuiteDetail/TestSuiteDetail.tsx
index 96caed882a53..c385b15f9823 100644
--- a/openmetadata-ui/src/main/resources/ui/src/components/observability/TestSuiteDetail/TestSuiteDetail.tsx
+++ b/openmetadata-ui/src/main/resources/ui/src/components/observability/TestSuiteDetail/TestSuiteDetail.tsx
@@ -13,7 +13,6 @@
 import {
   Box,
   Button,
-  ButtonUtility,
   Dialog,
   DialogTrigger,
   FeaturedIcon,
@@ -25,18 +24,14 @@ import {
   Tabs,
   Typography,
 } from '@openmetadata/ui-core-components';
-import {
-  Copy01,
-  TestSuite as TestSuiteIcon,
-} from '@openmetadata/ui-core-components/icons';
+import { TestSuite as TestSuiteIcon } from '@openmetadata/ui-core-components/icons';
 import classNames from 'classnames';
 import { isUndefined, toString } from 'lodash';
-import { ComponentProps, useCallback, useMemo } from 'react';
+import { ComponentProps, useMemo } from 'react';
 import { useTranslation } from 'react-i18next';
 import { useNavigate } from 'react-router-dom';
 import { EntityTabs, EntityType } from '../../../enums/entity.enum';
 import { Operation } from '../../../generated/entity/policies/policy';
-import { useClipboard } from '../../../hooks/useClipBoard';
 import { DataQualityPageTabs } from '../../../pages/DataQuality/DataQualityPage.interface';
 import '../../../pages/TestSuiteDetailsPage/test-suite-details-page.less';
 import { useTestSuiteDetailsPage } from '../../../pages/TestSuiteDetailsPage/useTestSuiteDetailsPage';
@@ -45,6 +40,7 @@ import { getEntityName } from '../../../utils/EntityNameUtils';
 import observabilityRouterClassBase from '../../../utils/ObservabilityRouterClassBase';
 import { getDerivedPermissionFlags } from '../../../utils/PermissionDerivation';
 import { useListSearchInput } from '../../common/atoms/navigation/useListSearchInput';
+import CopyButton from '../../common/CopyButton/CopyButton';
 import DocumentTitle from '../../common/DocumentTitle/DocumentTitle';
 import { DomainLabel } from '../../common/DomainLabel/DomainLabel.component';
 import NoDataPlaceholder from '../../common/EmptyPlaceholder/NoDataPlaceholder';
@@ -269,17 +265,6 @@ const TestSuiteDetail = () => {
     [t, testSuite]
   );
 
-  const { onCopyToClipBoard, hasCopied } = useClipboard('', 2000);
-
-  const handleCopyEntityUrl = useCallback(async () => {
-    await onCopyToClipBoard(globalThis.location.href);
-  }, [onCopyToClipBoard]);
-
-  const getCopyTooltipTitle = () =>
-    hasCopied
-      ? t('message.link-copy-to-clipboard')
-      : t('label.copy-item', { item: t('label.url-uppercase') });
-
   const activeTabContent = useMemo(() => {
     const renderDescription = () => (
       
@@ -442,12 +427,12 @@ const TestSuiteDetail = () => { displayName={testSuite?.displayName} name={testSuite?.name} /> - diff --git a/openmetadata-ui/src/main/resources/ui/src/components/observability/profiler/ExecutionSource/ExecutionSource.tsx b/openmetadata-ui/src/main/resources/ui/src/components/observability/profiler/ExecutionSource/ExecutionSource.tsx index b4e2da4c38c2..3fbbbc589473 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/observability/profiler/ExecutionSource/ExecutionSource.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/observability/profiler/ExecutionSource/ExecutionSource.tsx @@ -10,15 +10,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { - Box, - ButtonUtility, - Typography, -} from '@openmetadata/ui-core-components'; -import { Check, Copy01 } from '@openmetadata/ui-core-components/icons'; +import { Box, Typography } from '@openmetadata/ui-core-components'; import { useTranslation } from 'react-i18next'; import { TableExecutionSource } from '../../../../generated/type/tableExecutionSource'; -import { useClipboard } from '../../../../hooks/useClipBoard'; +import CopyButton from '../../../common/CopyButton/CopyButton'; interface ExecutionSourceProps { source?: TableExecutionSource; @@ -37,7 +32,6 @@ export const ExecutionSource = ({ const physicalName = source ? `${source.databaseName}.${source.schemaName}.${source.tableName}` : undefined; - const { hasCopied, onCopyToClipBoard } = useClipboard(physicalName ?? ''); if (!source && !isSharded) { return null; @@ -53,16 +47,11 @@ export const ExecutionSource = ({ {physicalName ?? t('message.execution-source-unavailable')} {physicalName && copyable && ( - onCopyToClipBoard(physicalName)} + testId="copy-execution-source" + tooltip={t('message.copy-to-clipboard')} + value={physicalName} /> )} diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/IncidentManager/IncidentManagerDetailPage/IncidentManagerDetailPage.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/IncidentManager/IncidentManagerDetailPage/IncidentManagerDetailPage.tsx index 0f99d6a7372b..d5d7c28cdbef 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/IncidentManager/IncidentManagerDetailPage/IncidentManagerDetailPage.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/IncidentManager/IncidentManagerDetailPage/IncidentManagerDetailPage.tsx @@ -18,7 +18,7 @@ import { import { useQuery } from '@tanstack/react-query'; import classNames from 'classnames'; import { isUndefined, toString } from 'lodash'; -import { useCallback, useMemo } from 'react'; +import { useMemo } from 'react'; import { useTranslation } from 'react-i18next'; import { useNavigate } from 'react-router-dom'; import { withActivityFeed } from '../../../components/AppRouter/withActivityFeed'; @@ -39,7 +39,6 @@ import PageLayoutV1 from '../../../components/PageLayoutV1/PageLayoutV1'; import { EntityType } from '../../../enums/entity.enum'; import { ServiceCategory } from '../../../enums/service.enum'; import { useIsAiMode } from '../../../hooks/useAppMode'; -import { useClipboard } from '../../../hooks/useClipBoard'; import useCustomLocation from '../../../hooks/useCustomLocation/useCustomLocation'; import { DetailsTabItem, @@ -270,12 +269,6 @@ const IncidentManagerDetailPage = ({ [breadcrumb] ); - const { onCopyToClipBoard, hasCopied } = useClipboard('', 2000); - - const handleCopyEntityUrl = useCallback(async () => { - await onCopyToClipBoard(globalThis.location.href); - }, [onCopyToClipBoard]); - if (isLoading) { return ; } @@ -353,9 +346,7 @@ const IncidentManagerDetailPage = ({ diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/IncidentManager/IncidentManagerDetailPage/TestCaseHeaderTitle.component.test.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/IncidentManager/IncidentManagerDetailPage/TestCaseHeaderTitle.component.test.tsx index aac8c412c449..1daf61f2714d 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/IncidentManager/IncidentManagerDetailPage/TestCaseHeaderTitle.component.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/IncidentManager/IncidentManagerDetailPage/TestCaseHeaderTitle.component.test.tsx @@ -11,25 +11,34 @@ * limitations under the License. */ -import { fireEvent, render, screen } from '@testing-library/react'; +import { act, fireEvent, render, screen } from '@testing-library/react'; import TestCaseHeaderTitle from './TestCaseHeaderTitle.component'; -const mockOnCopy = jest.fn().mockResolvedValue(undefined); +const mockWriteText = jest.fn().mockResolvedValue(undefined); const DISPLAY_NAME_TEST_ID = 'entity-header-display-name'; const TECHNICAL_NAME_TEST_ID = 'entity-header-name'; describe('TestCaseHeaderTitle', () => { + beforeAll(() => { + Object.defineProperty(window, 'isSecureContext', { + value: true, + configurable: true, + }); + Object.defineProperty(navigator, 'clipboard', { + value: { writeText: mockWriteText }, + configurable: true, + }); + }); + beforeEach(() => { - mockOnCopy.mockClear(); + mockWriteText.mockClear(); }); - it('renders display and technical names and invokes the copy action', () => { + it('renders display and technical names and copies the page url', async () => { render( ); @@ -42,18 +51,18 @@ describe('TestCaseHeaderTitle', () => { ); expect(screen.getByTestId(TECHNICAL_NAME_TEST_ID).tagName).toBe('SPAN'); - fireEvent.click(screen.getByTestId('entity-header-copy-button')); + await act(async () => { + fireEvent.click(screen.getByTestId('entity-header-copy-button')); + }); - expect(mockOnCopy).toHaveBeenCalledTimes(1); + expect(mockWriteText).toHaveBeenCalledWith(globalThis.location.href); }); it('renders the technical name as the heading without a display name', () => { render( ); @@ -69,9 +78,7 @@ describe('TestCaseHeaderTitle', () => { ); @@ -87,9 +94,7 @@ describe('TestCaseHeaderTitle', () => { ); diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/IncidentManager/IncidentManagerDetailPage/TestCaseHeaderTitle.component.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/IncidentManager/IncidentManagerDetailPage/TestCaseHeaderTitle.component.tsx index cc1158235c52..96b5786d45c7 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/IncidentManager/IncidentManagerDetailPage/TestCaseHeaderTitle.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/IncidentManager/IncidentManagerDetailPage/TestCaseHeaderTitle.component.tsx @@ -11,15 +11,11 @@ * limitations under the License. */ -import { - Box, - ButtonUtility, - Typography, -} from '@openmetadata/ui-core-components'; -import { Copy01 } from '@openmetadata/ui-core-components/icons'; +import { Box, Typography } from '@openmetadata/ui-core-components'; import classNames from 'classnames'; import type { ReactNode } from 'react'; import { useTranslation } from 'react-i18next'; +import CopyButton from '../../../components/common/CopyButton/CopyButton'; import type { TestCase } from '../../../generated/tests/testCase'; import { renderHighlightedText } from '../../../utils/EntitySearchUtils'; import type { UseTestCaseDetailPageResult } from './useTestCaseDetailPage'; @@ -27,9 +23,7 @@ import type { UseTestCaseDetailPageResult } from './useTestCaseDetailPage'; interface TestCaseHeaderTitleProps { deleted?: TestCase['deleted']; displayName: UseTestCaseDetailPageResult['displayName']; - hasCopied: boolean; testCaseName: TestCase['name']; - onCopy: () => Promise; } const breakableTooltipText = (text?: ReactNode) => ( @@ -39,9 +33,7 @@ const breakableTooltipText = (text?: ReactNode) => ( const TestCaseHeaderTitle = ({ deleted, displayName, - hasCopied, testCaseName, - onCopy, }: TestCaseHeaderTitleProps) => { const { t } = useTranslation(); @@ -88,18 +80,10 @@ const TestCaseHeaderTitle = ({ {t('label.deleted')} )} - ); diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/SearchIndexDetailsPage/SearchIndexFieldsTable/SearchIndexFieldsTable.test.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/SearchIndexDetailsPage/SearchIndexFieldsTable/SearchIndexFieldsTable.test.tsx index 6af26b3d6923..c3576ace14e6 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/SearchIndexDetailsPage/SearchIndexFieldsTable/SearchIndexFieldsTable.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/SearchIndexDetailsPage/SearchIndexFieldsTable/SearchIndexFieldsTable.test.tsx @@ -141,6 +141,11 @@ jest.mock('../../../utils/RouterUtils', () => ({ getEntityDetailsPath: jest .fn() .mockImplementation((_entityType, fqn) => `/searchIndex/${fqn}`), + getEntityDetailsUrl: jest + .fn() + .mockImplementation( + (_entityType, fqn) => `http://localhost/searchIndex/${fqn}` + ), })); describe('SearchIndexFieldsTable component', () => { diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/SearchIndexDetailsPage/SearchIndexFieldsTable/SearchIndexFieldsTable.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/SearchIndexDetailsPage/SearchIndexFieldsTable/SearchIndexFieldsTable.tsx index 5929f7b6c888..4b3b64422bf6 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/SearchIndexDetailsPage/SearchIndexFieldsTable/SearchIndexFieldsTable.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/SearchIndexDetailsPage/SearchIndexFieldsTable/SearchIndexFieldsTable.tsx @@ -30,7 +30,7 @@ import { } from '../../../components/common/Table/Table.interface'; import withSuspenseFallback from '../../../components/AppRouter/withSuspenseFallback'; -import CopyLinkButton from '../../../components/common/CopyLinkButton/CopyLinkButton'; +import CopyButton from '../../../components/common/CopyButton/CopyButton'; import NoSearchResultsPlaceholder from '../../../components/common/EmptyPlaceholder/NoSearchResultsPlaceholder'; import { EntityAttachmentProvider } from '../../../components/common/EntityDescription/EntityAttachmentProvider/EntityAttachmentProvider'; import Table from '../../../components/common/Table/TableV2'; @@ -68,6 +68,7 @@ import { } from '../../../utils/EntitySearchUtils'; import { getColumnSorter } from '../../../utils/EntitySortUtils'; import { getDerivedPermissionFlags } from '../../../utils/PermissionDerivation'; +import { getEntityDetailsUrl } from '../../../utils/RouterUtils'; import { makeData } from '../../../utils/SearchIndexUtils'; import { columnFilterIcon } from '../../../utils/TableColumn.util'; import { @@ -318,9 +319,15 @@ const SearchIndexFieldsTable = ({ highlightSearchText(getEntityName(record), searchText) )} -
), diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/TestSuiteDetailsPage/TestSuiteDetailsPage.component.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/TestSuiteDetailsPage/TestSuiteDetailsPage.component.tsx index 2376b3ca6e13..94f802c509d6 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/TestSuiteDetailsPage/TestSuiteDetailsPage.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/TestSuiteDetailsPage/TestSuiteDetailsPage.component.tsx @@ -14,7 +14,6 @@ import { Box, Button, - ButtonUtility, Dialog, DialogTrigger, FeaturedIcon, @@ -25,16 +24,14 @@ import { Tabs, Typography, } from '@openmetadata/ui-core-components'; -import { - Copy01, - TestSuite as TestSuiteIcon, -} from '@openmetadata/ui-core-components/icons'; +import { TestSuite as TestSuiteIcon } from '@openmetadata/ui-core-components/icons'; import classNames from 'classnames'; import { isUndefined } from 'lodash'; -import { ComponentProps, useCallback, useMemo } from 'react'; +import { ComponentProps, useMemo } from 'react'; import { useTranslation } from 'react-i18next'; import { useNavigate } from 'react-router-dom'; import { useListSearchInput } from '../../components/common/atoms/navigation/useListSearchInput'; +import CopyButton from '../../components/common/CopyButton/CopyButton'; import { DomainLabel } from '../../components/common/DomainLabel/DomainLabel.component'; import NoDataPlaceholder from '../../components/common/EmptyPlaceholder/NoDataPlaceholder'; import PermissionPlaceholder from '../../components/common/EmptyPlaceholder/PermissionPlaceholder'; @@ -54,7 +51,6 @@ import { LEARNING_PAGE_IDS } from '../../constants/Learning.constants'; import { EntityTabs, EntityType } from '../../enums/entity.enum'; import { Operation } from '../../generated/entity/policies/policy'; import { EntityReference } from '../../generated/entity/type'; -import { useClipboard } from '../../hooks/useClipBoard'; import { DataQualityPageTabs } from '../../pages/DataQuality/DataQualityPage.interface'; import { getRenderedActiveTab } from '../../utils/CustomizePage/CustomizePageEntityTabUtils'; import { HeaderDotSeparator } from '../../utils/DataAssetsHeader.utils'; @@ -71,15 +67,11 @@ const breakableTooltipText = (text?: string) => ( interface TestSuiteHeaderTitleProps { displayName?: string; name?: string; - hasCopied: boolean; - onCopyEntityUrl: () => void; } const TestSuiteHeaderTitle = ({ displayName, name, - hasCopied, - onCopyEntityUrl, }: TestSuiteHeaderTitleProps) => { const { t } = useTranslation(); @@ -121,18 +113,10 @@ const TestSuiteHeaderTitle = ({ {name}
- @@ -287,12 +271,6 @@ const TestSuiteDetailsPage = () => { [slashedBreadCrumb] ); - const { onCopyToClipBoard, hasCopied } = useClipboard('', 2000); - - const handleCopyEntityUrl = useCallback(async () => { - await onCopyToClipBoard(globalThis.location.href); - }, [onCopyToClipBoard]); - const tabItems: TabProps[] = useMemo(() => { const renderDescription = () => (
@@ -467,9 +445,7 @@ const TestSuiteDetailsPage = () => { /> diff --git a/openmetadata-ui/src/main/resources/ui/src/utils/RouterUtils.ts b/openmetadata-ui/src/main/resources/ui/src/utils/RouterUtils.ts index dc5d44fe4068..8851dd1a2f74 100644 --- a/openmetadata-ui/src/main/resources/ui/src/utils/RouterUtils.ts +++ b/openmetadata-ui/src/main/resources/ui/src/utils/RouterUtils.ts @@ -785,6 +785,9 @@ export const getEntityDetailsPath = ( return path; }; +export const getEntityDetailsUrl = (entityType: EntityType, fqn: string) => + `${window.location.origin}${getEntityDetailsPath(entityType, fqn)}`; + export const getGlossaryTermDetailsPath = ( glossaryFQN: string, tab?: string, diff --git a/openmetadata-ui/src/main/resources/ui/src/utils/TestConnectionModalUtils.tsx b/openmetadata-ui/src/main/resources/ui/src/utils/TestConnectionModalUtils.tsx index 94e9304a28ea..764fc3fc3c3d 100644 --- a/openmetadata-ui/src/main/resources/ui/src/utils/TestConnectionModalUtils.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/utils/TestConnectionModalUtils.tsx @@ -25,7 +25,6 @@ import { ChevronDown, ChevronRight, CloseCircleFilled, - Copy01, DotFilled, ExclamationCircleFilled, Lightbulb03, @@ -40,6 +39,7 @@ import { type ReactNode, type SetStateAction, } from 'react'; +import CopyButton from '../components/common/CopyButton/CopyButton'; import Loader from '../components/common/Loader/Loader'; import { ConnectionStepState, @@ -987,7 +987,6 @@ export function ConnectionFooterActions( isTestingConnection: boolean; onCancel: () => void; onConfirm: () => void; - onCopyToClipBoard: () => void; onTestConnection: () => void; rawLog: string; t: TranslateFn; @@ -999,7 +998,6 @@ export function ConnectionFooterActions( isTestingConnection, onCancel, onConfirm, - onCopyToClipBoard, onTestConnection, rawLog, t, @@ -1042,16 +1040,13 @@ export function ConnectionFooterActions( return ( <> - + label={t('label.copy-log')} + testId="copy-log-button" + value={rawLog} + /> {!isConnectionTimeout && !isTestingConnection && isFailed && (