Skip to content

Commit

Permalink
Merge branch 'develop' into regression/private-apps-status-filter
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] committed Mar 2, 2023
2 parents 139df74 + 47e3c6e commit 4fc1be6
Show file tree
Hide file tree
Showing 99 changed files with 1,563 additions and 933 deletions.
2 changes: 1 addition & 1 deletion apps/meteor/.eslintcache

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions apps/meteor/app/assets/server/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,28 @@ const assets: IRocketChatAssets = {
order: 2,
},
},
logo_dark: {
label: 'logo - dark theme (svg, png, jpg)',
defaultUrl: 'images/logo/logo_dark.svg',
constraints: {
type: 'image',
extensions: ['svg', 'png', 'jpg', 'jpeg'],
},
},
background: {
label: 'login background (svg, png, jpg)',
constraints: {
type: 'image',
extensions: ['svg', 'png', 'jpg', 'jpeg'],
},
},
background_dark: {
label: 'login background - dark theme (svg, png, jpg)',
constraints: {
type: 'image',
extensions: ['svg', 'png', 'jpg', 'jpeg'],
},
},
favicon_ico: {
label: 'favicon (ico)',
defaultUrl: 'favicon.ico',
Expand Down
31 changes: 19 additions & 12 deletions apps/meteor/app/autotranslate/client/lib/actionButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
hasTranslationLanguageInAttachments,
hasTranslationLanguageInMessage,
} from '../../../../client/views/room/MessageList/lib/autoTranslate';
import { roomCoordinator } from '../../../../client/lib/rooms/roomCoordinator';

Meteor.startup(() => {
AutoTranslate.init();
Expand All @@ -33,18 +34,20 @@ Meteor.startup(() => {
const action = 'autoTranslateShowInverse' in message ? '$unset' : '$set';
Messages.update({ _id: message._id }, { [action]: { autoTranslateShowInverse: true } });
},
condition({ message, subscription, user }) {
condition({ message, subscription, user, room }) {
if (!user) {
return false;
}
const language = subscription?.autoTranslateLanguage || AutoTranslate.getLanguage(message.rid) || '';
const isLivechatRoom = roomCoordinator.isLivechatRoom(room?.t);
const isDifferentUser = message?.u && message.u._id !== user._id;
const autoTranslateEnabled = subscription?.autoTranslate || isLivechatRoom;
const hasLanguage =
hasTranslationLanguageInMessage(message, language) || hasTranslationLanguageInAttachments(message.attachments, language);

return Boolean(
(message?.u &&
message.u._id !== user._id &&
subscription?.autoTranslate &&
(message as { autoTranslateShowInverse?: boolean }).autoTranslateShowInverse) ||
(!hasTranslationLanguageInMessage(message, language) && !hasTranslationLanguageInAttachments(message.attachments, language)),
(message as { autoTranslateShowInverse?: boolean }).autoTranslateShowInverse ||
(isDifferentUser && autoTranslateEnabled && !hasLanguage),
);
},
order: 90,
Expand All @@ -65,18 +68,22 @@ Meteor.startup(() => {
const action = 'autoTranslateShowInverse' in message ? '$unset' : '$set';
Messages.update({ _id: message._id }, { [action]: { autoTranslateShowInverse: true } });
},
condition({ message, subscription, user }) {
condition({ message, subscription, user, room }) {
const language = subscription?.autoTranslateLanguage || AutoTranslate.getLanguage(message.rid) || '';
const isLivechatRoom = roomCoordinator.isLivechatRoom(room?.t);
if (!user) {
return false;
}
const isDifferentUser = message?.u && message.u._id !== user._id;
const autoTranslateEnabled = subscription?.autoTranslate || isLivechatRoom;
const hasLanguage =
hasTranslationLanguageInMessage(message, language) || hasTranslationLanguageInAttachments(message.attachments, language);

return Boolean(
message?.u &&
message.u._id !== user._id &&
subscription?.autoTranslate &&
!(message as { autoTranslateShowInverse?: boolean }).autoTranslateShowInverse &&
(hasTranslationLanguageInMessage(message, language) || hasTranslationLanguageInAttachments(message.attachments, language)),
!(message as { autoTranslateShowInverse?: boolean }).autoTranslateShowInverse &&
isDifferentUser &&
autoTranslateEnabled &&
hasLanguage,
);
},
order: 90,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class FederationHooks {
callbacks.add(
'federation.beforeAddUserToARoom',
(params: { user: IUser | string; inviter?: IUser }, room: IRoom): void => {
if (!params || !params.user || !room) {
if (!params?.user || !room) {
return;
}
Promise.await(callback(params.user, room));
Expand All @@ -59,7 +59,7 @@ export class FederationHooks {
callbacks.add(
'federation.beforeAddUserToARoom',
(params: { user: IUser | string; inviter: IUser }, room: IRoom): void => {
if (!params || !params.user || !params.inviter || !room || !settings.get('Federation_Matrix_enabled')) {
if (!params?.user || !params.inviter || !room || !settings.get('Federation_Matrix_enabled')) {
return;
}

Expand Down Expand Up @@ -189,7 +189,7 @@ export class FederationHooks {
);
}

public static afterRoomRoleChanged(federationRoomService: FederationRoomServiceSender, data: Record<string, any>): void {
public static afterRoomRoleChanged(federationRoomService: FederationRoomServiceSender, data?: Record<string, any>): void {
if (!data || !settings.get('Federation_Matrix_enabled')) {
return;
}
Expand Down
14 changes: 8 additions & 6 deletions apps/meteor/app/lib/server/functions/updateMessage.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { IMessage, IMessageEdited, IUser } from '@rocket.chat/core-typings';
import type { IEditedMessage, IMessage, IUser } from '@rocket.chat/core-typings';
import { Meteor } from 'meteor/meteor';

import { Messages, Rooms } from '../../../models/server';
Expand Down Expand Up @@ -35,11 +35,13 @@ export const updateMessage = function (message: IMessage, user: IUser, originalM
Messages.cloneAndSaveAsHistoryById(message._id, user);
}

(message as IMessageEdited).editedAt = new Date();
(message as IMessageEdited).editedBy = {
_id: user._id,
username: user.username,
};
Object.assign<IMessage, Omit<IEditedMessage, keyof IMessage>>(message, {
editedAt: new Date(),
editedBy: {
_id: user._id,
username: user.username,
},
});

parseUrlsInMessage(message);

Expand Down
6 changes: 6 additions & 0 deletions apps/meteor/app/lib/server/startup/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1684,6 +1684,12 @@ settingsRegistry.addGroup('Layout', function () {
multiline: true,
public: true,
});
this.add('Layout_Sidenav_Footer_Dark', '<a href="/home"><img src="assets/logo_dark.png" alt="Home" /></a>', {
type: 'code',
code: 'text/html',
public: true,
i18nDescription: 'Layout_Sidenav_Footer_description',
});
return this.add('Layout_Sidenav_Footer', '<a href="/home"><img src="assets/logo.png" alt="Home" /></a>', {
type: 'code',
code: 'text/html',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ import { RoutingManager } from '../lib/RoutingManager';
callbacks.add(
'afterSaveMessage',
(message, room) => {
if (!isOmnichannelRoom(room)) {
return message;
}

// skip callback if message was edited
if (isEditedMessage(message)) {
if (!isOmnichannelRoom(room) || isEditedMessage(message) || message.t) {
return message;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ Meteor.methods({
name: file.name,
type: file.type,
},
files: [
{
_id: file._id,
name: file.name,
type: file.type,
},
],
groupable: false,
attachments: [attachment],
token: visitorToken,
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/models/server/models/LivechatRooms.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class LivechatRooms extends Base {
);
this.tryEnsureIndex({ 'livechatData.$**': 1 });
this.tryEnsureIndex({ pdfTranscriptRequested: 1 }, { sparse: true });
this.tryEnsureIndex({ pdfFileId: 1 }, { sparse: true });
this.tryEnsureIndex({ pdfTranscriptFileId: 1 }, { sparse: true });
}

findOneByIdOrName(_idOrName, options) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@
white-space: initial;

opacity: 1;
border: 1px solid var(--rcx-color-shadow-elevation-border, var(--rcx-color-stroke-extra-light, var(--rcx-color-neutral-250, #ebecef)));

border-radius: var(--popover-radius);

background-color: var(--rcx-color-surface-light, white);
box-shadow: 0 0 2px 0 rgba(47, 52, 61, 0.08), 0 0 12px 0 rgba(47, 52, 61, 0.12);

box-shadow: 0 0 1px 0 var(--rcx-color-shadow-elevation-2x, rgba(47, 52, 61, 0.08)), 0 0 12px 0 var(--rcx-color-shadow-elevation-2y, rgba(47, 52, 61, 0.12));

&.show {
display: flex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,29 @@ export type FormattingButton =

export const formattingButtons: ReadonlyArray<FormattingButton> = [
{
label: 'bold',
label: 'Bold',
icon: 'bold',
pattern: '*{{text}}*',
command: 'b',
},
{
label: 'italic',
label: 'Italic',
icon: 'italic',
pattern: '_{{text}}_',
command: 'i',
},
{
label: 'strike',
label: 'Strike',
icon: 'strike',
pattern: '~{{text}}~',
},
{
label: 'inline_code',
label: 'Inline_code',
icon: 'code',
pattern: '`{{text}}`',
},
{
label: 'multi_line',
label: 'Multi_line',
icon: 'multiline',
pattern: '```\n{{text}}\n``` ',
},
Expand Down
78 changes: 78 additions & 0 deletions apps/meteor/client/components/CustomFieldsFormV2.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/* eslint-disable react/no-multi-comp */
import type { SelectOption } from '@rocket.chat/fuselage';
import { Field, Select, TextInput } from '@rocket.chat/fuselage';
import type { TranslationKey } from '@rocket.chat/ui-contexts';
import { useTranslation } from '@rocket.chat/ui-contexts';
import React from 'react';
import type { Control, FieldValues } from 'react-hook-form';
import { Controller, get } from 'react-hook-form';

export type CustomFieldMetadata = {
name: string;
label: string;
type: 'select' | 'text';
required?: boolean;
defaultValue?: any;
options?: SelectOption[];
};

type CustomFieldFormProps<T extends FieldValues> = {
metadata: CustomFieldMetadata[];
formControl: Control<T>;
formName: string;
};

type CustomFieldProps<T extends FieldValues> = Omit<CustomFieldMetadata, 'name'> & {
control: Control<T>;
name: string;
};

const FIELD_TYPES = {
select: Select,
text: TextInput,
} as const;

export const CustomField = <T extends FieldValues>({
name,
type,
control,
label,
required,
defaultValue,
options = [],
...props
}: CustomFieldProps<T>) => {
const t = useTranslation();
const Component = FIELD_TYPES[type] ?? null;

return (
<Controller<T, any>
name={name}
control={control}
defaultValue={defaultValue ?? ''}
rules={{ required: t('The_field_is_required', label || name) }}
render={({ field, formState: { errors } }) => (
<Field>
<Field.Label>
{label || t(name as TranslationKey)}
{required && '*'}
</Field.Label>
<Field.Row>
<Component {...props} {...field} options={options} error={get(errors, name) as string} flexGrow={1} />
</Field.Row>
<Field.Error>{get(errors, name)?.message}</Field.Error>
</Field>
)}
/>
);
};

CustomField.displayName = 'CustomField';

export const CustomFieldsForm = <T extends FieldValues>({ formName, formControl, metadata }: CustomFieldFormProps<T>) => (
<>
{metadata.map(({ name: fieldName, ...props }) => (
<CustomField key={fieldName} name={`${formName}.${fieldName}`} control={formControl} {...props} />
))}
</>
);

0 comments on commit 4fc1be6

Please sign in to comment.