mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fixed 'ternary operators should not be nested' code smell.
This commit is contained in:
committed by
Akshay Joshi
parent
cbf5886430
commit
43022b7aa2
@@ -701,12 +701,18 @@ define('pgadmin.browser', [
|
||||
}
|
||||
|
||||
let get_menuitem_obj = function(_m) {
|
||||
let enable = _m.enable;
|
||||
if(_m.enable == '') {
|
||||
enable = true;
|
||||
} else if(_.isString(_m.enable) && _m.enable.toLowerCase() == 'false') {
|
||||
enable = false;
|
||||
}
|
||||
return new MenuItem({
|
||||
name: _m.name, label: _m.label, module: _m.module,
|
||||
category: _m.category, callback: _m.callback,
|
||||
priority: _m.priority, data: _m.data, url: _m.url || '#',
|
||||
target: _m.target, icon: _m.icon,
|
||||
enable: (_m.enable == '' ? true : (_.isString(_m.enable) && _m.enable.toLowerCase() == 'false') ? false : _m.enable),
|
||||
enable,
|
||||
node: _m.node, checked: _m.checked, below: _m.below,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -12,6 +12,32 @@ import {onlineHelpSearch} from './online_help';
|
||||
import {menuSearch} from './menuitems_help';
|
||||
import $ from 'jquery';
|
||||
import gettext from 'sources/gettext';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
function HelpArticleContents({isHelpLoading, isMenuLoading, helpSearchResult}) {
|
||||
return (isHelpLoading && !(isMenuLoading??true)) ? (
|
||||
<div>
|
||||
<div className='help-groups'>
|
||||
<span className='fa fa-question-circle'></span>
|
||||
HELP ARTICLES
|
||||
{Object.keys(helpSearchResult.data).length > 10
|
||||
? '(10 of ' + Object.keys(helpSearchResult.data).length + ')'
|
||||
: '(' + Object.keys(helpSearchResult.data).length + ')'
|
||||
}
|
||||
{ Object.keys(helpSearchResult.data).length > 10
|
||||
? <a href={helpSearchResult.url} className='pull-right no-padding' target='_blank' rel='noreferrer'>
|
||||
Show all <span className='fas fa-external-link-alt' ></span></a> : ''
|
||||
}
|
||||
</div>
|
||||
<div className='pad-12'><div className="search-icon">{gettext('Searching...')}</div></div>
|
||||
</div>) : '';
|
||||
}
|
||||
|
||||
HelpArticleContents.propTypes = {
|
||||
helpSearchResult: PropTypes.object,
|
||||
isHelpLoading: PropTypes.bool,
|
||||
isMenuLoading: PropTypes.bool
|
||||
};
|
||||
|
||||
export function Search() {
|
||||
const wrapperRef = useRef(null);
|
||||
@@ -180,6 +206,10 @@ export function Search() {
|
||||
|
||||
useOutsideAlerter(wrapperRef);
|
||||
|
||||
const showLoader = (loading) => {
|
||||
return loading ? <div className='pad-12'><div className="search-icon">{gettext('Searching...')}</div></div> : '';
|
||||
};
|
||||
|
||||
return (
|
||||
<div id='quick-search-container' onClick={setSearchTerm}></div>,
|
||||
<ul id='quick-search-container' ref={wrapperRef} className='test' role="menu">
|
||||
@@ -208,7 +238,7 @@ export function Search() {
|
||||
|
||||
|
||||
{refactorMenuItems(menuSearchResult.data)}
|
||||
</div> : ( (isMenuLoading) ? (<div className='pad-12'><div className="search-icon">{gettext('Searching...')}</div></div>) : '')}
|
||||
</div> : showLoader(isMenuLoading)}
|
||||
|
||||
{(menuSearchResult.data.length == 0 && menuSearchResult.fetched && !(isMenuLoading??true)) ? (<div className='pad-12 no-results'><span className='fa fa-info-circle'></span> {gettext('No search results')}</div>):''}
|
||||
|
||||
@@ -228,22 +258,8 @@ export function Search() {
|
||||
})}
|
||||
|
||||
{(Object.keys(helpSearchResult.data).length == 0) ? (<div className='pad-12 no-results'><span className='fa fa-info-circle'></span> {gettext('No search results')}</div>):''}
|
||||
</div> : ( (isHelpLoading && !(isMenuLoading??true)) ? (
|
||||
<div>
|
||||
<div className='help-groups'>
|
||||
<span className='fa fa-question-circle'></span>
|
||||
HELP ARTICLES
|
||||
{Object.keys(helpSearchResult.data).length > 10
|
||||
? '(10 of ' + Object.keys(helpSearchResult.data).length + ')'
|
||||
: '(' + Object.keys(helpSearchResult.data).length + ')'
|
||||
}
|
||||
{ Object.keys(helpSearchResult.data).length > 10
|
||||
? <a href={helpSearchResult.url} className='pull-right no-padding' target='_blank' rel='noreferrer'>
|
||||
Show all <span className='fas fa-external-link-alt' ></span></a> : ''
|
||||
}
|
||||
</div>
|
||||
<div className='pad-12'><div className="search-icon">{gettext('Searching...')}</div></div>
|
||||
</div>) : '')}
|
||||
|
||||
</div> : <HelpArticleContents isHelpLoading={isHelpLoading} isMenuLoading={isMenuLoading} helpSearchResult={helpSearchResult} /> }
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user