-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Uses
source
instead of room
to render the `OmnichannelR…
…oomIcon` (#33118)
- Loading branch information
1 parent
cdbca2a
commit e17b625
Showing
10 changed files
with
92 additions
and
112 deletions.
There are no files selected for viewing
50 changes: 13 additions & 37 deletions
50
apps/meteor/client/components/RoomIcon/OmnichannelRoomIcon/OmnichannelAppSourceRoomIcon.tsx
This file contains 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 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
39 changes: 25 additions & 14 deletions
39
apps/meteor/client/components/RoomIcon/OmnichannelRoomIcon/OmnichannelRoomIcon.tsx
This file contains 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 |
---|---|---|
@@ -1,23 +1,34 @@ | ||
import type { IOmnichannelRoom } from '@rocket.chat/core-typings'; | ||
import { isOmnichannelRoomFromAppSource } from '@rocket.chat/core-typings'; | ||
import type { IOmnichannelSource } from '@rocket.chat/core-typings'; | ||
import { UserStatus, isOmnichannelSourceFromApp } from '@rocket.chat/core-typings'; | ||
import type { Icon } from '@rocket.chat/fuselage'; | ||
import type { ComponentProps, ReactElement } from 'react'; | ||
import type { ComponentProps } from 'react'; | ||
import React from 'react'; | ||
|
||
import { OmnichannelAppSourceRoomIcon } from './OmnichannelAppSourceRoomIcon'; | ||
import { OmnichannelCoreSourceRoomIcon } from './OmnichannelCoreSourceRoomIcon'; | ||
|
||
export const OmnichannelRoomIcon = ({ | ||
room, | ||
size, | ||
placement = 'default', | ||
}: { | ||
room: IOmnichannelRoom; | ||
const colors = { | ||
busy: 'status-font-on-danger', | ||
away: 'status-font-on-warning', | ||
online: 'status-font-on-success', | ||
offline: 'annotation', | ||
disabled: 'annotation', | ||
} as const; | ||
|
||
type OmnichannelRoomIconProps = { | ||
source: IOmnichannelSource; | ||
color?: ComponentProps<typeof Icon>['color']; | ||
status?: UserStatus; | ||
size: ComponentProps<typeof Icon>['size']; | ||
placement: 'sidebar' | 'default'; | ||
}): ReactElement => { | ||
if (isOmnichannelRoomFromAppSource(room)) { | ||
return <OmnichannelAppSourceRoomIcon placement={placement} room={room} size={size} />; | ||
placement?: 'sidebar' | 'default'; | ||
}; | ||
|
||
export const OmnichannelRoomIcon = ({ source, color, status, size = 'x16', placement = 'default' }: OmnichannelRoomIconProps) => { | ||
const iconColor = color ?? colors[status || UserStatus.OFFLINE]; | ||
|
||
if (isOmnichannelSourceFromApp(source)) { | ||
return <OmnichannelAppSourceRoomIcon source={source} placement={placement} color={iconColor} size={size} />; | ||
} | ||
return <OmnichannelCoreSourceRoomIcon room={room} size={size} />; | ||
|
||
return <OmnichannelCoreSourceRoomIcon source={source} color={iconColor} size={size} />; | ||
}; |
This file contains 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 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 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 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 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 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 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