From 85f744be340d8f404978341186dd77cc05584f31 Mon Sep 17 00:00:00 2001 From: Mathieu Suen Date: Tue, 25 Jan 2022 16:31:56 +0100 Subject: [PATCH] SONAR-15865 Disabling new code toogle for portfolio when search is apply --- .../components/PortfolioNewCodeToggle.tsx | 14 +++++++--- .../main/js/apps/code/components/Search.tsx | 5 ++-- .../__tests__/PortfolioNewCodeToggle-test.tsx | 15 ++++++++++- .../code/components/__tests__/Search-test.tsx | 8 +++++- .../PortfolioNewCodeToggle-test.tsx.snap | 11 +++++--- .../__snapshots__/Search-test.tsx.snap | 27 ++++++++++++++++++- .../resources/org/sonar/l10n/core.properties | 2 +- 7 files changed, 68 insertions(+), 14 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/code/components/PortfolioNewCodeToggle.tsx b/server/sonar-web/src/main/js/apps/code/components/PortfolioNewCodeToggle.tsx index b69acfffd56..fe5b0c1b44b 100644 --- a/server/sonar-web/src/main/js/apps/code/components/PortfolioNewCodeToggle.tsx +++ b/server/sonar-web/src/main/js/apps/code/components/PortfolioNewCodeToggle.tsx @@ -19,29 +19,35 @@ */ import * as React from 'react'; import { Button } from '../../../components/controls/buttons'; +import Tooltip from '../../../components/controls/Tooltip'; import { translate } from '../../../helpers/l10n'; export interface PortfolioNewCodeToggleProps { + enabled: boolean; showNewCode: boolean; onNewCodeToggle: (newSelected: boolean) => void; } export default function PortfolioNewCodeToggle(props: PortfolioNewCodeToggleProps) { - const { showNewCode } = props; + const { showNewCode, enabled } = props; return ( -
-
+ +
-
+ ); } 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 188c4dff9c1..740504eabd9 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 @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { omit } from 'lodash'; +import { isEmpty, omit } from 'lodash'; import * as React from 'react'; import { getTree } from '../../../api/components'; import SearchBox from '../../../components/controls/SearchBox'; @@ -133,13 +133,14 @@ export class Search extends React.PureComponent { render() { const { component, newCodeSelected } = this.props; - const { loading } = this.state; + const { loading, query } = this.state; const isPortfolio = ['VW', 'SVW', 'APP'].includes(component.qualifier); return ( `; -exports[`should render correcly: node code toggle for portfolio 1`] = ` +exports[`should render correcly: new code toggle for portfolio 1`] = ` `; + +exports[`should render correcly: new code toggle for portfolio disabled 1`] = ` + +`; diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties index 3528fb722c5..7b88aed98fe 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -1418,7 +1418,7 @@ code_viewer.no_source_code_displayed_due_to_empty_analysis.VW=No projects, appli code_viewer.no_source_code_displayed_due_to_empty_analysis.SVW=No projects, applications, or portfolios in this portfolio. code_viewer.no_source_code_displayed_due_to_security=Due to security settings, no source code can be displayed. code_viewer.no_source_code_displayed_due_to_source_removed=The file was removed, no source code can be displayed. - +code_viewer.portfolio_code_toggle_disabled.help=New Code and Overall Code measures are not available when searching for projects or applications. #------------------------------------------------------------------------------ # -- 2.39.5