[NEW] Omnichannel source identification fields (#23090)
* Add new fields to IOmnichannelRoom and adapt livechat bridge to them * Add source information to places that create livechat rooms * Add deprecation warning to unused livechat methods and remove source from native facebook integration * Remove unnecesary alias for widget * Update app/lib/server/lib/deprecationWarningLogger.ts * Update Apps-Engine version * frontend part * Change way of identifying when a chat is coming through widget * Update deprecationlogger to new logger interface * Fix usage of source.type as key * sms icon * [NEW] Add Channel Source details to room info panel (#23224) * Add Source icon/text to room info * Fix TS error and styling * Change order * Typing and style fix * Use source.id instead of email object * useEndpoint * Revert "Merge branch 'develop' into new/omnichannel-source-fields" This reverts commitpull/23279/head7fea2ad1fc, reversing changes made todbbcaf4601. * Removing unnecesary changes from branch * why github, why? * Bump icons & fuselage to latest versions Co-authored-by: Kevin Aleman <kevin.aleman@rocket.chat> Co-authored-by: Tiago Evangelista Pinto <tiago.evangelista@rocket.chat> Co-authored-by: Martin Schoeler <martin.schoeler@rocket.chat>
parent
c2ab5e128c
commit
0f36b36ca4
@ -1,14 +0,0 @@ |
||||
import { API } from '../api'; |
||||
|
||||
API.helperMethods.set('deprecationWarning', function _deprecationWarning({ endpoint, versionWillBeRemoved, response }) { |
||||
const warningMessage = `The endpoint "${ endpoint }" is deprecated and will be removed after version ${ versionWillBeRemoved }`; |
||||
console.warn(warningMessage); |
||||
if (process.env.NODE_ENV === 'development') { |
||||
return { |
||||
warning: warningMessage, |
||||
...response, |
||||
}; |
||||
} |
||||
|
||||
return response; |
||||
}); |
||||
@ -0,0 +1,15 @@ |
||||
import { API } from '../api'; |
||||
import { apiDeprecationLogger } from '../../../lib/server/lib/deprecationWarningLogger'; |
||||
|
||||
(API as any).helperMethods.set('deprecationWarning', function _deprecationWarning({ endpoint, versionWillBeRemoved, response }: { endpoint: string; versionWillBeRemoved: string; response: any }) { |
||||
const warningMessage = `The endpoint "${ endpoint }" is deprecated and will be removed after version ${ versionWillBeRemoved }`; |
||||
apiDeprecationLogger.warn(warningMessage); |
||||
if (process.env.NODE_ENV === 'development') { |
||||
return { |
||||
warning: warningMessage, |
||||
...response, |
||||
}; |
||||
} |
||||
|
||||
return response; |
||||
}); |
||||
@ -0,0 +1,13 @@ |
||||
import { parse } from 'cookie'; |
||||
|
||||
import { API } from '../api'; |
||||
|
||||
(API as any).helperMethods.set('isWidget', function _isWidget() { |
||||
// @ts-expect-error
|
||||
const { headers } = this.request; |
||||
|
||||
const { rc_room_type: roomType, rc_is_widget: isWidget } = parse(headers.cookie); |
||||
|
||||
const isLivechatRoom = roomType && roomType === 'l'; |
||||
return !!(isLivechatRoom && isWidget === 't'); |
||||
}); |
||||
@ -0,0 +1,7 @@ |
||||
import { Logger } from '../../../logger/server'; |
||||
|
||||
const deprecationLogger = new Logger('DeprecationWarning'); |
||||
|
||||
export const apiDeprecationLogger = deprecationLogger.section('API'); |
||||
export const methodDeprecationLogger = deprecationLogger.section('METHOD'); |
||||
export const functionDeprecationLogger = deprecationLogger.section('FUNCTION'); |
||||
@ -0,0 +1,74 @@ |
||||
import { Icon, Box } from '@rocket.chat/fuselage'; |
||||
import React, { FC } from 'react'; |
||||
|
||||
import { IOmnichannelRoom } from '../../../../../../definition/IRoom'; |
||||
import { useTranslation } from '../../../../../contexts/TranslationContext'; |
||||
import { useRoomIcon } from '../../../../../hooks/useRoomIcon'; |
||||
import Field from '../../../components/Field'; |
||||
import Info from '../../../components/Info'; |
||||
import Label from '../../../components/Label'; |
||||
|
||||
type SourceFieldProps = { |
||||
room: IOmnichannelRoom; |
||||
}; |
||||
|
||||
const SourceField: FC<SourceFieldProps> = ({ room }) => { |
||||
const t = useTranslation(); |
||||
|
||||
const roomSource = room.source.alias || room.source.id || room.source.type; |
||||
|
||||
// TODO: create a hook that gets the default types values (alias, icons, ids, etc...)
|
||||
// so we don't have to write this object again and again
|
||||
const defaultTypesLabels: { |
||||
widget: string; |
||||
email: string; |
||||
sms: string; |
||||
app: string; |
||||
api: string; |
||||
other: string; |
||||
} = { |
||||
widget: t('Livechat'), |
||||
email: t('Email'), |
||||
sms: t('SMS'), |
||||
app: t('Custom_Integration'), // TODO: use app text
|
||||
api: t('Custom_Integration'), // TODO: use app text
|
||||
other: t('Custom_Integration'), |
||||
}; |
||||
|
||||
const defaultTypesVisitorData: { |
||||
widget: string | undefined; |
||||
email: string | undefined; |
||||
sms: string; |
||||
app: string; |
||||
api: string; |
||||
other: string; |
||||
} = { |
||||
widget: '', |
||||
email: room?.source.id, |
||||
sms: t('External'), |
||||
app: t('External'), // TODO: use app text
|
||||
api: t('External'), |
||||
other: t('External'), |
||||
}; |
||||
|
||||
const sourceIcon = useRoomIcon(room) as { name: string; color?: string | undefined }; |
||||
|
||||
const sourceName = sourceIcon?.name || ''; |
||||
|
||||
return ( |
||||
<Field> |
||||
<Label>{t('Channel')}</Label> |
||||
<Info> |
||||
<Box display='flex' alignItems='center'> |
||||
<Icon name={sourceName} size='x24' /> |
||||
<Label mi='x8' mbe='0'> |
||||
{defaultTypesLabels[room.source.type] || roomSource} |
||||
</Label> |
||||
{defaultTypesVisitorData[room.source.type]} |
||||
</Box> |
||||
</Info> |
||||
</Field> |
||||
); |
||||
}; |
||||
|
||||
export default SourceField; |
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue