Skip to content

Commit 6ae14df

Browse files
authored
enhancement active call contact display (#309)
* enhancement active call contact display * fix typo * upgrade commons
1 parent b34b6ba commit 6ae14df

File tree

14 files changed

+136
-35
lines changed

14 files changed

+136
-35
lines changed

dev-server/containers/App/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,13 @@ export default function App({
5151
/>
5252
<IncomingCallPage
5353
locale={phone.locale}
54+
brand={phone.brand}
5455
webphone={phone.webphone}
5556
forwardingNumber={phone.forwardingNumber}
5657
regionSettings={phone.regionSettings}
5758
router={phone.router}
5859
contactMatcher={phone.contactMatcher}
60+
showContactDisplayPlaceholder={false}
5961
getAvatarUrl={
6062
async (contact) => {
6163
const avatarUrl = await phone.contacts.getImageProfile(contact);
@@ -180,10 +182,12 @@ export default function App({
180182
path="/calls/active"
181183
component={() => (
182184
<CallCtrlPage
185+
brand={phone.brand}
183186
locale={phone.locale}
184187
contactMatcher={phone.contactMatcher}
185188
webphone={phone.webphone}
186189
regionSettings={phone.regionSettings}
190+
showContactDisplayPlaceholder={false}
187191
onAdd={() => {
188192
phone.router.push('/');
189193
}}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
"redux-thunk": "^2.1.0",
8585
"ringcentral": "^3.1.1",
8686
"ringcentral-client": "^1.0.0-rc1",
87-
"ringcentral-integration": "^0.7.0-rc16",
87+
"ringcentral-integration": "^0.7.0-rc17",
8888
"sass-loader": "^6.0.5",
8989
"source-map-loader": "^0.2.1",
9090
"style-loader": "^0.18.2",

src/components/ActiveCallPanel/index.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,14 @@ function CallInfo(props) {
4141
currentLocale={props.currentLocale}
4242
areaCode={props.areaCode}
4343
countryCode={props.countryCode}
44-
selectClassName={styles.contactNameSelect}
4544
showType={false}
4645
disabled={false}
4746
selected={props.selectedMatcherIndex}
4847
onSelectContact={props.onSelectMatcherName}
4948
isLogging={false}
5049
enableContactFallback
50+
brand={props.brand}
51+
showPlaceholder={props.showContactDisplayPlaceholder}
5152
/>
5253
{timeCounter}
5354
</div>
@@ -71,12 +72,16 @@ CallInfo.propTypes = {
7172
selectedMatcherIndex: PropTypes.number.isRequired,
7273
onSelectMatcherName: PropTypes.func.isRequired,
7374
avatarUrl: PropTypes.string,
75+
brand: PropTypes.string,
76+
showContactDisplayPlaceholder: PropTypes.bool,
7477
};
7578

7679
CallInfo.defaultProps = {
7780
phoneNumber: null,
7881
startTime: null,
7982
avatarUrl: null,
83+
brand: 'RingCentral',
84+
showContactDisplayPlaceholder: true,
8085
};
8186

8287
function ActiveCallPanel({
@@ -106,6 +111,8 @@ function ActiveCallPanel({
106111
hangup,
107112
onAdd,
108113
children,
114+
showContactDisplayPlaceholder,
115+
brand,
109116
}) {
110117
return (
111118
<div className={styles.root}>
@@ -132,6 +139,8 @@ function ActiveCallPanel({
132139
selectedMatcherIndex={selectedMatcherIndex}
133140
onSelectMatcherName={onSelectMatcherName}
134141
avatarUrl={avatarUrl}
142+
brand={brand}
143+
showContactDisplayPlaceholder={showContactDisplayPlaceholder}
135144
/>
136145
<ActiveCallPad
137146
className={styles.callPad}
@@ -182,6 +191,8 @@ ActiveCallPanel.propTypes = {
182191
onSelectMatcherName: PropTypes.func.isRequired,
183192
avatarUrl: PropTypes.string,
184193
backButtonLabel: PropTypes.string,
194+
brand: PropTypes.string,
195+
showContactDisplayPlaceholder: PropTypes.bool,
185196
};
186197

187198
ActiveCallPanel.defaultProps = {
@@ -193,6 +204,8 @@ ActiveCallPanel.defaultProps = {
193204
children: undefined,
194205
avatarUrl: null,
195206
backButtonLabel: 'Active Calls',
207+
brand: 'RingCentral',
208+
showContactDisplayPlaceholder: true,
196209
};
197210

198211
export default ActiveCallPanel;

src/components/ActiveCallPanel/styles.scss

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,6 @@ $avatar-width: 60px;
9191
line-height: 16px;
9292
}
9393

94-
.contactNameSelect {
95-
width: 100%;
96-
}
97-
9894
.userPhoneNumber {
9995
font-size: 12px;
10096
color: $grey-light;

src/components/CallCtrlPanel/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ class CallCtrlPanel extends Component {
6464
selectedMatcherIndex={this.props.selectedMatcherIndex}
6565
onSelectMatcherName={this.props.onSelectMatcherName}
6666
avatarUrl={this.props.avatarUrl}
67+
brand={this.props.brand}
68+
showContactDisplayPlaceholder={this.props.showContactDisplayPlaceholder}
6769
>
6870
{this.props.children}
6971
</ActiveCallPanel>
@@ -100,6 +102,8 @@ CallCtrlPanel.propTypes = {
100102
onSelectMatcherName: PropTypes.func.isRequired,
101103
avatarUrl: PropTypes.string,
102104
backButtonLabel: PropTypes.string,
105+
brand: PropTypes.string,
106+
showContactDisplayPlaceholder: PropTypes.bool,
103107
};
104108

105109
CallCtrlPanel.defaultProps = {
@@ -113,6 +117,8 @@ CallCtrlPanel.defaultProps = {
113117
backButtonLabel: 'Active Calls',
114118
sessionId: undefined,
115119
callStatus: null,
120+
brand: 'RingCentral',
121+
showContactDisplayPlaceholder: true,
116122
};
117123

118124
export default CallCtrlPanel;

src/components/ContactDisplay/index.js

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,30 @@ import React from 'react';
22
import PropTypes from 'prop-types';
33
import classnames from 'classnames';
44
import formatNumber from 'ringcentral-integration/lib/formatNumber';
5+
import formatMessage from 'format-message';
56
import DropdownSelect from '../DropdownSelect';
67
import i18n from './i18n';
78
import styles from './styles.scss';
89
import phoneSourceNames from '../../lib/phoneSourceNames';
910

10-
const displayFomatter = ({ entityName, entityType, phoneNumber }) => {
11+
const displayFomatter = ({
12+
entityName,
13+
entityType,
14+
phoneNumber,
15+
currentLocale,
16+
brand,
17+
}) => {
18+
let typeName;
19+
if (entityType) {
20+
typeName = formatMessage(
21+
phoneSourceNames.getString(entityType, currentLocale),
22+
{ brand }
23+
);
24+
}
1125
if (phoneNumber && entityName && entityType) {
12-
return `${entityName} | ${phoneSourceNames.getString(entityType)} ${phoneNumber}`;
26+
return `${entityName} | ${typeName} ${phoneNumber}`;
1327
} else if (entityName && entityType) {
14-
return `${entityName} | ${phoneSourceNames.getString(entityType)}`;
28+
return `${entityName} | ${typeName}`;
1529
} else if (entityName) {
1630
return entityName;
1731
} else if (phoneNumber) {
@@ -36,6 +50,8 @@ export default function ContactDisplay({
3650
groupNumbers,
3751
showType,
3852
selectClassName,
53+
showPlaceholder,
54+
brand,
3955
}) {
4056
let contentEl;
4157
if (groupNumbers) {
@@ -76,31 +92,41 @@ export default function ContactDisplay({
7692
const options = [
7793
...contactMatches,
7894
];
95+
let placeholder;
96+
if (showPlaceholder) {
97+
placeholder = i18n.getString('select', currentLocale);
98+
}
7999
contentEl = (
80100
<DropdownSelect
81101
className={classnames(styles.select, selectClassName)}
82102
value={`${selected}`}
83103
onChange={onSelectContact}
84104
disabled={disabled || isLogging}
85105
options={options}
86-
placeholder={i18n.getString('select', currentLocale)}
106+
placeholder={placeholder}
87107
renderFunction={entity => (
88108
displayFomatter({
89109
entityName: entity.name,
90110
entityType: entity.entityType,
111+
brand,
112+
currentLocale,
91113
})
92114
)}
93115
renderValue={value => (
94116
displayFomatter({
95117
entityName: options[value].name,
96118
entityType: showType && options[value].entityType,
119+
brand,
120+
currentLocale,
97121
})
98122
)}
99123
renderTitle={entity => (
100124
entity ? displayFomatter({
101125
entityName: entity.name,
102126
entityType: entity.entityType,
103127
phoneNumber,
128+
brand,
129+
currentLocale,
104130
}) : phoneNumber)
105131
}
106132
dropdownAlign="left"
@@ -136,6 +162,8 @@ ContactDisplay.propTypes = {
136162
groupNumbers: PropTypes.arrayOf(PropTypes.string),
137163
showType: PropTypes.bool,
138164
selectClassName: PropTypes.string,
165+
showPlaceholder: PropTypes.bool,
166+
brand: PropTypes.string,
139167
};
140168
ContactDisplay.defaultProps = {
141169
className: undefined,
@@ -146,4 +174,6 @@ ContactDisplay.defaultProps = {
146174
enableContactFallback: undefined,
147175
showType: true,
148176
selectClassName: undefined,
177+
showPlaceholder: true,
178+
brand: undefined,
149179
};

src/components/ContactDisplay/styles.scss

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,18 @@
1212

1313
.select {
1414
display: inline-block;
15-
width: 180px;
15+
width: 100%;
1616
height: 25px;
1717
border: 0px;
1818
button {
1919
margin: 0px;
2020
font-size: 14px;
2121
}
22+
ul {
23+
width: 200px;
24+
left: 50%;
25+
margin-left: -100px;
26+
}
2227
}
2328

2429
.select:after {

src/components/IncomingCallPanel/index.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ function UserInfo(props) {
2626
</div>
2727
<ContactDisplay
2828
className={styles.userName}
29-
selectClassName={styles.contactNameSelect}
3029
contactMatches={props.nameMatches}
3130
phoneNumber={props.phoneNumber}
3231
fallBackName={props.fallBackName}
@@ -39,6 +38,8 @@ function UserInfo(props) {
3938
onSelectContact={props.onSelectMatcherName}
4039
isLogging={false}
4140
enableContactFallback
41+
brand={props.brand}
42+
showPlaceholder={props.showContactDisplayPlaceholder}
4243
/>
4344
<div className={styles.userPhoneNumber}>
4445
{props.formatPhone(props.phoneNumber)}
@@ -58,12 +59,16 @@ UserInfo.propTypes = {
5859
selectedMatcherIndex: PropTypes.number.isRequired,
5960
onSelectMatcherName: PropTypes.func.isRequired,
6061
avatarUrl: PropTypes.string,
62+
brand: PropTypes.string,
63+
showContactDisplayPlaceholder: PropTypes.bool,
6164
};
6265

6366
UserInfo.defaultProps = {
6467
className: null,
6568
phoneNumber: null,
6669
avatarUrl: null,
70+
brand: 'RingCentral',
71+
showContactDisplayPlaceholder: true,
6772
};
6873

6974
export default function IncomingCallPanel(props) {
@@ -84,6 +89,8 @@ export default function IncomingCallPanel(props) {
8489
selectedMatcherIndex={props.selectedMatcherIndex}
8590
onSelectMatcherName={props.onSelectMatcherName}
8691
avatarUrl={props.avatarUrl}
92+
brand={props.brand}
93+
showContactDisplayPlaceholder={props.showContactDisplayPlaceholder}
8794
/>
8895
<IncomingCallPad
8996
forwardingNumbers={props.forwardingNumbers}
@@ -120,11 +127,15 @@ IncomingCallPanel.propTypes = {
120127
onBackButtonClick: PropTypes.func.isRequired,
121128
forwardingNumbers: PropTypes.array.isRequired,
122129
onForward: PropTypes.func.isRequired,
130+
brand: PropTypes.string,
131+
showContactDisplayPlaceholder: PropTypes.bool,
123132
};
124133

125134
IncomingCallPanel.defaultProps = {
126135
className: null,
127136
phoneNumber: null,
128137
children: undefined,
129138
avatarUrl: null,
139+
brand: 'RingCentral',
140+
showContactDisplayPlaceholder: true,
130141
};

src/components/IncomingCallPanel/styles.scss

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@
4343
line-height: 25px;
4444
}
4545

46-
.contactNameSelect {
47-
width: 100%;
48-
}
49-
5046
.userPhoneNumber {
5147
font-size: 12px;
5248
color: $grey-light;

0 commit comments

Comments
 (0)