From efea589596b63f01c6036f99dd0c76c06cdc2f5a Mon Sep 17 00:00:00 2001 From: Djorkaeff Alexandre Date: Tue, 3 Mar 2020 17:09:10 -0300 Subject: [PATCH 1/3] [FIX] Room Info items colors --- app/views/RoomInfoView/index.js | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/app/views/RoomInfoView/index.js b/app/views/RoomInfoView/index.js index d2937a7c6a5..49d26892adc 100644 --- a/app/views/RoomInfoView/index.js +++ b/app/views/RoomInfoView/index.js @@ -173,8 +173,9 @@ class RoomInfoView extends React.Component { const { theme } = this.props; return ( - {I18n.t(camelize(key))} + {I18n.t(camelize(key))} @@ -248,16 +249,20 @@ class RoomInfoView extends React.Component { ); } - renderBroadcast = () => ( - - {I18n.t('Broadcast_Channel')} - {I18n.t('Broadcast_channel_Description')} - - - ) + renderBroadcast = () => { + const { theme } = this.props; + + return ( + + {I18n.t('Broadcast_Channel')} + {I18n.t('Broadcast_channel_Description')} + + + ); + } renderCustomFields = () => { const { roomUser } = this.state; From 41701102c9c13e88936efb549b057a49dc634920 Mon Sep 17 00:00:00 2001 From: Djorkaeff Alexandre Date: Tue, 3 Mar 2020 17:16:57 -0300 Subject: [PATCH 2/3] [IMPROVEMENT] Code improvement --- app/views/RoomInfoView/index.js | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/app/views/RoomInfoView/index.js b/app/views/RoomInfoView/index.js index 49d26892adc..c4a02fb7ca0 100644 --- a/app/views/RoomInfoView/index.js +++ b/app/views/RoomInfoView/index.js @@ -213,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; @@ -221,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.renderSpecificItem({ + label: I18n.t('Timezone'), + content: `${ moment().utcOffset(utcOffset).format(Message_TimeFormat) } (UTC ${ utcOffset })`, + testID: 'room-info-view-timezone' + }); } return null; } @@ -249,16 +248,23 @@ class RoomInfoView extends React.Component { ); } - renderBroadcast = () => { + renderBroadcast = () => this.renderSpecificItem({ + label: I18n.t('Broadcast_Channel'), + content: I18n.t('Broadcast_channel_Description'), + testID: 'room-info-view-broadcast' + }); + + renderSpecificItem = ({ label, content, testID }) => { const { theme } = this.props; return ( - {I18n.t('Broadcast_Channel')} + {label} {I18n.t('Broadcast_channel_Description')} + testID={testID} + > + {content} ); From 2c6fb6dfe79e1bd9d2b940246a1dc7425ac1fe24 Mon Sep 17 00:00:00 2001 From: Djorkaeff Alexandre Date: Tue, 3 Mar 2020 17:46:20 -0300 Subject: [PATCH 3/3] [FIX] Remove renderSpecificItem --- app/views/RoomInfoView/index.js | 39 ++++++++++----------------------- 1 file changed, 12 insertions(+), 27 deletions(-) diff --git a/app/views/RoomInfoView/index.js b/app/views/RoomInfoView/index.js index c4a02fb7ca0..6aa143a162e 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,14 +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)} @@ -221,8 +221,8 @@ class RoomInfoView extends React.Component { if (!utcOffset) { return null; } - return this.renderSpecificItem({ - label: I18n.t('Timezone'), + return this.renderItem({ + label: 'Timezone', content: `${ moment().utcOffset(utcOffset).format(Message_TimeFormat) } (UTC ${ utcOffset })`, testID: 'room-info-view-timezone' }); @@ -248,28 +248,12 @@ class RoomInfoView extends React.Component { ); } - renderBroadcast = () => this.renderSpecificItem({ - label: I18n.t('Broadcast_Channel'), + renderBroadcast = () => this.renderItem({ + label: 'Broadcast_Channel', content: I18n.t('Broadcast_channel_Description'), testID: 'room-info-view-broadcast' }); - renderSpecificItem = ({ label, content, testID }) => { - const { theme } = this.props; - - return ( - - {label} - - {content} - - - ); - } - renderCustomFields = () => { const { roomUser } = this.state; if (roomUser) { @@ -322,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} );