import { KeyboardKeys } from '../../../helpers/keycodes';
import { translate } from '../../../helpers/l10n';
import { BranchLike } from '../../../types/branch-like';
-import { ComponentQualifier, isView } from '../../../types/component';
+import { ComponentQualifier, isPortfolioLike, isView } from '../../../types/component';
import { ComponentMeasure } from '../../../types/types';
interface Props {
render() {
const { className, component, newCodeSelected } = this.props;
const { loading, query } = this.state;
- const isViewLike = isView(component.qualifier);
+ const isPortfolio = isPortfolioLike(component.qualifier);
+
+ const searchPlaceholder = getSearchPlaceholderLabel(component.qualifier as ComponentQualifier);
return (
<div className={classNames('sw-flex sw-items-center', className)} id="code-search">
- {isViewLike && (
+ {isPortfolio && (
<div className="sw-mr-4">
<ToggleButton
disabled={!isEmpty(query)}
)}
<InputSearch
clearIconAriaLabel={translate('clear')}
- searchInputAriaLabel={translate(
- isViewLike ? 'code.search_placeholder.portfolio' : 'code.search_placeholder'
- )}
+ searchInputAriaLabel={searchPlaceholder}
minLength={3}
onChange={this.handleQueryChange}
onKeyDown={this.handleKeyDown}
- placeholder={translate(
- isViewLike ? 'code.search_placeholder.portfolio' : 'code.search_placeholder'
- )}
+ placeholder={searchPlaceholder}
size="large"
value={this.state.query}
/>
}
export default withRouter(Search);
+
+function getSearchPlaceholderLabel(qualifier: ComponentQualifier) {
+ switch (qualifier) {
+ case ComponentQualifier.Portfolio:
+ case ComponentQualifier.SubPortfolio:
+ return translate('code.search_placeholder.portfolio');
+
+ case ComponentQualifier.Application:
+ return translate('code.search_placeholder.application');
+
+ default:
+ return translate('code.search_placeholder.portfolio');
+ }
+}
#------------------------------------------------------------------------------
code.open_component_page=Open Component's Page
code.search_placeholder=Search for files...
+code.search_placeholder.application=Search for projects...
code.search_placeholder.portfolio=Search for projects and sub-portfolios...
code.parent_folder=Parent folder
code.last_analysis_date=Last analysis