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] Embedded layout opening sidebar #27892

Merged
merged 4 commits into from
Feb 6, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions apps/meteor/app/mentions-flextab/client/actionButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Meteor.startup(function () {
name: Rooms.findOne({ _id: message.rid })?.name ?? '',
},
{
...FlowRouter.current().queryParams,
jump: message._id,
},
);
Expand Down
1 change: 1 addition & 0 deletions apps/meteor/app/message-pin/client/actionButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ Meteor.startup(function () {
name: Rooms.findOne({ _id: message.rid })?.name ?? '',
},
{
...FlowRouter.current().queryParams,
jump: message._id,
},
);
Expand Down
1 change: 1 addition & 0 deletions apps/meteor/app/message-star/client/actionButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ Meteor.startup(function () {
name: Rooms.findOne({ _id: message.rid })?.name ?? '',
},
{
...FlowRouter.current().queryParams,
jump: message._id,
},
);
Expand Down
1 change: 1 addition & 0 deletions apps/meteor/app/search/client/provider/result.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Meteor.startup(function () {
name: Rooms.findOne({ _id: message.rid }).name,
},
{
...FlowRouter.current().queryParams,
jump: message._id,
},
);
Expand Down
4 changes: 3 additions & 1 deletion apps/meteor/client/components/UserCard/UserCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useTranslation } from '@rocket.chat/ui-contexts';
import type { ReactNode, ComponentProps, MouseEvent } from 'react';
import React, { forwardRef } from 'react';

import { useEmbeddedLayout } from '../../hooks/useEmbeddedLayout';
import MarkdownText from '../MarkdownText';
import * as Status from '../UserStatus';
import UserAvatar from '../avatar/UserAvatar';
Expand Down Expand Up @@ -65,6 +66,7 @@ const UserCard = forwardRef(function UserCard(
ref,
) {
const t = useTranslation();
const isLayoutEmbedded = useEmbeddedLayout();

return (
<UserCardContainer data-qa='UserCard' className={className} ref={ref} style={style}>
Expand Down Expand Up @@ -111,7 +113,7 @@ const UserCard = forwardRef(function UserCard(
{typeof bio === 'string' ? <MarkdownText variant='inline' content={bio} /> : bio}
</UserCardInfo>
)}
{!isLoading && open && <a onClick={open}>{t('See_full_profile')}</a>}
{!isLoading && open && !isLayoutEmbedded && <a onClick={open}>{t('See_full_profile')}</a>}
</Box>
{onClose && (
<Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { ComponentProps, UIEvent, ReactElement } from 'react';
import React, { useState, Fragment, useRef } from 'react';

import type { MessageActionConfig } from '../../../../app/ui-utils/client/lib/MessageAction';
import { useEmbeddedLayout } from '../../../hooks/useEmbeddedLayout';
import ToolboxDropdown from './ToolboxDropdown';

type MessageActionConfigOption = Omit<MessageActionConfig, 'condition' | 'context' | 'order' | 'action'> & {
Expand All @@ -19,6 +20,7 @@ export const MessageActionMenu = ({ options, ...props }: MessageActionMenuProps)

const t = useTranslation();
const [visible, setVisible] = useState(false);
const isLayoutEmbedded = useEmbeddedLayout();

const groupOptions = options
.map(({ color, ...option }) => ({
Expand All @@ -28,7 +30,8 @@ export const MessageActionMenu = ({ options, ...props }: MessageActionMenuProps)
.reduce((acc, option) => {
const group = option.variant ? option.variant : '';
acc[group] = acc[group] || [];
acc[group].push(option);
if (!(isLayoutEmbedded && option.id === 'reply-directly')) acc[group].push(option);

return acc;
}, {} as { [key: string]: MessageActionConfigOption[] }) as {
[key: string]: MessageActionConfigOption[];
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/client/views/room/hooks/useGoToThreadList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useRoom } from '../contexts/RoomContext';

export const useGoToThreadList = ({ replace = false }: { replace?: boolean } = {}): (() => void) => {
const room = useRoom();
const [routeName, { context, ...params } = { context: '' }] = useCurrentRoute();
const [routeName, { context, ...params } = { context: '' }, queryParams] = useCurrentRoute();

if (!routeName) {
throw new Error('Route name is not defined');
Expand All @@ -14,6 +14,6 @@ export const useGoToThreadList = ({ replace = false }: { replace?: boolean } = {
const roomRoute = useRoute(routeName);
const go = replace ? roomRoute.replace : roomRoute.push;
return useMutableCallback(() => {
go({ rid: room._id, ...params, tab: 'thread' });
go({ rid: room._id, ...params, tab: 'thread' }, queryParams);
});
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { IRoom, IUser } from '@rocket.chat/core-typings';
import { useMemo } from 'react';

import { useEmbeddedLayout } from '../../../../hooks/useEmbeddedLayout';
import type { Action } from '../../../hooks/useActionSpread';
import { useBlockUserAction } from './actions/useBlockUserAction';
import { useCallAction } from './actions/useCallAction';
Expand Down Expand Up @@ -28,10 +29,11 @@ export const useUserInfoActions = (
const muteUserOption = useMuteUserAction(user, rid);
const removeUserOption = useRemoveUserAction(user, rid, reload);
const callOption = useCallAction(user);
const isLayoutEmbedded = useEmbeddedLayout();

return useMemo(
() => ({
...(openDirectMessageOption && { openDirectMessage: openDirectMessageOption }),
...(openDirectMessageOption && !isLayoutEmbedded && { openDirectMessage: openDirectMessageOption }),
...(callOption && { call: callOption }),
...(changeOwnerOption && { changeOwner: changeOwnerOption }),
...(changeLeaderOption && { changeLeader: changeLeaderOption }),
Expand All @@ -51,6 +53,7 @@ export const useUserInfoActions = (
removeUserOption,
callOption,
blockUserOption,
isLayoutEmbedded,
],
);
};
15 changes: 9 additions & 6 deletions apps/meteor/client/views/room/providers/ToolboxProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const ToolboxProvider = ({ children, room }: { children: ReactNode; room: IRoom
});
const { listen, actions } = useToolboxActions(room);

const [routeName, params] = useCurrentRoute();
const [routeName, params, queryStringParams] = useCurrentRoute();
const router = useRoute(routeName || '');

const tab = params?.tab;
Expand All @@ -33,11 +33,14 @@ const ToolboxProvider = ({ children, room }: { children: ReactNode; room: IRoom
);

const close = useMutableCallback(() => {
router.push({
...params,
tab: '',
context: '',
});
router.push(
{
...params,
tab: '',
context: '',
},
queryStringParams,
);
});

const open = useMutableCallback((actionId: string, context?: string) => {
Expand Down