Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
05c79e4
wip
ggazzo Feb 6, 2023
023799c
Finished Users Channel Emoji
ggazzo Feb 9, 2023
d12ea29
added few more words to cspell
ggazzo Feb 9, 2023
5829c6f
add nickname to autocomplete definition
ggazzo Feb 9, 2023
6036dd7
Merge remote-tracking branch 'origin' into chore/message-popup-refactor
ggazzo Feb 9, 2023
d057d4f
Merge branch 'chore/message-popup-refactor' of github.com:RocketChat/…
ggazzo Feb 9, 2023
7fd54e5
Merge remote-tracking branch 'origin/develop' into chore/message-popu…
ggazzo Feb 10, 2023
7a2d6fd
wip
ggazzo Feb 10, 2023
5d2478a
Merge remote-tracking branch 'origin/develop' into chore/message-popu…
ggazzo Feb 13, 2023
af132db
Add omnichannel popup
ggazzo Feb 13, 2023
6431192
add ariaActiveDescendant
ggazzo Feb 13, 2023
7453d48
remove old templates
ggazzo Feb 13, 2023
14e4eae
tabIndex
ggazzo Feb 13, 2023
de68f2f
lint
ggazzo Feb 13, 2023
f71cadd
Merge branch 'develop' into chore/message-popup-refactor
ggazzo Feb 13, 2023
d9e77d8
Remove old components
ggazzo Feb 13, 2023
daf2838
bump fuselage
ggazzo Feb 13, 2023
74effa9
Merge remote-tracking branch 'origin/develop' into chore/message-popu…
ggazzo Feb 13, 2023
8be4bdb
Improve position
ggazzo Feb 13, 2023
23b1bc3
improve focused
ggazzo Feb 13, 2023
b17cbed
Merge remote-tracking branch 'origin/develop' into chore/message-popu…
ggazzo Feb 13, 2023
e9e719a
0.32.0-dev.245
ggazzo Feb 13, 2023
d8fad95
fix lint
ggazzo Feb 13, 2023
e4b5210
undo AdministrationModelList
ggazzo Feb 14, 2023
c4ab31c
Merge remote-tracking branch 'origin/develop' into chore/message-popu…
ggazzo Feb 14, 2023
11abe95
undo AdministrationModelList
ggazzo Feb 14, 2023
41e86cf
Merge branch 'develop' into chore/message-popup-refactor
ggazzo Feb 14, 2023
b213da0
improve add aria-label to popup
ggazzo Feb 14, 2023
4d68637
add missing strong
ggazzo Feb 14, 2023
bdf391a
Merge branch 'develop' into chore/message-popup-refactor
ggazzo Feb 14, 2023
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
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
"typescript.tsdk": "./node_modules/typescript/lib",
"cSpell.words": [
"autotranslate",
"fname",
"katex",
"listbox",
"livechat",
"oauthapps",
"omnichannel",
"photoswipe",
"searchbox",
"tmid"
"tmid",
"tshow"
]
}
42 changes: 0 additions & 42 deletions apps/meteor/app/theme/client/imports/general/base_old.css
Original file line number Diff line number Diff line change
Expand Up @@ -1051,38 +1051,6 @@
}
}

.rc-old .message-popup-position {
position: relative;

.message-popup {
display: flex;
flex-direction: column;

max-height: 20rem;
align-items: stretch;

.message-popup-items {
overflow-y: auto;

.popup-slash-command {
display: flex;
flex-flow: row wrap;

&-format {
flex-grow: 1;
}

&-description {
text-align: right;

font-style: italic;
flex-grow: 2;
}
}
}
}
}

.rc-old .message-popup-items.preview-items {
display: flex;
overflow-y: auto;
Expand Down Expand Up @@ -1111,16 +1079,6 @@
box-shadow: 0 -1px 10px 0 rgba(0, 0, 0, 0.2), 0 1px 1px rgba(0, 0, 0, 0.16);
}

.rc-old .message-popup-title {
padding: 0 20px;

border-width: 0 0 1px;

font-size: 14px;
font-weight: 300;
line-height: 32px;
}

.rc-old .popup-item {
padding: 0 20px;

Expand Down
5 changes: 0 additions & 5 deletions apps/meteor/app/ui-message/client/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
import './popup/customMessagePopups';
import './popup/messagePopup';
import './popup/messagePopupChannel';
import './popup/messagePopupConfig';
import './popup/messagePopupEmoji';
import './popup/messagePopupSlashCommandPreview';
34 changes: 34 additions & 0 deletions apps/meteor/app/ui-message/client/messageBox/createComposerAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,42 @@ export const createComposerAPI = (input: HTMLTextAreaElement, storageID: string)

setText(Meteor._localStorage.getItem(storageID) ?? '');

// Gets the text that is connected to the cursor and replaces it with the given text
const replaceText = (text: string, selection: { readonly start: number; readonly end: number }): void => {
const { selectionStart, selectionEnd } = input;

// Selects the text that is connected to the cursor
input.setSelectionRange(selection.start ?? 0, selection.end ?? text.length);
const textAreaTxt = input.value;

if (!document.execCommand || !document.execCommand('insertText', false, text)) {
input.value = textAreaTxt.substring(0, selection.start) + text + textAreaTxt.substring(selection.end);
}

input.selectionStart = selectionStart + text.length;
input.selectionEnd = selectionStart + text.length;
if (selectionStart !== selectionEnd) {
input.selectionStart = selectionStart;
}

triggerEvent(input, 'input');
triggerEvent(input, 'change');

focus();
};

return {
replaceText,
insertNewLine,
blur: () => input.blur(),

substring: (start: number, end?: number) => {
return input.value.substring(start, end);
},

getCursorPosition: () => {
return input.selectionStart;
},
setCursorToEnd: () => {
input.selectionEnd = input.value.length;
input.selectionStart = input.selectionEnd;
Expand Down
68 changes: 68 additions & 0 deletions apps/meteor/app/ui-message/client/popup/ComposerBoxPopup.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { Box, Option, OptionSkeleton, Tile } from '@rocket.chat/fuselage';
import { useUniqueId } from '@rocket.chat/fuselage-hooks';
import type { UseQueryResult } from '@tanstack/react-query';
import type { ReactElement } from 'react';
import React from 'react';

type ComposerBoxPopupProps<
T extends {
_id: string;
sort?: number;
},
> = {
title?: string;
focused?: T;
items: UseQueryResult<T[]>[];
select: (item: T) => void;
renderItem?: ({ item }: { item: T }) => ReactElement;
};

export const ComposerBoxPopup = <
T extends {
_id: string;
sort?: number;
},
>({
title,
items,
focused,
select,
renderItem = ({ item }: { item: T }) => <>{JSON.stringify(item)}</>,
}: ComposerBoxPopupProps<T>): ReactElement | null => {
const id = useUniqueId();
return (
<Box className='message-popup-position' position='relative'>
<Tile className='message-popup' padding={0} role='menu' mbe='x2' maxHeight='20rem' aria-labelledby={id}>
{title && (
<Box bg='tint' pi='x16' pb='x8' id={id}>
{title}
</Box>
)}
<Box pb='x8'>
{items
.flatMap((item) => {
if (item.isSuccess) {
return item.data;
}
return [];
})
.sort((a, b) => (('sort' in a && a.sort) || 0) - (('sort' in b && b.sort) || 0))
.map((item, index) => {
return (
<Option
onClick={() => select(item)}
selected={item === focused}
key={index}
id={`popup-item-${item._id}`}
tabIndex={item === focused ? 0 : -1}
>
{renderItem({ item })}
</Option>
);
})}
{items.some((item) => item.isLoading && item.fetchStatus !== 'idle') && <OptionSkeleton />}
</Box>
</Tile>
</Box>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react';
import { OptionColumn, OptionContent } from '@rocket.chat/fuselage';

export type ComposerBoxPopupCannedResponseProps = {
_id: string;
text: string;
shortcut: string;
};

const ComposerPopupCannedResponse = ({ shortcut, text }: ComposerBoxPopupCannedResponseProps) => {
return (
<>
<OptionColumn>
<strong>{shortcut}</strong>
</OptionColumn>
<OptionContent>{text}</OptionContent>
</>
);
};

export default ComposerPopupCannedResponse;
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react';
import { OptionColumn, OptionContent } from '@rocket.chat/fuselage';

import Emoji from '../../../../../client/components/Emoji';

export type ComposerBoxPopupEmojiProps = {
_id: string;
};

const ComposerPopupEmoji = ({ _id }: ComposerBoxPopupEmojiProps) => {
return (
<>
<OptionColumn>
<Emoji emojiHandle={_id} />
</OptionColumn>
<OptionContent>{_id}</OptionContent>
</>
);
};

export default ComposerPopupEmoji;
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react';
import { OptionColumn, OptionContent } from '@rocket.chat/fuselage';
import type { IRoom } from '@rocket.chat/core-typings';

import { RoomIcon } from '../../../../../client/components/RoomIcon';

export type ComposerBoxPopupRoomProps = Pick<IRoom, 't' | 'name' | 'fname' | '_id' | 'prid' | 'teamMain' | 'u'>;

const ComposerBoxPopupRoom = ({ fname, name, ...props }: ComposerBoxPopupRoomProps) => {
return (
<>
<OptionColumn>
<RoomIcon room={props} />
</OptionColumn>
<OptionContent>
<strong>{fname ?? name}</strong>
</OptionContent>
</>
);
};

export default ComposerBoxPopupRoom;
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react';
import { OptionColumn, OptionContent } from '@rocket.chat/fuselage';

export type ComposerBoxPopupSlashCommandProps = {
_id: string;
description?: string;
params?: string;
};

const ComposerPopupSlashCommand = ({ _id, description, params }: ComposerBoxPopupSlashCommandProps) => {
return (
<>
<OptionColumn>
<strong>{_id}</strong> {params}
</OptionColumn>
<OptionContent>{description}</OptionContent>
</>
);
};

export default ComposerPopupSlashCommand;
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import React from 'react';
import { useTranslation } from '@rocket.chat/ui-contexts';
import { OptionAvatar, OptionColumn, OptionContent } from '@rocket.chat/fuselage';

import UserAvatar from '../../../../../client/components/avatar/UserAvatar';
import ReactiveUserStatus from '../../../../../client/components/UserStatus/ReactiveUserStatus';

export type ComposerBoxPopupUserProps = {
_id: string;
system?: boolean;
outside?: boolean;
suggestion?: boolean;
username: string;
name?: string;
nickname?: string;
status?: string;
sort?: number;
};

const ComposerBoxPopupUser = ({ _id, system, username, name, nickname, outside, suggestion }: ComposerBoxPopupUserProps) => {
const t = useTranslation();
return (
<>
{!system && (
<>
<OptionAvatar>
<UserAvatar size='x28' username={username} />
</OptionAvatar>
<OptionColumn>
<ReactiveUserStatus uid={_id} />
</OptionColumn>
<OptionContent>
<strong>{name ?? username}</strong> {nickname && <span className='popup-user-nickname'>({nickname})</span>}
</OptionContent>
</>
)}

{system && (
<OptionContent>
<strong>{username}</strong> {name}
</OptionContent>
)}

{outside && <OptionColumn>{t('Not_in_channel')}</OptionColumn>}
{suggestion && <OptionColumn>{t('Suggestion_from_recent_messages')}</OptionColumn>}
</>
);
};

export default ComposerBoxPopupUser;
29 changes: 0 additions & 29 deletions apps/meteor/app/ui-message/client/popup/customMessagePopups.js

This file was deleted.

Loading