From d7ffb9e50ebd62c72c6d238250f18c221d48ff9f Mon Sep 17 00:00:00 2001 From: Alberto Maturano Date: Thu, 4 Oct 2018 12:36:16 -0500 Subject: [PATCH] Fix conditional logic Original code: ```js const listTitle = this.props.match.params.slug === 'languages' || 'databases' ? this.renderListTitle() : ''; ``` Is interpreted as: ```js const listTitle = ( this.props.match.params.slug === 'languages' || 'databases' ) ? this.renderListTitle() : '' ; ``` Been `databases` always been evaluate as `true`, this is the same that: ```js const listTitle = this.renderListTitle(); ``` Clearly is not the intention. I refactor this peace of code with what I think was the real intention; looking just the code, not knowing is this is the desire behavior --- .../admin/src/containers/HomePage/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/strapi-plugin-settings-manager/admin/src/containers/HomePage/index.js b/packages/strapi-plugin-settings-manager/admin/src/containers/HomePage/index.js index da3cfeeaa8..25073ec930 100644 --- a/packages/strapi-plugin-settings-manager/admin/src/containers/HomePage/index.js +++ b/packages/strapi-plugin-settings-manager/admin/src/containers/HomePage/index.js @@ -397,8 +397,8 @@ export class HomePage extends React.Component { // eslint-disable-line react/pre // if custom view display render specificComponent const Component = this.components[specificComponent]; const addRequiredInputDesign = this.props.match.params.slug === 'databases'; - const listTitle = this.props.match.params.slug === 'languages' || 'databases' ? this.renderListTitle() : ''; - const listButtonLabel = this.props.match.params.slug === 'languages' || 'databases' ? this.renderListButtonLabel() : ''; + const listTitle = ['languages', 'databases'].includes(this.props.match.params.slug) ? this.renderListTitle() : ''; + const listButtonLabel = ['languages', 'databases'].includes(this.props.match.params.slug) ? this.renderListButtonLabel() : ''; // check if HeaderNav component needs to render a form or a list const renderListComponent = this.props.match.params.slug === 'databases';