= ({
+ entranceAnimation = 'fadeInDown',
+ exitAnimation = 'fadeOutUp',
+ backdropEntranceAnimation = 'fadeIn',
+ backdropExitAnimation = 'fadeOut',
+ duration = 500,
+ messages,
+ className,
+ ...rest
+}) => {
+ const [currentMessages, setCurrentMessages] = useState(messages);
+ const { sleep, cancel } = useSleep();
+
+ useEffect(() => {
+ const updatedMessages: NotificationMessage[] = [];
+ // if length is grater means that is delete item.
+ if (currentMessages.length > messages.length) {
+ currentMessages.forEach((currentMessage) => {
+ const updatedMessage = {
+ ...currentMessage,
+ };
+ // if that can't find this id, that means that is delete
+ if (!messages.some((m) => m.id === currentMessage.id)) {
+ updatedMessage.animation = exitAnimation;
+ updatedMessage.backdropAnimation = backdropExitAnimation;
+ } else {
+ updatedMessage.animation = '';
+ updatedMessage.backdropAnimation = '';
+ }
+ updatedMessages.push(updatedMessage);
+ });
+
+ setCurrentMessages(updatedMessages);
+
+ if (duration > 0) {
+ sleep(duration)
+ .then(() => {
+ setCurrentMessages(messages);
+ })
+ .catch(() => {
+ // ignore cancel
+ });
+ }
+ } else {
+ cancel();
+ setCurrentMessages(messages);
+ }
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [messages]);
+
+ return (
+
+ {currentMessages.map((data, i) => {
+ return (
+
+ );
+ })}
+
+ );
+};
diff --git a/src/containers/App/index.js b/src/containers/App/index.js
index 27047332c..fc4c00c12 100644
--- a/src/containers/App/index.js
+++ b/src/containers/App/index.js
@@ -9,7 +9,6 @@ import {
import GlipChat from '@ringcentral-integration/glip-widgets/containers/GlipChat';
import GlipGroups from '@ringcentral-integration/glip-widgets/containers/GlipGroups';
-import { NotificationContainer } from '@ringcentral-integration/widgets/containers/NotificationContainer';
import CallBadgeContainer from '@ringcentral-integration/widgets/containers/CallBadgeContainer';
import CallingSettingsPage from '@ringcentral-integration/widgets/containers/CallingSettingsPage';
import { CallsOnholdPage } from '@ringcentral-integration/widgets/containers/CallsOnholdPage';
@@ -24,7 +23,6 @@ import { ThemeContainer } from '@ringcentral-integration/widgets/containers/Them
import { PhoneContext } from '@ringcentral-integration/widgets/lib/phoneContext';
-import { getAlertRenderer } from '../../components/AlertRenderer';
import ThirdPartyContactSourceIcon from '../../components/ThirdPartyContactSourceIcon';
import GenericMeetingPage from '../GenericMeetingPage';
import { formatMeetingInfo } from '../../lib/formatMeetingInfo';
@@ -55,6 +53,8 @@ import MeetingScheduleButton from '../ThirdPartyMeetingScheduleButton';
import ThirdPartySettingSectionPage from '../ThirdPartySettingSectionPage';
import ContactsPage from '../ContactsPage';
import CustomizedPage from '../CustomizedPage';
+import { NotificationContainer } from '../NotificationContainer';
+
export default function App({
phone,
showCallBadge,
@@ -135,7 +135,6 @@ export default function App({
diff --git a/src/containers/NotificationContainer/index.ts b/src/containers/NotificationContainer/index.ts
new file mode 100644
index 000000000..9f77717f2
--- /dev/null
+++ b/src/containers/NotificationContainer/index.ts
@@ -0,0 +1,8 @@
+import { connectModule } from '@ringcentral-integration/widgets/lib/phoneContext';
+import type { NotificationContainerProps } from '@ringcentral-integration/widgets/containers/NotificationContainer/NotificationContainer.interface';
+import { NotificationPanel } from '../../components/NotificationPanel';
+
+export const NotificationContainer = connectModule<
+ any,
+ NotificationContainerProps
+>((phone) => phone.alertUI)(NotificationPanel);
diff --git a/src/lib/Adapter/index.js b/src/lib/Adapter/index.js
index fb4811937..9a3729394 100644
--- a/src/lib/Adapter/index.js
+++ b/src/lib/Adapter/index.js
@@ -703,9 +703,9 @@ class Adapter extends AdapterCore {
return this._widgetCurrentPath === '/history';
}
- alertMessage({ message, level, ttl }) {
+ alertMessage({ message, level, ttl, details }) {
return this._requestWithPostMessage('/custom-alert-message', {
- message, level, ttl,
+ message, level, ttl, details,
});
}
diff --git a/src/modules/Adapter/index.js b/src/modules/Adapter/index.js
index 42a7c813d..8f12aac10 100644
--- a/src/modules/Adapter/index.js
+++ b/src/modules/Adapter/index.js
@@ -393,6 +393,7 @@ export default class Adapter extends AdapterModuleCore {
message: 'showCustomAlertMessage',
payload: {
alertMessage: data.alertMessage || data.body && data.body.message,
+ details: data.body && data.body.details,
}
});
this._postRCAdapterMessageResponse({
diff --git a/src/modules/AlertUI/index.ts b/src/modules/AlertUI/index.ts
new file mode 100644
index 000000000..527d14d12
--- /dev/null
+++ b/src/modules/AlertUI/index.ts
@@ -0,0 +1,38 @@
+import { AlertUI as AlertUIBase } from '@ringcentral-integration/widgets/modules/AlertUI';
+import { Module } from '@ringcentral-integration/commons/lib/di';
+import type {
+ NotificationMessage,
+} from '@ringcentral-integration/widgets/components/NotificationPanel/NotificationPanel.interface';
+import { getAlertRenderer } from '../../components/AlertRenderer';
+
+@Module({
+ name: 'AlertUI',
+ deps: ['ThirdPartyService'],
+})
+export class AlertUI extends AlertUIBase {
+ constructor(deps) {
+ super(deps);
+ this._ignoreModuleReadiness(deps.thirdPartyService);
+ }
+
+ getUIFunctions(options) {
+ const functions = super.getUIFunctions(options);
+ return {
+ ...functions,
+ getRenderer: (message: NotificationMessage) => {
+ const renderer = getAlertRenderer({
+ onThirdPartyLinkClick: (id)=> this._deps.thirdPartyService.onClickLinkInAlertDetail(id),
+ })(message);
+ if (renderer) {
+ return renderer;
+ }
+ return functions.getRenderer(message);
+ },
+ cancelAutoDismiss: (id) => {
+ this._deps.alert.update(id, {
+ ttl: 0,
+ });
+ },
+ };
+ }
+}
\ No newline at end of file
diff --git a/src/modules/Phone/index.js b/src/modules/Phone/index.js
index d4e65abd0..0bb5bacc3 100644
--- a/src/modules/Phone/index.js
+++ b/src/modules/Phone/index.js
@@ -110,7 +110,6 @@ import { RingCentralExtensions } from '@ringcentral-integration/commons/modules/
import {
ActiveCallsUI,
} from '@ringcentral-integration/widgets/modules/ActiveCallsUI';
-import { AlertUI } from '@ringcentral-integration/widgets/modules/AlertUI';
import {
CallBadgeUI,
} from '@ringcentral-integration/widgets/modules/CallBadgeUI';
@@ -167,6 +166,7 @@ import hackSend from '../../lib/hackSend';
import lockRefresh from '../../lib/lockRefresh';
import { ActiveCallControl } from '../ActiveCallControl';
import Adapter from '../Adapter';
+import { AlertUI } from '../AlertUI';
import { AccountContacts } from '../AccountContacts';
import { AddressBook } from '../AddressBook';
import { Analytics } from '../Analytics';
diff --git a/src/modules/ThirdPartyService/index.ts b/src/modules/ThirdPartyService/index.ts
index c598b25e8..c252d1d79 100644
--- a/src/modules/ThirdPartyService/index.ts
+++ b/src/modules/ThirdPartyService/index.ts
@@ -1415,6 +1415,19 @@ export default class ThirdPartyService extends RcModuleV2 {
});
}
+ async onClickLinkInAlertDetail(id) {
+ if (!this._additionalButtonPath) {
+ console.warn('Button event is not registered, ');
+ return;
+ }
+ await requestWithPostMessage(this._additionalButtonPath, {
+ button: {
+ id,
+ type: 'linkInAlertDetail',
+ },
+ });
+ }
+
@computed(that => [that.customizedPages])
get customizedTabs() {
return this.customizedPages.filter(x => x.type === 'tab').map(tab => ({