jiti-meet/react/features/base/dialog/components/AbstractDialogContainer.ts

73 lines
1.8 KiB
TypeScript
Raw Normal View History

import React, { Component, ComponentType } from 'react';
import { IReduxState } from '../../../app/types';
import { IReactionEmojiProps } from '../../../reactions/constants';
2017-03-07 03:34:51 +00:00
/**
* The type of the React {@code Component} props of {@link DialogContainer}.
2017-03-07 03:34:51 +00:00
*/
interface IProps {
2017-03-07 03:34:51 +00:00
/**
* The component to render.
2017-03-07 03:34:51 +00:00
*/
_component: ComponentType;
2017-03-07 03:34:51 +00:00
/**
* The props to pass to the component that will be rendered.
*/
_componentProps: Object;
/**
* Array of reactions to be displayed.
*/
_reactionsQueue: Array<IReactionEmojiProps>;
/**
* True if the UI is in a compact state where we don't show dialogs.
*/
_reducedUI: boolean;
}
2017-03-07 03:34:51 +00:00
/**
* Implements a DialogContainer responsible for showing all dialogs.
*/
export default class AbstractDialogContainer extends Component<IProps> {
2017-03-07 03:34:51 +00:00
/**
* Returns the dialog to be displayed.
2017-03-07 03:34:51 +00:00
*
* @private
* @returns {ReactElement|null}
2017-03-07 03:34:51 +00:00
*/
_renderDialogContent() {
const {
_component: component,
_reducedUI: reducedUI
} = this.props;
2017-03-07 03:34:51 +00:00
2017-09-18 15:58:03 +00:00
return (
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
}
}
/**
* 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
* @returns {IProps}
2017-03-07 03:34:51 +00:00
*/
export function abstractMapStateToProps(state: IReduxState) {
2017-09-18 15:58:03 +00:00
const stateFeaturesBaseDialog = state['features/base/dialog'];
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,
_componentProps: stateFeaturesBaseDialog.componentProps,
_reducedUI: reducedUI
2017-03-07 03:34:51 +00:00
};
}