Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ const FeedCardBodyNew = ({
onEditCancel,
showThread,
isForFeedTab,
isFeedWidget,
isThreadPanel,
}: FeedCardBodyV1Props) => {
const { t } = useTranslation();
Expand Down Expand Up @@ -267,10 +266,7 @@ const FeedCardBodyNew = ({
className={classNames(
'tw:overflow-y-auto',
showThread
? [
'tw:max-h-100',
isFeedWidget ? 'tw:mt-2.5 tw:px-4 tw:py-3' : 'tw:mt-5 tw:p-5',
]
? 'tw:mt-5 tw:max-h-100 tw:p-5'
: 'tw:mt-0.5 tw:max-h-50 tw:p-5 tw:scrollbar-hide',
// In the thread panels the card shares the drawer's surface, so the
// message sits recessed into it, as the Inbox's does. Elsewhere it does
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,11 @@ export interface FeedCardBodyV1Props {
feed?: Conversation;
activity?: ActivityEvent;
isEditPost: boolean;
className?: string;
message: string;
isPost?: boolean;
isOpenInDrawer?: boolean;
onUpdate?: (message: string) => void;
onEditCancel?: () => void;
showThread?: boolean;
isForFeedTab?: boolean;
isFeedWidget?: boolean;
/** In the activity thread panel, a message is edited in the comment edit form. */
isThreadPanel?: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import {
Box,
Card,
Divider,
Input,
SkeletonParagraph,
Tooltip,
Expand Down Expand Up @@ -86,15 +85,11 @@ const POST_SKELETON_KEYS = ['first', 'second', 'third'];
interface ActivityFeedCardNewProps {
feed?: Conversation;
activity?: ActivityEvent;
isPost?: boolean;
isActive?: boolean;
post?: ConversationReply;
showActivityFeedEditor?: boolean;
showThread?: boolean;
isForFeedTab?: boolean;
isOpenInDrawer?: boolean;
isFeedWidget?: boolean;
isFullSizeWidget?: boolean;
/** The activity thread panels' compact header, Inbox-style footer and replies. */
isThreadPanel?: boolean;
/** Replaces the footer reply's default of opening the thread drawer. */
Expand All @@ -105,17 +100,15 @@ interface ActivityFeedCardNewProps {
const getFeedCardWrapperClassName = (
baseClassName: string,
showThread: boolean | undefined,
isPost: boolean,
isOpenInDrawer: boolean,
isActive: boolean | undefined
): string =>
classNames(
baseClassName,
{
'activity-feed-card-new-right-panel m-0 gap-0':
showThread || isPost || isOpenInDrawer,
showThread || isOpenInDrawer,
},
{ 'activity-feed-reply-card': isPost },
{ 'active-card is-active': isActive }
);

Expand Down Expand Up @@ -203,15 +196,11 @@ const computeShouldAddBottomMargin = (
const ActivityFeedCardNew = ({
feed,
activity,
isPost = false,
post,
showActivityFeedEditor,
showThread,
isActive,
isForFeedTab,
isOpenInDrawer = false,
isFeedWidget = false,
isFullSizeWidget = false,
isThreadPanel,
onReplyPress,
onActivityClick,
Expand Down Expand Up @@ -245,12 +234,11 @@ const ActivityFeedCardNew = ({
}, [feed?.about, activity?.about, entityRef]);

const createdBy = useMemo(() => {
const postAuthor = post?.author.name ?? post?.author.fullyQualifiedName;
const feedCreator =
feed?.createdBy?.name ?? feed?.createdBy?.fullyQualifiedName;

return postAuthor ?? feedCreator ?? activity?.actor?.name ?? '';
}, [feed?.createdBy, post?.author, activity?.actor?.name]);
return feedCreator ?? activity?.actor?.name ?? '';
}, [feed?.createdBy, activity?.actor?.name]);

const feedId = computeFeedId(feed, activity);
const headerLayout = getHeaderLayout(isThreadPanel);
Expand Down Expand Up @@ -296,9 +284,8 @@ const ActivityFeedCardNew = ({
if (!feed) {
return;
}
const target = isPost && post ? post : feed;
const patch = compare(target, { ...target, message });
updateFeed(feed.id, post?.id ?? '', !isPost, patch);
const patch = compare(feed, { ...feed, message });
updateFeed(feed.id, '', true, patch);
setIsEditPost(!isEditPost);
};

Expand Down Expand Up @@ -414,8 +401,7 @@ const ActivityFeedCardNew = ({
isThreadPanel,
]);

const timestampValue =
post?.createdAt ?? feed?.createdAt ?? activity?.timestamp;
const timestampValue = feed?.createdAt ?? activity?.timestamp;

const timestamp = timestampValue ? (
<Tooltip
Expand All @@ -442,7 +428,7 @@ const ActivityFeedCardNew = ({
const feedActions = canManageConversation(
currentUser,
feed,
!isActivityEvent && !isPost
!isActivityEvent
) ? (
<ActivityFeedActions
className={ACTIONS_CLASS_NAME}
Expand Down Expand Up @@ -541,8 +527,8 @@ const ActivityFeedCardNew = ({
return activity?.summary ?? '';
}

return isPost ? post?.message ?? '' : feed?.message ?? '';
}, [isActivityEvent, activity, isPost, feed, post]);
return feed?.message ?? '';
}, [isActivityEvent, activity, feed]);

const headerTags = useMemo(
() => (
Expand All @@ -569,108 +555,6 @@ const ActivityFeedCardNew = ({
[isPanelLayout, renderEntityLink, isThreadPanel, t]
);

const renderWidgetCard = () => (
<Card
className={getFeedCardWrapperClassName(
'activity-feed-card-new activity-feed-card-new-surface tw:overflow-visible tw:rounded-none tw:border-primary tw:text-primary',
showThread,
isPost,
isOpenInDrawer,
isActive
)}
data-conversation-id={feed?.id}
data-testid="feed-card-v2-sidebar">
<Card.Content className="activity-feed-card-new-body tw:p-0">
<Box className="w-full" gap={2}>
<Box align="center" direction="col" justify="start">
<UserPopOverCard
className="m-r-0"
profileWidth={24}
userName={createdBy}
/>

{/* flex-1 + min-h-0 so the 100%-height line fills only what the
avatar leaves; otherwise the column overflows and the card
body's overflow:hidden clips the avatar. mx-auto centres the
line under the avatar, as the vertical Divider's self-stretch
otherwise pins it to the column's left edge. */}
<Divider
className="divider tw:mx-auto tw:min-h-0 tw:flex-1 tw:bg-transparent"
orientation="vertical"
/>
</Box>

<Box className="w-full min-w-0 overflow-hidden" direction="col">
<Box align="start" direction="col">
<Box
align="center"
className={classNames('w-full', {
'header-container-card': !showThread,
'header-container-right-panel': showThread,
})}
justify="between">
<div
className={classNames('mr-2', {
'activity-feed-user-name': !isPost,
'reply-card-user-name': isPost,
})}>
<UserPopOverCard
className={classNames('mr-2', {
'activity-feed-user-name': !isPost,
'reply-card-user-name': isPost,
})}
userName={createdBy}>
<Link to={getSettingsLink(getUserPath(createdBy))}>
{getEntityName(user)}
</Link>
</UserPopOverCard>
</div>
{timestamp}
</Box>
{!isPost && headerTags}
</Box>
<FeedCardBodyNew
activity={activity}
feed={feed}
isEditPost={isEditPost}
isFeedWidget={isFeedWidget}
isForFeedTab={isForFeedTab}
isPost={isPost}
message={feedMessage}
showThread={showThread}
onEditCancel={() => setIsEditPost(false)}
onUpdate={onUpdate}
/>
{isFullSizeWidget && !isActivityEvent && feed && (
<div className="m-b-md">
<FeedCardFooterNew
conversation={feed}
conversationId={feed.id}
isReply={isPost}
reply={post}
/>
</div>
)}
{isFullSizeWidget && isActivityEvent && activity && (
<div className="m-b-md">
<ActivityEventFooter
activity={activity}
isForFeedTab={isForFeedTab}
onActivityClick={onActivityClick}
/>
</div>
)}
</Box>
</Box>
{feedActions}
</Card.Content>
</Card>
);

if (isFeedWidget) {
return renderWidgetCard();
}

const hasNoReplies = computeHasNoReplies(
isActivityEvent,
activityReplies,
Expand Down Expand Up @@ -741,7 +625,6 @@ const ActivityFeedCardNew = ({
className={getFeedCardWrapperClassName(
getFullCardBaseClassName(isThreadPanel),
showThread,
isPost,
isOpenInDrawer,
isActive
)}
Expand Down Expand Up @@ -782,18 +665,11 @@ const ActivityFeedCardNew = ({
itemClassName={headerLayout.authorRowItem}>
<Typography
className={classNames(
'mr-2 not-prose',
headerLayout.authorName,
{
'activity-feed-user-name': !isPost,
'reply-card-user-name': isPost,
}
'mr-2 not-prose activity-feed-user-name',
headerLayout.authorName
)}>
<UserPopOverCard
className={classNames('mr-2', {
'activity-feed-user-name': !isPost,
'reply-card-user-name': isPost,
})}
className="mr-2 activity-feed-user-name"
userName={createdBy}>
<Link
className={headerLayout.authorLink}
Expand All @@ -806,9 +682,7 @@ const ActivityFeedCardNew = ({
{timestamp}
</Box>
</div>
{!isPost && (
<div className={SPACE_ITEM_CLASS_NAME}>{headerTags}</div>
)}
<div className={SPACE_ITEM_CLASS_NAME}>{headerTags}</div>
</Box>
</Box>
</div>
Expand All @@ -819,7 +693,6 @@ const ActivityFeedCardNew = ({
feed={feed}
isEditPost={isEditPost}
isForFeedTab={isForFeedTab}
isPost={isPost}
isThreadPanel={isThreadPanel}
message={feedMessage}
showThread={showThread}
Expand All @@ -837,8 +710,6 @@ const ActivityFeedCardNew = ({
)}
conversation={feed}
conversationId={feed.id}
isReply={isPost}
reply={post}
showReplyCount={isThreadPanel}
onReplyPress={onReplyPress}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,6 @@ import {
PANEL_HEADER_LAYOUT,
} from './ActivityFeedcardNew.constants';

// Shared across both card variants: the top-level Card wrapper always mixes
// the same "showThread || isPost || isOpenInDrawer" right-panel state with
// the reply/active-card modifiers, only the base class differs.
export const getFeedCardClassName = (
basePrefix: string,
{
showThread,
isPost,
isOpenInDrawer,
isActive,
}: {
showThread?: boolean;
isPost: boolean;
isOpenInDrawer: boolean;
isActive?: boolean;
}
) =>
classNames(
basePrefix,
{
'activity-feed-card-new-right-panel m-0 gap-0':
showThread || isPost || isOpenInDrawer,
},
{ 'activity-feed-reply-card': isPost },
{ 'active-card is-active': isActive }
);

// The whole feed/task card is clickable but also contains its own links and
// buttons, so it cannot be a <button> (interactive content may not nest). The
// container takes role="button" instead, and only reacts to keys pressed on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,11 @@
* limitations under the License.
*/

import {
Conversation,
ConversationReply,
} from '../../../../generated/entity/feed/conversation';
import { Conversation } from '../../../../generated/entity/feed/conversation';

export interface FeedCardFooterProps {
conversation?: Conversation;
conversationId: string;
reply?: ConversationReply;
isReply?: boolean;
componentsVisibility?: {
showThreadIcon?: boolean;
showRepliesContainer?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,17 +150,6 @@ describe('FeedCardFooterNew', () => {
);
});

it('hides the avatars and reply button on a reply', async () => {
await renderFooter({ isReply: true });

expect(
screen.queryByRole('button', { name: 'label.reply' })
).not.toBeInTheDocument();
expect(
screen.queryByRole('button', { name: 'label.view-replies-by-user' })
).not.toBeInTheDocument();
});

describe('in an activity thread panel', () => {
it('hands Reply to the caller instead of opening the drawer', async () => {
const onReplyPress = jest.fn();
Expand Down
Loading
Loading