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
@@ -1,6 +1,5 @@
import type { ISubscription } from '@rocket.chat/core-typings';
import { isPrivateRoom } from '@rocket.chat/core-typings';
import { useButtonPattern } from '@rocket.chat/fuselage-hooks';

import { roomCoordinator } from '../../../../../lib/rooms/roomCoordinator';
import SidePanelTag from '../SidePanelTag';
Expand All @@ -10,13 +9,8 @@ const SidePanelParentRoom = ({ subscription }: { subscription: ISubscription })
const icon = isPrivateRoom(subscription) ? 'hashtag-lock' : 'hashtag';
const roomName = roomCoordinator.getRoomName(subscription?.t, subscription);

const buttonProps = useButtonPattern((e) => {
e.preventDefault();
roomCoordinator.openRouteLink(subscription.t, { ...subscription });
});

return (
<SidePanelTag {...buttonProps}>
<SidePanelTag>
{icon && <SidePanelTagIcon icon={{ name: icon }} />}
{roomName}
</SidePanelTag>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
import { useButtonPattern } from '@rocket.chat/fuselage-hooks';
import type { SubscriptionWithRoom } from '@rocket.chat/ui-contexts';

import SidePanelTag from './SidePanelTag';
import SidePanelTagIcon from './SidePanelTagIcon';
import { useParentTeamData } from './useParentTeamData';

const SidePanelParentTeam = ({ room }: { room: SubscriptionWithRoom }) => {
const { redirectToMainRoom, teamName, shouldDisplayTeam, teamInfoError, isTeamPublic } = useParentTeamData(room.teamId);

const buttonProps = useButtonPattern((e) => {
e.preventDefault();
redirectToMainRoom();
});
const { teamName, shouldDisplayTeam, teamInfoError, isTeamPublic } = useParentTeamData(room.teamId);

if (teamInfoError || !shouldDisplayTeam) {
return null;
}

return (
<SidePanelTag {...buttonProps}>
<SidePanelTag>
<SidePanelTagIcon icon={{ name: isTeamPublic ? 'team' : 'team-lock' }} />
{teamName}
</SidePanelTag>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { TEAM_TYPE } from '@rocket.chat/core-typings';
import { useUserId } from '@rocket.chat/ui-contexts';

import { useTeamInfoQuery } from '../../../../hooks/useTeamInfoQuery';
import { goToRoomById } from '../../../../lib/utils/goToRoomById';
import { useUserTeamsQuery } from '../../../room/hooks/useUserTeamsQuery';

type APIErrorResult = { success: boolean; error: string };
Expand Down Expand Up @@ -31,19 +30,9 @@ export const useParentTeamData = (teamId?: ITeam['_id']) => {
const isTeamPublic = teamInfo?.type === TEAM_TYPE.PUBLIC;
const shouldDisplayTeam = isTeamPublic || userBelongsToTeam;

const redirectToMainRoom = (): void => {
const rid = teamInfo?.roomId;
if (!rid) {
return;
}

goToRoomById(rid);
};

return {
teamName: teamInfo?.name,
isLoading: userTeamsLoading || teamInfoLoading,
redirectToMainRoom,
teamInfoError,
shouldDisplayTeam,
isTeamPublic,
Expand Down
19 changes: 0 additions & 19 deletions apps/meteor/tests/e2e/feature-preview.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -449,25 +449,6 @@ test.describe.serial('feature preview', () => {
await expect(poHomeChannel.sidebar.favoritesTeamCollabFilter).toHaveAttribute('aria-selected', 'true');
});

test('should open parent team when clicking button on sidepanel discussion item', async ({ page }) => {
await page.goto(`/group/${sidepanelTeam}`);

const discussionName = faker.string.uuid();
await poHomeChannel.content.btnMenuMoreActions.click();
await page.getByRole('menuitem', { name: 'Discussion' }).click();
await poHomeChannel.content.inputDiscussionName.fill(discussionName);
await poHomeChannel.content.btnCreateDiscussionModal.click();

await expect(page.getByRole('heading', { name: discussionName })).toBeVisible();

await expect(poHomeChannel.sidepanel.getItemByName(discussionName).getByRole('button', { name: sidepanelTeam })).toBeVisible();

await poHomeChannel.sidepanel.getItemByName(discussionName).getByRole('button', { name: sidepanelTeam }).click();

await expect(page).toHaveURL(`/group/${sidepanelTeam}`);
await expect(page.getByRole('heading', { name: sidepanelTeam })).toBeVisible();
});

test('should show all filters and tablist on sidepanel', async ({ page }) => {
await page.goto('/home');

Expand Down
Loading