Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
2168d41
[IMPROVE] Add modal to close chats when tags/comments are not required
MartinSchoeler May 20, 2021
99bba88
Merge branch 'develop' into generic_modal_close_chats
rafaelblink May 21, 2021
c3ff721
Merge branch 'develop' into generic_modal_close_chats
pierre-lehnen-rc May 24, 2021
f70c095
Merge branch 'develop' into generic_modal_close_chats
renatobecker May 31, 2021
f4d42c8
Merge branch 'develop' into generic_modal_close_chats
rafaelblink May 31, 2021
71b1f95
department from subscribe correctly
May 31, 2021
4216e3f
Merge branch 'develop' into generic_modal_close_chats
rafaelblink May 31, 2021
3a714df
Merge remote-tracking branch 'origin/generic_modal_close_chats' into …
May 31, 2021
2e82857
fix departmentId and department from subscription.
May 31, 2021
ae6bd67
undo sub departmentId change
rafaelblink May 31, 2021
663b29a
undo sub departmentId change
rafaelblink May 31, 2021
d779b71
Merge remote-tracking branch 'origin/generic_modal_close_chats' into …
rafaelblink May 31, 2021
90d0c3c
fix room type
tiagoevanp May 31, 2021
5c4fbd8
Merge branch 'develop' into generic_modal_close_chats
tiagoevanp May 31, 2021
975fe76
fix RoomHeader props type
tiagoevanp Jun 1, 2021
9725ed8
Merge branch 'develop' into generic_modal_close_chats
rafaelblink Jun 1, 2021
668aa99
Tags required with asterisk as all default labels of RC.
rafaelblink Jun 1, 2021
6a6ca83
get deparment from subscription or room.
rafaelblink Jun 1, 2021
47c4ab1
normalizing subscription and room into useOmnichannelRoom
rafaelblink Jun 2, 2021
05ad11b
Get room from useOmnichannelRoom into omnichannel header.
rafaelblink Jun 2, 2021
4b6d7a0
Merge branch 'develop' into generic_modal_close_chats
rafaelblink Jun 2, 2021
2c581a2
trying to skip build fail
rafaelblink Jun 4, 2021
0374cc4
Revert "trying to skip build fail"
rafaelblink Jun 4, 2021
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
6 changes: 4 additions & 2 deletions client/components/Omnichannel/Tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { useEndpointData } from '../../hooks/useEndpointData';
import { formsSubscription } from '../../views/omnichannel/additionalForms';
import { FormSkeleton } from './Skeleton';

