Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into rw/f…
Browse files Browse the repository at this point in the history
…ile_upload

* 'develop' of github.com:RocketChat/Rocket.Chat:
  Regression: Data in the "New Users" section is delayed in 1 day (#22751)
  [FIX] Support ID param on createVisitor method (#22772)
  Regression: fix non ee tag field on canned responses (#22775)
  [FIX] Blank screen in message auditing DM tab (#22763)
  Show translated scope on cr dashboard (#22773)
  Regression: Fix empty tag field (#22767)
  Regression: Federation warnings on ci (#22765)
  Regression: fix outdated data on canned filters (#22766)
  [IMPROVE] Return open room if available for visitors (#22742)
  Regression: Fix empty canned responses table when searching (#22743)
  Regression: Filter of canned responses in contextual-bar (#22762)
  Regression: Fix users not being able to see the scope of the canned message (#22760)
  Regression: Fixes empty department field on edit canned responses (#22741)
  Regression: Allow users to update canned responses scope (#22738)
  allow users to search canned responses based on shortcut or content (#22735)
  Regression: Check for text before parse preview in create canned response form (#22754)
  • Loading branch information
gabriellsh committed Jul 27, 2021
2 parents 0fca028 + f475e6b commit 312cbba
Show file tree
Hide file tree
Showing 32 changed files with 497 additions and 292 deletions.
1 change: 1 addition & 0 deletions app/apps/server/bridges/livechat.ts
Expand Up @@ -127,6 +127,7 @@ export class AppLivechatBridge extends LivechatBridge {
email: '',
connectionData: undefined,
phone: {},
id: visitor.id,
};

if (visitor.visitorEmails && visitor.visitorEmails.length) {
Expand Down
32 changes: 21 additions & 11 deletions app/livechat/server/api/v1/room.js
Expand Up @@ -22,14 +22,20 @@ API.v1.addRoute('livechat/room', {

const extraCheckParams = onCheckRoomParams(defaultCheckParams);

try {
check(this.queryParams, extraCheckParams);
check(this.queryParams, extraCheckParams);

const { token, rid: roomId, agentId, ...extraParams } = this.queryParams;
const { token, rid: roomId, agentId, ...extraParams } = this.queryParams;

const guest = findGuest(token);
if (!guest) {
throw new Meteor.Error('invalid-token');
const guest = findGuest(token);
if (!guest) {
throw new Meteor.Error('invalid-token');
}

let room;
if (!roomId) {
room = LivechatRooms.findOneOpenByVisitorToken(token, {});
if (room) {
return API.v1.success({ room, newRoom: false });
}

let agent;
Expand All @@ -39,13 +45,17 @@ API.v1.addRoute('livechat/room', {
agent = { agentId, username };
}

const rid = roomId || Random.id();
const room = Promise.await(getRoom({ guest, rid, agent, extraParams }));

const rid = Random.id();
room = Promise.await(getRoom({ guest, rid, agent, extraParams }));
return API.v1.success(room);
} catch (e) {
return API.v1.failure(e);
}

room = LivechatRooms.findOneOpenByRoomIdAndVisitorToken(roomId, token, {});
if (!room) {
throw new Meteor.Error('invalid-room');
}

return API.v1.success({ room, newRoom: false });
},
});

Expand Down
4 changes: 3 additions & 1 deletion app/livechat/server/lib/Livechat.js
Expand Up @@ -221,8 +221,9 @@ export const Livechat = {
return true;
},

registerGuest({ token, name, email, department, phone, username, connectionData } = {}) {
registerGuest({ id, token, name, email, department, phone, username, connectionData } = {}) {
check(token, String);
check(id, Match.Maybe(String));

let userId;
const updateUser = {
Expand Down Expand Up @@ -264,6 +265,7 @@ export const Livechat = {
const userData = {
username,
ts: new Date(),
...id && { _id: id },
};

if (settings.get('Livechat_Allow_collect_and_store_HTTP_header_informations')) {
Expand Down
@@ -1,34 +1,67 @@
import { Box, Pagination, Table, Tile } from '@rocket.chat/fuselage';
import { useDebouncedValue } from '@rocket.chat/fuselage-hooks';
import React, { useState, useEffect, useCallback, forwardRef } from 'react';
import React, {
useState,
useEffect,
useCallback,
forwardRef,
ReactNode,
ReactElement,
Key,
RefAttributes,
} from 'react';
import flattenChildren from 'react-keyed-flatten-children';

import { useTranslation } from '../../contexts/TranslationContext';
import ScrollableContentWrapper from '../ScrollableContentWrapper';
import HeaderCell from './HeaderCell';
import LoadingRow from './LoadingRow';

const GenericTable = (
const defaultParamsValue = { text: '', current: 0, itemsPerPage: 25 } as const;
const defaultSetParamsValue = (): void => undefined;

type Params = { text?: string; current?: number; itemsPerPage?: 25 | 50 | 100 };

type GenericTableProps<
FilterProps extends { onChange?: (params: Params) => void },
ResultProps extends { _id?: Key },
> = {
fixed?: boolean;
header?: ReactNode;
params?: Params;
setParams?: (params: Params) => void;
children?: (props: ResultProps, key: number) => ReactElement;
renderFilter?: (props: FilterProps) => ReactElement;
renderRow?: (props: ResultProps) => ReactElement;
results?: ResultProps[];
total?: number;
pagination?: boolean;
} & FilterProps;

const GenericTable: {
<FilterProps extends { onChange?: (params: Params) => void }, ResultProps extends { _id?: Key }>(
props: GenericTableProps<FilterProps, ResultProps> & RefAttributes<HTMLElement>,
): ReactElement | null;
} = forwardRef(function GenericTable(
{
children,
fixed = true,
header,
params: paramsDefault = '',
params: paramsDefault = defaultParamsValue,
setParams = defaultSetParamsValue,
renderFilter,
renderRow: RenderRow,
results,
setParams = () => {},
total,
pagination = true,
...props
},
ref,
) => {
) {
const t = useTranslation();

const [filter, setFilter] = useState(paramsDefault);

const [itemsPerPage, setItemsPerPage] = useState(25);
const [itemsPerPage, setItemsPerPage] = useState<25 | 50 | 100>(25);

const [current, setCurrent] = useState(0);

Expand All @@ -40,7 +73,13 @@ const GenericTable = (

const Loading = useCallback(() => {
const headerCells = flattenChildren(header);
return Array.from({ length: 10 }, (_, i) => <LoadingRow key={i} cols={headerCells.length} />);
return (
<>
{Array.from({ length: 10 }, (_, i) => (
<LoadingRow key={i} cols={headerCells.length} />
))}
</>
);
}, [header]);

const showingResultsLabel = useCallback(
Expand All @@ -53,7 +92,9 @@ const GenericTable = (

return (
<>
{typeof renderFilter === 'function' ? renderFilter({ onChange: setFilter, ...props }) : null}
{typeof renderFilter === 'function'
? renderFilter({ ...props, onChange: setFilter } as any) // TODO: ugh
: null}
{results && !results.length ? (
<Tile fontScale='p1' elevation='0' color='info' textAlign='center'>
{t('No_data_found')}
Expand Down Expand Up @@ -98,8 +139,6 @@ const GenericTable = (
)}
</>
);
};

export default Object.assign(forwardRef(GenericTable), {
HeaderCell,
});

export default GenericTable;
6 changes: 6 additions & 0 deletions client/components/GenericTable/index.ts
@@ -0,0 +1,6 @@
import GenericTable from './GenericTable';
import HeaderCell from './HeaderCell';

export default Object.assign(GenericTable, {
HeaderCell,
});
6 changes: 3 additions & 3 deletions client/components/Omnichannel/Tags.js
Expand Up @@ -21,7 +21,7 @@ const Tags = ({ tags = [], handler = () => {}, error = '', tagRequired = false }
const dispatchToastMessage = useToastMessageDispatch();

const [tagValue, handleTagValue] = useState('');
const [paginatedTagValue, handlePaginatedTagValue] = useState([]);
const [paginatedTagValue, handlePaginatedTagValue] = useState(tags);

const removeTag = (tag) => {
const tagsFiltered = tags.filter((tagArray) => tagArray !== tag);
Expand Down Expand Up @@ -68,7 +68,7 @@ const Tags = ({ tags = [], handler = () => {}, error = '', tagRequired = false }
<Field.Row>
<TextInput
error={error}
value={tagValue}
value={tagValue?.value ? tagValue.value : tagValue}
onChange={(event) => handleTagValue(event.target.value)}
flexGrow={1}
placeholder={t('Enter_a_tag')}
Expand All @@ -80,7 +80,7 @@ const Tags = ({ tags = [], handler = () => {}, error = '', tagRequired = false }
<Field.Row justifyContent='flex-start'>
{tags.map((tag, i) => (
<Chip key={i} onClick={() => removeTag(tag)} mie='x8'>
{tag}
{tag?.value ? tag.value : tag}
</Chip>
))}
</Field.Row>
Expand Down
4 changes: 4 additions & 0 deletions client/contexts/ServerContext/endpoints.ts
Expand Up @@ -19,13 +19,15 @@ import { ImMembersEndpoint } from './endpoints/v1/im/members';
import { AppearanceEndpoint as LivechatAppearanceEndpoint } from './endpoints/v1/livechat/appearance';
import { LivechatCustomFieldsEndpoint } from './endpoints/v1/livechat/customFields';
import { LivechatDepartment } from './endpoints/v1/livechat/department';
import { LivechatDepartmentSingle } from './endpoints/v1/livechat/departmentSingle';
import { LivechatDepartmentsByUnit } from './endpoints/v1/livechat/departmentsByUnit';
import { LivechatMonitorsList } from './endpoints/v1/livechat/monitorsList';
import { LivechatRoomOnHoldEndpoint } from './endpoints/v1/livechat/onHold';
import { LivechatRoomsEndpoint } from './endpoints/v1/livechat/rooms';
import { LivechatTagsList } from './endpoints/v1/livechat/tagsList';
import { LivechatUsersAgentEndpoint } from './endpoints/v1/livechat/usersAgent';
import { LivechatVisitorInfoEndpoint } from './endpoints/v1/livechat/visitorInfo';
import { CannedResponseEndpoint } from './endpoints/v1/omnichannel/cannedResponse';
import { CannedResponsesEndpoint } from './endpoints/v1/omnichannel/cannedResponses';
import { AutocompleteAvailableForTeamsEndpoint as RoomsAutocompleteTeamsEndpoint } from './endpoints/v1/rooms/autocompleteAvailableForTeams';
import { AutocompleteChannelAndPrivateEndpoint as RoomsAutocompleteEndpoint } from './endpoints/v1/rooms/autocompleteChannelAndPrivate';
Expand Down Expand Up @@ -66,6 +68,7 @@ export type ServerEndpoints = {
'livechat/monitors.list': LivechatMonitorsList;
'livechat/tags.list': LivechatTagsList;
'livechat/department': LivechatDepartment;
'livechat/department/${string}': LivechatDepartmentSingle;
'livechat/departments.by-unit/': LivechatDepartmentsByUnit;
'engagement-dashboard/users/active-users': EngagementDashboardActiveUsersEndpoint;
'rooms.info': RoomsInfoEndpoint;
Expand All @@ -74,6 +77,7 @@ export type ServerEndpoints = {
'livechat/rooms': LivechatRoomsEndpoint;
'livechat/users/agent': LivechatUsersAgentEndpoint;
'canned-responses': CannedResponsesEndpoint;
'canned-responses/${string}': CannedResponseEndpoint;
};

export type ServerEndpointPath = keyof ServerEndpoints;
Expand Down
@@ -0,0 +1,10 @@
import { ILivechatDepartment } from '../../../../../../definition/ILivechatDepartment';

export type LivechatDepartmentSingleGetReturn = {
department: ILivechatDepartment;
success: boolean;
};

export type LivechatDepartmentSingle = {
GET: () => LivechatDepartmentSingleGetReturn;
};
@@ -0,0 +1,10 @@
import { IOmnichannelCannedResponse } from '../../../../../../definition/IOmnichannelCannedResponse';

export type CannedResponseEndpointGetReturn = {
cannedResponse: IOmnichannelCannedResponse;
success: boolean;
};

export type CannedResponseEndpoint = {
GET: () => CannedResponseEndpointGetReturn;
};
Expand Up @@ -86,15 +86,24 @@ export const FederationModal: FC<{ onClose: () => void }> = ({
} else {
setCurrentStep(currentStep + 1);
}
}, [currentStep, hasUnsavedChanges, domain, discoveryMethod]);
}, [
currentStep,
hasUnsavedChanges,
domain,
discoveryMethod,
commit,
onClose,
setFederationDomain,
setFederationDiscoveryMethod,
]);

const previousStep = useCallback(() => {
if (currentStep === 1) {
onClose();
} else {
setCurrentStep(currentStep - 1);
}
}, [currentStep]);
}, [currentStep, onClose]);

// Resolve DNS
const resolvedSRVString = useSetting('FEDERATION_ResolvedSRV') as string;
Expand Down Expand Up @@ -152,10 +161,10 @@ export const FederationModal: FC<{ onClose: () => void }> = ({
</Modal.Header>
<Modal.Content>
<Tabs>
<Tabs.Item selected={currentTab === 1} onClick={() => setCurrentTab(1)}>
<Tabs.Item selected={currentTab === 1} onClick={(): void => setCurrentTab(1)}>
Configure DNS
</Tabs.Item>
<Tabs.Item selected={currentTab === 2} onClick={() => setCurrentTab(2)}>
<Tabs.Item selected={currentTab === 2} onClick={(): void => setCurrentTab(2)}>
Legacy Support
</Tabs.Item>
</Tabs>
Expand Down
4 changes: 2 additions & 2 deletions client/views/teams/ChannelDesertionTable.tsx
Expand Up @@ -66,11 +66,11 @@ const ChannelDesertionTable: FC<ChannelDesertionTableProps> = ({
fixed={false}
pagination={false}
>
{(room: IRoom, key: string): ReactElement => (
{(room, key): ReactElement => (
<ChannelRow
key={key}
formatDate={formatDate}
room={room}
key={key}
onChange={onChangeRoomSelection}
selected={!!selectedRooms[room._id]}
lastOwnerWarning={lastOwnerWarning}
Expand Down

0 comments on commit 312cbba

Please sign in to comment.