@@ -227,10 +228,12 @@ ForwardForm.propTypes = {
searchContactList: PropTypes.array.isRequired,
searchContact: PropTypes.func.isRequired,
phoneTypeRenderer: PropTypes.func,
+ autoFocus: PropTypes.bool,
};
ForwardForm.defaultProps = {
className: null,
onChange: undefined,
phoneTypeRenderer: undefined,
+ autoFocus: true,
};
diff --git a/src/components/FromField/i18n/fr-CA.js b/src/components/FromField/i18n/fr-CA.js
index cb84186967..7b618d7c91 100644
--- a/src/components/FromField/i18n/fr-CA.js
+++ b/src/components/FromField/i18n/fr-CA.js
@@ -4,7 +4,7 @@ export default {
CompanyNumber: 'Entreprise',
CompanyFaxNumber: 'Fax',
Blocked: 'Bloqué',
- from: 'De',
+ from: 'De ',
AdditionalCompanyNumber: 'Entreprise',
ForwardedCompanyNumber: 'Transféré',
};
diff --git a/src/components/FromField/i18n/fr-FR.js b/src/components/FromField/i18n/fr-FR.js
index cb84186967..7b618d7c91 100644
--- a/src/components/FromField/i18n/fr-FR.js
+++ b/src/components/FromField/i18n/fr-FR.js
@@ -4,7 +4,7 @@ export default {
CompanyNumber: 'Entreprise',
CompanyFaxNumber: 'Fax',
Blocked: 'Bloqué',
- from: 'De',
+ from: 'De ',
AdditionalCompanyNumber: 'Entreprise',
ForwardedCompanyNumber: 'Transféré',
};
diff --git a/src/components/IncomingCallPad/i18n/es-419.js b/src/components/IncomingCallPad/i18n/es-419.js
index 42f44e1e6a..1caac29f5e 100644
--- a/src/components/IncomingCallPad/i18n/es-419.js
+++ b/src/components/IncomingCallPad/i18n/es-419.js
@@ -5,7 +5,7 @@ export default {
toVoicemail: 'A buzón de voz',
answer: 'Responder',
answerAndEnd: 'Resp. y finalizar',
- answerAndHold: 'Resp. y poner en esp.',
+ answerAndHold: 'Resp. y en esp.',
};
// @key: @#@"forward"@#@ @source: @#@"Forward"@#@
diff --git a/src/components/IncomingCallPad/i18n/fr-CA.js b/src/components/IncomingCallPad/i18n/fr-CA.js
index 568ff592cd..712fbf9217 100644
--- a/src/components/IncomingCallPad/i18n/fr-CA.js
+++ b/src/components/IncomingCallPad/i18n/fr-CA.js
@@ -4,8 +4,8 @@ export default {
ignore: 'Ignorer',
toVoicemail: 'Boîte vocale',
answer: 'Réponse',
- answerAndEnd: 'Répondre et\nterminer',
- answerAndHold: 'Répondre et\nmettre en attente',
+ answerAndEnd: 'Rép. et term.',
+ answerAndHold: 'Rép. et mise en att.',
};
// @key: @#@"forward"@#@ @source: @#@"Forward"@#@
diff --git a/src/components/IncomingCallPad/i18n/pt-BR.js b/src/components/IncomingCallPad/i18n/pt-BR.js
index 747142e475..1cab06e21f 100644
--- a/src/components/IncomingCallPad/i18n/pt-BR.js
+++ b/src/components/IncomingCallPad/i18n/pt-BR.js
@@ -5,7 +5,7 @@ export default {
toVoicemail: 'Para caixa postal',
answer: 'Responder',
answerAndEnd: 'Atender e enc.',
- answerAndHold: 'Atender e em espera',
+ answerAndHold: 'Atender e espera',
};
// @key: @#@"forward"@#@ @source: @#@"Forward"@#@
diff --git a/src/components/MessageSenderAlert/i18n/en-CA.js b/src/components/MessageSenderAlert/i18n/en-CA.js
index 80182bb24d..c945886069 100644
--- a/src/components/MessageSenderAlert/i18n/en-CA.js
+++ b/src/components/MessageSenderAlert/i18n/en-CA.js
@@ -30,19 +30,20 @@ export default {
// @key: @#@"[messageSenderMessages.textEmpty]"@#@ @source: @#@"Please enter the text to be sent."@#@
// @key: @#@"[messageSenderMessages.noPermission]"@#@ @source: @#@"You have no permission to send message."@#@
// @key: @#@"[messageSenderMessages.senderEmpty]"@#@ @source: @#@"You must select a number from your phone numbers to send"@#@
-// @key: @#@"[messageSenderMessages.noToNumber]"@#@ @source: @#@"Invalid phone number."@#@
+// @key: @#@"[messageSenderMessages.noToNumber]"@#@ @source: @#@"Please enter a valid phone number."@#@
// @key: @#@"[messageSenderMessages.recipientsEmpty]"@#@ @source: @#@"Please enter a valid receiver number."@#@
// @key: @#@"[messageSenderMessages.textTooLong]"@#@ @source: @#@"Text is too long, 1000 Limited"@#@
// @key: @#@"[messageSenderMessages.multipartTextTooLong]"@#@ @source: @#@"Text is too long, 5000 Limited"@#@
// @key: @#@"[messageSenderMessages.recipientNumberInvalids]"@#@ @source: @#@"Please enter a valid phone number."@#@
// @key: @#@"[messageSenderMessages.noAreaCode]"@#@ @source: @#@"Please set {areaCodeLink} to use 7-digit local phone numbers."@#@
-// @key: @#@"[messageSenderMessages.specialNumber]"@#@ @source: @#@"Dialing emergency or special service numbers is not supported."@#@
+// @key: @#@"[messageSenderMessages.specialNumber]"@#@ @source: @#@"Sending text to emergency/special service numbers is not supported."@#@
// @key: @#@"[messageSenderMessages.connectFailed]"@#@ @source: @#@"Connection failed. Please try again later."@#@
// @key: @#@"[messageSenderMessages.internalError]"@#@ @source: @#@"Cannot connect due to internal errors. Please try again later."@#@
// @key: @#@"[messageSenderMessages.notAnExtension]"@#@ @source: @#@"The extension number does not exist."@#@
// @key: @#@"[messageSenderMessages.networkError]"@#@ @source: @#@"Cannot connect due to network issues. Please try again later."@#@
-// @key: @#@"[messageSenderMessages.senderNumberInvalid]"@#@ @source: @#@"You don't have permission to send messages to recipients outside of your organization. Please contact your RingCentral account administrator for upgrade."@#@
+// @key: @#@"[messageSenderMessages.senderNumberInvalid]"@#@ @source: @#@"A valid Phone Number is required to send text message to recipients outside of your company, Please contact your Administrator to add a direct number to your account."@#@
// @key: @#@"[messageSenderMessages.notSmsToExtension]"@#@ @source: @#@"Cannot send To a extension number with main phone number. If you want to sent to a extension Number, please just enter extension Number."@#@
// @key: @#@"[messageSenderMessages.internationalSMSNotSupported]"@#@ @source: @#@"Sending SMS to international phone number is not supported."@#@
-// @key: @#@"[messageSenderMessages.noInternalSMSPermission]"@#@ @source: @#@"You don't have permission to send messages. Please contact your RingCentral account administrator for upgrade."@#@
+// @key: @#@"[messageSenderMessages.noInternalSMSPermission]"@#@ @source: @#@"You don't have permission to send messages. Please contact your {brand} account administrator for upgrade."@#@
+// @key: @#@"[messageSenderMessages.noSMSPermission]"@#@ @source: @#@"You don't have permission to send messages to recipients outside of your organization. Please contact your {brand} account administrator for upgrade."@#@
// @key: @#@"areaCode"@#@ @source: @#@"area code"@#@
diff --git a/src/components/MessageSenderAlert/i18n/fr-CA.js b/src/components/MessageSenderAlert/i18n/fr-CA.js
index 087b8a6807..2c63082ba6 100644
--- a/src/components/MessageSenderAlert/i18n/fr-CA.js
+++ b/src/components/MessageSenderAlert/i18n/fr-CA.js
@@ -12,7 +12,7 @@ export default {
[messageSenderMessages.textTooLong]: 'Le texte est trop long, limite\xA0: 1\xA0000',
[messageSenderMessages.multipartTextTooLong]: 'Le texte est trop long, limite\xA0: 5\xA0000',
[messageSenderMessages.recipientNumberInvalids]: 'Veuillez entrer un numéro de téléphone valide.',
- [messageSenderMessages.noAreaCode]: 'Veuillez configurer {areaCodeLink} pour utiliser des numéros de téléphone locaux à 7\xA0chiffres.',
+ [messageSenderMessages.noAreaCode]: 'Veuillez configurer l\'{areaCodeLink} pour utiliser des numéros de téléphone locaux à 7\xA0chiffres.',
[messageSenderMessages.specialNumber]: 'L\'envoi de textos à des numéros d\'urgence ou à des numéros pour services spéciaux n\'est pas pris en charge.',
[messageSenderMessages.connectFailed]: 'Échec de la connexion. Veuillez réessayer plus tard.',
[messageSenderMessages.internalError]: 'Connexion impossible en raison d\'erreurs internes. Veuillez réessayer plus tard.',
diff --git a/src/components/PresenceItem/i18n/en-GB.js b/src/components/PresenceItem/i18n/en-GB.js
index 211d3c2507..f7ac4f32b5 100644
--- a/src/components/PresenceItem/i18n/en-GB.js
+++ b/src/components/PresenceItem/i18n/en-GB.js
@@ -12,4 +12,3 @@ export default {
// @key: @#@"[presenceStatus.busy]"@#@ @source: @#@"Busy"@#@
// @key: @#@"[presenceStatus.offline]"@#@ @source: @#@"Invisible"@#@
// @key: @#@"[dndStatus.doNotAcceptAnyCalls]"@#@ @source: @#@"Do not Disturb"@#@
-
diff --git a/src/components/PresenceItem/i18n/es-419.js b/src/components/PresenceItem/i18n/es-419.js
index a23fecb86c..b98a48625d 100644
--- a/src/components/PresenceItem/i18n/es-419.js
+++ b/src/components/PresenceItem/i18n/es-419.js
@@ -12,4 +12,3 @@ export default {
// @key: @#@"[presenceStatus.busy]"@#@ @source: @#@"Busy"@#@
// @key: @#@"[presenceStatus.offline]"@#@ @source: @#@"Invisible"@#@
// @key: @#@"[dndStatus.doNotAcceptAnyCalls]"@#@ @source: @#@"Do not Disturb"@#@
-
diff --git a/src/components/PresenceItem/i18n/fr-CA.js b/src/components/PresenceItem/i18n/fr-CA.js
index 3ef6eb813b..d35979625c 100644
--- a/src/components/PresenceItem/i18n/fr-CA.js
+++ b/src/components/PresenceItem/i18n/fr-CA.js
@@ -12,4 +12,3 @@ export default {
// @key: @#@"[presenceStatus.busy]"@#@ @source: @#@"Busy"@#@
// @key: @#@"[presenceStatus.offline]"@#@ @source: @#@"Invisible"@#@
// @key: @#@"[dndStatus.doNotAcceptAnyCalls]"@#@ @source: @#@"Do not Disturb"@#@
-
diff --git a/src/components/RecipientsInput/i18n/fr-CA.js b/src/components/RecipientsInput/i18n/fr-CA.js
index f8ea27062d..1dcae1cd31 100644
--- a/src/components/RecipientsInput/i18n/fr-CA.js
+++ b/src/components/RecipientsInput/i18n/fr-CA.js
@@ -1,5 +1,5 @@
export default {
- to: 'À',
+ to: 'À ',
enterNameOrNumber: 'Entrer le nom ou le numéro',
};
diff --git a/src/components/RecipientsInput/i18n/fr-FR.js b/src/components/RecipientsInput/i18n/fr-FR.js
index e139061f2f..dd5d72f5e4 100644
--- a/src/components/RecipientsInput/i18n/fr-FR.js
+++ b/src/components/RecipientsInput/i18n/fr-FR.js
@@ -1,5 +1,5 @@
export default {
- to: 'À',
+ to: 'À ',
enterNameOrNumber: 'Saisir un nom ou numéro',
};
diff --git a/src/components/RolesAndPermissionsAlert/i18n/en-CA.js b/src/components/RolesAndPermissionsAlert/i18n/en-CA.js
index 5e7020f827..fe09ed77de 100644
--- a/src/components/RolesAndPermissionsAlert/i18n/en-CA.js
+++ b/src/components/RolesAndPermissionsAlert/i18n/en-CA.js
@@ -6,3 +6,4 @@ export default {
};
// @key: @#@"[permissionMessages.invalidTier]"@#@ @source: @#@"Your edition does not support {application} integration. Please contact your account representative to upgrade your {brand} edition."@#@
+// @key: @#@"[permissionMessages.insufficientPrivilege]"@#@ @source: @#@"Insufficient privilege. Please contact your account representative for an upgrade."@#@
diff --git a/src/components/SettingsPanel/i18n/fr-CA.js b/src/components/SettingsPanel/i18n/fr-CA.js
index faf0907dc4..4ea20c2461 100644
--- a/src/components/SettingsPanel/i18n/fr-CA.js
+++ b/src/components/SettingsPanel/i18n/fr-CA.js
@@ -7,7 +7,7 @@ export default {
clickToDial: 'Cliquer pour composer',
autoCreateLog: 'Créer automatiquement un journal des appels',
clickToSMS: 'Cliquez pour envoyer un texto',
- clickToDialSMS: 'Cliquez pour composer ou envoyer un texto',
+ clickToDialSMS: 'Cliquer pour composer ou envoyer un texto',
autoCreateSMSLog: 'Créer automatiquement une liste de textos',
autoLogCalls: 'Liste d\'appels automatique',
autoLogSMS: 'Liste de textos automatique',
diff --git a/src/components/ToField/i18n/fr-CA.js b/src/components/ToField/i18n/fr-CA.js
index 06a7bc19ad..4f710ca7fc 100644
--- a/src/components/ToField/i18n/fr-CA.js
+++ b/src/components/ToField/i18n/fr-CA.js
@@ -1,5 +1,5 @@
export default {
- to: 'À',
+ to: 'À ',
enterNameOrNumber: 'Saisir le numéro ou le nom',
};
diff --git a/src/components/ToField/i18n/fr-FR.js b/src/components/ToField/i18n/fr-FR.js
index 06a7bc19ad..4f710ca7fc 100644
--- a/src/components/ToField/i18n/fr-FR.js
+++ b/src/components/ToField/i18n/fr-FR.js
@@ -1,5 +1,5 @@
export default {
- to: 'À',
+ to: 'À ',
enterNameOrNumber: 'Saisir le numéro ou le nom',
};
diff --git a/src/components/TransferPanel/index.js b/src/components/TransferPanel/index.js
index 41793c25fa..bd9591a93e 100644
--- a/src/components/TransferPanel/index.js
+++ b/src/components/TransferPanel/index.js
@@ -20,11 +20,13 @@ export default class TransferPanel extends PureComponent {
formatPhone: PropTypes.func.isRequired,
phoneTypeRenderer: PropTypes.func,
isOnTransfer: PropTypes.bool,
+ autoFocus: PropTypes.bool,
};
static defaultProps = {
phoneTypeRenderer: undefined,
isOnTransfer: false,
+ autoFocus: true,
};
constructor(props) {
@@ -106,7 +108,7 @@ export default class TransferPanel extends PureComponent {
currentLocale={this.props.currentLocale}
phoneTypeRenderer={this.props.phoneTypeRenderer}
titleEnabled
- autoFocus
+ autoFocus={this.props.autoFocus}
/>
-
-
-
-
-
-
-
-
- `;
- this._headerEl = this._root.querySelector(
- `.${this._styles.header}`
- );
- this._logoEl = this._root.querySelector(
- `.${this._styles.logo}`
- );
- this._logoEl.addEventListener('dragstart', () => false);
-
- this._contentFrameContainerEl = this._root.querySelector(
- `.${this._styles.frameContainer}`
- );
-
- // toggle button
- this._toggleEl = this._root.querySelector(
- `.${this._styles.toggle}`
- );
- this._toggleEl.addEventListener('click', () => {
- this.toggleMinimized();
- });
-
- // close button
- this._closeEl = this._root.querySelector(
- `.${this._styles.close}`
- );
- this._closeEl.addEventListener('click', () => {
- this.setClosed(true);
- });
-
- this._presenceEl = this._root.querySelector(
- `.${this._styles.presence}`
- );
- this._presenceEl.addEventListener('click', () => {
- this._postMessage({
- type: this._messageTypes.presenceClicked,
- });
- });
- this._contentFrameEl = this._root.querySelector(
- `.${this._styles.contentFrame}`
- );
-
- this._headerEl.addEventListener('mousedown', (e) => {
- this._dragging = true;
- this._dragStartPosition = {
- x: e.clientX,
- y: e.clientY,
- translateX: this._translateX,
- translateY: this._translateY,
- minTranslateX: this._minTranslateX,
- };
- this._renderMainClass();
- });
- this._headerEl.addEventListener('mouseup', () => {
- this._dragging = false;
- this._renderMainClass();
- });
- window.addEventListener('mousemove', this._onWindowMouseMove);
-
- this._resizeTimeout = null;
- this._resizeTick = null;
- window.addEventListener('resize', this._onWindowResize);
-
- // hover detection for ie
- this._container.addEventListener('mouseenter', () => {
- this._hover = true;
- this._renderMainClass();
- });
- this._container.addEventListener('mouseleave', () => {
- this._hover = false;
- this._renderMainClass();
- });
- if (document.readyState === 'loading') {
- window.addEventListener('load', () => {
- document.body.appendChild(this._container);
- });
- } else {
- document.body.appendChild(this._container);
- }
-
- this._render();
- }
- _onWindowResize = () => {
- if (this._dragging) { return; }
- if (this._resizeTimeout) { clearTimeout(this._resizeTimeout); }
- this._resizeTimeout = setTimeout(() => this._renderRestrictedPosition(), 100);
- if (!this._resizeTick || Date.now() - this._resizeTick > 50) {
- this._resizeTick = Date.now();
- this._renderRestrictedPosition();
- }
- }
- _onWindowMouseMove = (e) => {
- if (this._dragging) {
- if (e.buttons === 0) {
- this._dragging = false;
- this._renderMainClass();
- return;
- }
- const factor = this._calculateFactor();
- const delta = {
- x: e.clientX - this._dragStartPosition.x,
- y: e.clientY - this._dragStartPosition.y,
- };
- if (this._minimized) {
- this._minTranslateX = this._dragStartPosition.minTranslateX + delta.x * factor;
- } else {
- this._translateX = this._dragStartPosition.translateX + delta.x * factor;
- this._translateY = this._dragStartPosition.translateY + delta.y;
- }
- this._syncPosition();
- this._renderRestrictedPosition();
- }
- }
-
- get messageTransport() {
- return this._messageTransport;
- }
-
- _postMessage(data) {
- this.messageTransport.postMessage(data);
- }
-
- _setLogoUrl(logoUrl) {
- this._logoUrl = logoUrl;
- this._logoEl.src = logoUrl;
- this._logoEl.setAttribute('class', classnames(
- this._styles.logo,
- this._logoUrl && this._logoUrl !== '' && this._styles.visible,
- ));
- }
-
- _setAppUrl(appUrl) {
- this._appUrl = appUrl;
- if (appUrl) {
- this.contentFrameEl.src = appUrl;
- }
- }
-
- _onSyncMinimized(minimized) {
- this._minimized = !!minimized;
- this._renderMainClass();
- this.renderAdapterSize();
- this._renderRestrictedPosition();
- }
- setMinimized(minimized) {
- this._onSyncMinimized(minimized);
- this._postMessage({
- type: this._messageTypes.syncMinimized,
- minimized: this._minimized,
- });
- }
- toggleMinimized() {
- this.setMinimized(!this._minimized);
- }
-
- _calculateMinMaxPosition() {
- const maximumX = window.innerWidth -
- (this._minimized ? this._headerEl.clientWidth : this._appWidth) - 2 * this._padding;
- const maximumY = window.innerHeight -
- (this._minimized ?
- this._headerEl.clientHeight :
- this._headerEl.clientHeight + this._appHeight) - this._padding;
- return {
- minimumX: this._padding,
- minimumY: this._padding,
- maximumX,
- maximumY,
- };
- }
-
- _onSyncClosed(closed) {
- this._closed = !!closed;
- this._renderMainClass();
- }
- setClosed(closed) {
- this._onSyncClosed(closed);
- this._postMessage({
- type: this._messageTypes.syncClosed,
- closed: this.closed,
- });
- }
- toggleClosed() {
- this.setClosed(!this.closed);
- }
-
- _onSyncSize({ width, height }) {
- this._appWidth = width;
- this._appHeight = height;
- this._contentFrameEl.style.width = `${width}px`;
- this._contentFrameEl.style.height = `${height}px`;
- this.renderAdapterSize();
- }
- setSize(size) {
- this._onSyncSize(size);
- this._postMessage({
- type: this._messageTypes.syncSize,
- size,
- });
- }
-
- _onPushRingState({ ringing }) {
- this._ringing = ringing;
- this._render();
- }
-
- _onPushPresence({ dndStatus, userStatus, telephonyStatus }) {
- if (
- dndStatus !== this._dndStatus ||
- userStatus !== this._userStatus ||
- telephonyStatus !== this._telephonyStatus
- ) {
- this._dndStatus = dndStatus;
- this._userStatus = userStatus;
- this._telephonyStatus = telephonyStatus;
- this.renderPresence();
- }
- }
- _onPushLocale({
- locale,
- strings = {},
- }) {
- this._locale = locale;
- this._strings = strings;
- }
-
- _debouncedPostMessage = debounce(this._postMessage, 200)
-
- _syncPosition() {
- this._debouncedPostMessage.call(this, {
- type: this._messageTypes.syncPosition,
- position: {
- translateX: this._translateX,
- translateY: this._translateY,
- minTranslateX: this._minTranslateX,
- },
- });
- }
- _onPushAdapterState({
- size: {
- width,
- height
- },
- minimized,
- closed,
- position: { translateX, translateY, minTranslateX },
- dndStatus,
- userStatus,
- telephonyStatus,
- }) {
- this._minimized = minimized;
- this._closed = closed;
- if (!this._dragging) {
- this._translateX = translateX;
- this._translateY = translateY;
- this._minTranslateX = minTranslateX;
- }
- this._appWidth = width;
- this._appHeight = height;
- this._dndStatus = dndStatus;
- this._userStatus = userStatus;
- this._telephonyStatus = telephonyStatus;
- this._loading = false;
- this._render();
- }
- _calculateFactor() {
- return this._defaultDirection === 'right' ?
- -1 :
- 1;
- }
- renderPosition() {
- const factor = this._calculateFactor();
- if (this._minimized) {
- this._container.setAttribute(
- 'style',
- `transform: translate( ${this._minTranslateX * factor}px, ${-this._padding}px)!important;`
- );
- } else {
- this._container.setAttribute(
- 'style',
- `transform: translate( ${this._translateX * factor}px, ${this._translateY}px)!important;`
- );
- }
- }
- _renderRestrictedPosition() {
- const {
- minimumX,
- minimumY,
- maximumX,
- maximumY,
- } = this._calculateMinMaxPosition();
-
- if (this._minimized) {
- const newMinTranslateX = Math.max(Math.min(this._minTranslateX, maximumX), minimumX);
- if (newMinTranslateX !== this._minTranslateX) {
- this._minTranslateX = newMinTranslateX;
- }
- } else {
- const newTranslateX = Math.max(Math.min(this._translateX, maximumX), minimumX);
- const newTranslateY = Math.max(Math.min(this._translateY, -minimumY), -maximumY);
- if (this._translateX !== newTranslateX || this._translateY !== newTranslateY) {
- this._translateX = newTranslateX;
- this._translateY = newTranslateY;
- }
- }
- this.renderPosition();
- }
- renderAdapterSize() {
- if (this._minimized) {
- this._contentFrameContainerEl.style.width = 0;
- this._contentFrameContainerEl.style.height = 0;
- } else {
- this._contentFrameContainerEl.style.width = `${this._appWidth}px`;
- this._contentFrameContainerEl.style.height = `${this._appHeight}px`;
- this._contentFrameEl.style.width = `${this._appWidth}px`;
- this._contentFrameEl.style.height = `${this._appHeight}px`;
- }
- }
- _renderMainClass() {
- this._container.setAttribute('class', classnames(
- this._styles.root,
- this._styles[this._defaultDirection],
- this._closed && this._styles.closed,
- this._minimized && this._styles.minimized,
- this._dragging && this._styles.dragging,
- this._hover && this._styles.hover,
- this._loading && this._styles.loading,
- ));
- this._headerEl.setAttribute('class', classnames(
- this._styles.header,
- this._minimized && this._styles.minimized,
- this._ringing && this._styles.ringing,
- ));
- }
- renderPresence() {
- this._presenceEl.setAttribute('class', classnames(
- this._minimized && this._styles.minimized,
- this._styles.presence,
- this._userStatus && this._styles[this._userStatus],
- this._dndStatus && this._styles[this._dndStatus],
- ));
- }
- _render() {
- this._renderMainClass();
- this.renderPresence();
- this.renderAdapterSize();
- this._renderRestrictedPosition();
- }
-
- dispose() {
- // TODO clean up
- window.removeEventListener('mousemove', this._onWindowMouseMove);
- window.removeEventListener('resize', this._onWindowResize);
- if (this._resizeTimeout) {
- clearTimeout(this._resizeTick);
- }
- this._container.remove();
- }
-
- get container() {
- return this._container;
- }
- get root() {
- return this._root;
- }
- get headerEl() {
- return this._headerEl;
- }
- get contentFrameContainerEl() {
- return this._contentFrameContainerEl;
- }
- get toggleEl() {
- return this._toggleEl;
- }
- get closeEl() {
- return this._closeEl;
- }
- get presenceEl() {
- return this._presenceEl;
- }
- get contentFrameEl() {
- return this._contentFrameEl;
- }
- get minTranslateX() {
- return this._minTranslateX;
- }
- get translateX() {
- return this._translateX;
- }
- get translateY() {
- return this._translateY;
- }
- get appWidth() {
- return this._appWidth;
- }
- get appHeight() {
- return this._appHeight;
- }
- get dragStartPosition() {
- return this._dragStartPosition;
- }
-
- get closed() {
- return this._closed;
- }
- get minimized() {
- return this._minimized;
- }
- get dragging() {
- return this._dragging;
- }
- get hover() {
- return this._hover;
- }
- get loading() {
- return this._loading;
- }
- get userStatus() {
- return this._userStatus;
- }
- get dndStatus() {
- return this._dndStatus;
- }
- get ringing() {
- return this._ringing;
- }
-}
+import classnames from 'classnames';
+import { prefixEnum } from 'ringcentral-integration/lib/Enum';
+import ensureExist from 'ringcentral-integration/lib/ensureExist';
+import debounce from 'ringcentral-integration/lib/debounce';
+import baseMessageTypes from './baseMessageTypes';
+
+const SANDBOX_ATTRIBUTE_VALUE = [
+ 'allow-same-origin',
+ 'allow-scripts',
+ 'allow-forms',
+ 'allow-popups',
+].join(' ');
+
+// chrome 63 mandate the declaration of this attribute for getUserMedia to work in iframes
+const ALLOW_ATTRIBUTE_VALUE = [
+ 'microphone',
+ // 'camera',
+].join(' ');
+
+export default class AdapterCore {
+ constructor({
+ prefix,
+ styles,
+ container,
+ root = container,
+ messageTypes = baseMessageTypes,
+ defaultDirection = 'left',
+ defaultPadding = 15,
+ }) {
+ this._prefix = prefix;
+ this._messageTypes = prefixEnum({ enumMap: messageTypes, prefix });
+ this._container = this::ensureExist(container, 'container');
+ this._root = root;
+ this._styles = styles;
+ this._defaultDirection = defaultDirection;
+
+ this._padding = defaultPadding;
+ this._minTranslateX = 0;
+ this._minTranslateY = 0;
+ this._translateX = 0;
+ this._translateY = 0;
+ this._appWidth = 0;
+ this._appHeight = 0;
+ this._dragStartPosition = null;
+
+ this._closed = true;
+ this._minimized = true;
+ this._dragging = false;
+ this._hover = false;
+ this._hoverHeader = false;
+ this._loading = true;
+ this._userStatus = null;
+ this._dndStatus = null;
+ this._telephonyStatus = null;
+ }
+ _onMessage(msg) {
+ if (msg) {
+ switch (msg.type) {
+ case this._messageTypes.syncClosed:
+ this._onSyncClosed(msg.closed);
+ break;
+ case this._messageTypes.syncMinimized:
+ this._onSyncMinimized(msg.minimized);
+ break;
+ case this._messageTypes.syncSize:
+ this._onSyncSize(msg.size);
+ break;
+ case this._messageTypes.syncPresence:
+ this._onPushPresence(msg);
+ break;
+ case this._messageTypes.pushAdapterState:
+ this._onPushAdapterState(msg);
+ break;
+ case this._messageTypes.pushLocale:
+ this._onPushLocale(msg);
+ break;
+ case this._messageTypes.pushRingState:
+ this._onPushRingState(msg);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ _getContentDOM(sanboxAttributeValue, allowAttributeValue) {
+ return `
+
+
+
+
`;
+ }
+
+ _generateContentDOM() {
+ this._root.innerHTML = this._getContentDOM(SANDBOX_ATTRIBUTE_VALUE, ALLOW_ATTRIBUTE_VALUE);
+ this._headerEl = this._root.querySelector(
+ `.${this._styles.header}`
+ );
+ this._logoEl = this._root.querySelector(
+ `.${this._styles.logo}`
+ );
+ this._logoEl.addEventListener('dragstart', () => false);
+
+ this._contentFrameContainerEl = this._root.querySelector(
+ `.${this._styles.frameContainer}`
+ );
+
+ // toggle button
+ this._toggleEl = this._root.querySelector(
+ `.${this._styles.toggle}`
+ );
+ this._toggleEl.addEventListener('click', (evt) => {
+ evt.stopPropagation();
+ this.toggleMinimized();
+ });
+
+ // close button
+ this._closeEl = this._root.querySelector(
+ `.${this._styles.close}`
+ );
+ this._closeEl.addEventListener('click', () => {
+ this.setClosed(true);
+ });
+
+ this._presenceEl = this._root.querySelector(
+ `.${this._styles.presence}`
+ );
+ this._presenceEl.addEventListener('click', (evt) => {
+ evt.stopPropagation();
+ this._postMessage({
+ type: this._messageTypes.presenceClicked,
+ });
+ });
+ this._contentFrameEl = this._root.querySelector(
+ `.${this._styles.contentFrame}`
+ );
+
+ this._headerEl.addEventListener('mousedown', (e) => {
+ this._dragging = true;
+ this._isClick = true;
+ this._dragStartPosition = {
+ x: e.clientX,
+ y: e.clientY,
+ translateX: this._translateX,
+ translateY: this._translateY,
+ minTranslateX: this._minTranslateX,
+ minTranslateY: this._minTranslateY,
+ };
+ this._renderMainClass();
+ });
+ this._headerEl.addEventListener('mouseup', () => {
+ this._dragging = false;
+ this._renderMainClass();
+ });
+ window.addEventListener('mousemove', this._onWindowMouseMove);
+
+ this._headerEl.addEventListener('mouseenter', () => {
+ if (!this._minimized) return;
+ this._hoverHeader = true;
+ this._renderMainClass();
+ });
+ this._headerEl.addEventListener('mouseleave', () => {
+ this._hoverHeader = false;
+ this._renderMainClass();
+ });
+
+ this._isClick = true;
+ this._headerEl.addEventListener('click', (evt) => {
+ if (!this._isClick) return;
+ this._onHeaderClicked(evt);
+ });
+
+ this._resizeTimeout = null;
+ this._resizeTick = null;
+ window.addEventListener('resize', this._onWindowResize);
+
+ // hover detection for ie
+ this._container.addEventListener('mouseenter', () => {
+ this._hover = true;
+ this._renderMainClass();
+ });
+ this._container.addEventListener('mouseleave', () => {
+ this._hover = false;
+ this._renderMainClass();
+ });
+ if (document.readyState === 'loading') {
+ window.addEventListener('load', () => {
+ document.body.appendChild(this._container);
+ });
+ } else {
+ document.body.appendChild(this._container);
+ }
+
+ if (typeof this._beforeRender === 'function') {
+ this._beforeRender();
+ }
+ this._render();
+ }
+ _onWindowResize = () => {
+ if (this._dragging) { return; }
+ if (this._resizeTimeout) { clearTimeout(this._resizeTimeout); }
+ this._resizeTimeout = setTimeout(() => this._renderRestrictedPosition(), 100);
+ if (!this._resizeTick || Date.now() - this._resizeTick > 50) {
+ this._resizeTick = Date.now();
+ this._renderRestrictedPosition();
+ }
+ }
+ _onWindowMouseMove = (e) => {
+ if (this._dragging) {
+ if (e.buttons === 0) {
+ this._dragging = false;
+ this._renderMainClass();
+ return;
+ }
+ const factor = this._calculateFactor();
+ const delta = {
+ x: e.clientX - this._dragStartPosition.x,
+ y: e.clientY - this._dragStartPosition.y,
+ };
+ if (this._minimized) {
+ this._minTranslateX = this._dragStartPosition.minTranslateX + delta.x * factor;
+ this._minTranslateY = this._dragStartPosition.minTranslateY + delta.y;
+ } else {
+ this._translateX = this._dragStartPosition.translateX + delta.x * factor;
+ this._translateY = this._dragStartPosition.translateY + delta.y;
+ }
+ if (delta.x !== 0 || delta.y !== 0) this._isClick = false;
+ this._syncPosition();
+ this._renderRestrictedPosition();
+ }
+ }
+
+ get messageTransport() {
+ return this._messageTransport;
+ }
+
+ _postMessage(data) {
+ this.messageTransport.postMessage(data);
+ }
+
+ _setLogoUrl(logoUrl) {
+ this._logoUrl = logoUrl;
+ this._logoEl.src = logoUrl;
+ this._logoEl.setAttribute('class', classnames(
+ this._styles.logo,
+ this._logoUrl && this._logoUrl !== '' && this._styles.visible,
+ ));
+ }
+
+ _setAppUrl(appUrl) {
+ this._appUrl = appUrl;
+ if (appUrl) {
+ this.contentFrameEl.src = appUrl;
+ }
+ }
+
+ _onSyncMinimized(minimized) {
+ this._minimized = !!minimized;
+ this._renderMainClass();
+ this.renderAdapterSize();
+ this._renderRestrictedPosition();
+ }
+ setMinimized(minimized) {
+ this._onSyncMinimized(minimized);
+ this._postMessage({
+ type: this._messageTypes.syncMinimized,
+ minimized: this._minimized,
+ });
+ }
+ toggleMinimized() {
+ this.setMinimized(!this._minimized);
+ }
+
+ _calculateMinMaxPosition() {
+ const maximumX = window.innerWidth -
+ (this._minimized ? this._headerEl.clientWidth : this._appWidth) - 2 * this._padding;
+ const maximumY = window.innerHeight -
+ (this._minimized ?
+ this._headerEl.clientHeight :
+ this._headerEl.clientHeight + this._appHeight) - this._padding;
+ return {
+ minimumX: this._padding,
+ minimumY: this._padding,
+ maximumX,
+ maximumY,
+ };
+ }
+
+ _onSyncClosed(closed) {
+ this._closed = !!closed;
+ this._renderMainClass();
+ }
+ setClosed(closed) {
+ this._onSyncClosed(closed);
+ this._postMessage({
+ type: this._messageTypes.syncClosed,
+ closed: this.closed,
+ });
+ }
+ toggleClosed() {
+ this.setClosed(!this.closed);
+ }
+
+ _onSyncSize({ width, height }) {
+ this._appWidth = width;
+ this._appHeight = height;
+ this._contentFrameEl.style.width = `${width}px`;
+ this._contentFrameEl.style.height = `${height}px`;
+ this.renderAdapterSize();
+ }
+ setSize(size) {
+ this._onSyncSize(size);
+ this._postMessage({
+ type: this._messageTypes.syncSize,
+ size,
+ });
+ }
+
+ _onPushRingState({ ringing }) {
+ this._ringing = ringing;
+ this._render();
+ }
+
+ _onPushPresence({ dndStatus, userStatus, telephonyStatus }) {
+ if (
+ dndStatus !== this._dndStatus ||
+ userStatus !== this._userStatus ||
+ telephonyStatus !== this._telephonyStatus
+ ) {
+ this._dndStatus = dndStatus;
+ this._userStatus = userStatus;
+ this._telephonyStatus = telephonyStatus;
+ this.renderPresence();
+ }
+ }
+ _onPushLocale({
+ locale,
+ strings = {},
+ }) {
+ this._locale = locale;
+ this._strings = strings;
+ }
+
+ _debouncedPostMessage = debounce(this._postMessage, 100)
+
+ _syncPosition() {
+ this._debouncedPostMessage.call(this, {
+ type: this._messageTypes.syncPosition,
+ position: {
+ translateX: this._translateX,
+ translateY: this._translateY,
+ minTranslateX: this._minTranslateX,
+ minTranslateY: this._minTranslateY,
+ },
+ });
+ }
+ _onPushAdapterState({
+ size: {
+ width,
+ height
+ },
+ minimized,
+ closed,
+ position: { translateX, translateY, minTranslateX, minTranslateY },
+ dndStatus,
+ userStatus,
+ telephonyStatus,
+ }) {
+ this._minimized = minimized;
+ this._closed = closed;
+ if (!this._dragging) {
+ this._translateX = translateX;
+ this._translateY = translateY;
+ this._minTranslateX = minTranslateX;
+ this._minTranslateY = minTranslateY;
+ }
+ this._appWidth = width;
+ this._appHeight = height;
+ this._dndStatus = dndStatus;
+ this._userStatus = userStatus;
+ this._telephonyStatus = telephonyStatus;
+ this._loading = false;
+ this._render();
+ }
+ _calculateFactor() {
+ return this._defaultDirection === 'right' ?
+ -1 :
+ 1;
+ }
+ renderPosition() {
+ const factor = this._calculateFactor();
+ if (this._minimized) {
+ this._container.setAttribute(
+ 'style',
+ `transform: translate( ${this._minTranslateX * factor}px, ${-this._padding}px)!important;`
+ );
+ } else {
+ this._container.setAttribute(
+ 'style',
+ `transform: translate( ${this._translateX * factor}px, ${this._translateY}px)!important;`
+ );
+ }
+ }
+ _renderRestrictedPosition() {
+ const {
+ minimumX,
+ minimumY,
+ maximumX,
+ maximumY,
+ } = this._calculateMinMaxPosition();
+
+ if (this._minimized) {
+ const newMinTranslateX = Math.max(Math.min(this._minTranslateX, maximumX), minimumX);
+ if (newMinTranslateX !== this._minTranslateX) {
+ this._minTranslateX = newMinTranslateX;
+ }
+ const newMinTranslateY = Math.max(Math.min(this._minTranslateY, -minimumY), -maximumY);
+ if (newMinTranslateY !== this._minTranslateY) {
+ this._minTranslateY = newMinTranslateY;
+ }
+ } else {
+ const newTranslateX = Math.max(Math.min(this._translateX, maximumX), minimumX);
+ const newTranslateY = Math.max(Math.min(this._translateY, -minimumY), -maximumY);
+ if (this._translateX !== newTranslateX || this._translateY !== newTranslateY) {
+ this._translateX = newTranslateX;
+ this._translateY = newTranslateY;
+ }
+ }
+ this.renderPosition();
+ }
+ renderAdapterSize() {
+ if (this._minimized) {
+ this._contentFrameContainerEl.style.width = 0;
+ this._contentFrameContainerEl.style.height = 0;
+ } else {
+ this._contentFrameContainerEl.style.width = `${this._appWidth}px`;
+ this._contentFrameContainerEl.style.height = `${this._appHeight}px`;
+ this._contentFrameEl.style.width = `${this._appWidth}px`;
+ this._contentFrameEl.style.height = `${this._appHeight}px`;
+ }
+ }
+ _renderMainClass() {
+ this._container.setAttribute('class', classnames(
+ this._styles.root,
+ this._styles[this._defaultDirection],
+ this._closed && this._styles.closed,
+ this._minimized && this._styles.minimized,
+ this._dragging && this._styles.dragging,
+ this._hover && this._styles.hover,
+ this._loading && this._styles.loading,
+ ));
+ this._headerEl.setAttribute('class', classnames(
+ this._styles.header,
+ this._minimized && this._styles.minimized,
+ this._ringing && this._styles.ringing,
+ ));
+ }
+ renderPresence() {
+ this._presenceEl.setAttribute('class', classnames(
+ this._minimized && this._styles.minimized,
+ this._styles.presence,
+ this._userStatus && this._styles[this._userStatus],
+ this._dndStatus && this._styles[this._dndStatus],
+ ));
+ }
+ _render() {
+ this.renderPresence();
+ this.renderAdapterSize();
+ this._renderRestrictedPosition();
+ this._renderMainClass();
+ }
+
+ dispose() {
+ // TODO clean up
+ window.removeEventListener('mousemove', this._onWindowMouseMove);
+ window.removeEventListener('resize', this._onWindowResize);
+ if (this._resizeTimeout) {
+ clearTimeout(this._resizeTick);
+ }
+ this._container.remove();
+ }
+
+ get container() {
+ return this._container;
+ }
+ get root() {
+ return this._root;
+ }
+ get headerEl() {
+ return this._headerEl;
+ }
+ get contentFrameContainerEl() {
+ return this._contentFrameContainerEl;
+ }
+ get toggleEl() {
+ return this._toggleEl;
+ }
+ get closeEl() {
+ return this._closeEl;
+ }
+ get presenceEl() {
+ return this._presenceEl;
+ }
+ get contentFrameEl() {
+ return this._contentFrameEl;
+ }
+ get minTranslateX() {
+ return this._minTranslateX;
+ }
+ get minTranslateY() {
+ return this._minTranslateY;
+ }
+ get translateX() {
+ return this._translateX;
+ }
+ get translateY() {
+ return this._translateY;
+ }
+ get appWidth() {
+ return this._appWidth;
+ }
+ get appHeight() {
+ return this._appHeight;
+ }
+ get dragStartPosition() {
+ return this._dragStartPosition;
+ }
+
+ get closed() {
+ return this._closed;
+ }
+ get minimized() {
+ return this._minimized;
+ }
+ get dragging() {
+ return this._dragging;
+ }
+ get hover() {
+ return this._hover;
+ }
+ get loading() {
+ return this._loading;
+ }
+ get userStatus() {
+ return this._userStatus;
+ }
+ get dndStatus() {
+ return this._dndStatus;
+ }
+ get ringing() {
+ return this._ringing;
+ }
+}
diff --git a/src/lib/AdapterCore/styles.scss b/src/lib/AdapterCore/styles.scss
index 0ed30f0bb6..da28c26947 100644
--- a/src/lib/AdapterCore/styles.scss
+++ b/src/lib/AdapterCore/styles.scss
@@ -42,12 +42,15 @@
transition: opacity 0.1s 0s linear;
}
-.root.closed,
-.root.loading {
+.root.closed {
visibility: hidden;
opacity: 0;
}
+.root.loading {
+ display: none;
+}
+
.header {
@include no-select;
position: relative;
diff --git a/src/lib/AdapterModuleCore/getDefaultGlobalStorageReducer.js b/src/lib/AdapterModuleCore/getDefaultGlobalStorageReducer.js
index ae4158c7e1..f2edd8f45c 100644
--- a/src/lib/AdapterModuleCore/getDefaultGlobalStorageReducer.js
+++ b/src/lib/AdapterModuleCore/getDefaultGlobalStorageReducer.js
@@ -1,78 +1,81 @@
-import { combineReducers } from 'redux';
-
-export function getClosedReducer(types) {
- return (state = false, { type, closed }) => {
- switch (type) {
- case types.syncClosed:
- return !!closed;
- case types.showAdapter:
- return false;
- default:
- return state;
- }
- };
-}
-
-export function getMinimizedReducer(types) {
- return (state = false, { type, minimized }) => {
- switch (type) {
- case types.syncMinimized:
- return !!minimized;
- case types.showAdapter:
- return false;
- default:
- return state;
- }
- };
-}
-
-
-export function getSizeReducer(types) {
- return (state = { width: 300, height: 500 }, { type, size = {} }) => {
- switch (type) {
- case types.syncSize:
- return {
- ...state,
- ...size,
- };
- default:
- return state;
- }
- };
-}
-
-export function getPositionReducer(types) {
- return (
- state = {
- translateX: null,
- translateY: null,
- minTranslateX: null,
- },
- {
- type,
- position: {
- translateX = state.translateX,
- translateY = state.translateY,
- minTranslateX = state.minTranslateX,
- } = {},
- },
- ) => {
- if (type === types.syncPosition) {
- return {
- translateX,
- translateY,
- minTranslateX,
- };
- }
- return state;
- };
-}
-
-export default function getDefaultGlobalStorageReducer(types) {
- return combineReducers({
- closed: getClosedReducer(types),
- minimized: getMinimizedReducer(types),
- size: getSizeReducer(types),
- position: getPositionReducer(types),
- });
-}
+import { combineReducers } from 'redux';
+
+export function getClosedReducer(types) {
+ return (state = false, { type, closed }) => {
+ switch (type) {
+ case types.syncClosed:
+ return !!closed;
+ case types.showAdapter:
+ return false;
+ default:
+ return state;
+ }
+ };
+}
+
+export function getMinimizedReducer(types) {
+ return (state = false, { type, minimized }) => {
+ switch (type) {
+ case types.syncMinimized:
+ return !!minimized;
+ case types.showAdapter:
+ return false;
+ default:
+ return state;
+ }
+ };
+}
+
+
+export function getSizeReducer(types) {
+ return (state = { width: 300, height: 500 }, { type, size = {} }) => {
+ switch (type) {
+ case types.syncSize:
+ return {
+ ...state,
+ ...size,
+ };
+ default:
+ return state;
+ }
+ };
+}
+
+export function getPositionReducer(types) {
+ return (
+ state = {
+ translateX: null,
+ translateY: null,
+ minTranslateX: null,
+ minTranslateY: null,
+ },
+ {
+ type,
+ position: {
+ translateX = state.translateX,
+ translateY = state.translateY,
+ minTranslateX = state.minTranslateX,
+ minTranslateY = state.minTranslateY,
+ } = {},
+ },
+ ) => {
+ if (type === types.syncPosition) {
+ return {
+ translateX,
+ translateY,
+ minTranslateX,
+ minTranslateY,
+ };
+ }
+ return state;
+ };
+}
+
+export default function getDefaultGlobalStorageReducer(types) {
+ return combineReducers({
+ closed: getClosedReducer(types),
+ minimized: getMinimizedReducer(types),
+ size: getSizeReducer(types),
+ position: getPositionReducer(types),
+ });
+}
diff --git a/src/lib/AdapterModuleCore/index.js b/src/lib/AdapterModuleCore/index.js
index a4f3f4f0c5..3c2bf6ca0f 100644
--- a/src/lib/AdapterModuleCore/index.js
+++ b/src/lib/AdapterModuleCore/index.js
@@ -1,282 +1,285 @@
-import RcModule from 'ringcentral-integration/lib/RcModule';
-import proxify from 'ringcentral-integration/lib/proxy/proxify';
-import ensureExist from 'ringcentral-integration/lib/ensureExist';
-import moduleStatuses from 'ringcentral-integration/enums/moduleStatuses';
-import callingModes from 'ringcentral-integration/modules/CallingSettings/callingModes';
-import { prefixEnum } from 'ringcentral-integration/lib/Enum';
-import baseMessageTypes from '../AdapterCore/baseMessageTypes';
-import baseActionTypes from './baseActionTypes';
-import getDefaultGlobalStorageReducer from './getDefaultGlobalStorageReducer';
-import IframeMessageTransport from '../IframeMessageTransport';
-
-
-export default class AdapterModuleCore extends RcModule {
- constructor({
- prefix,
- storageKey = 'adapterCore',
- messageTypes = baseMessageTypes,
- actionTypes = baseActionTypes,
- webphone,
- presence,
- locale,
- callingSettings,
- routerInteraction,
- globalStorage,
- getGlobalStorageReducer = getDefaultGlobalStorageReducer,
- messageTransport = new IframeMessageTransport({
- targetWindow: window.parent,
- }),
- ...options
- }) {
- super({
- prefix,
- actionTypes,
- ...options,
- });
-
- this._messageTypes = prefixEnum({ enumMap: messageTypes, prefix });
- this._locale = this::ensureExist(locale, 'locale');
- this._messageTransport = this::ensureExist(messageTransport, 'messageTransport');
- this._presence = this::ensureExist(presence, 'presence');
- this._router = this::ensureExist(routerInteraction, 'routerInteraction');
- this._callingSettings = callingSettings;
- this._webphone = webphone;
-
- this._storageKey = storageKey;
- this._globalStorage = this::ensureExist(globalStorage, 'globalStorage');
-
- this._globalStorage.registerReducer({
- key: this._storageKey,
- reducer: getGlobalStorageReducer(this.actionTypes),
- });
- }
- initialize() {
- this._messageTransport.addListener(msg => this._onMessage(msg));
- this.store.subscribe(() => this._onStateChange());
- }
- _shouldInit() {
- return this.pending &&
- this._globalStorage.ready &&
- this._locale.ready &&
- this._router.ready;
- }
- _onStateChange() {
- if (this._shouldInit()) {
- this.store.dispatch({
- type: this.actionTypes.init,
- });
- this._pushAdapterState();
- this._pushRingState();
- this.store.dispatch({
- type: this.actionTypes.initSuccess,
- });
- }
- this._pushPresence();
- this._pushLocale();
- this._pushRingState();
- }
- _onMessage(msg) {
- if (msg) {
- switch (msg.type) {
- case this._messageTypes.syncClosed:
- this._syncClosed(msg.closed);
- break;
- case this._messageTypes.syncMinimized:
- this._syncMinimized(msg.minimized);
- break;
- case this._messageTypes.syncSize:
- this._syncSize(msg.size);
- break;
- case this._messageTypes.syncPosition:
- this._syncPosition(msg.position);
- break;
- case this._messageTypes.presenceClicked:
- this._onPresenceClicked();
- break;
- default:
- break;
- }
- }
- }
- @proxify
- async _syncClosed(closed) {
- this.store.dispatch({
- type: this.actionTypes.syncClosed,
- closed,
- });
- }
- @proxify
- async _syncMinimized(minimized) {
- this.store.dispatch({
- type: this.actionTypes.syncMinimized,
- minimized,
- });
- }
- @proxify
- async _syncSize(size = {}) {
- this.store.dispatch({
- type: this.acitonTypes.syncSize,
- size,
- });
- }
- @proxify
- async _syncPosition(position = {}) {
- this.store.dispatch({
- type: this.actionTypes.syncPosition,
- position,
- });
- }
-
- _pushRingState() {
- if (!this.ready || !this._callingSettings) return;
-
- const { callingMode } = this._callingSettings;
- if (callingMode === callingModes.webphone) {
- const webphone = this._webphone;
- if (!webphone) {
- throw new Error('webphone is a required dependency for monitoring WebRTC call');
- }
- if (webphone.ringSession && webphone.ringSessionId !== this._ringSessionId) {
- this._ringSessionId = webphone.ringSessionId;
- this._postMessage({
- type: this._messageTypes.pushRingState,
- ringing: true
- });
- }
- // Check if ringing is over
- if (this._ringSessionId) {
- const ringingSessions = webphone.sessions.filter(session =>
- session.callStatus === 'webphone-session-connecting' && session.direction === 'Inbound'
- );
- if (ringingSessions.length <= 0) {
- this._postMessage({
- type: this._messageTypes.pushRingState,
- ringing: false
- });
- this._ringSessionId = null;
- }
- }
- } else {
- const status = this._presence.telephonyStatus;
- if (this._presence.telephonyStatus !== this._telephonyStatus) {
- this._postMessage({
- type: this._messageTypes.pushRingState,
- ringing: status === 'Ringing'
- });
- this._telephonyStatus = status;
- }
- }
- }
-
- _pushPresence() {
- if (
- this.ready &&
- (
- this._lastDndStatus !== this._presence.dndStatus ||
- this._lastUserStatus !== this._presence.userStatus ||
- this._lastTelephonyStatus !== this._presence.telephonyStatus
- )
- ) {
- this._lastDndStatus = this._presence.dndStatus;
- this._lastUserStatus = this._presence.userStatus;
- this._lastTelephonyStatus = this._presence.telephonyStatus;
- this._postMessage({
- type: this._messageTypes.pushPresence,
- telephonyStatus: this._presence.telephonyStatus,
- userStatus: this._presence.userStatus,
- dndStatus: this._presence.dndStatus,
- });
- }
- }
-
- get localeStrings() {
- return {};
- }
-
- _pushLocale() {
- if (
- this.ready &&
- this._lastLocale !== this._locale.currentLocale
- ) {
- this._lastLocale = this._locale.currentLocale;
- this._postMessage({
- type: this._messageTypes.pushLocale,
- locale: this._locale.currentLocale,
- strings: this._localeStrings,
- });
- }
- }
-
- _postMessage(data) {
- this._messageTransport.postMessage(data);
- }
-
- _pushAdapterState() {
- if (
- this.ready &&
- (
- this._lastDndStatus !== this._presence.dndStatus ||
- this._lastUserStatus !== this._presence.userStatus ||
- this._lastTelephonyStatus !== this._presence.telephonyStatus ||
- this._lastClosed !== this.closed ||
- this._lastMinimized !== this.minimized ||
- this._lastPosition !== this.position
- )
- ) {
- this._lastDndStatus = this._presence.dndStatus;
- this._lastUserStatus = this._presence.userStatus;
- this._lastTelephonyStatus = this._presence.telephonyStatus;
- this._lastClosed = this.closed;
- this._lastMinimized = this.minimized;
- this._lastPosition = this.position;
- this._postMessage({
- type: this._messageTypes.pushAdapterState,
- size: this.size,
- minimized: this.minimized,
- closed: this.closed,
- position: this.position,
- telephonyStatus: this._presence.telephonyStatus,
- userStatus: this._presence.userStatus,
- dndStatus: this._presence.dndStatus,
- });
- }
- }
- @proxify
- async _onPresenceClicked() {
- if (this.minimized) {
- this.showAdapter();
- }
- this._router.push('/settings?showPresenceSettings=1');
- }
-
- @proxify
- async showAdapter() {
- this.store.dispatch({
- type: this.actionTypes.showAdapter,
- });
- }
-
- get status() {
- return this.state.status;
- }
- get ready() {
- return this.status === moduleStatuses.ready;
- }
-
- get pending() {
- return this.status === moduleStatuses.pending;
- }
-
- get minimized() {
- return this._globalStorage.getItem(this._storageKey).minimized;
- }
- get closed() {
- return this._globalStorage.getItem(this._storageKey).closed;
- }
- get size() {
- return this._globalStorage.getItem(this._storageKey).size;
- }
- get position() {
- return this._globalStorage.getItem(this._storageKey).position;
- }
-}
+import RcModule from 'ringcentral-integration/lib/RcModule';
+import proxify from 'ringcentral-integration/lib/proxy/proxify';
+import ensureExist from 'ringcentral-integration/lib/ensureExist';
+import moduleStatuses from 'ringcentral-integration/enums/moduleStatuses';
+import callingModes from 'ringcentral-integration/modules/CallingSettings/callingModes';
+import { prefixEnum } from 'ringcentral-integration/lib/Enum';
+import baseMessageTypes from '../AdapterCore/baseMessageTypes';
+import baseActionTypes from './baseActionTypes';
+import getDefaultGlobalStorageReducer from './getDefaultGlobalStorageReducer';
+import IframeMessageTransport from '../IframeMessageTransport';
+
+
+export default class AdapterModuleCore extends RcModule {
+ constructor({
+ prefix,
+ storageKey = 'adapterCore',
+ messageTypes = baseMessageTypes,
+ actionTypes = baseActionTypes,
+ webphone,
+ presence,
+ locale,
+ callingSettings,
+ routerInteraction,
+ globalStorage,
+ getGlobalStorageReducer = getDefaultGlobalStorageReducer,
+ messageTransport = new IframeMessageTransport({
+ targetWindow: window.parent,
+ }),
+ ...options
+ }) {
+ super({
+ prefix,
+ actionTypes,
+ ...options,
+ });
+
+ this._messageTypes = prefixEnum({ enumMap: messageTypes, prefix });
+ this._locale = this::ensureExist(locale, 'locale');
+ this._messageTransport = this::ensureExist(messageTransport, 'messageTransport');
+ this._presence = this::ensureExist(presence, 'presence');
+ this._router = this::ensureExist(routerInteraction, 'routerInteraction');
+ this._callingSettings = callingSettings;
+ this._webphone = webphone;
+
+ this._storageKey = storageKey;
+ this._globalStorage = this::ensureExist(globalStorage, 'globalStorage');
+
+ this._globalStorage.registerReducer({
+ key: this._storageKey,
+ reducer: getGlobalStorageReducer(this.actionTypes),
+ });
+ }
+ initialize() {
+ this._messageTransport.addListener(msg => this._onMessage(msg));
+ this.store.subscribe(() => this._onStateChange());
+ }
+ _shouldInit() {
+ return this.pending &&
+ this._globalStorage.ready &&
+ this._locale.ready &&
+ this._router.ready;
+ }
+ _onStateChange() {
+ if (this._shouldInit()) {
+ this.store.dispatch({
+ type: this.actionTypes.init,
+ });
+ this._pushAdapterState();
+ this._pushRingState();
+ this.store.dispatch({
+ type: this.actionTypes.initSuccess,
+ });
+ }
+ this._pushPresence();
+ this._pushLocale();
+ this._pushRingState();
+ }
+ _onMessage(msg) {
+ if (msg) {
+ switch (msg.type) {
+ case this._messageTypes.syncClosed:
+ this._syncClosed(msg.closed);
+ break;
+ case this._messageTypes.syncMinimized:
+ this._syncMinimized(msg.minimized);
+ break;
+ case this._messageTypes.syncSize:
+ this._syncSize(msg.size);
+ break;
+ case this._messageTypes.syncPosition:
+ this._syncPosition(msg.position);
+ break;
+ case this._messageTypes.presenceClicked:
+ this._onPresenceClicked();
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ @proxify
+ async _syncClosed(closed) {
+ this.store.dispatch({
+ type: this.actionTypes.syncClosed,
+ closed,
+ });
+ }
+ @proxify
+ async _syncMinimized(minimized) {
+ this.store.dispatch({
+ type: this.actionTypes.syncMinimized,
+ minimized,
+ });
+ }
+ @proxify
+ async _syncSize(size = {}) {
+ this.store.dispatch({
+ type: this.acitonTypes.syncSize,
+ size,
+ });
+ }
+ @proxify
+ async _syncPosition(position = {}) {
+ this.store.dispatch({
+ type: this.actionTypes.syncPosition,
+ position,
+ });
+ }
+
+ _pushRingState() {
+ if (!this.ready || !this._callingSettings) return;
+
+ const { callingMode } = this._callingSettings;
+ if (callingMode === callingModes.webphone) {
+ const webphone = this._webphone;
+ if (!webphone) {
+ throw new Error('webphone is a required dependency for monitoring WebRTC call');
+ }
+ if (webphone.ringSession && webphone.ringSessionId !== this._ringSessionId) {
+ this._ringSessionId = webphone.ringSessionId;
+ this._postMessage({
+ type: this._messageTypes.pushRingState,
+ ringing: true
+ });
+ }
+ // Check if ringing is over
+ if (this._ringSessionId) {
+ const ringingSessions = webphone.sessions.filter(session =>
+ session.callStatus === 'webphone-session-connecting' && session.direction === 'Inbound'
+ );
+ if (ringingSessions.length <= 0) {
+ this._postMessage({
+ type: this._messageTypes.pushRingState,
+ ringing: false
+ });
+ this._ringSessionId = null;
+ }
+ }
+ } else {
+ const status = this._presence.telephonyStatus;
+ if (this._presence.telephonyStatus !== this._telephonyStatus) {
+ this._postMessage({
+ type: this._messageTypes.pushRingState,
+ ringing: status === 'Ringing'
+ });
+ this._telephonyStatus = status;
+ }
+ }
+ }
+
+ _pushPresence() {
+ if (
+ this.ready &&
+ (
+ this._lastDndStatus !== this._presence.dndStatus ||
+ this._lastUserStatus !== this._presence.userStatus ||
+ this._lastTelephonyStatus !== this._presence.telephonyStatus
+ )
+ ) {
+ this._lastDndStatus = this._presence.dndStatus;
+ this._lastUserStatus = this._presence.userStatus;
+ this._lastTelephonyStatus = this._presence.telephonyStatus;
+ this._postMessage({
+ type: this._messageTypes.pushPresence,
+ telephonyStatus: this._presence.telephonyStatus,
+ userStatus: this._presence.userStatus,
+ dndStatus: this._presence.dndStatus,
+ });
+ }
+ }
+
+ get localeStrings() {
+ return {};
+ }
+
+ _pushLocale() {
+ if (
+ this.ready &&
+ this._lastLocale !== this._locale.currentLocale
+ ) {
+ this._lastLocale = this._locale.currentLocale;
+ this._postMessage({
+ type: this._messageTypes.pushLocale,
+ locale: this._locale.currentLocale,
+ strings: this._localeStrings,
+ });
+ }
+ }
+
+ _postMessage(data) {
+ this._messageTransport.postMessage(data);
+ }
+
+ _pushAdapterState() {
+ if (
+ this.ready &&
+ (
+ this._lastDndStatus !== this._presence.dndStatus ||
+ this._lastUserStatus !== this._presence.userStatus ||
+ this._lastTelephonyStatus !== this._presence.telephonyStatus ||
+ this._lastClosed !== this.closed ||
+ this._lastMinimized !== this.minimized ||
+ this._lastPosition.translateX !== this.position.translateX ||
+ this._lastPosition.translateY !== this.position.translateY ||
+ this._lastPosition.minTranslateX !== this.position.minTranslateX ||
+ this._lastPosition.minTranslateY !== this.position.minTranslateY
+ )
+ ) {
+ this._lastDndStatus = this._presence.dndStatus;
+ this._lastUserStatus = this._presence.userStatus;
+ this._lastTelephonyStatus = this._presence.telephonyStatus;
+ this._lastClosed = this.closed;
+ this._lastMinimized = this.minimized;
+ this._lastPosition = this.position;
+ this._postMessage({
+ type: this._messageTypes.pushAdapterState,
+ size: this.size,
+ minimized: this.minimized,
+ closed: this.closed,
+ position: this.position,
+ telephonyStatus: this._presence.telephonyStatus,
+ userStatus: this._presence.userStatus,
+ dndStatus: this._presence.dndStatus,
+ });
+ }
+ }
+ @proxify
+ async _onPresenceClicked() {
+ if (this.minimized) {
+ this.showAdapter();
+ }
+ this._router.push('/settings?showPresenceSettings=1');
+ }
+
+ @proxify
+ async showAdapter() {
+ this.store.dispatch({
+ type: this.actionTypes.showAdapter,
+ });
+ }
+
+ get status() {
+ return this.state.status;
+ }
+ get ready() {
+ return this.status === moduleStatuses.ready;
+ }
+
+ get pending() {
+ return this.status === moduleStatuses.pending;
+ }
+
+ get minimized() {
+ return this._globalStorage.getItem(this._storageKey).minimized;
+ }
+ get closed() {
+ return this._globalStorage.getItem(this._storageKey).closed;
+ }
+ get size() {
+ return this._globalStorage.getItem(this._storageKey).size;
+ }
+ get position() {
+ return this._globalStorage.getItem(this._storageKey).position;
+ }
+}
diff --git a/yarn.lock b/yarn.lock
index b2f565becb..fd8a7a9e11 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -7447,7 +7447,7 @@ ringcentral-client@^1.0.0-beta.1:
"ringcentral-integration@https://github.com/ringcentral/ringcentral-js-integration-commons#latest":
version "0.1.0"
- resolved "https://github.com/ringcentral/ringcentral-js-integration-commons#657035373b66fe7a5d8279f47a1e1db8decbd590"
+ resolved "https://github.com/ringcentral/ringcentral-js-integration-commons#3d90b7d4b5a327238dcb091821dc0995511b4345"
dependencies:
file-loader "^0.11.2"
json-mask "^0.3.8"