From 0a27c66e8f4eca74876b19ef07e5ed0e95e3482b Mon Sep 17 00:00:00 2001 From: Benoit Genevaux Date: Thu, 15 Mar 2018 14:45:14 +0100 Subject: [PATCH] Panel's title can be not translated Adding the possibility to not translate the title of a Panel For old version compatibility reason, by default, the title is translated, but because we need to put ':' in Panel's titles (and i18n can't manage it) we sometimes don't want it to be translated. --- src/components/panel/index.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/panel/index.js b/src/components/panel/index.js index 8424814f1..ea8427e5d 100644 --- a/src/components/panel/index.js +++ b/src/components/panel/index.js @@ -6,13 +6,15 @@ import snakeCase from 'lodash/string/snakeCase'; import ButtonHelp from '../button-help'; const defaultProps = { - actionsPosition: 'top' + actionsPosition: 'top', + titleTranslated: true }; const propTypes = { actions: PropTypes.func, actionsPosition: PropTypes.oneOf(['both', 'bottom', 'top']).isRequired, title: PropTypes.string, + titleTranslated: PropTypes.bool, showHelp: PropTypes.bool, blockName: PropTypes.string }; @@ -36,7 +38,7 @@ class Panel extends Component { * @return {DOM} React DOM element */ render() { - const { actions, actionsPosition, children, title, showHelp, blockName, modalTitleId, ...otherProps } = this.props; + const { actions, actionsPosition, children, title, titleTranslated, showHelp, blockName, modalTitleId, ...otherProps } = this.props; const { spyId } = this.state; const shouldDisplayActionsTop = actions && ['both', 'top'].includes(actionsPosition); const shouldDisplayActionsBottom = actions && ['both', 'bottom'].includes(actionsPosition); @@ -50,12 +52,12 @@ class Panel extends Component {
{(title || shouldDisplayActionsTop || showHelp) &&
{title && -

{this.i18n(title)}

+

{titleTranslated ? this.i18n(title) : title}

} {shouldDisplayActionsTop &&
{actions()}
} - {showHelp && } + {showHelp && }
}
{children}