aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWouter Admiraal <wouter.admiraal@sonarsource.com>2019-08-26 12:18:36 +0200
committerSonarTech <sonartech@sonarsource.com>2019-09-10 20:21:02 +0200
commit0df26fe8b6e2273ddd5e6db253c4408abc55447c (patch)
tree7a127146b0947ba216502df5095ccccbffd235d7
parentac2f2bffa26573347670e0391b036d8d2319803c (diff)
downloadsonarqube-0df26fe8b6e2273ddd5e6db253c4408abc55447c.tar.gz
sonarqube-0df26fe8b6e2273ddd5e6db253c4408abc55447c.zip
SONAR-12400 Prefill searchbox with value from URL
-rw-r--r--server/sonar-web/src/main/js/apps/projects/components/PageHeader.tsx6
-rw-r--r--server/sonar-web/src/main/js/apps/projects/filters/SearchFilterContainer.tsx9
-rw-r--r--server/sonar-web/src/main/js/apps/projects/filters/__tests__/__snapshots__/SearchFilterContainer-test.tsx.snap1
3 files changed, 6 insertions, 10 deletions
diff --git a/server/sonar-web/src/main/js/apps/projects/components/PageHeader.tsx b/server/sonar-web/src/main/js/apps/projects/components/PageHeader.tsx
index 1cbfa649982..eaafe48c2bc 100644
--- a/server/sonar-web/src/main/js/apps/projects/components/PageHeader.tsx
+++ b/server/sonar-web/src/main/js/apps/projects/components/PageHeader.tsx
@@ -82,11 +82,7 @@ export default function PageHeader(props: Props) {
/>
)}
- <SearchFilterContainer
- onQueryChange={props.onQueryChange}
- organization={props.organization}
- query={props.query}
- />
+ <SearchFilterContainer onQueryChange={props.onQueryChange} query={props.query} />
<div
className={classNames('projects-topbar-item', 'is-last', {
diff --git a/server/sonar-web/src/main/js/apps/projects/filters/SearchFilterContainer.tsx b/server/sonar-web/src/main/js/apps/projects/filters/SearchFilterContainer.tsx
index a8b29e821ac..86463d139ce 100644
--- a/server/sonar-web/src/main/js/apps/projects/filters/SearchFilterContainer.tsx
+++ b/server/sonar-web/src/main/js/apps/projects/filters/SearchFilterContainer.tsx
@@ -22,15 +22,13 @@ import SearchBox from 'sonar-ui-common/components/controls/SearchBox';
import { translate } from 'sonar-ui-common/helpers/l10n';
interface Props {
- className?: string;
query: { search?: string };
- onQueryChange: (change: T.RawQuery) => void;
- organization?: { key: string };
+ onQueryChange: (change: { search?: string }) => void;
}
export default class SearchFilterContainer extends React.PureComponent<Props> {
- handleSearch = (userQuery?: string) => {
- this.props.onQueryChange({ search: userQuery });
+ handleSearch = (search?: string) => {
+ this.props.onQueryChange({ search });
};
render() {
@@ -40,6 +38,7 @@ export default class SearchFilterContainer extends React.PureComponent<Props> {
minLength={2}
onChange={this.handleSearch}
placeholder={translate('projects.search')}
+ value={this.props.query.search || ''}
/>
</div>
);
diff --git a/server/sonar-web/src/main/js/apps/projects/filters/__tests__/__snapshots__/SearchFilterContainer-test.tsx.snap b/server/sonar-web/src/main/js/apps/projects/filters/__tests__/__snapshots__/SearchFilterContainer-test.tsx.snap
index 870a9ad499a..b20d22bc8ef 100644
--- a/server/sonar-web/src/main/js/apps/projects/filters/__tests__/__snapshots__/SearchFilterContainer-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/projects/filters/__tests__/__snapshots__/SearchFilterContainer-test.tsx.snap
@@ -8,6 +8,7 @@ exports[`searches 1`] = `
minLength={2}
onChange={[Function]}
placeholder="projects.search"
+ value=""
/>
</div>
`;