const Tags = ({ tags = [], handler = () => {}, error = '' }) => {
const Tags = ({ tags = [], handler = () => {}, error = '', tagRequired = false }) => {
const { value: tagsResult = [], phase: stateTags } = useEndpointData('livechat/tags.list');
const t = useTranslation();
const forms = useSubscription(formsSubscription);
Expand Down Expand Up @@ -49,7 +49,9 @@ const Tags = ({ tags = [], handler = () => {}, error = '' }) => {

return (
<>
<Field.Label mb='x4'>{t('Tags')}</Field.Label>
<Field.Label required={tagRequired} mb='x4'>
{t('Tags')}
</Field.Label>
{Tags && tagsList && tagsList.length > 0 ? (
<Field.Row>
<Tags value={tags} handler={handler} />
Expand Down
16 changes: 15 additions & 1 deletion client/components/Omnichannel/modals/CloseChatModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useSetting } from '../../../contexts/SettingsContext';
import { useTranslation } from '../../../contexts/TranslationContext';
import { useComponentDidUpdate } from '../../../hooks/useComponentDidUpdate';
import { useForm } from '../../../hooks/useForm';
import GenericModal from '../../GenericModal';
import Tags from '../Tags';

const CloseChatModal = ({ department = {}, onCancel, onConfirm }) => {
Expand Down Expand Up @@ -46,6 +47,19 @@ const CloseChatModal = ({ department = {}, onCancel, onConfirm }) => {
);
}, [department, tagRequired, t, tags]);

if (!commentRequired && !tagRequired) {
return (
<GenericModal
variant='warning'
title={t('Are_you_sure_you_want_to_close_this_chat')}
onConfirm={handleConfirm}
onCancel={onCancel}
onClose={onCancel}
confirmText={t('Confirm')}
></GenericModal>
);
}

return (
<Modal>
<Modal.Header>
Expand All @@ -71,7 +85,7 @@ const CloseChatModal = ({ department = {}, onCancel, onConfirm }) => {
</Field>
{Tags && (
<Field>
<Tags tags={tags} handler={handleTags} error={tagError} />
<Tags tagRequired={tagRequired} tags={tags} handler={handleTags} error={tagError} />
<Field.Error>{tagError}</Field.Error>
</Field>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function ChatInfo({ id, route }) {
ts,
tags,
closedAt,
department,
departmentId,
v,
servedBy,
metrics,
Expand Down Expand Up @@ -103,7 +103,7 @@ function ChatInfo({ id, route }) {
{room && v && <ContactField contact={v} room={room} />}
{visitorId && <VisitorClientInfo uid={visitorId} />}
{servedBy && <AgentField agent={servedBy} />}
{department && <DepartmentField departmentId={department} />}
{departmentId && <DepartmentField departmentId={departmentId} />}
{tags && tags.length > 0 && (
<Field>
<Label>{t('Tags')}</Label>
Expand Down
2 changes: 1 addition & 1 deletion client/views/room/Header/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const Header = ({ room }) => {
}

if (room.t === 'l') {
return <OmnichannelRoomHeader slots={slots} room={room} />;
return <OmnichannelRoomHeader slots={slots} />;
}

return <RoomHeader slots={slots} room={room} topic={room.topic} />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ import React, { FC, useMemo } from 'react';
import TemplateHeader from '../../../../components/Header';
import { useLayout } from '../../../../contexts/LayoutContext';
import { useCurrentRoute } from '../../../../contexts/RouterContext';
import { useOmnichannelRoom } from '../../contexts/RoomContext';
import Burger from '../Burger';
import RoomHeader, { RoomHeaderProps } from '../RoomHeader';
import BackButton from './BackButton';
import QuickActions from './QuickActions';

const OmnichannelRoomHeader: FC<RoomHeaderProps> = ({ room, slots: parentSlot }) => {
const OmnichannelRoomHeader: FC<RoomHeaderProps> = ({ slots: parentSlot }) => {
const [name] = useCurrentRoute();
const { isMobile } = useLayout();
const room = useOmnichannelRoom();
const slots = useMemo(
() => ({
...parentSlot,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import toastr from 'toastr';
import { RoomManager } from '../../../../../../app/ui-utils/client';
import { handleError } from '../../../../../../app/utils/client';
import { IOmnichannelRoom } from '../../../../../../definition/IRoom';
import { IOmnichannelSubscription } from '../../../../../../definition/ISubscription';
import PlaceChatOnHoldModal from '../../../../../../ee/app/livechat-enterprise/client/components/modals/PlaceChatOnHoldModal';
import Header from '../../../../../components/Header';
import CloseChatModal from '../../../../../components/Omnichannel/modals/CloseChatModal';
Expand All @@ -35,7 +36,7 @@ import { QuickActionsActionConfig, QuickActionsEnum } from '../../../lib/QuickAc
import { QuickActionsContext } from '../../../lib/QuickActions/QuickActionsContext';

type QuickActionsProps = {
room: IOmnichannelRoom;
room: IOmnichannelRoom & IOmnichannelSubscription;
className?: ComponentProps<typeof Box>['className'];
};

Expand Down
3 changes: 2 additions & 1 deletion client/views/room/Header/RoomHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { FC } from 'react';

import { IOmnichannelRoom } from '../../../../definition/IRoom';
import { IOmnichannelSubscription } from '../../../../definition/ISubscription';
import Header from '../../../components/Header';
import MarkdownText from '../../../components/MarkdownText';
import RoomAvatar from '../../../components/avatar/RoomAvatar';
Expand All @@ -13,7 +14,7 @@ import Favorite from './icons/Favorite';
import Translate from './icons/Translate';

export type RoomHeaderProps = {
room: IOmnichannelRoom;
room: IOmnichannelRoom & IOmnichannelSubscription;
topic?: string;
slots: {
start?: unknown;
Expand Down
16 changes: 13 additions & 3 deletions client/views/room/contexts/RoomContext.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
import { createContext, useContext } from 'react';

import { IRoom, IOmnichannelRoom, isOmnichannelRoom } from '../../../../definition/IRoom';
import { IOmnichannelSubscription } from '../../../../definition/ISubscription';

export type RoomContextValue = {
rid: IRoom['_id'];
room: IRoom;
// tabBar: TabBar;
room: IOmnichannelRoom & IOmnichannelSubscription;
};

export const RoomContext = createContext<RoomContextValue | null>(null);

const normalizeRoomSubscription = (room: IOmnichannelRoom & IOmnichannelSubscription): IRoom => {
if (room.department) {
room.departmentId = room.department;
}
return room;
};

export const useRoom = (): IRoom => {
const { room } = useContext(RoomContext) || {};
if (!room) {
Expand All @@ -18,13 +25,16 @@ export const useRoom = (): IRoom => {
return room;
};

export const useOmnichannelRoom = (): IOmnichannelRoom => {
export const useOmnichannelRoom = (): IOmnichannelRoom & IOmnichannelSubscription => {
const { room } = useContext(RoomContext) || {};

if (!room) {
throw new Error('use useRoom only inside opened rooms');
}
if (!isOmnichannelRoom(room)) {
throw new Error('invalid room type');
}

normalizeRoomSubscription(room);
return room;
};
6 changes: 4 additions & 2 deletions client/views/room/providers/RoomProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React, { ReactNode, useMemo, memo, useEffect } from 'react';

import { roomTypes } from '../../../../app/utils/client';
import { IRoom } from '../../../../definition/IRoom';
import { IRoom, IOmnichannelRoom } from '../../../../definition/IRoom';
import { IOmnichannelSubscription } from '../../../../definition/ISubscription';
import { RoomManager, useHandleRoom } from '../../../lib/RoomManager';
import { AsyncStatePhase } from '../../../lib/asyncState';
import Skeleton from '../Room/Skeleton';
Expand All @@ -22,7 +23,8 @@ const RoomProvider = ({ rid, children }: Props): JSX.Element => {
room._id = rid;
return {
rid,
room: { ...room, name: roomTypes.getRoomName(room.t, room) },
room: { ...room, name: roomTypes.getRoomName(room.t, room) } as IOmnichannelRoom &
IOmnichannelSubscription,
};
}, [room, rid]);

Expand Down
4 changes: 4 additions & 0 deletions definition/ISubscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ export interface ISubscription extends IRocketChatRecord {
unreadAlert?: 'default' | 'all' | 'mentions' | 'nothing';
}

export interface IOmnichannelSubscription extends ISubscription {
department?: string;
}

export interface ISubscriptionDirectMessage extends Omit<ISubscription, 'name'> {
t: 'd';
}
1 change: 1 addition & 0 deletions packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,7 @@
"are_also_typing": "are also typing",
"are_typing": "are typing",
"Are_you_sure": "Are you sure?",
"Are_you_sure_you_want_to_close_this_chat": "Are you sure you want to close this chat?",
"Are_you_sure_you_want_to_delete_this_record": "Are you sure you want to delete this record?",
"Are_you_sure_you_want_to_delete_your_account": "Are you sure you want to delete your account?",
"Are_you_sure_you_want_to_disable_Facebook_integration": "Are you sure you want to disable Facebook integration?",
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-i18n/i18n/pt-BR.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@
"are_also_typing": "também estão digitando",
"are_typing": "estão digitando",
"Are_you_sure": "Você tem certeza?",
"Are_you_sure_you_want_to_close_this_chat": "Tem certeza de que deseja fechar esta conversa?",
"Are_you_sure_you_want_to_delete_this_record": "Tem certeza de que deseja remover este registro?",
"Are_you_sure_you_want_to_delete_your_account": "Tem certeza de que deseja excluir a sua conta?",
"Are_you_sure_you_want_to_disable_Facebook_integration": "Tem certeza de que deseja desabilitar a integração do Facebook?",
Expand Down