diff --git a/openmetadata-ui/src/main/resources/ui/src/components/ActivityFeed/ActivityFeedCardNew/ActivityFeedcardNew.component.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/ActivityFeed/ActivityFeedCardNew/ActivityFeedcardNew.component.test.tsx index 96738a585915..16004e1cabbb 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/ActivityFeed/ActivityFeedCardNew/ActivityFeedcardNew.component.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/ActivityFeed/ActivityFeedCardNew/ActivityFeedcardNew.component.test.tsx @@ -31,6 +31,7 @@ import { ConversationSource, } from '../../../generated/entity/feed/conversation'; import { ReactionType } from '../../../generated/type/reaction'; +import UserPopOverCard from '../../common/PopOverCard/UserPopOverCard'; import ActivityFeedCardNew from './ActivityFeedcardNew.component'; const mockProviderValue = { @@ -216,6 +217,39 @@ describe('ActivityFeedCardNew', () => { ); }); + it.each([ + ['user', 'bob'], + ['team', 'Data Platform'], + ])( + 'opens the linked %s profile, not the author, from a conversation about it', + (entityType, name) => { + render( + + `, + entityRef: { + id: `${entityType}-id`, + type: entityType, + name, + fullyQualifiedName: name, + }, + }} + /> + + ); + + const entityLinkPopover = (UserPopOverCard as jest.Mock).mock.calls + .map(([props]) => props) + .find((props) => props.showUserName && !props.showUserProfile); + + expect(entityLinkPopover).toEqual( + expect.objectContaining({ type: entityType, userName: name }) + ); + } + ); + it('names the field a conversation was started on after the entity', () => { render( diff --git a/openmetadata-ui/src/main/resources/ui/src/components/ActivityFeed/ActivityFeedCardNew/ActivityFeedcardNew.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/ActivityFeed/ActivityFeedCardNew/ActivityFeedcardNew.component.tsx index 940d45ef4182..2fd2b67611c3 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/ActivityFeed/ActivityFeedCardNew/ActivityFeedcardNew.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/ActivityFeed/ActivityFeedCardNew/ActivityFeedcardNew.component.tsx @@ -26,6 +26,7 @@ import { useTranslation } from 'react-i18next'; import { Link } from 'react-router-dom'; import withSuspenseFallback from '../../../components/AppRouter/withSuspenseFallback'; import { EntityType } from '../../../enums/entity.enum'; +import { OwnerType } from '../../../enums/user.enum'; import { ActivityEvent } from '../../../generated/entity/activity/activityEvent'; import { Conversation, @@ -112,6 +113,9 @@ const getFeedCardWrapperClassName = ( { 'active-card is-active': isActive } ); +const getLinkedOwnerType = (entityType: EntityType): OwnerType => + entityType === EntityType.TEAM ? OwnerType.TEAM : OwnerType.USER; + interface ThreadPanelEntityLinkProps { about: string; entityFQN: string; @@ -302,7 +306,8 @@ const ActivityFeedCardNew = ({ + type={getLinkedOwnerType(entityType)} + userName={entityFQN}> { + it.each([ + ['a conversation', { feed: conversation }], + ['an activity', { activity }], + ])( + 'renders a plain card, not a focusable button, for %s nobody handles a press on', + (_, props) => { + render(); + + const card = screen.getByTestId('message-container'); + + expect(card).not.toHaveAttribute('role'); + expect(card).not.toHaveAttribute('tabindex'); + } + ); + it('opens the conversation from a click anywhere on the card', () => { const onFeedClick = jest.fn(); render( @@ -57,6 +84,27 @@ describe('FeedPanelBodyV1New', () => { expect(onFeedClick).toHaveBeenCalledWith(conversation); }); + it('opens the activity from a click or Enter/Space on the card', () => { + const onActivityClick = jest.fn(); + render( + + ); + const card = screen.getByTestId('message-container'); + + expect(card).toHaveAttribute('role', 'button'); + expect(card).toHaveAttribute('tabindex', '0'); + + fireEvent.click(screen.getByTestId('card-content')); + fireEvent.keyDown(card, { key: 'Enter' }); + fireEvent.keyDown(card, { key: ' ' }); + + expect(onActivityClick).toHaveBeenCalledTimes(3); + expect(onActivityClick).toHaveBeenCalledWith(activity); + }); + it('opens the conversation only from Reply in the thread panel', () => { const onFeedClick = jest.fn(); render( diff --git a/openmetadata-ui/src/main/resources/ui/src/components/ActivityFeed/ActivityFeedPanel/FeedPanelBodyV1New.tsx b/openmetadata-ui/src/main/resources/ui/src/components/ActivityFeed/ActivityFeedPanel/FeedPanelBodyV1New.tsx index 0a14f2899d70..34864a216bd4 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/ActivityFeed/ActivityFeedPanel/FeedPanelBodyV1New.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/ActivityFeed/ActivityFeedPanel/FeedPanelBodyV1New.tsx @@ -12,6 +12,7 @@ */ import { Card } from '@openmetadata/ui-core-components'; +import classNames from 'classnames'; import { isUndefined } from 'lodash'; import { FC, useCallback } from 'react'; import ActivityFeedCardNew from '../ActivityFeedCardNew/ActivityFeedcardNew.component'; @@ -22,6 +23,21 @@ import { import './feed-panel-body-v1.less'; import { FeedPanelBodyPropV1 } from './FeedPanelBodyV1.interface'; +// The card is a button only when someone handles its press. +const getCardContainerProps = (onActivate?: () => void) => ({ + className: classNames( + 'activity-feed-card-container', + CARD_CONTAINER_CLASS_NAME, + { 'tw:cursor-pointer': onActivate } + ), + ...(onActivate && { + role: 'button', + tabIndex: 0, + onClick: onActivate, + onKeyDown: handleCardContainerKeyDown(onActivate), + }), +}); + const FeedPanelBodyV1: FC = ({ feed, activity, @@ -51,13 +67,11 @@ const FeedPanelBodyV1: FC = ({ if (isActivityEvent) { return ( + {...getCardContainerProps( + onActivityClick ? handleActivityClick : undefined + )}> = ({ return ( + {...getCardContainerProps(onFeedClick ? handleFeedClick : undefined)}> ({ isRecognizerFeedbackTask: jest.fn().mockReturnValue(false), })); +jest.mock('../../../utils/ToastUtils', () => ({ + showErrorToast: jest.fn(), + showSuccessToast: jest.fn(), +})); + jest.mock('../../../utils/TaskNavigationUtils', () => ({ ...jest.requireActual('../../../utils/TaskNavigationUtils'), getTaskDetailPathFromTask: jest.fn().mockReturnValue('/tasks/1'), @@ -366,6 +372,34 @@ describe('TaskFeedCardFromTask', () => { expect(screen.queryByTestId('approve-button')).not.toBeInTheDocument(); }); + it('tells the voter their vote is recorded while the task waits for other approvers', async () => { + const assignedTask: Task = { + ...MOCK_TASK, + assignees: [ + { + id: 'current-user-id', + type: 'user', + name: 'current-user', + }, + ], + }; + (resolveTask as jest.Mock).mockResolvedValueOnce(assignedTask); + + await act(async () => { + render(, { + wrapper: MemoryRouter, + }); + }); + + fireEvent.click(screen.getByTestId('approve-button')); + + await waitFor(() => + expect(showSuccessToast).toHaveBeenCalledWith( + 'message.vote-recorded-waiting-for-other-approvers' + ) + ); + }); + it('approves and rejects an assigned task through the Task V2 API', async () => { const assignedTask: Task = { ...MOCK_TASK, diff --git a/openmetadata-ui/src/main/resources/ui/src/components/ActivityFeed/TaskFeedCard/TaskFeedCardFromTask.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/ActivityFeed/TaskFeedCard/TaskFeedCardFromTask.component.tsx index 1cf46aa2cb60..055b5b2ea532 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/ActivityFeed/TaskFeedCard/TaskFeedCardFromTask.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/ActivityFeed/TaskFeedCard/TaskFeedCardFromTask.component.tsx @@ -293,7 +293,7 @@ const TaskFeedCardFromTask = ({ ); showSuccessToast( isTaskPendingFurtherApproval(updatedTask) - ? 'Vote recorded.' + ? t('message.vote-recorded-waiting-for-other-approvers') : t('server.task-resolved-successfully') ); onAfterClose?.(); diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Entity/Task/TaskTab/TaskTabNew.component.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Entity/Task/TaskTab/TaskTabNew.component.test.tsx index d09752615e07..ceb96b088201 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Entity/Task/TaskTab/TaskTabNew.component.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Entity/Task/TaskTab/TaskTabNew.component.test.tsx @@ -339,9 +339,11 @@ jest.mock( ); const mockShowErrorToast = jest.fn(); +const mockShowSuccessToast = jest.fn(); jest.mock('../../../../utils/ToastUtils', () => ({ ...jest.requireActual('../../../../utils/ToastUtils'), showErrorToast: (...args: unknown[]) => mockShowErrorToast(...args), + showSuccessToast: (...args: unknown[]) => mockShowSuccessToast(...args), })); jest.mock('../../../../rest/tasksAPI', () => ({ @@ -1544,6 +1546,10 @@ describe('TaskTabNew Component', () => { }, }); }); + + expect(mockShowSuccessToast).toHaveBeenCalledWith( + 'message.vote-recorded-waiting-for-other-approvers' + ); }); it('keeps workflow-driven tasks actionable outside the Open status', async () => { diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Entity/Task/TaskTab/TaskTabNew.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Entity/Task/TaskTab/TaskTabNew.component.tsx index 1375a67cf508..b4eb76ab0368 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Entity/Task/TaskTab/TaskTabNew.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Entity/Task/TaskTab/TaskTabNew.component.tsx @@ -776,7 +776,7 @@ export const TaskTabNew = ({ const taskRemainsOpen = isTaskPendingFurtherApproval(updatedTask); showSuccessToast( taskRemainsOpen - ? 'Vote recorded.' + ? t('message.vote-recorded-waiting-for-other-approvers') : t('server.task-resolved-successfully') ); diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Glossary/GlossaryTermTab/GlossaryTermTab.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Glossary/GlossaryTermTab/GlossaryTermTab.component.tsx index e2eed88c9e2e..aa974da9fe9e 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Glossary/GlossaryTermTab/GlossaryTermTab.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Glossary/GlossaryTermTab/GlossaryTermTab.component.tsx @@ -1138,7 +1138,7 @@ const GlossaryTermTab = ({ isGlossary, className }: GlossaryTermTabProps) => { showSuccessToast( isPendingFurtherApproval - ? 'Vote recorded.' + ? t('message.vote-recorded') : t('server.task-resolved-successfully') ); diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Glossary/GlossaryTermTab/GlossaryTermTab.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Glossary/GlossaryTermTab/GlossaryTermTab.test.tsx index f483bd1a57ee..d35b80e5909b 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Glossary/GlossaryTermTab/GlossaryTermTab.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Glossary/GlossaryTermTab/GlossaryTermTab.test.tsx @@ -1279,7 +1279,9 @@ describe('Test GlossaryTermTab component', () => { ); }); - expect(mockShowSuccessToast).toHaveBeenCalledWith('Vote recorded.'); + expect(mockShowSuccessToast).toHaveBeenCalledWith( + 'message.vote-recorded' + ); expect(mockSetGlossaryChildTerms).not.toHaveBeenCalled(); }); diff --git a/openmetadata-ui/src/main/resources/ui/src/hoc/withDomainFilter.test.tsx b/openmetadata-ui/src/main/resources/ui/src/hoc/withDomainFilter.test.tsx index 2f73da50bf0c..9db2c84e1bc9 100644 --- a/openmetadata-ui/src/main/resources/ui/src/hoc/withDomainFilter.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/hoc/withDomainFilter.test.tsx @@ -212,6 +212,14 @@ describe('withDomainFilter', () => { '/activity/entity/table/7f8baaa6-6bf2-4b57-9a16-dcc0a38746b6', { days: 30 }, ], + [ + '/activity/about', + { entityLink: '<#E::table::svc.db.sch.orders>', days: 30, limit: 200 }, + ], + [ + '/activity/mentions', + { entityLink: '<#E::table::svc.db.sch.orders>', days: 30, limit: 200 }, + ], ])("should leave an asset's own activity unscoped (%s)", (url, params) => { (getPathNameFromWindowLocation as jest.Mock).mockReturnValue( '/table/svc.db.sch.orders' @@ -246,20 +254,23 @@ describe('withDomainFilter', () => { } ); - it('should scope the activity feed, which is a list across assets', () => { - (getPathNameFromWindowLocation as jest.Mock).mockReturnValue('/'); - mockGetState.mockReturnValue({ activeDomain: 'engineering' }); + it.each(['/activity', '/activity/mentions'])( + 'should scope the activity feed, which is a list across assets (%s)', + (url) => { + (getPathNameFromWindowLocation as jest.Mock).mockReturnValue('/'); + mockGetState.mockReturnValue({ activeDomain: 'engineering' }); - const result = withDomainFilter( - createMockConfig('get', '/activity', { days: 30, limit: 200 }) - ); + const result = withDomainFilter( + createMockConfig('get', url, { days: 30, limit: 200 }) + ); - expect(result.params).toEqual({ - days: 30, - limit: 200, - domain: 'engineering', - }); - }); + expect(result.params).toEqual({ + days: 30, + limit: 200, + domain: 'engineering', + }); + } + ); it.each([ ['/tasks', { aboutEntity: 'svc.db.sch.orders' }], diff --git a/openmetadata-ui/src/main/resources/ui/src/hoc/withDomainFilter.tsx b/openmetadata-ui/src/main/resources/ui/src/hoc/withDomainFilter.tsx index 5135873f17c9..aa4ed9275022 100644 --- a/openmetadata-ui/src/main/resources/ui/src/hoc/withDomainFilter.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/hoc/withDomainFilter.tsx @@ -34,13 +34,18 @@ const isTaskListAboutAssets = (config: InternalAxiosRequestConfig) => Boolean(config.url?.startsWith(`${TASKS_PATH}/`))) && ABOUT_ASSET_TASK_PARAMS.some((param) => Boolean(config.params?.[param])); -// An asset's own activity (its Activity tab) is not narrowed either; the activity feed is. +// An asset's own activity (its Activity tab, in either mode) is not narrowed either; the activity feed is. +const ACTIVITY_PATH = '/activity/'; const ASSET_ACTIVITY_PATH = '/activity/entity/'; +const isActivityAboutOneAsset = (config: InternalAxiosRequestConfig) => + Boolean(config.url?.startsWith(ASSET_ACTIVITY_PATH)) || + (Boolean(config.url?.startsWith(ACTIVITY_PATH)) && + Boolean(config.params?.entityLink)); + const isAboutOneAsset = (config: InternalAxiosRequestConfig) => config.method === 'get' && - (isTaskListAboutAssets(config) || - Boolean(config.url?.startsWith(ASSET_ACTIVITY_PATH))); + (isTaskListAboutAssets(config) || isActivityAboutOneAsset(config)); // A request about one asset never carries the pick, even when its caller passed one. const withoutDomain = (