@@ -4,6 +4,7 @@ import Spinner from '../Spinner';
44import SlideMenu from '../SlideMenu' ;
55import EntityModal from '../EntityModal' ;
66import Button from '../Button' ;
7+ import LogButton from '../LogButton' ;
78import styles from './styles.scss' ;
89import dynamicsFont from '../../assets/DynamicsFont/DynamicsFont.scss' ;
910
@@ -70,52 +71,6 @@ ClickToSmsButton.defaultProps = {
7071 phoneNumber : undefined ,
7172} ;
7273
73- function LogButton ( {
74- className,
75- currentLocale,
76- onLogCall,
77- isLogged,
78- disableLinks,
79- isLogging,
80- } ) {
81- const spinner = isLogging ?
82- (
83- < div className = { styles . spinnerContainer } >
84- < Spinner ringWidth = { 2 } />
85- </ div >
86- ) :
87- null ;
88- return (
89- < Button
90- className = { classnames ( styles . log , className ) }
91- onClick = { onLogCall }
92- disabled = { disableLinks || isLogging }
93- >
94- < span
95- className = { isLogged ?
96- dynamicsFont . edit :
97- dynamicsFont . callLog
98- } />
99- { spinner }
100- </ Button >
101- ) ;
102- }
103- LogButton . propTypes = {
104- className : PropTypes . string ,
105- onLogCall : PropTypes . func ,
106- isLogged : PropTypes . bool ,
107- disableLinks : PropTypes . bool ,
108- isLogging : PropTypes . bool ,
109- currentLocale : PropTypes . string . isRequired ,
110- } ;
111- LogButton . defaultProps = {
112- className : undefined ,
113- onLogCall : undefined ,
114- isLogged : false ,
115- disableLinks : false ,
116- isLogging : false ,
117- } ;
118-
11974function EntityButton ( {
12075 className,
12176 currentLocale,
@@ -173,31 +128,35 @@ export default class ActionMenu extends Component {
173128 this . state = {
174129 entityModalVisible : false ,
175130 } ;
176-
177- this . openEntityModal = ( ) => {
178- this . setState ( {
179- entityModalVisible : true
180- } ) ;
181- } ;
182- this . closeEntityModal = ( ) => {
183- this . setState ( {
184- entityModalVisible : false
185- } ) ;
186- } ;
187- this . onCreateEnityModal = ( entityType ) => {
188- this . props . onCreateEntity ( entityType ) ;
189- this . closeEntityModal ( ) ;
190- } ;
191- this . onCancelEntityModal = ( ) => {
192- this . closeEntityModal ( ) ;
193- } ;
131+ }
132+ onCreateEnityModal = ( entityType ) => {
133+ this . props . onCreateEntity ( entityType ) ;
134+ this . closeEntityModal ( ) ;
135+ }
136+ onCancelEntityModal = ( ) => {
137+ this . closeEntityModal ( ) ;
138+ }
139+ openEntityModal = ( ) => {
140+ this . setState ( {
141+ entityModalVisible : true
142+ } ) ;
143+ }
144+ closeEntityModal = ( ) => {
145+ this . setState ( {
146+ entityModalVisible : false
147+ } ) ;
148+ }
149+ captureClick = ( e ) => {
150+ if ( this . props . stopPropagation ) {
151+ e . stopPropagation ( ) ;
152+ }
194153 }
195154
196155 render ( ) {
197156 const {
198157 className,
199158 currentLocale,
200- onLogCall ,
159+ onLog ,
201160 isLogged,
202161 isLogging,
203162 isCreating,
@@ -209,20 +168,21 @@ export default class ActionMenu extends Component {
209168 phoneNumber,
210169 disableLinks,
211170 disableClickToDial,
171+ stopPropagation,
212172 } = this . props ;
213173
214- const logButton = onLogCall ?
215- (
216- < LogButton
217- className = { styles . baseGroup }
218- onLogCall = { onLogCall }
219- disableLinks = { disableLinks }
220- isLogged = { isLogged }
221- isLogging = { isLogging }
222- currentLocale = { currentLocale }
223- />
224- ) :
225- null ;
174+ const logButton = onLog ?
175+ (
176+ < LogButton
177+ className = { styles . baseGroup }
178+ onLog = { onLog }
179+ disableLinks = { disableLinks }
180+ isLogged = { isLogged }
181+ isLogging = { isLogging }
182+ currentLocale = { currentLocale }
183+ />
184+ ) :
185+ null ;
226186
227187 let entityButton ;
228188 if ( hasEntity && onViewEntity ) {
@@ -232,15 +192,15 @@ export default class ActionMenu extends Component {
232192 hasEntity = { hasEntity }
233193 disableLinks = { disableLinks }
234194 currentLocale = { currentLocale }
235- /> ) ;
195+ /> ) ;
236196 } else if ( ! hasEntity && phoneNumber && onCreateEntity ) {
237197 entityButton = ( < EntityButton
238198 className = { styles . baseGroup }
239199 onCreateEntity = { this . openEntityModal }
240200 hasEntity = { hasEntity }
241201 disableLinks = { disableLinks }
242202 currentLocale = { currentLocale }
243- /> ) ;
203+ /> ) ;
244204 } else {
245205 entityButton = null ;
246206 }
@@ -251,7 +211,7 @@ export default class ActionMenu extends Component {
251211 show = { this . state . entityModalVisible }
252212 onCreate = { this . onCreateEnityModal }
253213 onCancel = { this . onCancelEntityModal }
254- />
214+ />
255215 ) : null ;
256216
257217 const hasBaseGroup = ! ! ( logButton || entityButton ) ;
@@ -283,17 +243,19 @@ export default class ActionMenu extends Component {
283243 if ( hasSecondGroup ) {
284244 // slide menu
285245 return (
286- < SlideMenu
287- className = { classnames ( styles . root , className ) }
288- minWidth = { 40 }
289- maxWidth = { 75 } >
290- { clickToDialButton }
291- { clickToSmsButton }
292- { entityButton }
293- { logButton }
294- { entityModal }
295- </ SlideMenu >
296-
246+ < div
247+ onClick = { this . captureClick } >
248+ < SlideMenu
249+ className = { classnames ( styles . root , className ) }
250+ minWidth = { 40 }
251+ maxWidth = { 75 } >
252+ { clickToDialButton }
253+ { clickToSmsButton }
254+ { entityButton }
255+ { logButton }
256+ { entityModal }
257+ </ SlideMenu >
258+ </ div >
297259 ) ;
298260 } else if (
299261 ! clickToDialButton &&
@@ -305,7 +267,8 @@ export default class ActionMenu extends Component {
305267 }
306268 // no slide menu
307269 return (
308- < div >
270+ < div
271+ onClick = { this . captureClick } >
309272 < div className = { classnames ( styles . root , className ) } >
310273 { clickToDialButton }
311274 { clickToSmsButton }
@@ -321,7 +284,7 @@ export default class ActionMenu extends Component {
321284ActionMenu . propTypes = {
322285 className : PropTypes . string ,
323286 currentLocale : PropTypes . string . isRequired ,
324- onLogCall : PropTypes . func ,
287+ onLog : PropTypes . func ,
325288 isLogged : PropTypes . bool ,
326289 isLogging : PropTypes . bool ,
327290 isCreating : PropTypes . bool ,
@@ -333,10 +296,11 @@ ActionMenu.propTypes = {
333296 phoneNumber : PropTypes . string ,
334297 disableLinks : PropTypes . bool ,
335298 disableClickToDial : PropTypes . bool ,
299+ stopPropagation : PropTypes . bool ,
336300} ;
337301ActionMenu . defaultProps = {
338302 className : undefined ,
339- onLogCall : undefined ,
303+ onLog : undefined ,
340304 isLogged : false ,
341305 isLogging : false ,
342306 isCreating : false ,
@@ -348,4 +312,5 @@ ActionMenu.defaultProps = {
348312 phoneNumber : undefined ,
349313 disableLinks : false ,
350314 disableClickToDial : false ,
315+ stopPropagation : false ,
351316} ;
0 commit comments