Skip to content

Commit 72ac3ed

Browse files
authored
FIX: 13552: fix menu system config value regexes (#13890)
1 parent bd465c8 commit 72ac3ed

5 files changed

Lines changed: 27 additions & 3 deletions

File tree

sormas-api/src/main/java/de/symeda/sormas/api/i18n/Strings.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,6 +1173,7 @@ public interface Strings {
11731173
String infoSyncUsers = "infoSyncUsers";
11741174
String infoSystemConfigurationValueDescriptionEmailSenderAddress = "infoSystemConfigurationValueDescriptionEmailSenderAddress";
11751175
String infoSystemConfigurationValueDescriptionEmailSenderName = "infoSystemConfigurationValueDescriptionEmailSenderName";
1176+
String infoSystemConfigurationValueDescriptionMenuBackgroundColor = "infoSystemConfigurationValueDescriptionMenuBackgroundColor";
11761177
String infoSystemConfigurationValueDescriptionSmsAuthKey = "infoSystemConfigurationValueDescriptionSmsAuthKey";
11771178
String infoSystemConfigurationValueDescriptionSmsAuthSecret = "infoSystemConfigurationValueDescriptionSmsAuthSecret";
11781179
String infoSystemConfigurationValueDescriptionSmsSenderName = "infoSystemConfigurationValueDescriptionSmsSenderName";

sormas-api/src/main/resources/strings.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2018,6 +2018,7 @@ infoSystemConfigurationValueDescriptionSmsSenderName=Name that will be set as th
20182018
infoSystemConfigurationValueDescriptionSmsAuthKey=SORMAS supports the delivery of SMS notifications via Vonage (https://www.vonage.com/communications-apis/). You need to specify a valid authentication key and secret in order to use this feature. SORMAS will not attempt to send out SMS if these properties are left empty.
20192019
infoSystemConfigurationValueDescriptionSmsAuthSecret=Secret for SMS authentication.
20202020
infoSystemConfigurationValueDescriptionUseDeterminedVaccinationStatus=Use automatic vaccination status. The status will be derived from vaccination data.
2021+
infoSystemConfigurationValueDescriptionMenuBackgroundColor=Allows to change background color of the menu to distinguish between different SORMAS instances.
20212022

20222023
notificationCannotCreate=Cannot Create Or Edit Notification
20232024
notificationCreationNotAllowedWithoutSurveillanceReport=Notifier creation or modification is not allowed when a surveillance report already exists for this case.

sormas-api/src/main/resources/validations.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,5 +330,5 @@ systemConfigurationValueValidationNotAValidEmailsenderName = Value is not a vali
330330
systemConfigurationValueValidationNotAValidSmsSenderName = Value is not a valid name. Name should contain only letters and numbers without spaces & special characters. For more info please see https://developer.vonage.com/en/messaging/sms/guides/custom-sender-id .
331331
smsAuthKeyValueValidation = SMS Auth key value is not valid
332332
smsAuthSecretValueValidation = SMS Auth secret value is not valid
333-
systemConfigurationValueValidationInvalidBackgroundColor = Pre-defined values are: green, red, indigo, gray, default (case-sensitive) otherwise must match hexadecimal format, example: #dd2b0e or #4AA
333+
systemConfigurationValueValidationInvalidBackgroundColor = Pre-defined values are: green, red, indigo, gray, default (case-sensitive) otherwise must match hexadecimal format (with or without hash "#"), example: #dd2b0e or #4AA or dd2b0e
334334
systemConfigurationValueValidationMenuSubtitle = Can be empty or up to 16 (any) characters. Can be used to define name of the environment: PRODUCTION - TEST etc.

sormas-backend/src/main/resources/sql/sormas_schema.sql

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15770,4 +15770,17 @@ UPDATE diseaseconfiguration SET exposurecategories = 'VECTOR_BORNE' WHERE diseas
1577015770

1577115771
INSERT INTO schema_version (version_number, comment) VALUES (622, '#13887 default disease exposure category configuration');
1577215772

15773-
-- *** Insert new sql commands BEFORE this line. Remember to always consider _history tables. ***
15773+
-- updated regexes for MENU system config values
15774+
UPDATE systemconfigurationvalue
15775+
SET value_pattern = '^(default|red|green|indigo|gray)$|^(#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3}))$',
15776+
value_description = 'i18n/infoSystemConfigurationValueDescriptionMenuBackgroundColor',
15777+
validation_message = 'i18n/systemConfigurationValueValidationInvalidBackgroundColor'
15778+
WHERE config_key = 'MENU_BACKGROUND_COLOR';
15779+
15780+
UPDATE systemconfigurationvalue
15781+
SET value_pattern = '^[\w\s]{0,16}$'
15782+
WHERE config_key = 'MENU_SUBTITLE';
15783+
15784+
INSERT INTO schema_version (version_number, comment) VALUES (623, '#13552 - FIX menu regexes');
15785+
15786+
-- *** Insert new sql commands BEFORE this line. Remember to always consider _history tables. ***

sormas-ui/src/main/java/de/symeda/sormas/ui/Menu.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ public class Menu extends CssLayout {
7575
private static final String COLOR_BACKGROUND_STYLE_NAME = "color-background";
7676
private static final String MENU_SUBTITLE_STYLE_NAME = "menu-subtitle";
7777
private static final String TOP_MENU_CONTAINER_STYLE_NAME = "top-menu-container";
78+
private static final String HASH = "#";
79+
7880

7981
private final Navigator navigator;
8082
private final Map<String, Button> viewButtons = new HashMap<>();
@@ -214,11 +216,18 @@ private static void defineMenuSubtitleIfSystemConfigured(VerticalLayout topConta
214216
actualColorBackgroundColor = "#737278";
215217
break;
216218
default:
217-
actualColorBackgroundColor = backgroundColor;
219+
actualColorBackgroundColor = addHashIfMissing(backgroundColor);
218220
}
219221
return actualColorBackgroundColor;
220222
}
221223

224+
private static String addHashIfMissing(String backgroundColor) {
225+
if (!StringUtils.startsWith(backgroundColor, HASH)) {
226+
return HASH + backgroundColor;
227+
}
228+
return backgroundColor;
229+
}
230+
222231
private void showSettingsPopup() {
223232

224233
Window window = VaadinUiUtil.createPopupWindow();

0 commit comments

Comments
 (0)