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

feat: Place the room topic next to the room title #35631

Merged
merged 3 commits into from
Mar 28, 2025
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
7 changes: 7 additions & 0 deletions .changeset/plenty-baboons-kneel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@rocket.chat/ui-client': minor
'@rocket.chat/meteor': minor
---

Places the room topic next to the room title
> This change is being tested under `Enhanced navigation experience` feature preview, in order to check it you need to enabled it
2 changes: 2 additions & 0 deletions apps/meteor/client/views/room/HeaderV2/RoomHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import ParentRoomWithData from './ParentRoomWithData';
import ParentTeam from './ParentTeam';
import RoomTitle from './RoomTitle';
import RoomToolbox from './RoomToolbox';
import RoomTopic from './RoomTopic';
import Encrypted from './icons/Encrypted';
import Favorite from './icons/Favorite';
import Translate from './icons/Translate';
Expand Down Expand Up @@ -47,6 +48,7 @@ const RoomHeader = ({ room, slots = {}, roomToolbox }: RoomHeaderProps) => {
{isRoomFederated(room) && <FederatedRoomOriginServer room={room} />}
<Encrypted room={room} />
<Translate room={room} />
<RoomTopic room={room} />
{slots?.insideContent}
</HeaderContentRow>
</HeaderContent>
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/client/views/room/HeaderV2/RoomTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const RoomTitle = ({ room }: RoomTitleProps) => {
mie={4}
>
<HeaderIconWithRoom room={room} />
<HeaderTitle is='h1'>{room.name}</HeaderTitle>
<HeaderTitle>{room.name}</HeaderTitle>
</HeaderTitleButton>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { mockAppRoot } from '@rocket.chat/mock-providers';
import type { SubscriptionWithRoom } from '@rocket.chat/ui-contexts';
import { render, screen } from '@testing-library/react';

import { RoomTopic } from './RoomTopic';
import RoomTopic from './RoomTopic';
import FakeRoomProvider from '../../../../tests/mocks/client/FakeRoomProvider';
import { createFakeRoom, createFakeSubscription, createFakeUser } from '../../../../tests/mocks/data';

Expand Down Expand Up @@ -36,7 +36,7 @@ describe('RoomTopic', () => {

render(
<FakeRoomProvider roomOverrides={room} subscriptionOverrides={subscription}>
<RoomTopic room={room} user={user} />
<RoomTopic room={room} />
</FakeRoomProvider>,
{
wrapper: mockAppRoot()
Expand All @@ -56,7 +56,7 @@ describe('RoomTopic', () => {

render(
<FakeRoomProvider roomOverrides={room} subscriptionOverrides={subscription}>
<RoomTopic room={room} user={user} />
<RoomTopic room={room} />
</FakeRoomProvider>,
{
wrapper: mockAppRoot()
Expand All @@ -75,7 +75,7 @@ describe('RoomTopic', () => {

render(
<FakeRoomProvider roomOverrides={room} subscriptionOverrides={subscription}>
<RoomTopic room={room} user={user} />
<RoomTopic room={room} />
</FakeRoomProvider>,
{
wrapper: mockAppRoot()
Expand All @@ -96,7 +96,7 @@ describe('RoomTopic', () => {

render(
<FakeRoomProvider roomOverrides={room} subscriptionOverrides={subscription}>
<RoomTopic room={room} user={user} />
<RoomTopic room={room} />
</FakeRoomProvider>,
{
wrapper: mockAppRoot()
Expand All @@ -115,7 +115,7 @@ describe('RoomTopic', () => {

render(
<FakeRoomProvider roomOverrides={room} subscriptionOverrides={subscription}>
<RoomTopic room={room} user={user} />
<RoomTopic room={room} />
</FakeRoomProvider>,
{
wrapper: mockAppRoot()
Expand All @@ -137,7 +137,7 @@ describe('RoomTopic', () => {

render(
<FakeRoomProvider roomOverrides={room} subscriptionOverrides={subscription}>
<RoomTopic room={room} user={user} />
<RoomTopic room={room} />
</FakeRoomProvider>,
{
wrapper: mockAppRoot()
Expand All @@ -159,7 +159,7 @@ describe('RoomTopic', () => {

render(
<FakeRoomProvider roomOverrides={room} subscriptionOverrides={subscription}>
<RoomTopic room={room} user={user} />
<RoomTopic room={room} />
</FakeRoomProvider>,
{
wrapper: mockAppRoot()
Expand All @@ -179,7 +179,7 @@ describe('RoomTopic', () => {

render(
<FakeRoomProvider roomOverrides={room} subscriptionOverrides={subscription}>
<RoomTopic room={room} user={user} />
<RoomTopic room={room} />
</FakeRoomProvider>,
{
wrapper: mockAppRoot()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import type { IRoom, IUser } from '@rocket.chat/core-typings';
import type { IRoom } from '@rocket.chat/core-typings';
import { isDirectMessageRoom, isPrivateRoom, isPublicRoom, isTeamRoom } from '@rocket.chat/core-typings';
import { Box } from '@rocket.chat/fuselage';
import { RoomBanner, RoomBannerContent } from '@rocket.chat/ui-client';
import { useUserId, useTranslation, useRouter, useUserPresence } from '@rocket.chat/ui-contexts';

import MarkdownText from '../../../components/MarkdownText';
import { useCanEditRoom } from '../contextualBar/Info/hooks/useCanEditRoom';

type RoomTopicProps = {
room: IRoom;
user: IUser | null;
};

export const RoomTopic = ({ room }: RoomTopicProps) => {
const RoomTopic = ({ room }: RoomTopicProps) => {
const t = useTranslation();
const canEdit = useCanEditRoom(room);
const userId = useUserId();
Expand All @@ -26,21 +24,19 @@ export const RoomTopic = ({ room }: RoomTopicProps) => {
const topic = isDirectMessageRoom(room) && (room.uids?.length ?? 0) < 3 ? directUserData?.statusText : room.topic;
const canEditTopic = canEdit && (isPublicRoom(room) || isPrivateRoom(room));

if (!topic && !canEdit) {
if (!topic && !canEditTopic) {
return null;
}

return (
<RoomBanner className='rcx-header-section rcx-topic-section' role='note'>
<RoomBannerContent>
{!topic && canEditTopic ? (
<Box is='a' href={href}>
{t('Add_topic')}
</Box>
) : (
<MarkdownText parseEmoji={true} variant='inlineWithoutBreaks' withTruncatedText content={topic} />
)}
</RoomBannerContent>
</RoomBanner>
);
if (!topic && canEditTopic) {
return (
<Box is='a' href={href}>
{t('Add_topic')}
</Box>
);
}

return <MarkdownText color='default' parseEmoji={true} variant='inlineWithoutBreaks' withTruncatedText content={topic} />;
};

export default RoomTopic;
2 changes: 0 additions & 2 deletions apps/meteor/client/views/room/body/RoomBodyV2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import { useDateScroll } from '../hooks/useDateScroll';
import { useMessageListNavigation } from '../hooks/useMessageListNavigation';
import { useRetentionPolicy } from '../hooks/useRetentionPolicy';
import RoomForeword from './RoomForeword/RoomForeword';
import { RoomTopic } from './RoomTopic';
import UnreadMessagesIndicator from './UnreadMessagesIndicator';
import { UploadProgressContainer, UploadProgressIndicator } from './UploadProgress';
import { useBannerSection } from './hooks/useBannerSection';
Expand Down Expand Up @@ -193,7 +192,6 @@ const RoomBody = (): ReactElement => {
<>
<Box position='relative' w='full'>
<Box animated className={[wrapperStyle, hideSection && 'animated-hidden'].filter(isTruthy)} ref={sectionWrapperRef}>
<RoomTopic room={room} user={user} />
{!isLayoutEmbedded && room.announcement && <RoomAnnouncement announcement={room.announcement} announcementDetails={undefined} />}
</Box>
</Box>
Expand Down
11 changes: 10 additions & 1 deletion packages/ui-client/src/components/HeaderV2/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,16 @@ const Header = (props: HeaderProps) => {
const { isMobile } = useLayout();

return (
<Box rcx-room-header is='header' display='flex' justifyContent='center' flexDirection='column' overflow='hidden' flexShrink={0}>
<Box
rcx-room-header
is='header'
color='default'
display='flex'
justifyContent='center'
flexDirection='column'
overflow='hidden'
flexShrink={0}
>
<Box
pi={isMobile ? 'x12' : 'x16'}
height='x44'
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-client/src/components/HeaderV2/HeaderTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import type { ComponentPropsWithoutRef } from 'react';

type HeaderTitleProps = ComponentPropsWithoutRef<typeof Box>;

const HeaderTitle = (props: HeaderTitleProps) => <Box color='default' mi={4} is='h1' fontScale='h4' withTruncatedText {...props} />;
const HeaderTitle = (props: HeaderTitleProps) => <Box color='titles-labels' mi={4} is='h1' fontScale='h4' withTruncatedText {...props} />;

export default HeaderTitle;
Loading