• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ringcentral / ringcentral-js-widgets / 5607299609

pending completion
5607299609

push

github

web-flow
sync features and bugfixs from dd3f20d7 (#1730)

8800 of 15728 branches covered (55.95%)

Branch coverage included in aggregate %.

881 of 1290 new or added lines in 248 files covered. (68.29%)

13 existing lines in 7 files now uncovered.

14708 of 22609 relevant lines covered (65.05%)

142084.43 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.65
/packages/ringcentral-widgets/modules/SettingsUI/SettingsUI.ts
1
import { Module } from '@ringcentral-integration/commons/lib/di';
2
import { formatNumber } from '@ringcentral-integration/commons/lib/formatNumber';
3
import { loginStatus } from '@ringcentral-integration/commons/modules/Auth';
4
import type { UIFunctions, UIProps } from '@ringcentral-integration/core';
5
import { RcUIModuleV2 } from '@ringcentral-integration/core';
6

7
import type { SettingsPanelProps } from '../../components/SettingsPanel/SettingsPanel.interface';
8
import type { Deps, SettingsContainerProps } from './SettingUI.interface';
9

10
const DEFAULT_REGION_SETTINGS_URL = '/settings/region';
171✔
11
const DEFAULT_CALLING_SETTINGS_URL = '/settings/calling';
171✔
12
const DEFAULT_AUDIO_SETTINGS_URL = '/settings/audio';
171✔
13
const DEFAULT_FEEDBACK_SETTINGS_URL = '/settings/feedback';
171✔
14

15
@Module({
16
  name: 'SettingsUI',
17
  deps: [
18
    'Auth',
19
    'Brand',
20
    'Locale',
21
    'AccountInfo',
22
    'ExtensionInfo',
23
    'RegionSettings',
24
    'ExtensionFeatures',
25
    'AppFeatures',
26
    'RouterInteraction',
27
    {
28
      dep: 'CPRClient',
29
      optional: true,
30
    },
31
    {
32
      dep: 'CPRClientUI',
33
      optional: true,
34
    },
35
    {
36
      dep: 'Version',
37
      optional: true,
38
    },
39
    {
40
      dep: 'Presence',
41
      optional: true,
42
    },
43
    {
44
      dep: 'CallingSettings',
45
      optional: true,
46
    },
47
    {
48
      dep: 'LocaleSettings',
49
      optional: true,
50
    },
51
    {
52
      dep: 'QuickAccess',
53
      optional: true,
54
    },
55
    {
56
      dep: 'UserGuide',
57
      optional: true,
58
    },
59
    {
60
      dep: 'SettingsUIOptions',
61
      optional: true,
62
    },
63
  ],
64
})
65
export class SettingsUI<T extends Deps = Deps> extends RcUIModuleV2<T> {
66
  constructor({
67
    storageKey,
68
    enableCache,
69
    deps,
70
    ...options
71
  }: {
72
    storageKey?: string;
73
    enableCache?: boolean;
74
    deps?: T;
75
  }) {
76
    super({
263✔
77
      deps: deps || (options as T),
526✔
78
      storageKey,
79
      enableCache,
80
    });
81
  }
82

83
  getUIProps({
84
    showCalling = true,
36✔
85
    showAudio = true,
36✔
86
    showFeedback = true,
36✔
87
    showUserGuide = true,
36✔
88
    showPresenceSettings = true,
36✔
89
    showQuickAccess = false,
×
90
    params,
91
  }: SettingsContainerProps): UIProps<SettingsPanelProps> {
92
    let loginNumber = this._deps.brand.name;
36✔
93
    const loggedIn = this._deps.auth.loginStatus === loginStatus.loggedIn;
36✔
94
    if (
36✔
95
      loggedIn &&
102✔
96
      this._deps.accountInfo.ready &&
97
      this._deps.extensionInfo.ready &&
98
      this._deps.accountInfo.mainCompanyNumber
99
    ) {
100
      // If no extensionNumber, extensionNumber field needs to be omitted
101
      const extensionNumber =
102
        this._deps.extensionInfo.extensionNumber &&
22!
103
        this._deps.extensionInfo.extensionNumber !== '0'
104
          ? this._deps.extensionInfo.extensionNumber
105
          : null;
106
      const phoneNumber = [
22✔
107
        this._deps.accountInfo.mainCompanyNumber,
108
        extensionNumber,
109
      ].join('*');
110
      // @ts-expect-error TS(2322): Type 'string | null | undefined' is not assignable... Remove this comment to see the full error message
111
      loginNumber = formatNumber({
22✔
112
        phoneNumber,
113
        countryCode: this._deps.regionSettings.countryCode,
114
        areaCode: this._deps.regionSettings.areaCode,
115
      });
116
    }
117
    return {
36✔
118
      // @ts-expect-error TS(2322): Type 'string | undefined' is not assignable to typ... Remove this comment to see the full error message
119
      version: this._deps.version,
120
      loginNumber,
121
      showFeedback,
122
      showQuickAccess,
123
      showSpinner: !(
124
        this._deps.accountInfo.ready &&
328✔
125
        this._deps.auth.ready &&
126
        loggedIn &&
127
        this._deps.extensionInfo.ready &&
128
        this._deps.locale.ready &&
129
        this._deps.regionSettings.ready &&
130
        (!this._deps.callingSettings || this._deps.callingSettings.ready) &&
131
        this._deps.appFeatures.ready &&
132
        (!this._deps.presence || this._deps.presence.ready) &&
133
        (!this._deps.localeSettings || this._deps.localeSettings.ready)
134
      ),
135
      showCalling:
136
        showCalling &&
108✔
137
        this._deps.callingSettings &&
138
        this._deps.appFeatures.isCallingEnabled,
139
      showAudio: showAudio && this._deps.appFeatures.isCallingEnabled,
72✔
140
      showRegion:
141
        loggedIn &&
80✔
142
        this._deps.regionSettings.showRegionSettings &&
143
        this._deps.appFeatures.isCallingEnabled,
144
      currentLocale: this._deps.locale.currentLocale,
145
      // @ts-expect-error TS(2322): Type 'string | { translations: { [x: string]: stri... Remove this comment to see the full error message
146
      eulaLabel: this._deps.brand.brandConfig.eulaLabel,
147
      // @ts-expect-error TS(2322): Type 'URL | { translations: { [x: string]: string;... Remove this comment to see the full error message
148
      eulaLink: this._deps.brand.brandConfig.eulaLink,
149
      outboundSMS:
150
        !!this._deps.appFeatures.hasOutboundSMSPermission ||
36!
151
        !!this._deps.appFeatures.hasInternalSMSPermission,
152
      isCallQueueMember: this._deps.extensionInfo.isCallQueueMember,
153
      // @ts-expect-error TS(2322): Type '"TakeAllCalls" | "DoNotAcceptAnyCalls" | "Do... Remove this comment to see the full error message
154
      dndStatus: this._deps.presence?.dndStatus,
155
      // @ts-expect-error TS(2322): Type '"Offline" | "Busy" | "Available" | null | un... Remove this comment to see the full error message
156
      userStatus: this._deps.presence?.userStatus,
157
      openPresenceSettings: !!(
158
        this._deps.presence &&
108✔
159
        params &&
160
        params.showPresenceSettings
161
      ),
162
      showPresenceSettings:
163
        showPresenceSettings &&
72✔
164
        !!this._deps.extensionFeatures.features?.EditPresenceStatus?.available,
165
      supportedLocales: this._deps.localeSettings?.supportedLocales,
166
      savedLocale: this._deps.localeSettings?.savedLocale,
167
      showUserGuide: showUserGuide && !!this._deps.userGuide?.hasPermission,
72✔
168
      showReportIssue: this._deps.cPRClient?.hasPermission,
169
      brandConfig: this._deps.brand.brandConfig,
170
      showRemoveMeetingWarning:
171
        !!this._deps.settingsUIOptions?.showRemoveMeetingWarning,
172
    };
173
  }
174

175
  getUIFunctions({
176
    regionSettingsUrl = DEFAULT_REGION_SETTINGS_URL,
11✔
177
    callingSettingsUrl = DEFAULT_CALLING_SETTINGS_URL,
11✔
178
    audioSettingsUrl = DEFAULT_AUDIO_SETTINGS_URL,
11✔
179
    feedbackSettingsUrl = DEFAULT_FEEDBACK_SETTINGS_URL,
11✔
180
  }: SettingsContainerProps): UIFunctions<SettingsPanelProps> {
181
    return {
11✔
182
      onLogoutButtonClick: async () => {
183
        await this._deps.auth.logout();
2✔
184
      },
185
      onRegionSettingsLinkClick: () => {
186
        this._deps.routerInteraction.push(regionSettingsUrl);
×
187
      },
188
      onCallingSettingsLinkClick: () => {
189
        this._deps.routerInteraction.push(callingSettingsUrl);
3✔
190
      },
191
      onAudioSettingsLinkClick: () => {
192
        this._deps.routerInteraction.push(audioSettingsUrl);
×
193
      },
194
      onFeedbackSettingsLinkClick: () => {
195
        this._deps.routerInteraction.push(feedbackSettingsUrl);
×
196
      },
197
      onUserGuideClick: () => {
NEW
198
        this._deps.userGuide?.start();
×
199
      },
200
      onReportIssueClick: () => {
NEW
201
        this._deps.cPRClientUI?.openCPRDialog();
×
202
      },
203
      onQuickAccessLinkClick: () => {
NEW
204
        this._deps.quickAccess?.enter();
×
205
      },
206
      setAvailable: () => this._deps.presence?.setAvailable(),
2✔
207
      setBusy: () => this._deps.presence?.setBusy(),
1✔
208
      setDoNotDisturb: () => this._deps.presence?.setDoNotDisturb(),
2✔
209
      setInvisible: () => this._deps.presence?.setInvisible(),
1✔
210
      toggleAcceptCallQueueCalls: () =>
211
        this._deps.presence?.toggleAcceptCallQueueCalls(),
1✔
212
      // @ts-expect-error TS(2322): Type '((locale: string) => Promise<void>) | undefi... Remove this comment to see the full error message
213
      saveLocale:
214
        this._deps.localeSettings &&
22✔
NEW
215
        ((locale) => this._deps.localeSettings?.saveLocale(locale)),
×
216
    };
217
  }
218
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc