Turn TranscribingLabel a self-containing component
This commit is contained in:
parent
dc90800e50
commit
d604cdfe27
|
@ -20,11 +20,6 @@ export type Props = {
|
||||||
*/
|
*/
|
||||||
_filmstripVisible: boolean,
|
_filmstripVisible: boolean,
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether the video quality label should be displayed.
|
|
||||||
*/
|
|
||||||
_showTranscribingLabel: boolean,
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the video quality label should be displayed.
|
* Whether the video quality label should be displayed.
|
||||||
*/
|
*/
|
||||||
|
@ -71,13 +66,9 @@ export default class AbstractLabels<P: Props, S> extends Component<P, S> {
|
||||||
* @returns {React$Element}
|
* @returns {React$Element}
|
||||||
*/
|
*/
|
||||||
_renderTranscribingLabel() {
|
_renderTranscribingLabel() {
|
||||||
if (this.props._showTranscribingLabel) {
|
return (
|
||||||
return (
|
<TranscribingLabel />
|
||||||
<TranscribingLabel />
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -101,14 +92,12 @@ export default class AbstractLabels<P: Props, S> extends Component<P, S> {
|
||||||
* @private
|
* @private
|
||||||
* @returns {{
|
* @returns {{
|
||||||
* _filmstripVisible: boolean,
|
* _filmstripVisible: boolean,
|
||||||
* _showTranscribingLabel: boolean,
|
|
||||||
* _showVideoQualityLabel: boolean
|
* _showVideoQualityLabel: boolean
|
||||||
* }}
|
* }}
|
||||||
*/
|
*/
|
||||||
export function _abstractMapStateToProps(state: Object) {
|
export function _abstractMapStateToProps(state: Object) {
|
||||||
return {
|
return {
|
||||||
_filmstripVisible: isFilmstripVisible(state),
|
_filmstripVisible: isFilmstripVisible(state),
|
||||||
_showTranscribingLabel: state['features/transcribing'].isTranscribing,
|
|
||||||
_showVideoQualityLabel: !shouldDisplayTileView(state)
|
_showVideoQualityLabel: !shouldDisplayTileView(state)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,29 @@
|
||||||
*/
|
*/
|
||||||
export type Props = {
|
export type Props = {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* True if the label needs to be rendered, false otherwise.
|
||||||
|
*/
|
||||||
|
_showLabel: boolean,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invoked to obtain translated strings.
|
* Invoked to obtain translated strings.
|
||||||
*/
|
*/
|
||||||
t: Function
|
t: Function
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maps (parts of) the redux state to the associated props of the
|
||||||
|
* {@link AbstractTranscribingLabel} {@code Component}.
|
||||||
|
*
|
||||||
|
* @param {Object} state - The redux state.
|
||||||
|
* @private
|
||||||
|
* @returns {{
|
||||||
|
* _showLabel: boolean
|
||||||
|
* }}
|
||||||
|
*/
|
||||||
|
export function _mapStateToProps(state: Object) {
|
||||||
|
return {
|
||||||
|
_showLabel: state['features/transcribing'].isTranscribing
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
|
import { connect } from 'react-redux';
|
||||||
|
|
||||||
import { translate } from '../../base/i18n';
|
import { translate } from '../../base/i18n';
|
||||||
import { CircularLabel } from '../../base/label';
|
import { CircularLabel } from '../../base/label';
|
||||||
|
|
||||||
import { type Props } from './AbstractTranscribingLabel';
|
import { _mapStateToProps, type Props } from './AbstractTranscribingLabel';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* React {@code Component} for displaying a label when a transcriber is in the
|
* React {@code Component} for displaying a label when a transcriber is in the
|
||||||
|
@ -21,6 +22,10 @@ class TranscribingLabel extends Component<Props> {
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
render() {
|
render() {
|
||||||
|
if (!this.props._showLabel) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CircularLabel
|
<CircularLabel
|
||||||
label = { this.props.t('transcribing.tr') } />
|
label = { this.props.t('transcribing.tr') } />
|
||||||
|
@ -28,4 +33,4 @@ class TranscribingLabel extends Component<Props> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default translate(TranscribingLabel);
|
export default translate(connect(_mapStateToProps)(TranscribingLabel));
|
||||||
|
|
|
@ -2,11 +2,12 @@
|
||||||
|
|
||||||
import Tooltip from '@atlaskit/tooltip';
|
import Tooltip from '@atlaskit/tooltip';
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
|
import { connect } from 'react-redux';
|
||||||
|
|
||||||
import { translate } from '../../base/i18n';
|
import { translate } from '../../base/i18n';
|
||||||
import { CircularLabel } from '../../base/label';
|
import { CircularLabel } from '../../base/label';
|
||||||
|
|
||||||
import { type Props } from './AbstractTranscribingLabel';
|
import { _mapStateToProps, type Props } from './AbstractTranscribingLabel';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* React {@code Component} for displaying a label when a transcriber is in the
|
* React {@code Component} for displaying a label when a transcriber is in the
|
||||||
|
@ -23,6 +24,10 @@ class TranscribingLabel extends Component<Props> {
|
||||||
* @returns {ReactElement}
|
* @returns {ReactElement}
|
||||||
*/
|
*/
|
||||||
render() {
|
render() {
|
||||||
|
if (!this.props._showLabel) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tooltip
|
<Tooltip
|
||||||
content = { this.props.t('transcribing.labelToolTip') }
|
content = { this.props.t('transcribing.labelToolTip') }
|
||||||
|
@ -36,4 +41,4 @@ class TranscribingLabel extends Component<Props> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default translate(TranscribingLabel);
|
export default translate(connect(_mapStateToProps)(TranscribingLabel));
|
||||||
|
|
Loading…
Reference in New Issue