From abcb9a091d999569ed6f5bbe86a8ba24c11994cc Mon Sep 17 00:00:00 2001
From: Philippe Perrin <philippe.perrin@sonarsource.com>
Date: Tue, 12 Jul 2022 11:09:07 +0200
Subject: [NO-JIRA] Consistently use ButtonToggle component

---
 .../src/main/js/apps/code/components/Search.tsx    | 23 +++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

(limited to 'server/sonar-web/src/main/js/apps/code/components/Search.tsx')

diff --git a/server/sonar-web/src/main/js/apps/code/components/Search.tsx b/server/sonar-web/src/main/js/apps/code/components/Search.tsx
index d4b5c14b8e5..8fee9b154cc 100644
--- a/server/sonar-web/src/main/js/apps/code/components/Search.tsx
+++ b/server/sonar-web/src/main/js/apps/code/components/Search.tsx
@@ -20,6 +20,7 @@
 import { isEmpty, omit } from 'lodash';
 import * as React from 'react';
 import { getTree } from '../../../api/components';
+import ButtonToggle from '../../../components/controls/ButtonToggle';
 import SearchBox from '../../../components/controls/SearchBox';
 import { Location, Router, withRouter } from '../../../components/hoc/withRouter';
 import DeferredSpinner from '../../../components/ui/DeferredSpinner';
@@ -28,7 +29,6 @@ import { KeyboardKeys } from '../../../helpers/keycodes';
 import { translate } from '../../../helpers/l10n';
 import { BranchLike } from '../../../types/branch-like';
 import { ComponentMeasure } from '../../../types/types';
-import PortfolioNewCodeToggle from './PortfolioNewCodeToggle';
 
 interface Props {
   branchLike?: BranchLike;
@@ -140,10 +140,23 @@ export class Search extends React.PureComponent<Props, State> {
     return (
       <div className="code-search" id="code-search">
         {isPortfolio && (
-          <PortfolioNewCodeToggle
-            enabled={isEmpty(query)}
-            onNewCodeToggle={this.props.onNewCodeToggle}
-            showNewCode={newCodeSelected}
+          <ButtonToggle
+            name="portfolio-scope"
+            className="big-spacer-right"
+            options={[
+              {
+                value: true,
+                label: translate('projects.view.new_code'),
+                disabled: !isEmpty(query)
+              },
+              {
+                value: false,
+                label: translate('projects.view.overall_code'),
+                disabled: !isEmpty(query)
+              }
+            ]}
+            value={newCodeSelected}
+            onCheck={this.props.onNewCodeToggle}
           />
         )}
         <SearchBox
-- 
cgit v1.2.3

