-
Notifications
You must be signed in to change notification settings - Fork 13.8k
feat: Use IconButton to navigate to parent room
#35613
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
Merged
Merged
Changes from 14 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
0b6a73e
feat: use `IconButton` in favor of `Tag` for parent room
dougfabris f12838d
i18n: translations
dougfabris f5ebdca
Merge branch 'develop' into feat/replace-parentTag
dougfabris b852a7f
chore: tweaks
dougfabris 21ab07f
chore: changeset
dougfabris 3578e85
test: add e2e test
dougfabris df00b27
chore: bump `fuselage-icons`
dougfabris af7e10f
test: update width in e2e test
dougfabris 0020b39
fix: translation tweak
dougfabris 7ddae36
chore: remove `createTargetDiscussion`
dougfabris aebc7e1
fix: review
dougfabris 0ef6ab0
Merge branch 'develop' into feat/replace-parentTag
kodiakhq[bot] c0d4e9f
chore: `HeaderState` tweaks
dougfabris 88973a1
test: add e2e test
dougfabris e0adc27
Merge branch 'develop' into feat/replace-parentTag
dougfabris 7bf6300
fix: e2e tests
dougfabris 2394d6d
Merge branch 'develop' into feat/replace-parentTag
kodiakhq[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| '@rocket.chat/ui-client': minor | ||
| '@rocket.chat/i18n': minor | ||
| '@rocket.chat/meteor': minor | ||
| --- | ||
|
|
||
| Replaces the parent room tag in room header in favor of a button to back to the parent room | ||
| > This change is being tested under `Enhanced navigation experience` feature preview, in order to check it you need to enabled it |
This file was deleted.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
apps/meteor/client/views/room/HeaderV2/ParentRoom/ParentDiscussion/ParentDiscussion.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import type { IRoom } from '@rocket.chat/core-typings'; | ||
| import { useTranslation } from 'react-i18next'; | ||
|
|
||
| import { roomCoordinator } from '../../../../../lib/rooms/roomCoordinator'; | ||
| import ParentRoomButton from '../ParentRoomButton'; | ||
|
|
||
| type ParentDiscussionProps = { | ||
| loading?: boolean; | ||
| room: Pick<IRoom, '_id' | 't' | 'name' | 'fname' | 'prid' | 'u'>; | ||
| }; | ||
|
|
||
| const ParentDiscussion = ({ loading = false, room }: ParentDiscussionProps) => { | ||
| const { t } = useTranslation(); | ||
| const roomName = roomCoordinator.getRoomName(room.t, room); | ||
| const handleRedirect = (): void => roomCoordinator.openRouteLink(room.t, { rid: room._id, ...room }); | ||
|
|
||
| return <ParentRoomButton loading={loading} onClick={handleRedirect} title={t('Back_to__roomName__channel', { roomName })} />; | ||
| }; | ||
|
|
||
| export default ParentDiscussion; |
27 changes: 27 additions & 0 deletions
27
apps/meteor/client/views/room/HeaderV2/ParentRoom/ParentDiscussion/ParentDiscussionRoute.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import type { IRoom } from '@rocket.chat/core-typings'; | ||
| import { useUserSubscription } from '@rocket.chat/ui-contexts'; | ||
|
|
||
| import ParentDiscussion from './ParentDiscussion'; | ||
| import ParentDiscussionWithData from './ParentDiscussionWithData'; | ||
|
|
||
| type ParentDiscussionRouteProps = { | ||
| room: Pick<IRoom, '_id' | 't' | 'name' | 'fname' | 'prid' | 'u'>; | ||
| }; | ||
|
|
||
| const ParentDiscussionRoute = ({ room }: ParentDiscussionRouteProps) => { | ||
| const { prid } = room; | ||
|
|
||
| if (!prid) { | ||
| throw new Error('Parent room ID is missing'); | ||
| } | ||
|
|
||
| const subscription = useUserSubscription(prid); | ||
|
|
||
| if (subscription) { | ||
| return <ParentDiscussion room={subscription} />; | ||
| } | ||
|
|
||
| return <ParentDiscussionWithData rid={prid} />; | ||
| }; | ||
|
|
||
| export default ParentDiscussionRoute; |
16 changes: 16 additions & 0 deletions
16
...eteor/client/views/room/HeaderV2/ParentRoom/ParentDiscussion/ParentDiscussionWithData.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import type { IRoom } from '@rocket.chat/core-typings'; | ||
|
|
||
| import ParentDiscussion from './ParentDiscussion'; | ||
| import { useRoomInfoEndpoint } from '../../../../../hooks/useRoomInfoEndpoint'; | ||
|
|
||
| const ParentDiscussionWithData = ({ rid }: { rid: IRoom['_id'] }) => { | ||
| const { data, isPending, isError } = useRoomInfoEndpoint(rid); | ||
|
|
||
| if (isError || !data?.room) { | ||
| return null; | ||
| } | ||
|
|
||
| return <ParentDiscussion loading={isPending} room={data.room} />; | ||
| }; | ||
|
|
||
| export default ParentDiscussionWithData; |
1 change: 1 addition & 0 deletions
1
apps/meteor/client/views/room/HeaderV2/ParentRoom/ParentDiscussion/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { default } from './ParentDiscussionRoute'; |
22 changes: 22 additions & 0 deletions
22
apps/meteor/client/views/room/HeaderV2/ParentRoom/ParentRoom.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import type { IRoom } from '@rocket.chat/core-typings'; | ||
|
|
||
| import ParentDiscussion from './ParentDiscussion'; | ||
| import ParentTeam from './ParentTeam'; | ||
|
|
||
| const ParentRoom = ({ room }: { room: IRoom }) => { | ||
| const parentRoomId = Boolean(room.prid || (room.teamId && !room.teamMain)); | ||
|
|
||
| if (!parentRoomId) { | ||
| return null; | ||
| } | ||
|
|
||
| if (room.prid) { | ||
| return <ParentDiscussion room={room} />; | ||
| } | ||
|
|
||
| if (room.teamId && !room.teamMain) { | ||
| return <ParentTeam room={room} />; | ||
| } | ||
| }; | ||
|
|
||
| export default ParentRoom; |
14 changes: 14 additions & 0 deletions
14
apps/meteor/client/views/room/HeaderV2/ParentRoom/ParentRoomButton.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import { IconButton, Skeleton } from '@rocket.chat/fuselage'; | ||
| import type { ComponentProps } from 'react'; | ||
|
|
||
| type ParentRoomButtonProps = Omit<ComponentProps<typeof IconButton>, 'icon'> & { loading: boolean }; | ||
|
|
||
| const ParentRoomButton = ({ loading, ...props }: ParentRoomButtonProps) => { | ||
| if (loading) { | ||
| return <Skeleton variant='rect' size={28} />; | ||
| } | ||
|
|
||
| return <IconButton small icon='arrow-back-up' {...props} />; | ||
| }; | ||
|
|
||
| export default ParentRoomButton; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { default } from './ParentRoom'; |
27 changes: 0 additions & 27 deletions
27
apps/meteor/client/views/room/HeaderV2/ParentRoomWithData.tsx
This file was deleted.
Oops, something went wrong.
25 changes: 0 additions & 25 deletions
25
apps/meteor/client/views/room/HeaderV2/ParentRoomWithEndpointData.tsx
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.