Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX][ENTERPRISE] Auditing RoomAutocomplete #20311

Merged
merged 5 commits into from Jan 23, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions ee/client/audit/RoomAutoComplete.js
Expand Up @@ -4,16 +4,16 @@ import { AutoComplete, Option, Options } from '@rocket.chat/fuselage';
import RoomAvatar from '../../../client/components/avatar/RoomAvatar';
import { useEndpointData } from '../../../client/hooks/useEndpointData';

const query = (term = '') => ({ selector: JSON.stringify({ term }) });
const query = (name = '') => ({ selector: JSON.stringify({ name }) });

const Avatar = ({ value, type, avatarETag, ...props }) => <RoomAvatar size={Options.AvatarSize} room={{ type, _id: value, avatarETag }} {...props} />;

const RoomAutoComplete = React.memo((props) => {
const [filter, setFilter] = useState('');
const { value: data } = useEndpointData('rooms.autocomplete.channelAndPrivate', useMemo(() => query(filter), [filter]));
const options = useMemo(() => (data && data.items.map(({ name, _id, avatarETag, t }) => ({
const options = useMemo(() => (data && data.items.map(({ name, _id, fname, avatarETag, t }) => ({
value: _id,
label: { name, avatarETag, type: t },
label: { name: fname || name, avatarETag, type: t },
}))) || [], [data]);

return <AutoComplete
Expand All @@ -23,7 +23,7 @@ const RoomAutoComplete = React.memo((props) => {
renderSelected={({
value,
label,
}) => <><RoomAvatar size='x20' room={{ _id: value, ...label }} /> {label?.name}</>}
}) => <Option label={label.name} avatar={<Avatar value={value} room={{ _id: value, ...label }} />} />}
renderItem={({ value, label, ...props }) => <Option key={value} {...props} label={label.name} avatar={<Avatar value={value} {...label} />} />}
options={ options }
/>;
Expand Down
16 changes: 7 additions & 9 deletions package-lock.json

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