From 5f40223e9b7260af5b2a656c7b9c81c202fd344c Mon Sep 17 00:00:00 2001 From: Mathieu Suen Date: Tue, 20 Sep 2022 14:34:41 +0200 Subject: [PATCH] SONAR-17096 Add system announcement settings --- .../core/config/CorePropertyDefinitions.java | 25 ++++++++++++++++--- .../resources/org/sonar/l10n/core.properties | 1 + .../config/CorePropertyDefinitionsTest.java | 2 +- 3 files changed, 23 insertions(+), 5 deletions(-) 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 609fbf159c0..985e3120895 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 @@ -31,9 +31,7 @@ import org.sonar.api.resources.Qualifiers; import org.sonar.core.extension.PluginRiskConsent; import static java.util.Arrays.asList; -import static org.sonar.api.PropertyType.BOOLEAN; -import static org.sonar.api.PropertyType.SINGLE_SELECT_LIST; -import static org.sonar.api.PropertyType.STRING; +import static org.sonar.api.PropertyType.*; import static org.sonar.core.extension.PluginRiskConsent.NOT_ACCEPTED; public class CorePropertyDefinitions { @@ -44,6 +42,10 @@ public class CorePropertyDefinitions { public static final String DISABLE_NOTIFICATION_ON_BUILT_IN_QPROFILES = "sonar.builtInQualityProfiles.disableNotificationOnUpdate"; + public static final String SUB_SYSTEM_ANNOUNCEMENT = "announcement"; + public static final String SYSTEM_ANNOUNCEMENT_MESSAGE = "sonar.systemAnnouncement.message"; + public static final String SYSTEM_ANNOUNCEMENT_DISPLAY_MESSAGE = "sonar.systemAnnouncement.displayMessage"; + public static final String PLUGINS_RISK_CONSENT = "sonar.plugins.risk.consent"; private CorePropertyDefinitions() { @@ -69,7 +71,7 @@ public class CorePropertyDefinitions { .category(CoreProperties.CATEGORY_GENERAL) .subCategory(CoreProperties.SUBCATEGORY_MODULES) .onlyOnQualifiers(Qualifiers.PROJECT) - .type(PropertyType.TEXT) + .type(TEXT) .build(), PropertyDefinition.builder(CoreProperties.SERVER_BASE_URL) .name("Server base URL") @@ -90,6 +92,21 @@ public class CorePropertyDefinitions { .defaultValue(String.valueOf(false)) .hidden() .build(), + PropertyDefinition.builder(SYSTEM_ANNOUNCEMENT_MESSAGE) + .name("System announcement message") + .description("If \"Display system announcement message\" is set to True, this message will be displayed in a banner to all authenticate SonarQube users.") + .category(CoreProperties.CATEGORY_GENERAL) + .subCategory(SUB_SYSTEM_ANNOUNCEMENT) + .type(TEXT) + .build(), + PropertyDefinition.builder(SYSTEM_ANNOUNCEMENT_DISPLAY_MESSAGE) + .name("Display system announcement message") + .description("If set to True, the \"System announcement message\" will be displayed in a banner to all authenticate SonarQube users.") + .defaultValue(Boolean.toString(false)) + .subCategory(SUB_SYSTEM_ANNOUNCEMENT) + .category(CoreProperties.CATEGORY_GENERAL) + .type(BOOLEAN) + .build(), PropertyDefinition.builder(DISABLE_NOTIFICATION_ON_BUILT_IN_QPROFILES) .name("Avoid quality profiles notification") .description("Avoid sending email notification on each update of built-in quality profiles to quality profile administrators.") 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 b0ebf52877e..76a127bceed 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -1314,6 +1314,7 @@ settings.pr_decoration.binding.form.bitbucketcloud.repository.help=The repositor settings.pr_decoration.binding.form.gitlab.repository=Project ID settings.pr_decoration.binding.form.gitlab.repository.help=The Project ID is a numerical unique identifier for your project. You can find it on your Project Overview. +property.category.announcement=Annoucement property.category.general=General property.category.general.email=Email property.category.general.duplications=Duplications 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 00d1068c7a3..ed3f949f563 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 @@ -30,7 +30,7 @@ public class CorePropertyDefinitionsTest { @Test public void all() { List defs = CorePropertyDefinitions.all(); - assertThat(defs).hasSize(52); + assertThat(defs).hasSize(54); } @Test -- 2.39.5