From f6ff49007d98d12b4827f5d6ec07478780933137 Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Tue, 3 Oct 2017 14:55:22 +0200 Subject: [PATCH] SONAR-9378 Rename "sonar.lf.sonarqube.com.enabled" setting --- .../ComputeEngineContainerImplTest.java | 10 ++--- .../org/sonar/server/ui/ws/GlobalAction.java | 4 +- .../sonar/server/ui/ws/GlobalActionTest.java | 2 +- .../ui/ws/GlobalActionTest/settings.json | 2 +- .../src/main/js/app/components/App.tsx | 2 +- .../app/components/DefaultHelmetContainer.js | 2 +- .../app/components/GlobalFooterContainer.js | 2 +- .../js/app/components/nav/global/GlobalNav.js | 2 +- .../main/js/apps/about/components/AboutApp.js | 2 +- .../onboarding/OnboardingContainer.js | 2 +- .../core/config/CorePropertyDefinitions.java | 1 + .../org/sonar/core/config/WebConstants.java | 2 +- .../org/sonar/core/config/WebProperties.java | 43 +++++++++++++++++++ .../config/CorePropertyDefinitionsTest.java | 2 +- 14 files changed, 61 insertions(+), 17 deletions(-) create mode 100644 sonar-core/src/main/java/org/sonar/core/config/WebProperties.java diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java index 7c71c910ed3..8a003284a5d 100644 --- a/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java +++ b/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java @@ -110,7 +110,7 @@ public class ComputeEngineContainerImplTest { picoContainer.getComponentAdapters().stream() .map(ComponentAdapter::getComponentImplementation) .collect(Collectors.toList())).contains((Class) StartableHazelcastMember.class, - (Class) CeDistributedInformationImpl.class); + (Class) CeDistributedInformationImpl.class); underTest.stop(); } @@ -139,7 +139,7 @@ public class ComputeEngineContainerImplTest { + 4 // content of ReportAnalysisFailureNotificationModule + 3 // CeCleaningModule + its content + 1 // CeDistributedInformation - ); + ); assertThat(picoContainer.getParent().getComponentAdapters()).hasSize( CONTAINER_ITSELF + 5 // level 3 @@ -154,15 +154,15 @@ public class ComputeEngineContainerImplTest { + 26 // level 1 + 51 // content of DaoModule + 3 // content of EsSearchModule - + 65 // content of CorePropertyDefinitions + + 66 // content of CorePropertyDefinitions + 1 // StopFlagContainer ); assertThat( picoContainer.getComponentAdapters().stream() .map(ComponentAdapter::getComponentImplementation) .collect(Collectors.toList())).doesNotContain((Class) StartableHazelcastMember.class, - (Class) CeDistributedInformationImpl.class).contains( - (Class) StandaloneCeDistributedInformation.class); + (Class) CeDistributedInformationImpl.class).contains( + (Class) StandaloneCeDistributedInformation.class); assertThat(picoContainer.getParent().getParent().getParent().getParent()).isNull(); underTest.stop(); diff --git a/server/sonar-server/src/main/java/org/sonar/server/ui/ws/GlobalAction.java b/server/sonar-server/src/main/java/org/sonar/server/ui/ws/GlobalAction.java index 5364af20f59..42652292532 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/ui/ws/GlobalAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/ui/ws/GlobalAction.java @@ -40,7 +40,7 @@ import org.sonar.server.ui.VersionFormatter; import org.sonar.server.user.UserSession; import static org.sonar.api.CoreProperties.RATING_GRID; -import static org.sonar.core.config.WebConstants.SONARQUBE_DOT_COM_ENABLED; +import static org.sonar.core.config.WebConstants.SONARCLOUD_ENABLED; import static org.sonar.core.config.WebConstants.SONAR_LF_ENABLE_GRAVATAR; import static org.sonar.core.config.WebConstants.SONAR_LF_GRAVATAR_SERVER_URL; import static org.sonar.core.config.WebConstants.SONAR_LF_LOGO_URL; @@ -55,7 +55,7 @@ public class GlobalAction implements NavigationWsAction { SONAR_LF_ENABLE_GRAVATAR, SONAR_LF_GRAVATAR_SERVER_URL, SONAR_UPDATECENTER_ACTIVATE, - SONARQUBE_DOT_COM_ENABLED, + SONARCLOUD_ENABLED, RATING_GRID); private final PageRepository pageRepository; diff --git a/server/sonar-server/src/test/java/org/sonar/server/ui/ws/GlobalActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/ui/ws/GlobalActionTest.java index 562417f1969..bdc667d415f 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/ui/ws/GlobalActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/ui/ws/GlobalActionTest.java @@ -95,7 +95,7 @@ public class GlobalActionTest { settings.setProperty("sonar.lf.logoWidthPx", 135); settings.setProperty("sonar.lf.gravatarServerUrl", "https://secure.gravatar.com/avatar/{EMAIL_MD5}.jpg?s={SIZE}&d=identicon"); settings.setProperty("sonar.lf.enableGravatar", true); - settings.setProperty("sonar.lf.sonarqube.com.enabled", true); + settings.setProperty("sonar.sonarcloud.enabled", true); settings.setProperty("sonar.updatecenter.activate", false); settings.setProperty("sonar.technicalDebt.ratingGrid", "0.05,0.1,0.2,0.5"); // This setting should be ignored as it's not needed diff --git a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/settings.json b/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/settings.json index bf414b18b00..885c52ba52a 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/settings.json +++ b/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/settings.json @@ -4,7 +4,7 @@ "sonar.lf.logoWidthPx": "135", "sonar.lf.gravatarServerUrl": "https://secure.gravatar.com/avatar/{EMAIL_MD5}.jpg?s={SIZE}&d=identicon", "sonar.lf.enableGravatar": "true", - "sonar.lf.sonarqube.com.enabled": "true", + "sonar.sonarcloud.enabled": "true", "sonar.updatecenter.activate": "false", "sonar.technicalDebt.ratingGrid": "0.05,0.1,0.2,0.5" } diff --git a/server/sonar-web/src/main/js/app/components/App.tsx b/server/sonar-web/src/main/js/app/components/App.tsx index 8ab6f6b8f40..e69c1116cda 100644 --- a/server/sonar-web/src/main/js/app/components/App.tsx +++ b/server/sonar-web/src/main/js/app/components/App.tsx @@ -74,7 +74,7 @@ class App extends React.PureComponent { if (this.mounted) { const onSonarCloud = appState.settings != undefined && - appState.settings['sonar.lf.sonarqube.com.enabled'] === 'true'; + appState.settings['sonar.sonarcloud.enabled'] === 'true'; this.setState({ branchesEnabled: appState.branchesEnabled, canAdmin: appState.canAdmin, diff --git a/server/sonar-web/src/main/js/app/components/DefaultHelmetContainer.js b/server/sonar-web/src/main/js/app/components/DefaultHelmetContainer.js index 36d16d56568..8a3be89e41f 100644 --- a/server/sonar-web/src/main/js/app/components/DefaultHelmetContainer.js +++ b/server/sonar-web/src/main/js/app/components/DefaultHelmetContainer.js @@ -36,7 +36,7 @@ function DefaultHelmetContainer({ children, sonarqubeDotCom }) { } const mapStateToProps = state => ({ - sonarqubeDotCom: getGlobalSettingValue(state, 'sonar.lf.sonarqube.com.enabled') + sonarqubeDotCom: getGlobalSettingValue(state, 'sonar.sonarcloud.enabled') }); export default connect(mapStateToProps)(DefaultHelmetContainer); diff --git a/server/sonar-web/src/main/js/app/components/GlobalFooterContainer.js b/server/sonar-web/src/main/js/app/components/GlobalFooterContainer.js index 02d44ad5ba4..4a2a7725cef 100644 --- a/server/sonar-web/src/main/js/app/components/GlobalFooterContainer.js +++ b/server/sonar-web/src/main/js/app/components/GlobalFooterContainer.js @@ -25,7 +25,7 @@ import GlobalFooter from './GlobalFooter'; const mapStateToProps = state => ({ sonarqubeVersion: getAppState(state).version, productionDatabase: getAppState(state).productionDatabase, - sonarqubeDotCom: getGlobalSettingValue(state, 'sonar.lf.sonarqube.com.enabled') + sonarqubeDotCom: getGlobalSettingValue(state, 'sonar.sonarcloud.enabled') }); export default connect(mapStateToProps)(GlobalFooter); diff --git a/server/sonar-web/src/main/js/app/components/nav/global/GlobalNav.js b/server/sonar-web/src/main/js/app/components/nav/global/GlobalNav.js index fe155adbbe6..4611d30d5c8 100644 --- a/server/sonar-web/src/main/js/app/components/nav/global/GlobalNav.js +++ b/server/sonar-web/src/main/js/app/components/nav/global/GlobalNav.js @@ -144,7 +144,7 @@ class GlobalNav extends React.PureComponent { } const mapStateToProps = state => { - const sonarCloudSetting = getGlobalSettingValue(state, 'sonar.lf.sonarqube.com.enabled'); + const sonarCloudSetting = getGlobalSettingValue(state, 'sonar.sonarcloud.enabled'); return { currentUser: getCurrentUser(state), diff --git a/server/sonar-web/src/main/js/apps/about/components/AboutApp.js b/server/sonar-web/src/main/js/apps/about/components/AboutApp.js index d736f754310..c748fa60444 100644 --- a/server/sonar-web/src/main/js/apps/about/components/AboutApp.js +++ b/server/sonar-web/src/main/js/apps/about/components/AboutApp.js @@ -203,7 +203,7 @@ const mapStateToProps = state => ({ appState: getAppState(state), currentUser: getCurrentUser(state), customText: getGlobalSettingValue(state, 'sonar.lf.aboutText'), - sonarqubeDotCom: getGlobalSettingValue(state, 'sonar.lf.sonarqube.com.enabled') + sonarqubeDotCom: getGlobalSettingValue(state, 'sonar.sonarcloud.enabled') }); const mapDispatchToProps = { fetchAboutPageSettings }; diff --git a/server/sonar-web/src/main/js/apps/tutorials/onboarding/OnboardingContainer.js b/server/sonar-web/src/main/js/apps/tutorials/onboarding/OnboardingContainer.js index 246062de818..c1b395878e4 100644 --- a/server/sonar-web/src/main/js/apps/tutorials/onboarding/OnboardingContainer.js +++ b/server/sonar-web/src/main/js/apps/tutorials/onboarding/OnboardingContainer.js @@ -27,7 +27,7 @@ import { } from '../../../store/rootReducer'; const mapStateToProps = state => { - const sonarCloudSetting = getGlobalSettingValue(state, 'sonar.lf.sonarqube.com.enabled'); + const sonarCloudSetting = getGlobalSettingValue(state, 'sonar.sonarcloud.enabled'); return { currentUser: getCurrentUser(state), diff --git a/sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java b/sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java index 562a5e7cf7a..1836e69ab52 100644 --- a/sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java +++ b/sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java @@ -63,6 +63,7 @@ public class CorePropertyDefinitions { defs.addAll(WebhookProperties.all()); defs.addAll(TelemetryProperties.all()); defs.addAll(ScannerProperties.all()); + defs.addAll(WebProperties.all()); defs.addAll(asList( PropertyDefinition.builder(PROP_PASSWORD) diff --git a/sonar-core/src/main/java/org/sonar/core/config/WebConstants.java b/sonar-core/src/main/java/org/sonar/core/config/WebConstants.java index 7e53e1832c7..398eee95a0e 100644 --- a/sonar-core/src/main/java/org/sonar/core/config/WebConstants.java +++ b/sonar-core/src/main/java/org/sonar/core/config/WebConstants.java @@ -30,7 +30,7 @@ public final class WebConstants { public static final String SONAR_LF_LOGO_WIDTH_PX = "sonar.lf.logoWidthPx"; public static final String SONAR_LF_ABOUT_TEXT = "sonar.lf.aboutText"; public static final String SONAR_UPDATECENTER_ACTIVATE = "sonar.updatecenter.activate"; - public static final String SONARQUBE_DOT_COM_ENABLED = "sonar.lf.sonarqube.com.enabled"; + public static final String SONARCLOUD_ENABLED = "sonar.sonarcloud.enabled"; private WebConstants() { } diff --git a/sonar-core/src/main/java/org/sonar/core/config/WebProperties.java b/sonar-core/src/main/java/org/sonar/core/config/WebProperties.java new file mode 100644 index 00000000000..724dbc97aba --- /dev/null +++ b/sonar-core/src/main/java/org/sonar/core/config/WebProperties.java @@ -0,0 +1,43 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.core.config; + +import java.util.List; +import org.sonar.api.PropertyType; +import org.sonar.api.config.PropertyDefinition; + +import static java.util.Arrays.asList; + +public final class WebProperties { + + private WebProperties() { + } + + public static List all() { + return asList( + PropertyDefinition.builder(WebConstants.SONARCLOUD_ENABLED) + .deprecatedKey("sonar.lf.sonarqube.com.enabled") + .defaultValue("false") + .name("Enable SonarCloud look&feel") + .type(PropertyType.BOOLEAN) + .hidden() + .build()); + } +} diff --git a/sonar-core/src/test/java/org/sonar/core/config/CorePropertyDefinitionsTest.java b/sonar-core/src/test/java/org/sonar/core/config/CorePropertyDefinitionsTest.java index c26a8cda61b..aa7bcd07d0d 100644 --- a/sonar-core/src/test/java/org/sonar/core/config/CorePropertyDefinitionsTest.java +++ b/sonar-core/src/test/java/org/sonar/core/config/CorePropertyDefinitionsTest.java @@ -33,7 +33,7 @@ public class CorePropertyDefinitionsTest { @Test public void all() { List defs = CorePropertyDefinitions.all(); - assertThat(defs).hasSize(65); + assertThat(defs).hasSize(66); } @Test -- 2.39.5