Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
517e8e5
Fix: register message type as system on test
Mar 30, 2022
f230707
fix: e2e test with old settings
Mar 30, 2022
e99e721
fix: cypress tests
Apr 1, 2022
61bb9b1
Merge remote-tracking branch 'origin/message-template-2' into fix-ci
ggazzo Apr 1, 2022
5c29438
Fix: typechek and module not found errors
Apr 1, 2022
1f18d37
Merge remote-tracking branch 'origin/message-template-2' into fix-ci
ggazzo Apr 2, 2022
6dd5e4a
fix: ci issu on service
Apr 2, 2022
bd357c4
style: remove unsed console
Apr 4, 2022
89a9182
fix: add start discussion to message action dfault
Apr 4, 2022
3962af1
fix: add tmid on thread message
Apr 4, 2022
14a53e8
tests: update
Apr 4, 2022
b3c42e8
fix: uncomment code
Apr 4, 2022
daad4b1
refactor: rename data-type to data-qa-type
Apr 4, 2022
335524d
refactor: change attr elements
Apr 4, 2022
2b111d3
fix: add cypress wait to check last message content
Apr 4, 2022
051ab99
tests: change special character order
Apr 4, 2022
d355ef7
test: increase wait
Apr 5, 2022
4497e8f
refactor: rename data attr
Apr 5, 2022
aab7026
fix: update head tag
Apr 5, 2022
3108f1f
fix: increase cypres wait on login test
Apr 6, 2022
a972172
fix: add wait until to discussion test
Apr 6, 2022
10569c0
fix: attatchment icon and name when start a discussion
Apr 6, 2022
3ad6743
fix: add await before open message action menu
Apr 6, 2022
389b96a
tests: add await after save discussion
Apr 6, 2022
e0f9a0d
tests: add await after click on sidebar
Apr 6, 2022
8e0d31d
tests: force click
Apr 6, 2022
45e0e9c
tests: increase wait
Apr 6, 2022
a6bf8a3
tests: wait until sidebar open
Apr 6, 2022
618ee0b
tests: replace await
Apr 6, 2022
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
10 changes: 5 additions & 5 deletions app/lib/server/functions/attachMessage.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/camelcase */
import { getUserAvatarURL } from '../../../utils/lib/getUserAvatarURL';
import { roomCoordinator } from '../../../../server/lib/rooms/roomCoordinator';
import { IMessage } from '../../../../definition/IMessage';
Expand All @@ -9,8 +10,8 @@ export const attachMessage = function (
room: IRoom,
): {
text: string;
authorName?: string;
authorIcon: string;
author_name?: string;
author_icon: string;
message_link: string;
attachments?: MessageAttachment[];
ts: Date;
Expand All @@ -24,9 +25,8 @@ export const attachMessage = function (
} = message;
return {
text: msg,
authorName: username,
authorIcon: getUserAvatarURL(username),
// eslint-disable-next-line @typescript-eslint/camelcase
author_name: username,
author_icon: getUserAvatarURL(username),
message_link: `${roomCoordinator.getRouteLink(room.t, room)}?msg=${_id}`,
attachments,
ts,
Expand Down
2 changes: 2 additions & 0 deletions app/theme/client/imports/general/base_old.css
Original file line number Diff line number Diff line change
Expand Up @@ -1732,6 +1732,8 @@
line-height: 24px;

&.not {
z-index: 1;

transform: translateY(150%);
}

Expand Down
2 changes: 1 addition & 1 deletion app/ui-message/client/message.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template name="message">
<li id="{{templatePrefix}}{{msg._id}}" data-id="{{msg._id}}" data-own={{isOwnMessageAndNotSystem}} data-context={{actionContext}} class="message {{className}} {{ignoredClass}} {{system}} {{t}} {{own}} {{isTemp}} {{chatops}} {{collapsed}} {{customClass}}" data-username="{{msg.u.username}}" data-tmid="{{msg.tmid}}" data-groupable="{{isGroupable}}" data-date="{{date}}" data-timestamp="{{timestamp}}" data-alias="{{msg.alias}}">
<li id="{{templatePrefix}}{{msg._id}}" data-id="{{msg._id}}" data-own={{isOwnMessageAndNotSystem}} data-context={{actionContext}} class="message {{className}} {{ignoredClass}} {{system}} {{t}} {{own}} {{isTemp}} {{chatops}} {{collapsed}} {{customClass}}" data-username="{{msg.u.username}}" data-tmid="{{msg.tmid}}" data-groupable="{{isGroupable}}" data-date="{{date}}" data-timestamp="{{timestamp}}" data-alias="{{msg.alias}}" data-qa-type="message">
{{#if isThreadReply}}
{{> messageThread parentMessage=parentMessage msg=msg tmid=msg.tmid class=bodyClass following=msg.following}}
<div class="thread-replied js-open-thread">
Expand Down
46 changes: 46 additions & 0 deletions app/ui-utils/client/lib/messageActionDefault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { modal } from './modal';
import { MessageAction } from './MessageAction';
import { imperativeModal } from '../../../../client/lib/imperativeModal';
import ReactionList from '../../../../client/views/room/modals/ReactionListModal';
import CreateDiscussion from '../../../../client/components/CreateDiscussion/CreateDiscussion';
import { canDeleteMessage } from '../../../../client/lib/utils/canDeleteMessage';
import { dispatchToastMessage } from '../../../../client/lib/toast';
import { IMessage } from '../../../../definition/IMessage';
Expand Down Expand Up @@ -280,4 +281,49 @@ Meteor.startup(async function () {
order: 18,
group: 'menu',
});

MessageAction.addButton({
id: 'start-discussion',
icon: 'discussion',
label: 'Discussion_start',
context: ['message', 'message-mobile'],
async action(_, props) {
const { message = messageArgs(this).msg, room } = props;

imperativeModal.open({
component: CreateDiscussion,
props: {
defaultParentRoom: room.prid || room._id,
onClose: imperativeModal.close,
parentMessageId: message._id,
nameSuggestion: message?.msg?.substr(0, 140),
},
});
},
condition({
message: {
u: { _id: uid },
drid,
dcount,
},
room,
subscription,
user,
}) {
if (drid || (!Number.isNaN(dcount) && dcount !== undefined)) {
return false;
}
if (!subscription) {
return false;
}
const isLivechatRoom = roomCoordinator.isLivechatRoom(room.t);
if (isLivechatRoom) {
return false;
}

return uid !== user._id ? hasPermission('start-discussion-other-user') : hasPermission('start-discussion');
},
order: 1,
group: 'menu',
});
});
2 changes: 1 addition & 1 deletion app/ui-utils/client/lib/popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ Template.popover.events({
});
popover.close();
},
'click [data-type="message-action"]'(e, t) {
'click [data-qa-type="message-action"]'(e, t) {
const button = MessageAction.getButtonById(e.currentTarget.dataset.id);
if ((button != null ? button.action : undefined) != null) {
e.stopPropagation();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Avatar } from '@rocket.chat/fuselage';
import React, { FC } from 'react';

const AuthorAvatar: FC<{ url: string }> = ({ url }) => <Avatar {...({ url, size: 'x24' } as any)} />;
import BaseAvatar from '../../../avatar/BaseAvatar';

const AuthorAvatar: FC<{ url: string }> = ({ url }) => <BaseAvatar {...({ url, size: 'x24' } as any)} />;

export default AuthorAvatar;
30 changes: 17 additions & 13 deletions client/components/Message/MessageBodyRender/Heading.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
import { Bold as ASTHeading } from '@rocket.chat/message-parser';
import { Heading as ASTHeading } from '@rocket.chat/message-parser';
import React, { FC } from 'react';

import PlainText from './PlainText';

const Heading: FC<{ value: ASTHeading['value'] }> = ({ value = [] }) => (
<h1>
{value.map((block, index) => {
switch (block.type) {
case 'PLAIN_TEXT':
return <PlainText key={index} value={block.value} />;
default:
return null;
}
})}
</h1>
);
const Heading: FC<{ value: ASTHeading['value']; level: ASTHeading['level'] }> = ({ value = [], level = 1 }) => {
const HeadingTag = `h${level}` as keyof JSX.IntrinsicElements;

return (
<HeadingTag>
{value.map((block, index) => {
switch (block.type) {
case 'PLAIN_TEXT':
return <PlainText key={index} value={block.value} />;
default:
return null;
}
})}
</HeadingTag>
);
};

export default Heading;
2 changes: 1 addition & 1 deletion client/components/Message/MessageBodyRender/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const MessageBodyRender: FC<BodyProps> = ({
}

if (block.type === 'HEADING') {
return <Heading value={block.value} key={index} />;
return <Heading value={block.value} level={block.level} key={index} />;
}

return null;
Expand Down
2 changes: 2 additions & 0 deletions client/views/room/MessageList/MessageList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export const MessageList: FC<{ rid: IRoom['_id'] }> = ({ rid }) => {
data-unread={isFirstUnread}
data-sequential={isSequential}
data-own={isUserOwnMessage}
data-qa-type='message'
sequential={shouldShowAsSequential}
message={message}
subscription={subscription}
Expand All @@ -76,6 +77,7 @@ export const MessageList: FC<{ rid: IRoom['_id'] }> = ({ rid }) => {
<ThreadMessagePreview
data-system-message={Boolean(message.t)}
data-mid={message._id}
data-tmid={message.tmid}
data-unread={isFirstUnread}
data-sequential={isSequential}
sequential={shouldShowAsSequential}
Expand Down
2 changes: 1 addition & 1 deletion client/views/room/MessageList/components/Message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const Message: FC<{ message: IMessage; sequential: boolean; subscription?: ISubs

{!isMessageIgnored && <MessageContent id={message._id} message={message} subscription={subscription} sequential={sequential} />}
{isMessageIgnored && (
<MessageBody>
<MessageBody data-qa-type='message-body'>
<MessageContentIgnored onShowMessageIgnored={toggleMessageIgnored} />
</MessageBody>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const MessageContent: FC<{ message: IMessage; sequential: boolean; subscription?

return (
<>
<MessageBody>
<MessageBody data-qa-type='message-body'>
{!isEncryptedMessage && !message.blocks && message.md && (
<MessageBodyRender
onUserMentionClick={openUserCard}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type MessageActionConfigOption = Omit<MessageActionConfig, 'condition' | 'contex

export const MessageActionMenu: FC<{
options: MessageActionConfig[];
}> = ({ options }) => {
}> = ({ options, ...rest }) => {
const ref = useRef(null);

const t = useTranslation();
Expand All @@ -30,9 +30,15 @@ export const MessageActionMenu: FC<{
};

return (
<MessageToolboxItem ref={ref} icon='kebab' onClick={(): void => setVisible(!visible)}>
<MessageToolboxItem
ref={ref}
icon='kebab'
onClick={(): void => setVisible(!visible)}
data-qa-id='menu'
data-qa-type='message-action-menu'
>
{visible && (
<ToolboxDropdown reference={ref}>
<ToolboxDropdown reference={ref} {...rest}>
{Object.entries(groupOptions).map(([, options], index, arr) => (
<Fragment key={index}>
{options.map((option) => (
Expand All @@ -43,6 +49,8 @@ export const MessageActionMenu: FC<{
icon={option.icon as ComponentProps<typeof Option>['icon']}
label={t(option.label)}
onClick={option.action as any}
data-qa-type='message-action'
data-qa-id={option.id}
/>
))}
{index !== arr.length - 1 && <Option.Divider />}
Expand Down
3 changes: 3 additions & 0 deletions client/views/room/MessageList/components/Toolbox/Toolbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ export const Toolbox: FC<{ message: IMessage }> = ({ message }) => {
key={action.id}
icon={action.icon}
title={t(action.label)}
data-qa-id={action.label}
data-qa-type='message-action-menu'
/>
))}
{menuActions.length > 0 && (
Expand All @@ -58,6 +60,7 @@ export const Toolbox: FC<{ message: IMessage }> = ({ message }) => {
action.action(e, { message, tabbar, room });
},
}))}
data-qa-type='message-action-menu-options'
/>
)}
</MessageToolbox>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const style = css`
export const ToolboxDropdown = <R extends HTMLElement>({
reference,
children,
...rest
}: {
reference: React.RefObject<R>;
children: ReactNode;
Expand All @@ -26,7 +27,7 @@ export const ToolboxDropdown = <R extends HTMLElement>({
return (
<>
<Box className={style} position='fixed' />
<DropdownTemplate ref={target} reference={reference}>
<DropdownTemplate ref={target} reference={reference} {...rest}>
{children}
</DropdownTemplate>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ export const ToolboxDropdownDesktop = forwardRef<
reference: RefObject<HTMLElement>;
children: ReactNode;
}
>(({ reference, children }, ref) => {
>(({ reference, children, ...rest }, ref) => {
const { style: s } = usePosition(reference, ref as RefObject<HTMLElement>, {
watch: true,
placement: 'bottom-start',
});

return (
<Tile is='ul' padding={0} paddingBlock={'x12'} paddingInline={0} elevation='2' ref={ref} style={s}>
<Tile is='ul' padding={0} paddingBlock={'x12'} paddingInline={0} elevation='2' ref={ref} style={s} {...rest}>
{children}
</Tile>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const ToolboxDropdownMobile = forwardRef<
{
children: ReactNode;
}
>(function ToolboxDropdownMobile({ children }, ref) {
>(function ToolboxDropdownMobile({ children, ...rest }, ref) {
return (
<Tile
position='fixed'
Expand All @@ -30,6 +30,7 @@ export const ToolboxDropdownMobile = forwardRef<
className={dropdownStyle}
maxHeight='50%'
h='full'
{...rest}
>
<ScrollableContentWrapper autoHide={false}>{children}</ScrollableContentWrapper>
</Tile>
Expand Down
8 changes: 8 additions & 0 deletions client/views/room/MessageList/lib/isOwnUserMessage.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-env mocha */
import { expect } from 'chai';

import { MessageTypes } from '../../../../../app/ui-utils/lib/MessageTypes';
import { IMessage } from '../../../../../definition/IMessage';
import { ISubscription } from '../../../../../definition/ISubscription';
import { isOwnUserMessage } from './isOwnUserMessage';
Expand All @@ -21,6 +22,13 @@ const baseMessage = {
urls: [],
};

// Register a system message
MessageTypes.registerType({
id: 'au',
system: true,
message: 'User_added_by',
});

describe('isUserMessage', () => {
it('should return true if the message is from user', () => {
const message: IMessage = {
Expand Down
4 changes: 3 additions & 1 deletion ee/server/services/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
"esModuleInterop": true,
"preserveSymlinks": true,

"outDir": "./dist"
"outDir": "./dist",

"skipLibCheck": true

// "sourceMap": true,
// "declaration": true,
Expand Down
28 changes: 28 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading