2018-10-30 05:02:23 +00:00
|
|
|
/* @flow */
|
|
|
|
|
2017-03-07 03:34:51 +00:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
|
2021-07-13 06:50:08 +00:00
|
|
|
import { type ReactionEmojiProps } from '../../../reactions/constants';
|
|
|
|
|
2017-03-07 03:34:51 +00:00
|
|
|
/**
|
2018-10-30 05:02:23 +00:00
|
|
|
* The type of the React {@code Component} props of {@link DialogContainer}.
|
2017-03-07 03:34:51 +00:00
|
|
|
*/
|
2018-10-30 05:02:23 +00:00
|
|
|
type Props = {
|
|
|
|
|
2017-03-07 03:34:51 +00:00
|
|
|
/**
|
2018-10-30 05:02:23 +00:00
|
|
|
* The component to render.
|
2017-03-07 03:34:51 +00:00
|
|
|
*/
|
2018-10-30 05:02:23 +00:00
|
|
|
_component: Function,
|
2017-03-07 03:34:51 +00:00
|
|
|
|
2018-10-30 05:02:23 +00:00
|
|
|
/**
|
|
|
|
* The props to pass to the component that will be rendered.
|
|
|
|
*/
|
|
|
|
_componentProps: Object,
|
2018-09-03 13:53:24 +00:00
|
|
|
|
2018-10-30 05:02:23 +00:00
|
|
|
/**
|
|
|
|
* True if the UI is in a compact state where we don't show dialogs.
|
|
|
|
*/
|
2021-07-13 06:50:08 +00:00
|
|
|
_reducedUI: boolean,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Array of reactions to be displayed.
|
|
|
|
*/
|
|
|
|
_reactionsQueue: Array<ReactionEmojiProps>
|
2018-10-30 05:02:23 +00:00
|
|
|
};
|
2017-03-07 03:34:51 +00:00
|
|
|
|
2018-10-30 05:02:23 +00:00
|
|
|
/**
|
2018-12-21 04:01:27 +00:00
|
|
|
* Implements a DialogContainer responsible for showing all dialogs.
|
2018-10-30 05:02:23 +00:00
|
|
|
*/
|
2018-12-21 04:01:27 +00:00
|
|
|
export default class AbstractDialogContainer extends Component<Props> {
|
2017-03-07 03:34:51 +00:00
|
|
|
/**
|
2018-12-21 04:01:27 +00:00
|
|
|
* Returns the dialog to be displayed.
|
2017-03-07 03:34:51 +00:00
|
|
|
*
|
2018-12-21 04:01:27 +00:00
|
|
|
* @private
|
|
|
|
* @returns {ReactElement|null}
|
2017-03-07 03:34:51 +00:00
|
|
|
*/
|
2018-12-21 04:01:27 +00:00
|
|
|
_renderDialogContent() {
|
2018-09-03 13:53:24 +00:00
|
|
|
const {
|
|
|
|
_component: component,
|
|
|
|
_reducedUI: reducedUI
|
|
|
|
} = this.props;
|
2017-03-07 03:34:51 +00:00
|
|
|
|
2017-09-18 15:58:03 +00:00
|
|
|
return (
|
2018-09-03 13:53:24 +00:00
|
|
|
component && !reducedUI
|
2017-09-18 15:58:03 +00:00
|
|
|
? React.createElement(component, this.props._componentProps)
|
|
|
|
: null);
|
2017-03-07 03:34:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-12-21 04:01:27 +00:00
|
|
|
* Maps (parts of) the redux state to the associated
|
|
|
|
* {@code AbstractDialogContainer}'s props.
|
2017-03-07 03:34:51 +00:00
|
|
|
*
|
2017-09-18 15:58:03 +00:00
|
|
|
* @param {Object} state - The redux state.
|
2017-03-07 03:34:51 +00:00
|
|
|
* @private
|
2020-05-20 08:25:31 +00:00
|
|
|
* @returns {Props}
|
2017-03-07 03:34:51 +00:00
|
|
|
*/
|
2020-05-20 08:25:31 +00:00
|
|
|
export function abstractMapStateToProps(state: Object): $Shape<Props> {
|
2017-09-18 15:58:03 +00:00
|
|
|
const stateFeaturesBaseDialog = state['features/base/dialog'];
|
2018-09-03 13:53:24 +00:00
|
|
|
const { reducedUI } = state['features/base/responsive-ui'];
|
2017-09-18 15:58:03 +00:00
|
|
|
|
2017-03-07 03:34:51 +00:00
|
|
|
return {
|
2017-09-18 15:58:03 +00:00
|
|
|
_component: stateFeaturesBaseDialog.component,
|
2018-09-03 13:53:24 +00:00
|
|
|
_componentProps: stateFeaturesBaseDialog.componentProps,
|
|
|
|
_reducedUI: reducedUI
|
2017-03-07 03:34:51 +00:00
|
|
|
};
|
|
|
|
}
|