Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
feat(notifications) Use our own component
robertpin7156df5b9970
diff --git a/css/_atlaskit_overrides.scss b/css/_atlaskit_overrides.scssindex 00a5e2dfeb..35a265e028 100644--- a/css/_atlaskit_overrides.scss+++ b/css/_atlaskit_overrides.scss@@ -16,14 +16,6 @@border-radius: 0;}-/**- * Move the @atlaskit/flag container up a little bit so it does not cover the- * toolbar with the first notification.- */-.atlaskit-portal > #notifications-container {- bottom: calc(#{$newToolbarSizeWithPadding}) !important;-}-/*** Keep overflow menu within screen vertical bounds and make it scrollable.diff --git a/package-lock.json b/package-lock.jsonindex 0560bce6ca..1894ec25f4 100644--- a/package-lock.json+++ b/package-lock.json@@ -11,7 +11,6 @@"license": "Apache-2.0","dependencies": {"@amplitude/react-native": "2.7.0",- "@atlaskit/flag": "14.1.0","@atlaskit/inline-dialog": "13.0.9","@atlaskit/inline-message": "11.0.8","@atlaskit/multi-select": "15.0.5",@@ -114,7 +113,6 @@"react-native-youtube-iframe": "2.2.1","react-redux": "7.1.0","react-textarea-autosize": "8.3.0",- "react-transition-group": "2.4.0","react-window": "1.8.6","react-youtube": "10.1.0","redux": "4.0.4",@@ -491,24 +489,6 @@"react": "^16.8.0"}},- "node_modules/@atlaskit/flag": {- "version": "14.1.0",- "resolved": "https://registry.npmjs.org/@atlaskit/flag/-/flag-14.1.0.tgz",- "integrity": "sha512-xpjVmXpwpknlD0gVU+tkfG35x2i8pkq2tGMkRO50EstbF+hENPgv24oIaGOQHSOANM98hnRG3aO45rTbc4QcvA==",- "dependencies": {- "@atlaskit/analytics-next": "^8.0.0",- "@atlaskit/button": "^15.1.0",- "@atlaskit/icon": "^21.0.0",- "@atlaskit/motion": "^0.4.0",- "@atlaskit/portal": "^4.0.0",- "@atlaskit/theme": "^11.0.0",- "@babel/runtime": "^7.0.0",- "@emotion/core": "^10.0.9"- },- "peerDependencies": {- "react": "^16.8.0"- }- },"node_modules/@atlaskit/icon": {"version": "21.2.0","resolved": "https://registry.npmjs.org/@atlaskit/icon/-/icon-21.2.0.tgz",@@ -9548,14 +9528,6 @@"node": ">=6.0.0"}},- "node_modules/dom-helpers": {- "version": "3.4.0",- "resolved": "https://registry.npmjs.org/dom-helpers/-/dom-helpers-3.4.0.tgz",- "integrity": "sha512-LnuPJ+dwqKDIyotW1VzmOZ5TONUN7CwkCR5hrgawTUbkBGYdeoNLZo6nNfGkCrjtE1nXXaj7iMMpDa8/d9WoIA==",- "dependencies": {- "@babel/runtime": "^7.1.2"- }- },"node_modules/dom-serializer": {"version": "1.4.1","resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.4.1.tgz",@@ -16030,11 +16002,6 @@"resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz","integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w=="},- "node_modules/react-lifecycles-compat": {- "version": "3.0.4",- "resolved": "https://registry.npmjs.org/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz",- "integrity": "sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA=="- },"node_modules/react-linkify": {"version": "1.0.0-alpha","resolved": "https://registry.npmjs.org/react-linkify/-/react-linkify-1.0.0-alpha.tgz",@@ -16581,21 +16548,6 @@"react": "^16.8.0 || ^17.0.0"}},- "node_modules/react-transition-group": {- "version": "2.4.0",- "resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-2.4.0.tgz",- "integrity": "sha512-Xv5d55NkJUxUzLCImGSanK8Cl/30sgpOEMGc5m86t8+kZwrPxPCPcFqyx83kkr+5Lz5gs6djuvE5By+gce+VjA==",- "dependencies": {- "dom-helpers": "^3.3.1",- "loose-envify": "^1.3.1",- "prop-types": "^15.6.2",- "react-lifecycles-compat": "^3.0.4"- },- "peerDependencies": {- "react": ">=15.0.0",- "react-dom": ">=15.0.0"- }- },"node_modules/react-uid": {"version": "2.3.1","resolved": "https://registry.npmjs.org/react-uid/-/react-uid-2.3.1.tgz",@@ -20671,21 +20623,6 @@}}},- "@atlaskit/flag": {- "version": "14.1.0",- "resolved": "https://registry.npmjs.org/@atlaskit/flag/-/flag-14.1.0.tgz",- "integrity": "sha512-xpjVmXpwpknlD0gVU+tkfG35x2i8pkq2tGMkRO50EstbF+hENPgv24oIaGOQHSOANM98hnRG3aO45rTbc4QcvA==",- "requires": {- "@atlaskit/analytics-next": "^8.0.0",- "@atlaskit/button": "^15.1.0",- "@atlaskit/icon": "^21.0.0",- "@atlaskit/motion": "^0.4.0",- "@atlaskit/portal": "^4.0.0",- "@atlaskit/theme": "^11.0.0",- "@babel/runtime": "^7.0.0",- "@emotion/core": "^10.0.9"- }- },"@atlaskit/icon": {"version": "21.2.0","resolved": "https://registry.npmjs.org/@atlaskit/icon/-/icon-21.2.0.tgz",@@ -27353,14 +27290,6 @@"esutils": "^2.0.2"}},- "dom-helpers": {- "version": "3.4.0",- "resolved": "https://registry.npmjs.org/dom-helpers/-/dom-helpers-3.4.0.tgz",- "integrity": "sha512-LnuPJ+dwqKDIyotW1VzmOZ5TONUN7CwkCR5hrgawTUbkBGYdeoNLZo6nNfGkCrjtE1nXXaj7iMMpDa8/d9WoIA==",- "requires": {- "@babel/runtime": "^7.1.2"- }- },"dom-serializer": {"version": "1.4.1","resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.4.1.tgz",@@ -32316,11 +32245,6 @@"resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz","integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w=="},- "react-lifecycles-compat": {- "version": "3.0.4",- "resolved": "https://registry.npmjs.org/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz",- "integrity": "sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA=="- },"react-linkify": {"version": "1.0.0-alpha","resolved": "https://registry.npmjs.org/react-linkify/-/react-linkify-1.0.0-alpha.tgz",@@ -32703,17 +32627,6 @@"use-latest": "^1.0.0"}},- "react-transition-group": {- "version": "2.4.0",- "resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-2.4.0.tgz",- "integrity": "sha512-Xv5d55NkJUxUzLCImGSanK8Cl/30sgpOEMGc5m86t8+kZwrPxPCPcFqyx83kkr+5Lz5gs6djuvE5By+gce+VjA==",- "requires": {- "dom-helpers": "^3.3.1",- "loose-envify": "^1.3.1",- "prop-types": "^15.6.2",- "react-lifecycles-compat": "^3.0.4"- }- },"react-uid": {"version": "2.3.1","resolved": "https://registry.npmjs.org/react-uid/-/react-uid-2.3.1.tgz",diff --git a/package.json b/package.jsonindex c33ba5e471..1bab1ca13f 100644--- a/package.json+++ b/package.json@@ -16,7 +16,6 @@"readmeFilename": "README.md","dependencies": {"@amplitude/react-native": "2.7.0",- "@atlaskit/flag": "14.1.0","@atlaskit/inline-dialog": "13.0.9","@atlaskit/inline-message": "11.0.8","@atlaskit/multi-select": "15.0.5",@@ -119,7 +118,6 @@"react-native-youtube-iframe": "2.2.1","react-redux": "7.1.0","react-textarea-autosize": "8.3.0",- "react-transition-group": "2.4.0","react-window": "1.8.6","react-youtube": "10.1.0","redux": "4.0.4",diff --git a/react/features/base/icons/components/Icon.tsx b/react/features/base/icons/components/Icon.tsxindex f714883a60..0831c21b82 100644--- a/react/features/base/icons/components/Icon.tsx+++ b/react/features/base/icons/components/Icon.tsx@@ -100,6 +100,11 @@ interface IProps {* TabIndex for the Icon.*/tabIndex?: number;++ /**+ * Test id for the icon.+ */+ testId?: string;}export const DEFAULT_COLOR = navigator.product === 'ReactNative' ? 'white' : undefined;@@ -132,6 +137,7 @@ export default function Icon(props: IProps) {role,onKeyPress,onKeyDown,+ testId,...rest}: IProps = props;@@ -167,6 +173,7 @@ export default function Icon(props: IProps) {aria-label = { ariaLabel }aria-pressed = { ariaPressed }className = { `${jitsiIconClassName} ${className || ''}` }+ data-testid = { testId }id = { containerId }onClick = { onClick }onKeyDown = { onKeyDown }diff --git a/react/features/conference/functions.any.ts b/react/features/conference/functions.any.tsindex 5d8c58ffe9..5e4db2d206 100644--- a/react/features/conference/functions.any.ts+++ b/react/features/conference/functions.any.ts@@ -1,6 +1,5 @@import { IStateful } from '../base/app/types';import { toState } from '../base/redux/functions';-import { areThereNotifications } from '../notifications/functions';/**@@ -14,5 +13,5 @@ export function shouldDisplayNotifications(stateful: IStateful) {const state = toState(stateful);const { calleeInfoVisible } = state['features/invite'];- return areThereNotifications(state) && !calleeInfoVisible;+ return !calleeInfoVisible;}diff --git a/react/features/notifications/components/AbstractNotification.tsx b/react/features/notifications/components/AbstractNotification.tsxdeleted file mode 100644index 55ca69c942..0000000000--- a/react/features/notifications/components/AbstractNotification.tsx+++ /dev/null@@ -1,172 +0,0 @@-import { Component } from 'react';-import { WithTranslation } from 'react-i18next';--import { NOTIFICATION_TYPE } from '../constants';--export interface IProps extends WithTranslation {-- /**- * Display appearance for the component, passed directly to the- * notification.- */- appearance: string;-- /**- * Whether or not the title and description should be concatenated.- */- concatText?: boolean;-- /**- * Callback invoked when the custom button is clicked.- */- customActionHandler: Function[];-- /**- * The text to display as button in the notification for the custom action.- */- customActionNameKey: string[];-- /**- * The type of button.- */- customActionType?: string[];-- /**- * The text to display in the body of the notification. If not passed- * in, the passed in descriptionKey will be used.- */- defaultTitleKey: string;-- /**- * A description string that can be used in addition to the prop- * descriptionKey.- */- description: string;-- /**- * The translation arguments that may be necessary for the description.- */- descriptionArguments: Object;-- /**- * The translation key to use as the body of the notification.- */- descriptionKey: string;-- /**- * Whether the support link should be hidden in the case of an error- * message.- */- hideErrorSupportLink: boolean;-- /**- * The type of icon to be displayed. If not passed in, the appearance- * type will be used.- */- icon?: string;-- /**- * Maximum lines of the description.- */- maxLines?: number;-- /**- * Callback invoked when the user clicks to dismiss the notification.- */- onDismissed: Function;-- /**- * The text to display at the top of the notification. If not passed in,- * the passed in titleKey will be used.- */- title: string;-- /**- * The translation arguments that may be necessary for the title.- */- titleArguments: Object;-- /**- * The translation key to display as the title of the notification if- * no title is provided.- */- titleKey: string;-- /**- * The unique identifier for the notification.- */- uid: string;-}--/**- * Abstract class for {@code Notification} component.- *- * @augments Component- */-export default class AbstractNotification<P extends IProps> extends Component<P> {- /**- * Default values for {@code Notification} component's properties.- *- * @static- */- static defaultProps = {- appearance: NOTIFICATION_TYPE.NORMAL- };-- /**- * Initializes a new {@code Notification} instance.- *- * @param {Object} props - The read-only properties with which the new- * instance is to be initialized.- */- constructor(props: P) {- super(props);-- // Bind event handler so it is only bound once for every instance.- this._onDismissed = this._onDismissed.bind(this);- }-- /**- * Returns the description array to be displayed.- *- * @protected- * @returns {Array<string>}- */- _getDescription() {- const {- description,- descriptionArguments,- descriptionKey,- t- } = this.props;-- const descriptionArray = [];-- descriptionKey- && descriptionArray.push(t(descriptionKey, descriptionArguments));-- description && descriptionArray.push(description);-- return descriptionArray;- }-- /**- * Returns the description key that was used if any.- *- * @protected- * @returns {string}- */- _getDescriptionKey() {- return this.props.descriptionKey;- }-- /**- * Callback to dismiss the notification.- *- * @private- * @returns {void}- */- _onDismissed() {- this.props.onDismissed(this.props.uid);- }-}diff --git a/react/features/notifications/components/NotificationsTransition.tsx b/react/features/notifications/components/NotificationsTransition.tsxnew file mode 100644index 0000000000..98a3a0a312--- /dev/null+++ b/react/features/notifications/components/NotificationsTransition.tsx@@ -0,0 +1,57 @@+import React, { ReactElement, useEffect, useState } from 'react';++export const NotificationsTransitionContext = React.createContext({+ unmounting: new Map<string, TimeoutType | null>()+});++type TimeoutType = ReturnType<typeof setTimeout>;++const NotificationsTransition = ({ children }: { children: ReactElement[]; }) => {+ const [ childrenToRender, setChildrenToRender ] = useState(children);+ const [ timeoutIds, setTimeoutIds ] = useState(new Map<string, TimeoutType | null>());++ useEffect(() => {+ const toUnmount = childrenToRender.filter(child =>+ children.findIndex(c => c.props.uid === child.props.uid) === -1) ?? [];+ const toMount = children?.filter(child =>+ childrenToRender.findIndex(c => c.props.uid === child.props.uid) === -1) ?? [];++ if (toUnmount.length > 0) {+ const ids = new Map(timeoutIds);++ toUnmount.forEach(child => {+ const timeoutId = setTimeout(() => {+ timeoutIds.set(child.props.uid, null);+ setTimeoutIds(timeoutIds);+ }, 250);++ ids.set(child.props.uid, timeoutId);+ });+ setTimeoutIds(ids);+ }++ setChildrenToRender(toMount.concat(childrenToRender));+ }, [ children ]);++ useEffect(() => {+ const toRemove: string[] = [];++ timeoutIds.forEach((value, key) => {+ if (value === null) {+ toRemove.push(key);+ timeoutIds.delete(key);+ }+ });++ toRemove.length > 0 && setChildrenToRender(childrenToRender.filter(child =>+ toRemove.findIndex(id => child.props.uid === id) === -1));+ }, [ timeoutIds ]);++ return (+ <NotificationsTransitionContext.Provider value = {{ unmounting: timeoutIds }}>+ {childrenToRender}+ </NotificationsTransitionContext.Provider>+ );+};++export default NotificationsTransition;diff --git a/react/features/notifications/components/native/Notification.tsx b/react/features/notifications/components/native/Notification.tsxindex ddd703b217..178e2d2515 100644--- a/react/features/notifications/components/native/Notification.tsx+++ b/react/features/notifications/components/native/Notification.tsx@@ -1,29 +1,23 @@-/* eslint-disable lines-around-comment */--import React from 'react';-import { WithTranslation } from 'react-i18next';+import React, { useCallback, useContext, useEffect, useRef } from 'react';+import { useTranslation } from 'react-i18next';import { Animated, Text, View } from 'react-native';-import { translate } from '../../../base/i18n/functions';+import Icon from '../../../base/icons/components/Icon';import {- Icon,IconCloseLarge,IconInfoCircle,IconUsers,IconWarning- // @ts-ignore-} from '../../../base/icons';+} from '../../../base/icons/svg';import { colors } from '../../../base/ui/Tokens';import BaseTheme from '../../../base/ui/components/BaseTheme.native';import Button from '../../../base/ui/components/native/Button';import IconButton from '../../../base/ui/components/native/IconButton';import { BUTTON_MODES, BUTTON_TYPES } from '../../../base/ui/constants.native';import { replaceNonUnicodeEmojis } from '../../../chat/functions';-import { NOTIFICATION_ICON } from '../../constants';-import AbstractNotification, {- type IProps as AbstractNotificationProps- // @ts-ignore-} from '../AbstractNotification';+import { NOTIFICATION_ICON, NOTIFICATION_TYPE } from '../../constants';+import { INotificationProps } from '../../types';+import { NotificationsTransitionContext } from '../NotificationsTransition';// @ts-ignoreimport styles from './styles';@@ -43,64 +37,59 @@ const ICON_COLOR = {};-export type Props = AbstractNotificationProps & WithTranslation & {+export interface IProps extends INotificationProps {_participants: ArrayLike<any>;-};---/**- * Implements a React {@link Component} to display a notification.- *- * @augments Component- */-class Notification extends AbstractNotification<Props> {-- /**- * Initializes a new {@code Notification} instance.- *- * @inheritdoc- */- constructor(props: Props) {- super(props);-- // @ts-ignore- this.state = {- notificationContainerAnimation: new Animated.Value(0)- };- }+ onDismissed: Function;+}- /**- * Implements React's {@link Component#componentDidMount()}.- *- * @inheritdoc- */- componentDidMount() {+const Notification = ({+ appearance = NOTIFICATION_TYPE.NORMAL,+ customActionHandler,+ customActionNameKey,+ customActionType,+ description,+ descriptionArguments,+ descriptionKey,+ icon,+ onDismissed,+ title,+ titleArguments,+ titleKey,+ uid+}: IProps) => {+ const { t } = useTranslation();+ const notificationOpacityAnimation = useRef(new Animated.Value(0)).current;+ const { unmounting } = useContext(NotificationsTransitionContext);++ useEffect(() => {Animated.timing(- // @ts-ignore- this.state.notificationContainerAnimation,+ notificationOpacityAnimation,{toValue: 1,- duration: 500,+ duration: 200,useNativeDriver: true}).start();- }+ }, []);++ useEffect(() => {+ if (unmounting.get(uid ?? '')) {+ Animated.timing(+ notificationOpacityAnimation,+ {+ toValue: 0,+ duration: 200,+ useNativeDriver: true+ })+ .start();+ }+ }, [ unmounting ]);- /**- * Creates action button configurations for the notification based on- * notification appearance.- *- * @private- * @returns {Object[]}- */- _mapAppearanceToButtons() {- const {- customActionHandler,- customActionNameKey,- customActionType- // @ts-ignore- } = this.props;+ const onDismiss = useCallback(() => {+ onDismissed(uid);+ }, [ onDismissed, uid ]);+ const mapAppearanceToButtons = () => {if (customActionNameKey?.length && customActionHandler?.length && customActionType?.length) {return customActionNameKey?.map((customAction: string, index: number) => (<Button@@ -111,30 +100,20 @@ class Notification extends AbstractNotification<Props> {// eslint-disable-next-line react/jsx-no-bindonClick = { () => {if (customActionHandler[index]()) {- this._onDismissed();+ onDismiss();}} }style = { styles.btn }+// @ts-ignoretype = { customActionType[index] } />));}return [];- }-- /**- * Returns the Icon type component to be used, based on icon or appearance.- *- * @returns {ReactElement}- */- _getIcon() {- const {- appearance,- icon- // @ts-ignore- } = this.props;+ };+ const getIcon = () => {let src;switch (icon || appearance) {@@ -153,103 +132,36 @@ class Notification extends AbstractNotification<Props> {}return src;- }+ };- /**- * Creates an icon component depending on the configured notification- * appearance.- *- * @private- * @returns {ReactElement}- */- _mapAppearanceToIcon() {- // @ts-ignore- const { appearance } = this.props;- // @ts-ignore- const color = ICON_COLOR[appearance];+ const _getDescription = () => {+ const descriptionArray = [];- return (- <View style = { styles.iconContainer }>- <Icon- color = { color }- size = { 24 }- src = { this._getIcon() } />- </View>- );- }+ descriptionKey+ && descriptionArray.push(t(descriptionKey, descriptionArguments));- /**- * Implements React's {@link Component#render()}.- *- * @inheritdoc- * @returns {ReactElement}- */- render() {- // @ts-ignore- const { icon } = this.props;- const contentColumnStyles = icon === NOTIFICATION_ICON.PARTICIPANTS- ? styles.contentColumn : styles.interactiveContentColumn;- const description = this._getDescription();+ description && descriptionArray.push(description);- const notificationStyles = description?.length- ? styles.notificationWithDescription- : styles.notification;+ return descriptionArray;+ };- return (- <Animated.View- pointerEvents = 'box-none'- style = { [- notificationStyles,- {- // @ts-ignore- opacity: this.state.notificationContainerAnimation- }- ] }>- <View style = { contentColumnStyles }>- { this._mapAppearanceToIcon() }- <View- pointerEvents = 'box-none'- style = { styles.contentContainer }>- { this._renderContent() }- </View>- <View style = { styles.btnContainer }>- { this._mapAppearanceToButtons() }- </View>- </View>- <IconButton- color = { BaseTheme.palette.icon04 }- onPress = { this._onDismissed }- src = { IconCloseLarge }- type = { BUTTON_TYPES.TERTIARY } />- </Animated.View>- );- }-- /**- * Renders the notification's content. If the title or title key is present- * it will be just the title. Otherwise it will fallback to description.- *- * @returns {Array<ReactElement>}- * @private- */- _renderContent() {- // @ts-ignore- const { t, title, titleArguments, titleKey } = this.props;+ // eslint-disable-next-line react/no-multi-comp+ const _renderContent = () => {const titleText = title || (titleKey && t(titleKey, titleArguments));- const description = this._getDescription();+ const descriptionArray = _getDescription();- if (description?.length) {+ if (descriptionArray?.length) {return (<><Text style = { styles.contentTextTitle }>- { titleText }+ {titleText}</Text>{- description.map((line, index) => (+ descriptionArray.map((line, index) => (<Textkey = { index }style = { styles.contentText }>- { replaceNonUnicodeEmojis(line) }+ {replaceNonUnicodeEmojis(line)}</Text>))}@@ -259,16 +171,49 @@ class Notification extends AbstractNotification<Props> {return (<Text style = { styles.contentTextTitle }>- { titleText }+ {titleText}</Text>);- }-- _getDescription: () => Array<string>;-- _onDismissed: () => void;-}+ };++ return (+ <Animated.View+ pointerEvents = 'box-none'+ style = { [+ _getDescription()?.length+ ? styles.notificationWithDescription+ : styles.notification,+ {+ opacity: notificationOpacityAnimation+ }+ ] }>+ <View+ style = { icon === NOTIFICATION_ICON.PARTICIPANTS+ ? styles.contentColumn+ : styles.interactiveContentColumn }>+ <View style = { styles.iconContainer }>+ <Icon+ color = { ICON_COLOR[appearance as keyof typeof ICON_COLOR] }+ size = { 24 }+ src = { getIcon() } />+ </View>+ <View+ pointerEvents = 'box-none'+ style = { styles.contentContainer }>+ {_renderContent()}+ </View>+ <View style = { styles.btnContainer }>+ {mapAppearanceToButtons()}+ </View>+ </View>+ <IconButton+ color = { BaseTheme.palette.icon04 }+ onPress = { onDismiss }+ src = { IconCloseLarge }+ type = { BUTTON_TYPES.TERTIARY } />+ </Animated.View>+ );+};-// @ts-ignore-export default translate(Notification);+export default Notification;diff --git a/react/features/notifications/components/native/NotificationsContainer.js b/react/features/notifications/components/native/NotificationsContainer.jsindex 6282c74fbd..e74f6aa423 100644--- a/react/features/notifications/components/native/NotificationsContainer.js+++ b/react/features/notifications/components/native/NotificationsContainer.js@@ -7,6 +7,7 @@ import { SafeAreaView } from 'react-native-safe-area-context';import { connect } from '../../../base/redux';import { hideNotification } from '../../actions';import { areThereNotifications } from '../../functions';+import NotificationsTransition from '../NotificationsTransition';import Notification from './Notification';@@ -22,14 +23,14 @@ type Props = {/*** Invoked to update the redux store in order to remove notifications.*/- dispatch: Function,+ dispatch: Function,- toolboxVisible: boolean+ toolboxVisible: boolean};/*** Implements a React {@link Component} which displays notifications and handles- * automatic dismissmal after a notification is shown for a defined timeout+ * automatic dismissal after a notification is shown for a defined timeout* period.** @augments {Component}@@ -95,9 +96,9 @@ class NotificationsContainer extends Component<Props> {if (_notifications.length) {const notification = _notifications[0];const previousNotification- = prevProps && prevProps._notifications.length- ? prevProps._notifications[0]- : undefined;+ = prevProps && prevProps._notifications.length+ ? prevProps._notifications[0]+ : undefined;if (notification !== previousNotification) {this._clearNotificationDismissTimeout();@@ -175,19 +176,21 @@ class NotificationsContainer extends Component<Props> {return (<SafeAreaViewedges = { [ bottomEdge && 'bottom', 'left', 'right' ].filter(Boolean) }>- {- _notifications.map((notification, index) => {- const { props, uid } = notification;-- return (- <Notification- { ...props }- key = { index }- onDismissed = { this._onDismissed }- uid = { uid } />- );- })- }+ <NotificationsTransition>+ {+ _notifications.map((notification, index) => {+ const { props, uid } = notification;++ return (+ <Notification+ { ...props }+ key = { index }+ onDismissed = { this._onDismissed }+ uid = { uid } />+ );+ })+ }+ </NotificationsTransition></SafeAreaView>);}diff --git a/react/features/notifications/components/web/Notification.tsx b/react/features/notifications/components/web/Notification.tsxindex a570e79a19..829674ba59 100644--- a/react/features/notifications/components/web/Notification.tsx+++ b/react/features/notifications/components/web/Notification.tsx@@ -1,117 +1,243 @@-import Flag from '@atlaskit/flag';-import React, { isValidElement } from 'react';+import { Theme } from '@mui/material';+import React, { isValidElement, useCallback, useContext } from 'react';+import { useTranslation } from 'react-i18next';+import { keyframes } from 'tss-react';+import { makeStyles } from 'tss-react/mui';-import { translate } from '../../../base/i18n/functions';import Icon from '../../../base/icons/components/Icon';-import { IconCheck, IconInfo, IconMessage, IconUser, IconUsers, IconWarningCircle } from '../../../base/icons/svg';+import {+ IconCheck,+ IconCloseLarge,+ IconInfo,+ IconMessage,+ IconUser,+ IconUsers,+ IconWarningCircle+} from '../../../base/icons/svg';import Message from '../../../base/react/components/web/Message';-import { colors } from '../../../base/ui/Tokens';+import { withPixelLineHeight } from '../../../base/styles/functions.web';import { NOTIFICATION_ICON, NOTIFICATION_TYPE } from '../../constants';-import AbstractNotification, { IProps } from '../AbstractNotification';+import { INotificationProps } from '../../types';+import { NotificationsTransitionContext } from '../NotificationsTransition';++interface IProps extends INotificationProps {++ /**+ * Callback invoked when the user clicks to dismiss the notification.+ */+ onDismissed: Function;+}/*** Secondary colors for notification icons.** @type {{error, info, normal, success, warning}}*/-const ICON_COLOR = {- error: colors.error06,- normal: colors.primary06,- success: colors.success05,- warning: colors.warning05-};-/**- * Implements a React {@link Component} to display a notification.- *- * @augments Component- */-class Notification extends AbstractNotification<IProps> {- /**- * Implements React's {@link Component#render()}.- *- * @inheritdoc- * @returns {ReactElement}- */- render() {- const {- hideErrorSupportLink,- t,- title,- titleArguments,- titleKey,- uid- } = this.props;- return (- <Flag- actions = { this._mapAppearanceToButtons(hideErrorSupportLink) }- description = { this._renderDescription() }- icon = { this._mapAppearanceToIcon() }- id = { uid }- testId = { titleKey || this._getDescriptionKey() }- title = { title || t(titleKey, titleArguments) } />- );- }+const useStyles = makeStyles()((theme: Theme) => {+ return {+ container: {+ backgroundColor: theme.palette.ui10,+ padding: '8px 16px 8px 20px',+ display: 'flex',+ position: 'relative' as const,+ borderRadius: `${theme.shape.borderRadius}px`,+ boxShadow: '0px 6px 20px rgba(0, 0, 0, 0.25)',+ marginBottom: theme.spacing(2),- /**- * Creates a {@code ReactElement} for displaying the contents of the- * notification.- *- * @private- * @returns {ReactElement}- */- _renderDescription() {- const description = this._getDescription();+ '&:last-of-type': {+ marginBottom: 0+ },++ animation: `${keyframes`+ 0% {+ opacity: 0;+ transform: translateX(-80%);+ }+ 100% {+ opacity: 1;+ transform: translateX(0);+ }+ `} 0.2s forwards ease`,++ '&.unmount': {+ animation: `${keyframes`+ 0% {+ opacity: 1;+ transform: translateX(0);+ }+ 100% {+ opacity: 0;+ transform: translateX(-80%);+ }+ `} 0.2s forwards ease`+ }+ },++ ribbon: {+ width: '4px',+ height: 'calc(100% - 16px)',+ position: 'absolute' as const,+ left: 0,+ top: '8px',+ borderRadius: '4px',++ '&.normal': {+ backgroundColor: theme.palette.action01+ },++ '&.error': {+ backgroundColor: theme.palette.iconError+ },++ '&.success': {+ backgroundColor: theme.palette.success01+ },++ '&.warning': {+ backgroundColor: theme.palette.warning01+ }+ },++ content: {+ display: 'flex',+ alignItems: 'flex-start',+ padding: '8px 0',+ flex: 1+ },++ textContainer: {+ display: 'flex',+ flexDirection: 'column' as const,+ justifyContent: 'space-between',+ color: theme.palette.text04,+ flex: 1,+ margin: '0 8px'+ },++ title: {+ ...withPixelLineHeight(theme.typography.bodyShortBold)+ },++ description: {+ ...withPixelLineHeight(theme.typography.bodyShortRegular),++ '&:not(:empty)': {+ marginTop: theme.spacing(1)+ }+ },++ actionsContainer: {+ display: 'flex',+ width: '100%',++ '&:not(:empty)': {+ marginTop: theme.spacing(2)+ }+ },++ action: {+ border: 0,+ outline: 0,+ backgroundColor: 'transparent',+ color: theme.palette.action01,+ ...withPixelLineHeight(theme.typography.bodyShortBold),+ marginRight: theme.spacing(3),+ padding: 0,+ cursor: 'pointer',++ '&:last-of-type': {+ marginRight: 0+ },++ '&.destructive': {+ color: theme.palette.textError+ }+ },++ closeIcon: {+ cursor: 'pointer'+ }+ };+});++const Notification = ({+ appearance = NOTIFICATION_TYPE.NORMAL,+ customActionHandler,+ customActionNameKey,+ customActionType,+ description,+ descriptionArguments,+ descriptionKey,+ hideErrorSupportLink,+ icon,+ onDismissed,+ title,+ titleArguments,+ titleKey,+ uid+}: IProps) => {+ const { classes, cx, theme } = useStyles();+ const { t } = useTranslation();+ const { unmounting } = useContext(NotificationsTransitionContext);++ const ICON_COLOR = {+ error: theme.palette.iconError,+ normal: theme.palette.action01,+ success: theme.palette.success01,+ warning: theme.palette.warning01+ };++ const onDismiss = useCallback(() => {+ onDismissed(uid);+ }, [ uid ]);++ // eslint-disable-next-line react/no-multi-comp+ const renderDescription = useCallback(() => {+ const descriptionArray = [];++ descriptionKey+ && descriptionArray.push(t(descriptionKey, descriptionArguments));++ description && descriptionArray.push(description);// Keeping in mind that:// - Notifications that use the `translateToHtml` function get an element-based description array with one entry// - Message notifications receive string-based description arrays that might need additional parsing// We look for ready-to-render elements, and if present, we roll with them// Otherwise, we use the Message component that accepts a string `text` prop- const shouldRenderHtml = description.length === 1 && isValidElement(description[0]);+ const shouldRenderHtml = descriptionArray.length === 1 && isValidElement(descriptionArray[0]);// the id is used for testing the UIreturn (- <p data-testid = { this._getDescriptionKey() } >- { shouldRenderHtml ? description : <Message text = { description.join(' ') } /> }+ <p+ className = { classes.description }+ data-testid = { descriptionKey } >+ {shouldRenderHtml ? descriptionArray : <Message text = { descriptionArray.join(' ') } />}</p>);- }+ }, [ description, descriptionArguments, descriptionKey, classes ]);- /**- * Opens the support page.- *- * @returns {void}- * @private- */- _onOpenSupportLink() {+ const _onOpenSupportLink = () => {window.open(interfaceConfig.SUPPORT_URL, '_blank', 'noopener');- }+ };- /**- * Creates action button configurations for the notification based on- * notification appearance.- *- * @param {boolean} hideErrorSupportLink - Indicates if the support link- * should be hidden in the error messages.- * @private- * @returns {Object[]}- */- _mapAppearanceToButtons(hideErrorSupportLink: boolean) {- switch (this.props.appearance) {+ const mapAppearanceToButtons = useCallback((): {+ content: string; onClick: () => void; testId?: string; type?: string; }[] => {+ switch (appearance) {case NOTIFICATION_TYPE.ERROR: {const buttons = [{- content: this.props.t('dialog.dismiss'),- onClick: this._onDismissed+ content: t('dialog.dismiss'),+ onClick: onDismiss}];if (!hideErrorSupportLink && interfaceConfig.SUPPORT_URL) {buttons.push({- content: this.props.t('dialog.contactSupport'),- onClick: this._onOpenSupportLink+ content: t('dialog.contactSupport'),+ onClick: _onOpenSupportLink});}@@ -120,21 +246,22 @@ class Notification extends AbstractNotification<IProps> {case NOTIFICATION_TYPE.WARNING:return [{- content: this.props.t('dialog.Ok'),- onClick: this._onDismissed+ content: t('dialog.Ok'),+ onClick: onDismiss}];default:- if (this.props.customActionNameKey?.length && this.props.customActionHandler?.length) {- return this.props.customActionNameKey.map((customAction: string, customActionIndex: number) => {+ if (customActionNameKey?.length && customActionHandler?.length) {+ return customActionNameKey.map((customAction: string, customActionIndex: number) => {return {- content: this.props.t(customAction),+ content: t(customAction),onClick: () => {- if (this.props.customActionHandler[customActionIndex]()) {- this._onDismissed();+ if (customActionHandler?.[customActionIndex]()) {+ onDismiss();}},+ type: customActionType?.[customActionIndex],testId: customAction};});@@ -142,61 +269,75 @@ class Notification extends AbstractNotification<IProps> {return [];}- }+ }, [ appearance, onDismiss, customActionHandler, customActionNameKey, hideErrorSupportLink ]);- /**- * Returns the Icon type component to be used, based on icon or appearance.- *- * @returns {ReactElement}- */- _getIcon() {- let icon;+ const getIcon = useCallback(() => {+ let iconToDisplay;- switch (this.props.icon || this.props.appearance) {+ switch (icon || appearance) {case NOTIFICATION_ICON.ERROR:case NOTIFICATION_ICON.WARNING:- icon = IconWarningCircle;+ iconToDisplay = IconWarningCircle;break;case NOTIFICATION_ICON.SUCCESS:- icon = IconCheck;+ iconToDisplay = IconCheck;break;case NOTIFICATION_ICON.MESSAGE:- icon = IconMessage;+ iconToDisplay = IconMessage;break;case NOTIFICATION_ICON.PARTICIPANT:- icon = IconUser;+ iconToDisplay = IconUser;break;case NOTIFICATION_ICON.PARTICIPANTS:- icon = IconUsers;+ iconToDisplay = IconUsers;break;default:- icon = IconInfo;+ iconToDisplay = IconInfo;break;}- return icon;- }+ return iconToDisplay;+ }, [ icon, appearance ]);- /**- * Creates an icon component depending on the configured notification- * appearance.- *- * @private- * @returns {ReactElement}- */- _mapAppearanceToIcon() {- const { appearance, icon } = this.props;- const iconColor = ICON_COLOR[appearance as keyof typeof ICON_COLOR];- const iconSrc = this._getIcon();-- return (<div className = { icon }>- <div className = { `ribbon ${appearance}` } />- <Icon- color = { iconColor }- size = { 20 }- src = { iconSrc } />- </div>);- }-}+ return (+ <div+ className = { cx(classes.container, unmounting.get(uid ?? '') && 'unmount') }+ data-testid = { titleKey || descriptionKey }+ id = { uid }>+ <div className = { cx(classes.ribbon, appearance) } />+ <div className = { classes.content }>+ <div className = { icon }>+ <Icon+ color = { ICON_COLOR[appearance as keyof typeof ICON_COLOR] }+ size = { 20 }+ src = { getIcon() } />+ </div>+ <div className = { classes.textContainer }>+ <span className = { classes.title }>{title || t(titleKey ?? '', titleArguments)}</span>+ {renderDescription()}+ <div className = { classes.actionsContainer }>+ {mapAppearanceToButtons().map(({ content, onClick, type, testId }) => (+ <button+ className = { cx(classes.action, type) }+ data-testid = { testId }+ key = { content }+ onClick = { onClick }>+ {content}+ </button>+ ))}+ </div>+ </div>+ <Icon+ className = { classes.closeIcon }+ color = { theme.palette.icon04 }+ id = 'close-notification'+ onClick = { onDismiss }+ size = { 20 }+ src = { IconCloseLarge }+ testId = { `${titleKey || descriptionKey}-dismiss` } />+ </div>+ </div>+ );+};-export default translate(Notification);+export default Notification;diff --git a/react/features/notifications/components/web/NotificationsContainer.tsx b/react/features/notifications/components/web/NotificationsContainer.tsxindex 181b3348e5..319c32fcfe 100644--- a/react/features/notifications/components/web/NotificationsContainer.tsx+++ b/react/features/notifications/components/web/NotificationsContainer.tsx@@ -1,20 +1,16 @@-import { FlagGroupContext } from '@atlaskit/flag/flag-group';-import { AtlasKitThemeProvider } from '@atlaskit/theme';-import { Theme } from '@mui/material/styles';import { withStyles } from '@mui/styles';import clsx from 'clsx';import React, { Component } from 'react';import { WithTranslation } from 'react-i18next';-import { CSSTransition, TransitionGroup } from 'react-transition-group';import { IReduxState } from '../../../app/types';-import { translate } from '../../../base/i18n/functions';import { connect } from '../../../base/redux/functions';import { hideNotification } from '../../actions';import { areThereNotifications } from '../../functions';+import { INotificationProps } from '../../types';+import NotificationsTransition from '../NotificationsTransition';import Notification from './Notification';-interface IProps extends WithTranslation {/**@@ -32,7 +28,7 @@ interface IProps extends WithTranslation {* notification at the top and the rest shown below it in order.*/_notifications: Array<{- props: Object;+ props: INotificationProps;uid: string;}>;@@ -52,64 +48,20 @@ interface IProps extends WithTranslation {portal?: boolean;}-const useStyles = (theme: Theme) => {+const useStyles = () => {return {container: {position: 'absolute' as const,left: '16px',- bottom: '90px',- width: '400px',+ bottom: '84px',+ width: '320px',maxWidth: '100%',zIndex: 600},containerPortal: {+ width: '100%',maxWidth: 'calc(100% - 32px)'- },-- transitionGroup: {- '& > *': {- marginBottom: '20px',- borderRadius: '6px!important', // !important used to overwrite atlaskit style- position: 'relative'- },-- '& div > span > svg > path': {- fill: 'inherit'- },-- '& div > span, & div > p': {- color: theme.palette.field01- },-- '& div.message > span': {- color: theme.palette.link01Active- },-- '& .ribbon': {- width: '4px',- height: 'calc(100% - 16px)',- position: 'absolute',- left: 0,- top: '8px',- borderRadius: '4px',-- '&.normal': {- backgroundColor: theme.palette.link01Active- },-- '&.error': {- backgroundColor: theme.palette.iconError- },-- '&.success': {- backgroundColor: theme.palette.success01- },-- '&.warning': {- backgroundColor: theme.palette.warning01- }- }}};};@@ -122,7 +74,6 @@ const useStyles = (theme: Theme) => {* @augments {Component}*/class NotificationsContainer extends Component<IProps> {- _api: Object;/*** Initializes a new {@code NotificationsContainer} instance.@@ -134,14 +85,6 @@ class NotificationsContainer extends Component<IProps> {// Bind event handlers so they are only bound once for every instance.this._onDismissed = this._onDismissed.bind(this);-- // HACK ALERT! We are rendering AtlasKit Flag elements outside of a FlagGroup container.- // In order to hook-up the dismiss action we'll a fake context provider,- // just like FlagGroup does.- this._api = {- onDismissed: this._onDismissed,- dismissAllowed: () => true- };}/**@@ -151,25 +94,28 @@ class NotificationsContainer extends Component<IProps> {* @returns {ReactElement}*/render() {+ const { _notifications } = this.props;+if (this.props._iAmSipGateway) {return null;}return (- <AtlasKitThemeProvider mode = 'light'>- {/* @ts-ignore */}- <FlagGroupContext.Provider value = { this._api }>- <div- className = { clsx(this.props.classes.container, {- [this.props.classes.containerPortal]: this.props.portal- }) }- id = 'notifications-container'>- <TransitionGroup className = { this.props.classes.transitionGroup }>- {this._renderFlags()}- </TransitionGroup>- </div>- </FlagGroupContext.Provider>- </AtlasKitThemeProvider>+ <div+ className = { clsx(this.props.classes.container, {+ [this.props.classes.containerPortal]: this.props.portal+ }) }+ id = 'notifications-container'>+ <NotificationsTransition>+ {_notifications.map(({ props, uid }) => (+ <Notification+ { ...props }+ key = { uid }+ onDismissed = { this._onDismissed }+ uid = { uid } />+ )) || null }+ </NotificationsTransition>+ </div>);}@@ -184,39 +130,6 @@ class NotificationsContainer extends Component<IProps> {_onDismissed(uid: string) {this.props.dispatch(hideNotification(uid));}-- /**- * Renders notifications to display as ReactElements. An empty array will- * be returned if notifications are disabled.- *- * @private- * @returns {ReactElement[]}- */- _renderFlags() {- const { _notifications } = this.props;-- return _notifications.map(notification => {- const { props, uid } = notification;-- // The id attribute is necessary as {@code FlagGroup} looks for- // either id or key to set a key on notifications, but accessing- // props.key will cause React to print an error.- return (- <CSSTransition- appear = { true }- classNames = 'notification'- in = { true }- key = { uid }- timeout = { 200 }>- {/* @ts-ignore */}- <Notification- { ...props }- onDismissed = { this._onDismissed }- uid = { uid } />- </CSSTransition>- );- });- }}/**@@ -239,4 +152,4 @@ function _mapStateToProps(state: IReduxState) {};}-export default translate(connect(_mapStateToProps)(withStyles(useStyles)(NotificationsContainer)));+export default connect(_mapStateToProps)(withStyles(useStyles)(NotificationsContainer));