Skip to content

Commit edc5f23

Browse files
Eric Huangembbnux
authored andcommitted
fix some styles and recent container initialization issues (#351)
* fix some styles issues and recent container initialization issues * reduce unneccessary update
1 parent 9ecf9a0 commit edc5f23

File tree

9 files changed

+89
-84
lines changed

9 files changed

+89
-84
lines changed

src/components/BackHeader/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Header from '../Header';
66
import dynamicsFont from '../../assets/DynamicsFont/DynamicsFont.scss';
77

88
const BackHeader = (props) => {
9-
const buttons = props.buttons;
9+
const buttons = props.buttons || [];
1010
const defaultBackButton =
1111
<i className={classnames(dynamicsFont.arrow, styles.iconRotate)} />;
1212
buttons.push({
@@ -37,6 +37,6 @@ BackHeader.propTypes = {
3737

3838
BackHeader.defaultProps = {
3939
className: '',
40-
buttons: [],
40+
buttons: undefined,
4141
backButton: undefined,
4242
};

src/components/CallingSettingsPanel/index.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -140,17 +140,9 @@ export default class CallingSettingsPanel extends Component {
140140
className,
141141
disabled,
142142
} = this.props;
143-
const buttons = [];
144143
const hasChanges = this.state.callWith !== callWith ||
145144
this.state.myLocation !== myLocation ||
146145
this.state.ringoutPrompt !== ringoutPrompt;
147-
buttons.push({
148-
label: <Revert width="19" className={styles.revertIcon} />,
149-
onClick: this.onReset,
150-
placement: 'right',
151-
hidden: !hasChanges,
152-
});
153-
154146
const ringout =
155147
(
156148
this.state.callWith !== callingOptions.softphone &&
@@ -200,7 +192,7 @@ export default class CallingSettingsPanel extends Component {
200192
return (
201193
<div className={classnames(styles.root, className)}>
202194
<BackHeader
203-
buttons={buttons}
195+
buttons={[]}
204196
onBackClick={onBackButtonClick}
205197
>
206198
{i18n.getString('title', currentLocale)}

src/components/DialTextInput/styles.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
left: 42px;
1414
display: inline-block;
1515
border: none;
16+
width: calc(100% - 70px);
1617
input {
1718
font-size: 15px;
1819
padding: 0;
19-
max-width: 72%;
2020
color: $primary-neutral-color;
2121
}
2222
}

src/components/DropdownSelect/styles.scss

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
padding: 5px 10px;
6262
&:hover {
6363
color: $primary-color;
64+
cursor: pointer;
6465
}
6566
}
6667
.dropdownItem:first-child {
@@ -143,9 +144,6 @@
143144
white-space: nowrap;
144145
overflow: hidden;
145146
}
146-
li:hover {
147-
cursor: pointer;
148-
}
149147
}
150148

151149

src/components/RecentActivityCalls/index.js

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import React, { Component } from 'react';
22
import PropTypes from 'prop-types';
33
import classnames from 'classnames';
44
import dynamicsFont from '../../assets/DynamicsFont/DynamicsFont.scss';
@@ -56,35 +56,44 @@ CallItem.propTypes = {
5656
currentLocale: PropTypes.string.isRequired
5757
};
5858

59-
export default function RecentActivityMessages({
60-
currentLocale,
61-
calls,
62-
isCallsLoaded,
63-
dateTimeFormatter
64-
}) {
65-
let callListView = null;
66-
if (!isCallsLoaded) {
67-
callListView = (<Spinner className={styles.spinner} ringWidth={4} />);
68-
} else if (calls.length > 0) {
69-
callListView = calls.map(call => (
70-
<CallItem
71-
key={call.id}
72-
call={call}
73-
currentLocale={currentLocale}
74-
dateTimeFormatter={dateTimeFormatter}
75-
/>
76-
));
77-
} else {
78-
callListView = (<p className={styles.noRecords}>{i18n.getString('noRecords', currentLocale)}</p>);
59+
export default class RecentActivityCalls extends Component {
60+
shouldComponentUpdate(nextProps) {
61+
return nextProps.currentLocale !== this.props.currentLocale ||
62+
nextProps.calls !== this.props.calls ||
63+
nextProps.isCallsLoaded !== this.props.isCallsLoaded;
64+
}
65+
66+
render() {
67+
const {
68+
currentLocale,
69+
calls,
70+
isCallsLoaded,
71+
dateTimeFormatter
72+
} = this.props;
73+
let callListView = null;
74+
if (!isCallsLoaded) {
75+
callListView = (<Spinner className={styles.spinner} ringWidth={4} />);
76+
} else if (calls.length > 0) {
77+
callListView = calls.map(call => (
78+
<CallItem
79+
key={call.id}
80+
call={call}
81+
currentLocale={currentLocale}
82+
dateTimeFormatter={dateTimeFormatter}
83+
/>
84+
));
85+
} else {
86+
callListView = (<p className={styles.noRecords}>{i18n.getString('noRecords', currentLocale)}</p>);
87+
}
88+
return (
89+
<div className={styles.calls}>
90+
{callListView}
91+
</div>
92+
);
7993
}
80-
return (
81-
<div className={styles.calls}>
82-
{ callListView }
83-
</div>
84-
);
8594
}
8695

87-
RecentActivityMessages.propTypes = {
96+
RecentActivityCalls.propTypes = {
8897
currentLocale: PropTypes.string.isRequired,
8998
calls: PropTypes.array.isRequired,
9099
isCallsLoaded: PropTypes.bool.isRequired,

src/components/RecentActivityMessages/index.js

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import React, { Component } from 'react';
22
import PropTypes from 'prop-types';
33
import classNames from 'classnames/bind';
44
import Spinner from '../Spinner';
@@ -29,33 +29,42 @@ MessageItem.propTypes = {
2929
dateTimeFormatter: PropTypes.func.isRequired
3030
};
3131

32-
export default function RecentActivityMessages({
33-
currentLocale,
34-
messages,
35-
isMessagesLoaded,
36-
navigateTo,
37-
dateTimeFormatter
38-
}) {
39-
let messageListView = null;
40-
if (!isMessagesLoaded) {
41-
messageListView = (<Spinner className={styles.spinner} ringWidth={4} />);
42-
} else if (messages.length > 0) {
43-
messageListView = messages.map(message => (
44-
<MessageItem
45-
key={message.id}
46-
message={message}
47-
navigateTo={navigateTo}
48-
dateTimeFormatter={dateTimeFormatter}
49-
/>
50-
));
51-
} else {
52-
messageListView = (<p className={styles.noRecords}>{i18n.getString('noRecords', currentLocale)}</p>);
32+
export default class RecentActivityMessages extends Component {
33+
shouldComponentUpdate(nextProps) {
34+
return nextProps.currentLocale !== this.props.currentLocale ||
35+
nextProps.messages !== this.props.messages ||
36+
nextProps.isMessagesLoaded !== this.props.isMessagesLoaded;
37+
}
38+
39+
render() {
40+
const {
41+
currentLocale,
42+
messages,
43+
isMessagesLoaded,
44+
navigateTo,
45+
dateTimeFormatter
46+
} = this.props;
47+
let messageListView = null;
48+
if (!isMessagesLoaded) {
49+
messageListView = (<Spinner className={styles.spinner} ringWidth={4} />);
50+
} else if (messages.length > 0) {
51+
messageListView = messages.map(message => (
52+
<MessageItem
53+
key={message.id}
54+
message={message}
55+
navigateTo={navigateTo}
56+
dateTimeFormatter={dateTimeFormatter}
57+
/>
58+
));
59+
} else {
60+
messageListView = (<p className={styles.noRecords}>{i18n.getString('noRecords', currentLocale)}</p>);
61+
}
62+
return (
63+
<div className={styles.messages}>
64+
{messageListView}
65+
</div>
66+
);
5367
}
54-
return (
55-
<div className={styles.messages}>
56-
{ messageListView }
57-
</div>
58-
);
5968
}
6069

6170
RecentActivityMessages.propTypes = {

src/components/RegionSettingsPanel/index.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,8 @@ export default class RegionSettings extends Component {
8888
}
8989

9090
render() {
91-
const buttons = [];
9291
const hasChanges = this.state.areaCodeValue !== this.props.areaCode ||
9392
this.state.countryCodeValue !== this.props.countryCode;
94-
if (this.props.onBackButtonClick) {
95-
buttons.push({
96-
label: <Revert width="19" className={styles.revertIcon} />,
97-
onClick: this.onResetClick,
98-
placement: 'right',
99-
hidden: !hasChanges,
100-
});
101-
}
10293
const hasNA = !!this.props.availableCountries.find(c => c.isoCode === 'US') ||
10394
!!this.props.availableCountries.find(c => c.isoCode === 'CA');
10495
let messageId;
@@ -117,7 +108,7 @@ export default class RegionSettings extends Component {
117108
return (
118109
<div className={classnames(styles.root, this.props.className)}>
119110
<BackHeader
120-
buttons={buttons}
111+
buttons={[]}
121112
onBackClick={this.onBackClick}
122113
>
123114
{i18n.getString('title', this.props.currentLocale)}

src/components/TransferPanel/styles.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ $input-height: 30px;
2929
padding: 0;
3030
outline: 0;
3131
height: 100%;
32-
width: calc(100% - 55px);
33-
margin-left: 5%;
32+
width: calc(100% - 75px);
33+
margin-left: 15px;
3434
background-color: transparent;
3535
border: none;
3636
font-size:15px;

src/containers/RecentActivityContainer/index.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,29 @@ import FaxIcon from '../../assets/images/Fax.svg';
1010
import i18n from './i18n';
1111

1212
function getTabs({
13+
ready,
1314
currentLocale,
1415
dateTimeFormatter,
1516
navigateTo,
1617
recentMessages,
1718
recentCalls,
1819
currentContact,
1920
}) {
21+
if (!ready) return [];
2022
let messages = [];
2123
let calls = [];
2224
let unreadMessageCounts = 0;
2325
if (currentContact && currentContact.id) {
2426
const contactId = currentContact.id;
25-
if (recentMessages.messages[contactId])
27+
if (recentMessages.messages[contactId]) {
2628
messages = recentMessages.messages[contactId];
27-
if (recentCalls.calls[contactId])
29+
}
30+
if (recentCalls.calls[contactId]) {
2831
calls = recentCalls.calls[contactId];
29-
if (recentMessages.unreadMessageCounts[contactId])
32+
}
33+
if (recentMessages.unreadMessageCounts[contactId]) {
3034
unreadMessageCounts = recentMessages.unreadMessageCounts[contactId];
35+
}
3136
}
3237
return [
3338
{
@@ -124,6 +129,7 @@ function mapToProps(_, {
124129
currentContact,
125130
calls: recentCalls.calls || [],
126131
tabs: getTabs({
132+
ready,
127133
currentLocale,
128134
dateTimeFormatter,
129135
navigateTo,

0 commit comments

Comments
 (0)