diff --git a/app/views/RoomInfoView/index.js b/app/views/RoomInfoView/index.js index c81fb91a6..579fb1ba5 100644 --- a/app/views/RoomInfoView/index.js +++ b/app/views/RoomInfoView/index.js @@ -24,7 +24,6 @@ import { getUserSelector } from '../../selectors/login'; import Markdown from '../../containers/markdown'; const PERMISSION_EDIT_ROOM = 'edit-room'; -const camelize = str => str.replace(/^(.)/, (match, chr) => chr.toUpperCase()); const getRoomTitle = (room, type, name, username, theme) => (type === 'd' ? ( <> @@ -169,13 +168,15 @@ class RoomInfoView extends React.Component { isDirect = () => this.t === 'd' - renderItem = (key, room) => { + renderItem = ({ label, content, testID }) => { const { theme } = this.props; return ( - {I18n.t(camelize(key))} + {I18n.t(label)} @@ -212,7 +213,7 @@ class RoomInfoView extends React.Component { renderTimezone = () => { const { roomUser } = this.state; - const { Message_TimeFormat, theme } = this.props; + const { Message_TimeFormat } = this.props; if (roomUser) { const { utcOffset } = roomUser; @@ -220,12 +221,11 @@ class RoomInfoView extends React.Component { if (!utcOffset) { return null; } - return ( - - {I18n.t('Timezone')} - {moment().utcOffset(utcOffset).format(Message_TimeFormat)} (UTC { utcOffset }) - - ); + return this.renderItem({ + label: 'Timezone', + content: `${ moment().utcOffset(utcOffset).format(Message_TimeFormat) } (UTC ${ utcOffset })`, + testID: 'room-info-view-timezone' + }); } return null; } @@ -248,16 +248,11 @@ class RoomInfoView extends React.Component { ); } - renderBroadcast = () => ( - - {I18n.t('Broadcast_Channel')} - {I18n.t('Broadcast_channel_Description')} - - - ) + renderBroadcast = () => this.renderItem({ + label: 'Broadcast_Channel', + content: I18n.t('Broadcast_channel_Description'), + testID: 'room-info-view-broadcast' + }); renderCustomFields = () => { const { roomUser } = this.state; @@ -311,11 +306,12 @@ class RoomInfoView extends React.Component { renderChannel = () => { const { room } = this.state; + const { description, topic, announcement } = room; return ( <> - {this.renderItem('description', room)} - {this.renderItem('topic', room)} - {this.renderItem('announcement', room)} + {this.renderItem({ label: 'Description', content: description })} + {this.renderItem({ label: 'Topic', content: topic })} + {this.renderItem({ label: 'Announcement', content: announcement })} {room.broadcast ? this.renderBroadcast() : null} );