Commit 41750720 authored by jbuechele's avatar jbuechele
Browse files

Merge branch 'develop' into v2.8.0

parents c03a8154 b75e192e
......@@ -13,6 +13,7 @@ import { events, logEvent } from '../../utils/log';
interface IMessageBoxRecordAudioProps {
theme: string;
permissionToUpload: boolean;
recordingCallback: Function;
onFinish: Function;
}
......@@ -192,9 +193,11 @@ export default class RecordAudio extends React.PureComponent<IMessageBoxRecordAu
};
render() {
const { theme } = this.props;
const { theme, permissionToUpload } = this.props;
const { isRecording, isRecorderActive } = this.state;
if (!permissionToUpload) {
return null;
}
if (!isRecording && !isRecorderActive) {
return (
<BorderlessButton
......
......@@ -109,6 +109,8 @@ interface IMessageBoxProps {
sharing: boolean;
isActionsEnabled: boolean;
usedCannedResponse: string;
uploadFilePermission: string[];
serverVersion: string;
}
interface IMessageBoxState {
......@@ -124,6 +126,7 @@ interface IMessageBoxState {
};
tshow: boolean;
mentionLoading: boolean;
permissionToUpload: boolean;
}
class MessageBox extends Component<IMessageBoxProps, IMessageBoxState> {
......@@ -179,41 +182,13 @@ class MessageBox extends Component<IMessageBoxProps, IMessageBoxState> {
showCommandPreview: false,
command: {},
tshow: false,
mentionLoading: false
mentionLoading: false,
permissionToUpload: true
};
this.text = '';
this.selection = { start: 0, end: 0 };
this.focused = false;
// MessageBox Actions
this.options = [
{
title: I18n.t('Take_a_photo'),
icon: 'camera-photo',
onPress: this.takePhoto
},
{
title: I18n.t('Take_a_video'),
icon: 'camera',
onPress: this.takeVideo
},
{
title: I18n.t('Choose_from_library'),
icon: 'image',
onPress: this.chooseFromLibrary
},
{
title: I18n.t('Choose_file'),
icon: 'attach',
onPress: this.chooseFile
},
{
title: I18n.t('Create_Discussion'),
icon: 'discussions',
onPress: this.createDiscussion
}
];
const libPickerLabels = {
cropperChooseText: I18n.t('Choose'),
cropperCancelText: I18n.t('Cancel'),
......@@ -277,6 +252,8 @@ class MessageBox extends Component<IMessageBoxProps, IMessageBoxState> {
this.onChangeText(usedCannedResponse);
}
this.setOptions();
this.unsubscribeFocus = navigation.addListener('focus', () => {
// didFocus
// We should wait pushed views be dismissed
......@@ -321,10 +298,20 @@ class MessageBox extends Component<IMessageBoxProps, IMessageBoxState> {
}
}
shouldComponentUpdate(nextProps: any, nextState: any) {
const { showEmojiKeyboard, showSend, recording, mentions, commandPreview, tshow, mentionLoading, trackingType } = this.state;
const { roomType, replying, editing, isFocused, message, theme, usedCannedResponse } = this.props;
shouldComponentUpdate(nextProps: IMessageBoxProps, nextState: IMessageBoxState) {
const {
showEmojiKeyboard,
showSend,
recording,
mentions,
commandPreview,
tshow,
mentionLoading,
trackingType,
permissionToUpload
} = this.state;
const { roomType, replying, editing, isFocused, message, theme, usedCannedResponse, uploadFilePermission } = this.props;
if (nextProps.theme !== theme) {
return true;
}
......@@ -358,6 +345,9 @@ class MessageBox extends Component<IMessageBoxProps, IMessageBoxState> {
if (nextState.tshow !== tshow) {
return true;
}
if (nextState.permissionToUpload !== permissionToUpload) {
return true;
}
if (!dequal(nextState.mentions, mentions)) {
return true;
}
......@@ -367,12 +357,22 @@ class MessageBox extends Component<IMessageBoxProps, IMessageBoxState> {
if (!dequal(nextProps.message?.id, message?.id)) {
return true;
}
if (!dequal(nextProps.uploadFilePermission, uploadFilePermission)) {
return true;
}
if (nextProps.usedCannedResponse !== usedCannedResponse) {
return true;
}
return false;
}
componentDidUpdate(prevProps: IMessageBoxProps) {
const { uploadFilePermission } = this.props;
if (!dequal(prevProps.uploadFilePermission, uploadFilePermission)) {
this.setOptions();
}
}
componentWillUnmount() {
console.countReset(`${this.constructor.name}.render calls`);
if (this.onChangeText && this.onChangeText.stop) {
......@@ -404,6 +404,19 @@ class MessageBox extends Component<IMessageBoxProps, IMessageBoxState> {
}
}
setOptions = async () => {
const { uploadFilePermission, rid } = this.props;
// Servers older than 4.2
if (!uploadFilePermission) {
this.setState({ permissionToUpload: true });
return;
}
const permissionToUpload = await RocketChat.hasPermission([uploadFilePermission], rid);
this.setState({ permissionToUpload: permissionToUpload[0] });
};
onChangeText: any = (text: string): void => {
const isTextEmpty = text.length === 0;
this.setShowSend(!isTextEmpty);
......@@ -666,8 +679,9 @@ class MessageBox extends Component<IMessageBoxProps, IMessageBoxState> {
};
canUploadFile = (file: any) => {
const { permissionToUpload } = this.state;
const { FileUpload_MediaTypeWhiteList, FileUpload_MaxFileSize } = this.props;
const result = canUploadFile(file, FileUpload_MediaTypeWhiteList, FileUpload_MaxFileSize);
const result = canUploadFile(file, FileUpload_MediaTypeWhiteList, FileUpload_MaxFileSize, permissionToUpload);
if (result.success) {
return true;
}
......@@ -766,8 +780,41 @@ class MessageBox extends Component<IMessageBoxProps, IMessageBoxState> {
showMessageBoxActions = () => {
logEvent(events.ROOM_SHOW_BOX_ACTIONS);
const { permissionToUpload } = this.state;
const { showActionSheet } = this.props;
showActionSheet({ options: this.options });
const options = [];
if (permissionToUpload) {
options.push(
{
title: I18n.t('Take_a_photo'),
icon: 'camera-photo',
onPress: this.takePhoto
},
{
title: I18n.t('Take_a_video'),
icon: 'camera',
onPress: this.takeVideo
},
{
title: I18n.t('Choose_from_library'),
icon: 'image',
onPress: this.chooseFromLibrary
},
{
title: I18n.t('Choose_file'),
icon: 'attach',
onPress: this.chooseFile
}
);
}
options.push({
title: I18n.t('Create_Discussion'),
icon: 'discussions',
onPress: this.createDiscussion
});
showActionSheet({ options });
};
editCancel = () => {
......@@ -968,8 +1015,17 @@ class MessageBox extends Component<IMessageBoxProps, IMessageBoxState> {
};
renderContent = () => {
const { recording, showEmojiKeyboard, showSend, mentions, trackingType, commandPreview, showCommandPreview, mentionLoading } =
this.state;
const {
recording,
showEmojiKeyboard,
showSend,
mentions,
trackingType,
commandPreview,
showCommandPreview,
mentionLoading,
permissionToUpload
} = this.state;
const {
editing,
message,
......@@ -995,7 +1051,12 @@ class MessageBox extends Component<IMessageBoxProps, IMessageBoxState> {
const recordAudio =
showSend || !Message_AudioRecorderEnabled ? null : (
<RecordAudio theme={theme} recordingCallback={this.recordingCallback} onFinish={this.finishAudioMessage} />
<RecordAudio
theme={theme}
recordingCallback={this.recordingCallback}
onFinish={this.finishAudioMessage}
permissionToUpload={permissionToUpload}
/>
);
const commandsPreviewAndMentions = !recording ? (
......@@ -1117,7 +1178,8 @@ const mapStateToProps = (state: any) => ({
user: getUserSelector(state),
FileUpload_MediaTypeWhiteList: state.settings.FileUpload_MediaTypeWhiteList,
FileUpload_MaxFileSize: state.settings.FileUpload_MaxFileSize,
Message_AudioRecorderEnabled: state.settings.Message_AudioRecorderEnabled
Message_AudioRecorderEnabled: state.settings.Message_AudioRecorderEnabled,
uploadFilePermission: state.permissions['mobile-upload-file']
});
const dispatchToProps = {
......
......@@ -328,7 +328,6 @@
"N_users": "{{n}} مستخدمين",
"N_channels": "{{n}} القنوات",
"Name": "اسم",
"Navigation_history": "تاريخ التصفح",
"Never": "أبداً",
"New_Message": "رسالة جديدة",
"New_Password": "كلمة مرور جديدة",
......
......@@ -330,7 +330,6 @@
"N_users": "{{n}} Benutzer",
"N_channels": "{{n}} Kanäle",
"Name": "Name",
"Navigation_history": "Navigations-Verlauf",
"Never": "Niemals",
"New_Message": "Neue Nachricht",
"New_Password": "Neues Kennwort",
......
......@@ -21,6 +21,7 @@
"error-save-video": "Error while saving video",
"error-field-unavailable": "{{field}} is already in use :(",
"error-file-too-large": "File is too large",
"error-not-permission-to-upload-file": "You don't have permission to upload files",
"error-importer-not-defined": "The importer was not defined correctly, it is missing the Import class.",
"error-input-is-not-a-valid-field": "{{input}} is not a valid {{field}}",
"error-invalid-actionlink": "Invalid action link",
......@@ -330,7 +331,6 @@
"N_users": "{{n}} users",
"N_channels": "{{n}} channels",
"Name": "Name",
"Navigation_history": "Navigation history",
"Never": "Never",
"New_Message": "New Message",
"New_Password": "New Password",
......
......@@ -330,7 +330,6 @@
"N_users": "{{n}} utilisateurs",
"N_channels": "{{n}} canaux",
"Name": "Nom",
"Navigation_history": "Historique de navigation",
"Never": "Jamais",
"New_Message": "Nouveau message",
"New_Password": "Nouveau mot de passe",
......
......@@ -322,7 +322,6 @@
"N_people_reacted": "{{n}} persone hanno reagito",
"N_users": "{{n}} utenti",
"Name": "Nome",
"Navigation_history": "Cronologia di navigazione",
"Never": "Mai",
"New_Message": "Nuovo messaggio",
"New_Password": "Nuova password",
......
......@@ -330,7 +330,6 @@
"N_users": "{{n}} gebruikers",
"N_channels": "{{n}} kanalen",
"Name": "Naam",
"Navigation_history": "Navigatie geschiedenis",
"Never": "Nooit",
"New_Message": "Nieuw bericht",
"New_Password": "Nieuw wachtwoord",
......
......@@ -309,7 +309,6 @@
"N_users": "{{n}} usuários",
"N_channels": "{{n}} canais",
"Name": "Nome",
"Navigation_history": "Histórico de navegação",
"Never": "Nunca",
"New_Message": "Nova Mensagem",
"New_Password": "Nova Senha",
......
......@@ -329,7 +329,6 @@
"N_users": "{{n}} utilizadores",
"N_channels": "{{n}} canais",
"Name": "Nome",
"Navigation_history": "Histórico de navegação",
"Never": "Nunca",
"New_Message": "Nova Mensagem",
"New_Password": "Nova Palavra-passe",
......
......@@ -330,7 +330,6 @@
"N_users": "{{n}} пользователи",
"N_channels": "{{n}} каналов",
"Name": "Имя",
"Navigation_history": "История навигации",
"Never": "Никогда",
"New_Message": "Новое сообщение",
"New_Password": "Новый пароль",
......
......@@ -323,7 +323,6 @@
"N_people_reacted": "{{n}} kişi tepki verdi",
"N_users": "{{n}} kullanıcı",
"Name": "İsim",
"Navigation_history": "Gezinti geçmişi",
"Never": "Asla",
"New_Message": "Yeni İleti",
"New_Password": "Yeni Şifre",
......
......@@ -320,7 +320,6 @@
"N_people_reacted": "{{n}} 人回复",
"N_users": "{{n}} 位用户",
"Name": "名称",
"Navigation_history": "浏览历史记录",
"Never": "从不",
"New_Message": "新信息",
"New_Password": "新密码",
......
......@@ -321,7 +321,6 @@
"N_people_reacted": "{{n}} 人回复",
"N_users": "{{n}} 位使用者",
"Name": "名稱",
"Navigation_history": "瀏覽歷史記錄",
"Never": "從不",
"New_Message": "新訊息",
"New_Password": "新密碼",
......
......@@ -55,7 +55,8 @@ const PERMISSIONS = [
'convert-team',
'edit-omnichannel-contact',
'edit-livechat-room-customfields',
'view-canned-responses'
'view-canned-responses',
'mobile-upload-file'
];
export async function setPermissions() {
......
......@@ -1138,10 +1138,6 @@ const RocketChat = {
// RC 0.36.0
return this.methodCallWrapper('livechat:transfer', transferData);
},
getPagesLivechat(rid, offset) {
// RC 2.3.0
return this.sdk.get(`livechat/visitors.pagesVisited/${rid}?count=50&offset=${offset}`);
},
getDepartmentInfo(departmentId) {
// RC 2.2.0
return this.sdk.get(`livechat/department/${departmentId}?includeAgents=false`);
......@@ -1520,16 +1516,7 @@ const RocketChat = {
return this.sdk.get(`${this.roomTypeToApiType(type)}.files`, {
roomId,
offset,
sort: { uploadedAt: -1 },
fields: {
name: 1,
description: 1,
size: 1,
type: 1,
uploadedAt: 1,
url: 1,
userId: 1
}
sort: { uploadedAt: -1 }
});
},
getMessages(roomId, type, query, offset) {
......
......@@ -46,7 +46,7 @@ interface IUserItem {
testID: string;
onLongPress?: () => void;
style?: StyleProp<ViewStyle>;
icon?: string;
icon?: string | null;
theme: string;
}
......
......@@ -21,7 +21,6 @@ import MessagesView from '../views/MessagesView';
import AutoTranslateView from '../views/AutoTranslateView';
import DirectoryView from '../views/DirectoryView';
import NotificationPrefView from '../views/NotificationPreferencesView';
import VisitorNavigationView from '../views/VisitorNavigationView';
import ForwardLivechatView from '../views/ForwardLivechatView';
import LivechatEditView from '../views/LivechatEditView';
import PickerView from '../views/PickerView';
......@@ -114,11 +113,6 @@ const ChatsStackNavigator = () => {
component={NotificationPrefView}
options={NotificationPrefView.navigationOptions}
/>
<ChatsStack.Screen
name='VisitorNavigationView'
component={VisitorNavigationView}
options={VisitorNavigationView.navigationOptions}
/>
<ChatsStack.Screen
name='ForwardLivechatView'
component={ForwardLivechatView}
......
......@@ -20,7 +20,6 @@ import MessagesView from '../../views/MessagesView';
import AutoTranslateView from '../../views/AutoTranslateView';
import DirectoryView from '../../views/DirectoryView';
import NotificationPrefView from '../../views/NotificationPreferencesView';
import VisitorNavigationView from '../../views/VisitorNavigationView';
import ForwardLivechatView from '../../views/ForwardLivechatView';
import CannedResponsesListView from '../../views/CannedResponsesListView';
import CannedResponseDetail from '../../views/CannedResponseDetail';
......@@ -158,11 +157,6 @@ const ModalStackNavigator = React.memo(({ navigation }: INavigation) => {
component={NotificationPrefView}
options={NotificationPrefView.navigationOptions}
/>
<ModalStack.Screen
name='VisitorNavigationView'
component={VisitorNavigationView}
options={VisitorNavigationView.navigationOptions}
/>
<ModalStack.Screen
name='ForwardLivechatView'
component={ForwardLivechatView}
......
......@@ -97,9 +97,6 @@ export type ModalStackParamList = {
rid: string;
room: IRoom;
};
VisitorNavigationView: {
rid: string;
};
ForwardLivechatView: {
rid: string;
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment