import { Module } from '@ringcentral-integration/commons/lib/di' ; import { computed , RcUIModuleV2 , UIFunctions , UIProps , } from '@ringcentral-integration/core' ; import { TabContentViewProps } from '../../components/TabContentView/TabContentView' ; import { hasActiveCalls } from '../../lib/hasActiveCalls' ; import { Deps , DialerAndCallsTabContainerProps , } from './DialerAndCallsTabUI.interface' ; import i18n from './i18n' ; @ Module ( { name : 'DialerAndCallsTabUI' , deps : [ 'Locale' , 'RouterInteraction' , 'CallingSettings' , { dep : 'Webphone' , optional : true } , { dep : 'CallMonitor' , optional : true } , { dep : 'DialerAndCallsTabUIOptions' , optional : true } , ] , } ) export class DialerAndCallsTabUI extends RcUIModuleV2 < Deps > { constructor ( deps ) { super ( { deps , } ) ; } @ computed ( ( that ) => [ that . _deps . locale . currentLocale , that . _deps . routerInteraction . currentPath , ] ) get tabs ( ) { return [ { path : '/dialer' , label : i18n . getString ( 'dialer' , this . _deps . locale . currentLocale ) , dataSign : 'dialer' , isActive : ( ) => { return this . _deps . routerInteraction . currentPath === '/dialer' ; } , } , { path : '/calls' , label : i18n . getString ( 'allCalls' , this . _deps . locale . currentLocale ) , dataSign : 'allCalls' , isActive : ( ) => { return this . _deps . routerInteraction . currentPath === '/calls' ; } , } , ] ; } getUIProps ( props ) { return { showTabs : props . hasActiveCalls ? props . hasActiveCalls ( { callingSettings : this . _deps . callingSettings , webphone : this . _deps . webphone , callMonitor : this . _deps . callMonitor , } ) : hasActiveCalls ( { callingSettings : this . _deps . callingSettings , webphone : this . _deps . webphone , callMonitor : this . _deps . callMonitor , } ) , showSpinner : ! this . _deps . locale . ready , tabs : this . tabs , } ; } getUIFunctions ( props ) { return { goTo : ( path ) => { this . _deps . routerInteraction . push ( path ) ; } , } ; } }