From a6372b3143a939e7bafa6838e374914071ee44e1 Mon Sep 17 00:00:00 2001 From: Tobias Koch Date: Mon, 2 Sep 2024 17:17:56 +0200 Subject: [PATCH] switch to notificatino factory --- .../sample/SampleRegistrationService.java | 3 - ...TokenDeletionConfirmationNotification.java | 3 +- .../account/PersonalAccessTokenMain.java | 12 +- .../ProjectSideNavigationComponent.java | 14 +- .../MessageSourceNotificationFactory.java | 164 ++++++++++++++++++ .../MessageSourceToastFactory.java | 13 +- .../notifications/NotificationDialog.java | 30 ++-- .../notifications/NotificationLevel.java | 14 ++ .../notifications/{toasts => }/Toast.java | 9 +- .../projects/project/ProjectMainLayout.java | 2 +- ...ctUserRemovalConfirmationNotification.java | 3 +- .../experiments/ExperimentMainLayout.java | 2 +- .../ExistingSamplesPreventGroupEdit.java | 3 +- .../ExperimentDetailsComponent.java | 12 +- .../ExistingGroupsPreventVariableEdit.java | 3 +- ...xistingSamplesPreventSampleOriginEdit.java | 3 +- .../ExistingSamplesPreventVariableEdit.java | 3 +- .../project/info/ProjectInformationMain.java | 14 +- ...ementDeletionConfirmationNotification.java | 3 +- ...BatchDeletionConfirmationNotification.java | 3 +- .../samples/SampleInformationMain.java | 34 ++-- ...eItemDeletionConfirmationNotification.java | 3 +- ...CItemDeletionConfirmationNotification.java | 3 +- .../src/main/resources/application.properties | 2 +- .../messages/dialog-messages.properties | 3 + .../messages/dialog-notifications.properties | 15 ++ 26 files changed, 287 insertions(+), 86 deletions(-) create mode 100644 user-interface/src/main/java/life/qbic/datamanager/views/notifications/MessageSourceNotificationFactory.java rename user-interface/src/main/java/life/qbic/datamanager/views/notifications/{toasts => }/MessageSourceToastFactory.java (93%) create mode 100644 user-interface/src/main/java/life/qbic/datamanager/views/notifications/NotificationLevel.java rename user-interface/src/main/java/life/qbic/datamanager/views/notifications/{toasts => }/Toast.java (97%) create mode 100644 user-interface/src/main/resources/messages/dialog-notifications.properties diff --git a/project-management/src/main/java/life/qbic/projectmanagement/application/sample/SampleRegistrationService.java b/project-management/src/main/java/life/qbic/projectmanagement/application/sample/SampleRegistrationService.java index 3940fadb64..34a5cace52 100644 --- a/project-management/src/main/java/life/qbic/projectmanagement/application/sample/SampleRegistrationService.java +++ b/project-management/src/main/java/life/qbic/projectmanagement/application/sample/SampleRegistrationService.java @@ -3,8 +3,6 @@ import static life.qbic.logging.service.LoggerFactory.logger; import java.util.Collection; -import java.util.HashMap; -import java.util.Map; import java.util.Objects; import life.qbic.application.commons.Result; import life.qbic.logging.api.Logger; @@ -13,7 +11,6 @@ import life.qbic.projectmanagement.application.batch.SampleUpdateRequest; import life.qbic.projectmanagement.domain.model.project.ProjectId; import life.qbic.projectmanagement.domain.model.sample.Sample; -import life.qbic.projectmanagement.domain.model.sample.SampleCode; import life.qbic.projectmanagement.domain.model.sample.SampleRegistrationRequest; import life.qbic.projectmanagement.domain.service.SampleDomainService; import org.springframework.beans.factory.annotation.Autowired; diff --git a/user-interface/src/main/java/life/qbic/datamanager/views/account/AccessTokenDeletionConfirmationNotification.java b/user-interface/src/main/java/life/qbic/datamanager/views/account/AccessTokenDeletionConfirmationNotification.java index 65c08f92de..b8dee23bb5 100644 --- a/user-interface/src/main/java/life/qbic/datamanager/views/account/AccessTokenDeletionConfirmationNotification.java +++ b/user-interface/src/main/java/life/qbic/datamanager/views/account/AccessTokenDeletionConfirmationNotification.java @@ -2,6 +2,7 @@ import com.vaadin.flow.component.html.Span; import life.qbic.datamanager.views.notifications.NotificationDialog; +import life.qbic.datamanager.views.notifications.NotificationLevel; /** * Warns the user that the personal access token will be deleted and cannot be used @@ -11,7 +12,7 @@ public class AccessTokenDeletionConfirmationNotification extends NotificationDialog { public AccessTokenDeletionConfirmationNotification() { - super(Type.WARNING); + super(NotificationLevel.WARNING); withTitle("Personal Access Token will be deleted"); withContent(new Span( "Deleting this Personal Access Token will make it unusable. Proceed?")); diff --git a/user-interface/src/main/java/life/qbic/datamanager/views/account/PersonalAccessTokenMain.java b/user-interface/src/main/java/life/qbic/datamanager/views/account/PersonalAccessTokenMain.java index 4252d05d6a..b749b1d8b3 100644 --- a/user-interface/src/main/java/life/qbic/datamanager/views/account/PersonalAccessTokenMain.java +++ b/user-interface/src/main/java/life/qbic/datamanager/views/account/PersonalAccessTokenMain.java @@ -18,8 +18,8 @@ import life.qbic.datamanager.views.account.PersonalAccessTokenComponent.DeleteTokenEvent; import life.qbic.datamanager.views.account.PersonalAccessTokenComponent.PersonalAccessTokenFrontendBean; import life.qbic.datamanager.views.general.Main; -import life.qbic.datamanager.views.notifications.toasts.MessageSourceToastFactory; -import life.qbic.datamanager.views.notifications.toasts.Toast; +import life.qbic.datamanager.views.notifications.MessageSourceNotificationFactory; +import life.qbic.datamanager.views.notifications.Toast; import life.qbic.identity.api.PersonalAccessToken; import life.qbic.identity.api.PersonalAccessTokenService; import life.qbic.identity.api.RawToken; @@ -48,18 +48,18 @@ public class PersonalAccessTokenMain extends Main implements BeforeEnterObserver private final PersonalAccessTokenComponent personalAccessTokenComponent; private final PersonalAccessTokenService personalAccessTokenService; private final AuthenticationToUserIdTranslationService userIdTranslator; - private final life.qbic.datamanager.views.notifications.toasts.MessageSourceToastFactory messageSourceToastFactory; + private final MessageSourceNotificationFactory messageSourceNotificationFactory; public PersonalAccessTokenMain(PersonalAccessTokenService personalAccessTokenService, PersonalAccessTokenComponent personalAccessTokenComponent, AuthenticationToUserIdTranslationService userIdTranslator, - MessageSourceToastFactory messageSourceToastFactory) { + MessageSourceNotificationFactory messageSourceNotificationFactory) { this.personalAccessTokenService = requireNonNull(personalAccessTokenService, "personalAccessTokenService must not be null"); this.personalAccessTokenComponent = requireNonNull(personalAccessTokenComponent, "personalAccessTokenComponent must not be null"); this.userIdTranslator = requireNonNull(userIdTranslator, "userIdTranslator must not be null"); - this.messageSourceToastFactory = requireNonNull(messageSourceToastFactory, + this.messageSourceNotificationFactory = requireNonNull(messageSourceNotificationFactory, "messageSourceToastFactory must not be null"); addClassName("personal-access-token"); @@ -103,7 +103,7 @@ private void onAddTokenClicked(AddTokenEvent addTokenEvent) { .tokenDescription(), event.personalAccessTokenDTO().expirationDate()); personalAccessTokenComponent.showCreatedToken(createdToken); event.getSource().close(); - Toast toast = messageSourceToastFactory.create("personal-access-token.created.success", + Toast toast = messageSourceNotificationFactory.toast("personal-access-token.created.success", new Object[]{event.personalAccessTokenDTO().tokenDescription()}, getLocale()); toast.open(); }); diff --git a/user-interface/src/main/java/life/qbic/datamanager/views/navigation/ProjectSideNavigationComponent.java b/user-interface/src/main/java/life/qbic/datamanager/views/navigation/ProjectSideNavigationComponent.java index c130c1ea24..8321e2c842 100644 --- a/user-interface/src/main/java/life/qbic/datamanager/views/navigation/ProjectSideNavigationComponent.java +++ b/user-interface/src/main/java/life/qbic/datamanager/views/navigation/ProjectSideNavigationComponent.java @@ -32,8 +32,8 @@ import life.qbic.datamanager.security.UserPermissions; import life.qbic.datamanager.views.AppRoutes.Projects; import life.qbic.datamanager.views.Context; -import life.qbic.datamanager.views.notifications.toasts.MessageSourceToastFactory; -import life.qbic.datamanager.views.notifications.toasts.Toast; +import life.qbic.datamanager.views.notifications.MessageSourceNotificationFactory; +import life.qbic.datamanager.views.notifications.Toast; import life.qbic.datamanager.views.projects.overview.ProjectOverviewMain; import life.qbic.datamanager.views.projects.project.ProjectMainLayout; import life.qbic.datamanager.views.projects.project.experiments.ExperimentInformationMain; @@ -76,7 +76,7 @@ public class ProjectSideNavigationComponent extends Div implements private final transient ExperimentInformationService experimentInformationService; private final AddExperimentToProjectService addExperimentToProjectService; private final transient UserPermissions userPermissions; - private final MessageSourceToastFactory messageSourceToastFactory; + private final MessageSourceNotificationFactory messageSourceNotificationFactory; private final TerminologyService terminologyService; private final SpeciesLookupService speciesLookupService; private Context context = new Context(); @@ -88,13 +88,13 @@ public ProjectSideNavigationComponent( UserPermissions userPermissions, SpeciesLookupService speciesLookupService, TerminologyService terminologyService, - MessageSourceToastFactory messageSourceToastFactory) { + MessageSourceNotificationFactory messageSourceNotificationFactory) { content = new Div(); requireNonNull(projectInformationService); requireNonNull(experimentInformationService); requireNonNull(addExperimentToProjectService); - this.messageSourceToastFactory = requireNonNull(messageSourceToastFactory, - "messageSourceToastFactory must not be null"); + this.messageSourceNotificationFactory = requireNonNull(messageSourceNotificationFactory, + "messageSourceNotificationFactory must not be null"); this.speciesLookupService = speciesLookupService; this.addExperimentToProjectService = addExperimentToProjectService; this.userPermissions = requireNonNull(userPermissions, "userPermissions must not be null"); @@ -361,7 +361,7 @@ private ExperimentId createExperiment(ProjectId projectId, } private void displayExperimentCreationSuccess(String experimentName) { - Toast toast = messageSourceToastFactory.create("experiment.created.success", + Toast toast = messageSourceNotificationFactory.toast("experiment.created.success", new Object[]{experimentName}, getLocale()); toast.open(); } diff --git a/user-interface/src/main/java/life/qbic/datamanager/views/notifications/MessageSourceNotificationFactory.java b/user-interface/src/main/java/life/qbic/datamanager/views/notifications/MessageSourceNotificationFactory.java new file mode 100644 index 0000000000..166c40bcb6 --- /dev/null +++ b/user-interface/src/main/java/life/qbic/datamanager/views/notifications/MessageSourceNotificationFactory.java @@ -0,0 +1,164 @@ +package life.qbic.datamanager.views.notifications; + +import static java.util.Objects.isNull; +import static life.qbic.logging.service.LoggerFactory.logger; + +import com.vaadin.flow.component.Component; +import com.vaadin.flow.component.Html; +import com.vaadin.flow.component.html.Span; +import com.vaadin.flow.router.RouteParameters; +import com.vaadin.flow.spring.annotation.SpringComponent; +import java.time.Duration; +import java.time.format.DateTimeParseException; +import java.util.Locale; +import java.util.Optional; +import life.qbic.logging.api.Logger; +import org.springframework.context.MessageSource; +import org.springframework.context.NoSuchMessageException; + +/** + * TODO! + * short description + * + *

detailed description

+ * + * @since + */ +@SpringComponent +public class MessageSourceNotificationFactory { + + private static final Logger log = logger(MessageSourceNotificationFactory.class); + public static final Object[] EMPTY_PARAMETERS = new Object[]{}; + private static final String DEFAULT_CONFIRM_TEXT = "Okay"; + private final MessageSource messageSource; + + public MessageSourceNotificationFactory(MessageSource messageSource) { + this.messageSource = messageSource; + } + + public Toast toast(String key, Object[] parameters, Locale locale) { + MessageType type = parseMessageType(key, locale); + String messageText = parseMessage(key, parameters, locale); + + Component content = switch (type) { + case HTML -> new Html("
%s
".formatted(messageText)); + case TEXT -> new Span(messageText); + }; + + NotificationLevel level = parseLevel(key, locale); + Duration duration = parseDuration(key, locale).orElse(Toast.DEFAULT_OPEN_DURATION); + + Toast toast = new Toast(level); + toast.withContent(content); + toast.setDuration(duration); + + return toast; + } + + public Toast routingToast(String key, Object[] messageArgs, Object[] routeArgs, + Class navigationTarget, RouteParameters routeParameters, Locale locale) { + var toast = toast(key, messageArgs, locale); + String linkText = parseLinkText(key, routeArgs, locale); + return toast.withRouting(linkText, navigationTarget, routeParameters); + } + + public NotificationDialog dialog(String key, Object[] parameters, Locale locale) { + MessageType type = parseMessageType(key, locale); + String messageText = parseMessage(key, parameters, locale); + Component content = switch (type) { + case HTML -> new Html("
%s
".formatted(messageText)); + case TEXT -> new Span(messageText); + }; + + NotificationLevel level = parseLevel(key, locale); + NotificationDialog notificationDialog = new NotificationDialog(level) + .withContent(content); + parseTitle(key, locale).ifPresent(notificationDialog::withTitle); + parseConfirmText(key, locale).ifPresentOrElse( + notificationDialog::setConfirmText, + () -> notificationDialog.setConfirmText(DEFAULT_CONFIRM_TEXT)); + + return notificationDialog; + } + + private NotificationLevel parseLevel(String key, Locale locale) { + String levelProperty; + try { + levelProperty = messageSource.getMessage("%s.level".formatted(key), + EMPTY_PARAMETERS, locale); + } catch (NoSuchMessageException e) { + throw new RuntimeException("Missing level info for %s.".formatted(key)); + } + + try { + return NotificationLevel.valueOf(levelProperty.trim().toUpperCase()); + } catch (IllegalArgumentException e) { + throw new RuntimeException( + "Could not parse toast level for key %s: %s".formatted(key, levelProperty)); + } + } + + private String parseMessage(String key, Object[] parameters, Locale locale) { + try { + return messageSource.getMessage("%s.message.text".formatted(key), + parameters, locale).strip(); + } catch (NoSuchMessageException e) { + throw new RuntimeException("No message specified for " + key, e); + } + } + + private MessageType parseMessageType(String key, Locale locale) { + try { + String messageType = messageSource.getMessage("%s.message.type".formatted(key), + EMPTY_PARAMETERS, locale).strip().toUpperCase(); + return MessageType.valueOf(messageType); + } catch (NoSuchMessageException e) { + throw new RuntimeException("No message type specified for " + key, e); + } + } + + private Optional parseTitle(String key, Locale locale) { + try { + return Optional.of(messageSource.getMessage("%s.title".formatted(key), + EMPTY_PARAMETERS, locale).strip()); + } catch (NoSuchMessageException e) { + log.warn("No title specified for %s.title".formatted(key)); + return Optional.empty(); + } + } + + private Optional parseDuration(String key, Locale locale) { + String durationProperty = messageSource.getMessage("%s.duration".formatted(key), + EMPTY_PARAMETERS, null, locale); + if (isNull(durationProperty)) { + return Optional.empty(); + } + try { + return Optional.of(Duration.parse(durationProperty)); + } catch (DateTimeParseException e) { + log.warn("Could not parse duration for key %s: %s".formatted(key, durationProperty)); + return Optional.empty(); + } + } + + private String parseLinkText(String key, Object[] routeArgs, Locale locale) { + String linkText; + try { + linkText = messageSource.getMessage("%s.routing.link.text".formatted(key), + routeArgs, locale).strip(); + } catch (NoSuchMessageException e) { + throw new RuntimeException("No link text specified for " + key, e); + } + return linkText; + } + + private Optional parseConfirmText(String key, Locale locale) { + return Optional.ofNullable(messageSource.getMessage("%s.confirm-text".formatted(key), + new Object[]{}, null, locale)); + } + + private enum MessageType { + HTML, + TEXT + } +} diff --git a/user-interface/src/main/java/life/qbic/datamanager/views/notifications/toasts/MessageSourceToastFactory.java b/user-interface/src/main/java/life/qbic/datamanager/views/notifications/MessageSourceToastFactory.java similarity index 93% rename from user-interface/src/main/java/life/qbic/datamanager/views/notifications/toasts/MessageSourceToastFactory.java rename to user-interface/src/main/java/life/qbic/datamanager/views/notifications/MessageSourceToastFactory.java index af1c2faf8d..137abe8e87 100644 --- a/user-interface/src/main/java/life/qbic/datamanager/views/notifications/toasts/MessageSourceToastFactory.java +++ b/user-interface/src/main/java/life/qbic/datamanager/views/notifications/MessageSourceToastFactory.java @@ -1,4 +1,4 @@ -package life.qbic.datamanager.views.notifications.toasts; +package life.qbic.datamanager.views.notifications; import static java.util.Objects.isNull; @@ -11,7 +11,6 @@ import java.time.format.DateTimeParseException; import java.util.Locale; import java.util.Optional; -import life.qbic.datamanager.views.notifications.toasts.Toast.Level; import life.qbic.logging.api.Logger; import life.qbic.logging.service.LoggerFactory; import org.springframework.beans.factory.annotation.Qualifier; @@ -55,7 +54,7 @@ public MessageSourceToastFactory(@Qualifier("messageSource") MessageSource messa * @param locale the locale for which to load the message * @return a Toast with loaded content */ - public Toast create(String key, Object[] parameters, Locale locale) { + private Toast create(String key, Object[] parameters, Locale locale) { MessageType type = parseMessageType(key, locale); String messageText = parseMessage(key, parameters, locale); @@ -64,7 +63,7 @@ public Toast create(String key, Object[] parameters, Locale locale) { case TEXT -> new Span(messageText); }; - Level level = parseLevel(key, locale); + NotificationLevel level = parseLevel(key, locale); Duration duration = parseDuration(key, locale).orElse(Toast.DEFAULT_OPEN_DURATION); Toast toast = new Toast(level); @@ -93,7 +92,7 @@ private MessageType parseMessageType(String key, Locale locale) { } } - private Level parseLevel(String key, Locale locale) { + private NotificationLevel parseLevel(String key, Locale locale) { String levelProperty; try { levelProperty = messageSource.getMessage("%s.level".formatted(key), @@ -103,7 +102,7 @@ private Level parseLevel(String key, Locale locale) { } try { - return Level.valueOf(levelProperty.trim().toUpperCase()); + return NotificationLevel.valueOf(levelProperty.trim().toUpperCase()); } catch (IllegalArgumentException e) { throw new RuntimeException( "Could not parse toast level for key %s: %s".formatted(key, levelProperty)); @@ -150,7 +149,7 @@ private Optional parseDuration(String key, Locale locale) { * @return a Toast with loaded content * @see #create(String, Object[], Locale) */ - public Toast createRouting(String key, Object[] messageArgs, Object[] routeArgs, + private Toast createRouting(String key, Object[] messageArgs, Object[] routeArgs, Class navigationTarget, RouteParameters routeParameters, Locale locale) { var toast = create(key, messageArgs, locale); diff --git a/user-interface/src/main/java/life/qbic/datamanager/views/notifications/NotificationDialog.java b/user-interface/src/main/java/life/qbic/datamanager/views/notifications/NotificationDialog.java index fa1dcfcd87..49f2065192 100644 --- a/user-interface/src/main/java/life/qbic/datamanager/views/notifications/NotificationDialog.java +++ b/user-interface/src/main/java/life/qbic/datamanager/views/notifications/NotificationDialog.java @@ -35,26 +35,22 @@ public class NotificationDialog extends ConfirmDialog { private final H2 title; - private final Type type; + private final NotificationLevel level; protected final Div layout; private Icon headerIcon; protected Component content; - protected enum Type { - SUCCESS, WARNING, ERROR, INFO - } - - protected NotificationDialog(Type type) { + protected NotificationDialog(NotificationLevel level) { addClassName("notification-dialog"); - addClassName(switch (type) { + addClassName(switch (level) { case SUCCESS -> "success-dialog"; case WARNING -> "warning-dialog"; case ERROR -> "error-dialog"; case INFO -> "info-dialog"; }); - this.type = requireNonNull(type, "type must not be null"); + this.level = requireNonNull(level, "level must not be null"); - var defaultTitle = switch (type) { + var defaultTitle = switch (level) { case SUCCESS -> "Success"; case WARNING -> "Warning"; case ERROR -> "Error"; @@ -62,7 +58,7 @@ protected NotificationDialog(Type type) { }; title = new H2(defaultTitle); title.addClassName("title"); - withHeaderIcon(typeBasedHeaderIcon(this.type)); + withHeaderIcon(typeBasedHeaderIcon(this.level)); updateHeader(); layout = new Div(); @@ -73,14 +69,14 @@ protected NotificationDialog(Type type) { setConfirmText("Okay"); } - protected static Icon typeBasedHeaderIcon(Type newType) { - var iconCssClass = switch (newType) { + protected static Icon typeBasedHeaderIcon(NotificationLevel notificationLevel) { + var iconCssClass = switch (notificationLevel) { case SUCCESS -> "success-icon"; case WARNING -> "warning-icon"; case ERROR -> "error-icon"; case INFO -> "info-icon"; }; - var icon = switch (newType) { + var icon = switch (notificationLevel) { case SUCCESS -> VaadinIcon.CHECK.create(); case WARNING -> VaadinIcon.WARNING.create(); case ERROR -> VaadinIcon.CLOSE_CIRCLE.create(); @@ -96,7 +92,7 @@ protected static Icon typeBasedHeaderIcon(Type newType) { * @return a notification dialog showing a success notification */ public static NotificationDialog successDialog() { - return new NotificationDialog(Type.SUCCESS); + return new NotificationDialog(NotificationLevel.SUCCESS); } /** @@ -105,7 +101,7 @@ public static NotificationDialog successDialog() { * @return a notification dialog showing a warning notification */ public static NotificationDialog warningDialog() { - return new NotificationDialog(Type.WARNING); + return new NotificationDialog(NotificationLevel.WARNING); } /** @@ -114,7 +110,7 @@ public static NotificationDialog warningDialog() { * @return a notification dialog showing an error notification */ public static NotificationDialog errorDialog() { - return new NotificationDialog(Type.ERROR); + return new NotificationDialog(NotificationLevel.ERROR); } /** @@ -123,7 +119,7 @@ public static NotificationDialog errorDialog() { * @return a notification dialog showing an info notification */ public static NotificationDialog infoDialog() { - return new NotificationDialog(Type.INFO); + return new NotificationDialog(NotificationLevel.INFO); } private void updateHeader() { diff --git a/user-interface/src/main/java/life/qbic/datamanager/views/notifications/NotificationLevel.java b/user-interface/src/main/java/life/qbic/datamanager/views/notifications/NotificationLevel.java new file mode 100644 index 0000000000..cc0697e865 --- /dev/null +++ b/user-interface/src/main/java/life/qbic/datamanager/views/notifications/NotificationLevel.java @@ -0,0 +1,14 @@ +package life.qbic.datamanager.views.notifications; + +/** + * The level of a notification + *
    + *
  1. SUCCESS: The notification informs of a successful operation
  2. + *
  3. INFO: The notification is used solely to convey information
  4. + *
  5. WARNING: The notification warns the user of something
  6. + *
  7. ERROR: The notification informs about an error
  8. + *
+ */ +public enum NotificationLevel { + SUCCESS, INFO, WARNING, ERROR +} diff --git a/user-interface/src/main/java/life/qbic/datamanager/views/notifications/toasts/Toast.java b/user-interface/src/main/java/life/qbic/datamanager/views/notifications/Toast.java similarity index 97% rename from user-interface/src/main/java/life/qbic/datamanager/views/notifications/toasts/Toast.java rename to user-interface/src/main/java/life/qbic/datamanager/views/notifications/Toast.java index 03bb347cfc..8bb6344aef 100644 --- a/user-interface/src/main/java/life/qbic/datamanager/views/notifications/toasts/Toast.java +++ b/user-interface/src/main/java/life/qbic/datamanager/views/notifications/Toast.java @@ -1,4 +1,4 @@ -package life.qbic.datamanager.views.notifications.toasts; +package life.qbic.datamanager.views.notifications; import static java.util.Objects.nonNull; import static java.util.Objects.requireNonNull; @@ -41,17 +41,14 @@ public final class Toast extends Notification { private Component content; - enum Level { - SUCCESS, - INFO; - } - Toast(Level level) { + Toast(NotificationLevel level) { super(); addClassName("toast-notification"); addClassName(switch (level) { case SUCCESS -> "success-toast"; case INFO -> "info-toast"; + case WARNING, ERROR -> ""; }); setPosition(DEFAULT_POSITION); diff --git a/user-interface/src/main/java/life/qbic/datamanager/views/projects/project/ProjectMainLayout.java b/user-interface/src/main/java/life/qbic/datamanager/views/projects/project/ProjectMainLayout.java index 03c3d9b2cf..582dd99663 100644 --- a/user-interface/src/main/java/life/qbic/datamanager/views/projects/project/ProjectMainLayout.java +++ b/user-interface/src/main/java/life/qbic/datamanager/views/projects/project/ProjectMainLayout.java @@ -17,7 +17,7 @@ import life.qbic.datamanager.views.general.DataManagerMenu; import life.qbic.datamanager.views.general.footer.FooterComponentFactory; import life.qbic.datamanager.views.navigation.ProjectSideNavigationComponent; -import life.qbic.datamanager.views.notifications.toasts.MessageSourceToastFactory; +import life.qbic.datamanager.views.notifications.MessageSourceToastFactory; import life.qbic.datamanager.views.projects.overview.ProjectOverviewMain; import life.qbic.identity.api.UserInformationService; import life.qbic.projectmanagement.application.AddExperimentToProjectService; diff --git a/user-interface/src/main/java/life/qbic/datamanager/views/projects/project/access/ProjectUserRemovalConfirmationNotification.java b/user-interface/src/main/java/life/qbic/datamanager/views/projects/project/access/ProjectUserRemovalConfirmationNotification.java index 810d3195dd..4463c961eb 100644 --- a/user-interface/src/main/java/life/qbic/datamanager/views/projects/project/access/ProjectUserRemovalConfirmationNotification.java +++ b/user-interface/src/main/java/life/qbic/datamanager/views/projects/project/access/ProjectUserRemovalConfirmationNotification.java @@ -2,6 +2,7 @@ import com.vaadin.flow.component.html.Span; import life.qbic.datamanager.views.notifications.NotificationDialog; +import life.qbic.datamanager.views.notifications.NotificationLevel; import life.qbic.datamanager.views.projects.project.access.ProjectAccessComponent.ProjectUser; /** @@ -13,7 +14,7 @@ public class ProjectUserRemovalConfirmationNotification extends NotificationDialog { public ProjectUserRemovalConfirmationNotification(ProjectUser projectUser) { - super(Type.WARNING); + super(NotificationLevel.WARNING); withTitle("Remove user from project"); withContent(new Span( "Are you sure you want to remove the user %s from the project?".formatted( diff --git a/user-interface/src/main/java/life/qbic/datamanager/views/projects/project/experiments/ExperimentMainLayout.java b/user-interface/src/main/java/life/qbic/datamanager/views/projects/project/experiments/ExperimentMainLayout.java index 8181e7b23a..f3d6802099 100644 --- a/user-interface/src/main/java/life/qbic/datamanager/views/projects/project/experiments/ExperimentMainLayout.java +++ b/user-interface/src/main/java/life/qbic/datamanager/views/projects/project/experiments/ExperimentMainLayout.java @@ -24,7 +24,7 @@ import life.qbic.datamanager.views.general.DataManagerMenu; import life.qbic.datamanager.views.general.footer.FooterComponentFactory; import life.qbic.datamanager.views.navigation.ProjectSideNavigationComponent; -import life.qbic.datamanager.views.notifications.toasts.MessageSourceToastFactory; +import life.qbic.datamanager.views.notifications.MessageSourceToastFactory; import life.qbic.datamanager.views.projects.overview.ProjectOverviewMain; import life.qbic.datamanager.views.projects.project.experiments.ExperimentNavigationComponent.RoutingTab; import life.qbic.identity.api.UserInformationService; diff --git a/user-interface/src/main/java/life/qbic/datamanager/views/projects/project/experiments/experiment/ExistingSamplesPreventGroupEdit.java b/user-interface/src/main/java/life/qbic/datamanager/views/projects/project/experiments/experiment/ExistingSamplesPreventGroupEdit.java index b0ba1c6e54..93abf72d3b 100644 --- a/user-interface/src/main/java/life/qbic/datamanager/views/projects/project/experiments/experiment/ExistingSamplesPreventGroupEdit.java +++ b/user-interface/src/main/java/life/qbic/datamanager/views/projects/project/experiments/experiment/ExistingSamplesPreventGroupEdit.java @@ -4,6 +4,7 @@ import com.vaadin.flow.component.html.Div; import com.vaadin.flow.component.html.Span; import life.qbic.datamanager.views.notifications.NotificationDialog; +import life.qbic.datamanager.views.notifications.NotificationLevel; /** * Notifies the user that samples exist in the experiment. @@ -14,7 +15,7 @@ public class ExistingSamplesPreventGroupEdit extends NotificationDialog { public ExistingSamplesPreventGroupEdit(int sampleCount) { - super(Type.ERROR); + super(NotificationLevel.ERROR); addClassName("existing-samples-prevent-group-edit"); withTitle("Cannot edit experimental groups"); customizeContent(sampleCount); diff --git a/user-interface/src/main/java/life/qbic/datamanager/views/projects/project/experiments/experiment/ExperimentDetailsComponent.java b/user-interface/src/main/java/life/qbic/datamanager/views/projects/project/experiments/experiment/ExperimentDetailsComponent.java index 723bef87f0..c67c3068af 100644 --- a/user-interface/src/main/java/life/qbic/datamanager/views/projects/project/experiments/experiment/ExperimentDetailsComponent.java +++ b/user-interface/src/main/java/life/qbic/datamanager/views/projects/project/experiments/experiment/ExperimentDetailsComponent.java @@ -37,7 +37,7 @@ import life.qbic.datamanager.views.general.ConfirmEvent; import life.qbic.datamanager.views.general.Disclaimer; import life.qbic.datamanager.views.general.PageArea; -import life.qbic.datamanager.views.notifications.toasts.MessageSourceToastFactory; +import life.qbic.datamanager.views.notifications.MessageSourceNotificationFactory; import life.qbic.datamanager.views.projects.project.experiments.ExperimentInformationMain; import life.qbic.datamanager.views.projects.project.experiments.experiment.components.CardCollection; import life.qbic.datamanager.views.projects.project.experiments.experiment.components.ExistingGroupsPreventVariableEdit; @@ -101,7 +101,7 @@ public class ExperimentDetailsComponent extends PageArea { private final Disclaimer addExperimentalVariablesNote; private final DeletionService deletionService; private final TerminologyService terminologyService; - private final MessageSourceToastFactory messageSourceToastFactory; + private final MessageSourceNotificationFactory messageSourceNotificationFactory; private Context context; private int experimentalGroupCount; @@ -112,9 +112,9 @@ public ExperimentDetailsComponent( @Autowired DeletionService deletionService, @Autowired SpeciesLookupService ontologyTermInformationService, TerminologyService terminologyService, - MessageSourceToastFactory messageSourceToastFactory) { - this.messageSourceToastFactory = requireNonNull(messageSourceToastFactory, - "messageSourceToastFactory must not be null"); + MessageSourceNotificationFactory messageSourceNotificationFactory) { + this.messageSourceNotificationFactory = requireNonNull(messageSourceNotificationFactory, + "messageSourceNotificationFactory must not be null"); this.experimentInformationService = requireNonNull(experimentInformationService); this.sampleInformationService = sampleInformationService; this.deletionService = requireNonNull(deletionService); @@ -151,7 +151,7 @@ private Notification createSampleRegistrationPossibleNotification() { RouteParam experimentRouteParam = new RouteParam(EXPERIMENT_ID_ROUTE_PARAMETER, context.experimentId().orElseThrow().value()); - return messageSourceToastFactory.createRouting("from.experiment.to.sample.batch", + return messageSourceNotificationFactory.routingToast("from.experiment.to.sample.batch", new Object[]{}, new Object[]{}, SampleInformationMain.class, diff --git a/user-interface/src/main/java/life/qbic/datamanager/views/projects/project/experiments/experiment/components/ExistingGroupsPreventVariableEdit.java b/user-interface/src/main/java/life/qbic/datamanager/views/projects/project/experiments/experiment/components/ExistingGroupsPreventVariableEdit.java index ca5aeb91bf..95d691a1fb 100644 --- a/user-interface/src/main/java/life/qbic/datamanager/views/projects/project/experiments/experiment/components/ExistingGroupsPreventVariableEdit.java +++ b/user-interface/src/main/java/life/qbic/datamanager/views/projects/project/experiments/experiment/components/ExistingGroupsPreventVariableEdit.java @@ -5,6 +5,7 @@ import com.vaadin.flow.component.html.Div; import com.vaadin.flow.component.html.Span; import life.qbic.datamanager.views.notifications.NotificationDialog; +import life.qbic.datamanager.views.notifications.NotificationLevel; /** * Notifies the user that experimental groups exist in the experiment. @@ -15,7 +16,7 @@ public final class ExistingGroupsPreventVariableEdit extends NotificationDialog { public ExistingGroupsPreventVariableEdit(int numberOfExperimentalGroups) { - super(Type.ERROR); + super(NotificationLevel.ERROR); addClassName("existing-groups-prevent-variable-edit"); withTitle("Cannot edit variables"); customizeContent(numberOfExperimentalGroups); diff --git a/user-interface/src/main/java/life/qbic/datamanager/views/projects/project/experiments/experiment/components/ExistingSamplesPreventSampleOriginEdit.java b/user-interface/src/main/java/life/qbic/datamanager/views/projects/project/experiments/experiment/components/ExistingSamplesPreventSampleOriginEdit.java index 6cc628fdf1..01401e0173 100644 --- a/user-interface/src/main/java/life/qbic/datamanager/views/projects/project/experiments/experiment/components/ExistingSamplesPreventSampleOriginEdit.java +++ b/user-interface/src/main/java/life/qbic/datamanager/views/projects/project/experiments/experiment/components/ExistingSamplesPreventSampleOriginEdit.java @@ -3,6 +3,7 @@ import com.vaadin.flow.component.Text; import com.vaadin.flow.component.html.Div; import life.qbic.datamanager.views.notifications.NotificationDialog; +import life.qbic.datamanager.views.notifications.NotificationLevel; /** * Notifies the user that samples exist in the experiment and reference the Ontology term the user @@ -14,7 +15,7 @@ public class ExistingSamplesPreventSampleOriginEdit extends NotificationDialog { public ExistingSamplesPreventSampleOriginEdit(String ontologyLabel) { - super(Type.ERROR); + super(NotificationLevel.ERROR); addClassName("existing-samples-prevent-variable-edit"); withTitle("Cannot remove sample origin"); withContent(new Div( diff --git a/user-interface/src/main/java/life/qbic/datamanager/views/projects/project/experiments/experiment/components/ExistingSamplesPreventVariableEdit.java b/user-interface/src/main/java/life/qbic/datamanager/views/projects/project/experiments/experiment/components/ExistingSamplesPreventVariableEdit.java index 6b9ca11df0..10a36f2a21 100644 --- a/user-interface/src/main/java/life/qbic/datamanager/views/projects/project/experiments/experiment/components/ExistingSamplesPreventVariableEdit.java +++ b/user-interface/src/main/java/life/qbic/datamanager/views/projects/project/experiments/experiment/components/ExistingSamplesPreventVariableEdit.java @@ -4,6 +4,7 @@ import com.vaadin.flow.component.html.Div; import com.vaadin.flow.component.html.Span; import life.qbic.datamanager.views.notifications.NotificationDialog; +import life.qbic.datamanager.views.notifications.NotificationLevel; /** * Notifies the user that samples exist in the experiment. @@ -14,7 +15,7 @@ public class ExistingSamplesPreventVariableEdit extends NotificationDialog { public ExistingSamplesPreventVariableEdit(int sampleCount) { - super(Type.ERROR); + super(NotificationLevel.ERROR); addClassName("existing-samples-prevent-variable-edit"); withTitle("Cannot edit variables"); customizeContent(sampleCount); diff --git a/user-interface/src/main/java/life/qbic/datamanager/views/projects/project/info/ProjectInformationMain.java b/user-interface/src/main/java/life/qbic/datamanager/views/projects/project/info/ProjectInformationMain.java index 861479176c..1cbbe5d529 100644 --- a/user-interface/src/main/java/life/qbic/datamanager/views/projects/project/info/ProjectInformationMain.java +++ b/user-interface/src/main/java/life/qbic/datamanager/views/projects/project/info/ProjectInformationMain.java @@ -21,8 +21,8 @@ import life.qbic.datamanager.views.general.Main; import life.qbic.datamanager.views.general.download.OfferDownload; import life.qbic.datamanager.views.general.download.QualityControlDownload; -import life.qbic.datamanager.views.notifications.toasts.MessageSourceToastFactory; -import life.qbic.datamanager.views.notifications.toasts.Toast; +import life.qbic.datamanager.views.notifications.MessageSourceNotificationFactory; +import life.qbic.datamanager.views.notifications.Toast; import life.qbic.datamanager.views.projects.project.ProjectMainLayout; import life.qbic.datamanager.views.projects.project.experiments.ExperimentInformationMain; import life.qbic.datamanager.views.projects.project.experiments.ExperimentListComponent; @@ -89,7 +89,7 @@ public class ProjectInformationMain extends Main implements BeforeEnterObserver private final QualityControlDownload qualityControlDownload; private final OfferListComponent offerListComponent; private final QualityControlListComponent qualityControlListComponent; - private final MessageSourceToastFactory messageSourceToastFactory; + private final MessageSourceNotificationFactory messageSourceNotificationFactory; private final TerminologyService terminologyService; private Context context; @@ -102,7 +102,7 @@ public ProjectInformationMain(@Autowired ProjectDetailsComponent projectDetailsC @Autowired ProjectPurchaseService projectPurchaseService, @Autowired QualityControlService qualityControlService, @Autowired TerminologyService terminologyService, - MessageSourceToastFactory messageSourceToastFactory) { + MessageSourceNotificationFactory messageSourceNotificationFactory) { this.projectDetailsComponent = requireNonNull(projectDetailsComponent, "projectDetailsComponent must not be null"); this.experimentListComponent = requireNonNull(experimentListComponent, @@ -118,8 +118,8 @@ public ProjectInformationMain(@Autowired ProjectDetailsComponent projectDetailsC "projectPurchaseService must not be null"); this.qualityControlService = requireNonNull(qualityControlService, "qualityControlService must not be null"); - this.messageSourceToastFactory = requireNonNull(messageSourceToastFactory, - "messageSourceToastFactory must not be null"); + this.messageSourceNotificationFactory = requireNonNull(messageSourceNotificationFactory, + "messageSourceNotificationFactory must not be null"); offerListComponent = getConfiguredOfferList(); @@ -328,7 +328,7 @@ private void showAddExperimentDialog() { } private void displayExperimentCreationSuccess(String experimentName) { - Toast toast = messageSourceToastFactory.create("experiment.created.success", + Toast toast = messageSourceNotificationFactory.toast("experiment.created.success", new Object[]{experimentName}, getLocale()); toast.open(); } diff --git a/user-interface/src/main/java/life/qbic/datamanager/views/projects/project/measurements/MeasurementDeletionConfirmationNotification.java b/user-interface/src/main/java/life/qbic/datamanager/views/projects/project/measurements/MeasurementDeletionConfirmationNotification.java index 61428d767a..03e0bb8252 100644 --- a/user-interface/src/main/java/life/qbic/datamanager/views/projects/project/measurements/MeasurementDeletionConfirmationNotification.java +++ b/user-interface/src/main/java/life/qbic/datamanager/views/projects/project/measurements/MeasurementDeletionConfirmationNotification.java @@ -2,6 +2,7 @@ import com.vaadin.flow.component.html.Span; import life.qbic.datamanager.views.notifications.NotificationDialog; +import life.qbic.datamanager.views.notifications.NotificationLevel; /** * Warns the user that measurements will be deleted @@ -11,7 +12,7 @@ public class MeasurementDeletionConfirmationNotification extends NotificationDialog { public MeasurementDeletionConfirmationNotification(String title, int amount) { - super(Type.WARNING); + super(NotificationLevel.WARNING); withTitle(title); withContent(new Span( "Are you sure you want to delete %s measurements?".formatted(String.valueOf(amount)))); diff --git a/user-interface/src/main/java/life/qbic/datamanager/views/projects/project/samples/BatchDeletionConfirmationNotification.java b/user-interface/src/main/java/life/qbic/datamanager/views/projects/project/samples/BatchDeletionConfirmationNotification.java index ba2605b26c..c80a07e836 100644 --- a/user-interface/src/main/java/life/qbic/datamanager/views/projects/project/samples/BatchDeletionConfirmationNotification.java +++ b/user-interface/src/main/java/life/qbic/datamanager/views/projects/project/samples/BatchDeletionConfirmationNotification.java @@ -2,6 +2,7 @@ import com.vaadin.flow.component.html.Span; import life.qbic.datamanager.views.notifications.NotificationDialog; +import life.qbic.datamanager.views.notifications.NotificationLevel; /** * Warns the user that the samples contained in the batch will also be deleted @@ -12,7 +13,7 @@ public class BatchDeletionConfirmationNotification extends NotificationDialog { public BatchDeletionConfirmationNotification() { - super(Type.WARNING); + super(NotificationLevel.ERROR); withTitle("Samples within batch will be deleted"); withContent(new Span( "Deleting this Batch will also delete the samples contained within. Proceed?")); diff --git a/user-interface/src/main/java/life/qbic/datamanager/views/projects/project/samples/SampleInformationMain.java b/user-interface/src/main/java/life/qbic/datamanager/views/projects/project/samples/SampleInformationMain.java index b84abbdc62..abb4d67eae 100644 --- a/user-interface/src/main/java/life/qbic/datamanager/views/projects/project/samples/SampleInformationMain.java +++ b/user-interface/src/main/java/life/qbic/datamanager/views/projects/project/samples/SampleInformationMain.java @@ -28,10 +28,10 @@ import life.qbic.datamanager.views.general.Main; import life.qbic.datamanager.views.general.download.DownloadProvider; import life.qbic.datamanager.views.notifications.CancelConfirmationDialogFactory; -import life.qbic.datamanager.views.notifications.ErrorMessage; +import life.qbic.datamanager.views.notifications.MessageSourceNotificationFactory; +import life.qbic.datamanager.views.notifications.MessageSourceToastFactory; import life.qbic.datamanager.views.notifications.StyledNotification; import life.qbic.datamanager.views.notifications.SuccessMessage; -import life.qbic.datamanager.views.notifications.toasts.MessageSourceToastFactory; import life.qbic.datamanager.views.projects.project.experiments.ExperimentMainLayout; import life.qbic.datamanager.views.projects.project.samples.BatchDetailsComponent.DeleteBatchEvent; import life.qbic.datamanager.views.projects.project.samples.BatchDetailsComponent.EditBatchEvent; @@ -101,6 +101,7 @@ public class SampleInformationMain extends Main implements BeforeEnterObserver { private final ProjectInformationService projectInformationService; private final CancelConfirmationDialogFactory cancelConfirmationDialogFactory; private final MessageSourceToastFactory messageSourceToastFactory; + private final MessageSourceNotificationFactory messageSourceNotificationFactory; private transient Context context; public SampleInformationMain(@Autowired ExperimentInformationService experimentInformationService, @@ -112,7 +113,8 @@ public SampleInformationMain(@Autowired ExperimentInformationService experimentI @Autowired BatchDetailsComponent batchDetailsComponent, ProjectInformationService projectInformationService, CancelConfirmationDialogFactory cancelConfirmationDialogFactory, - MessageSourceToastFactory messageSourceToastFactory) { + MessageSourceToastFactory messageSourceToastFactory, + MessageSourceNotificationFactory messageSourceNotificationFactory) { this.experimentInformationService = requireNonNull(experimentInformationService, "ExperimentInformationService cannot be null"); this.batchRegistrationService = requireNonNull(batchRegistrationService, @@ -131,6 +133,8 @@ public SampleInformationMain(@Autowired ExperimentInformationService experimentI this.messageSourceToastFactory = messageSourceToastFactory; this.cancelConfirmationDialogFactory = requireNonNull(cancelConfirmationDialogFactory, "cancelConfirmationDialogFactory must not be null"); + this.messageSourceNotificationFactory = requireNonNull(messageSourceNotificationFactory, + "messageSourceNotificationFactory must not be null"); noGroupsDefinedDisclaimer = createNoGroupsDefinedDisclaimer(); noGroupsDefinedDisclaimer.setVisible(false); @@ -157,7 +161,6 @@ public SampleInformationMain(@Autowired ExperimentInformationService experimentI System.identityHashCode(batchDetailsComponent), sampleDetailsComponent.getClass().getSimpleName(), System.identityHashCode(sampleDetailsComponent))); - } private static boolean noExperimentGroupsInExperiment(Experiment experiment) { @@ -240,7 +243,7 @@ private void registerBatch(ConfirmEvent confirmEvent) { .onError(responseCode -> displayRegistrationFailure()) .onValue(ignored -> fireEvent(new BatchRegisteredEvent(this, false))) .onValue(ignored -> confirmEvent.getSource().close()) - .onValue(batchId -> displayRegistrationSuccess()) + .onValue(batchId -> displayRegistrationSuccess(batchLabel)) .onValue(ignored -> setBatchAndSampleInformation()); } @@ -313,22 +316,25 @@ private void displayUpdateSuccess() { notification.open(); } - private void displayDeletionSuccess(String batchName) { - messageSourceToastFactory.create("sample-batch.deleted.success", new String[]{batchName}, + private void displayDeletionSuccess(String batchLabel) { + messageSourceNotificationFactory.toast("sample-batch.deleted.success", new String[]{batchLabel}, getLocale()) .open(); } - private void displayRegistrationSuccess() { - SuccessMessage successMessage = new SuccessMessage("Batch registration succeeded.", ""); - StyledNotification notification = new StyledNotification(successMessage); - notification.open(); + private void displayRegistrationSuccess(String batchLabel) { + messageSourceNotificationFactory.toast("sample-batch.registered.success", + new String[]{batchLabel}, + getLocale()) + .open(); + } private void displayRegistrationFailure() { - ErrorMessage errorMessage = new ErrorMessage("Batch registration failed.", ""); - StyledNotification notification = new StyledNotification(errorMessage); - notification.open(); + messageSourceNotificationFactory.dialog( + "sample-batch.register.failure", + MessageSourceNotificationFactory.EMPTY_PARAMETERS, getLocale()) + .open(); } private void onEditBatchClicked(EditBatchEvent editBatchEvent) { diff --git a/user-interface/src/main/java/life/qbic/datamanager/views/projects/purchase/PurchaseItemDeletionConfirmationNotification.java b/user-interface/src/main/java/life/qbic/datamanager/views/projects/purchase/PurchaseItemDeletionConfirmationNotification.java index 40d5ae93e0..2849c7bca7 100644 --- a/user-interface/src/main/java/life/qbic/datamanager/views/projects/purchase/PurchaseItemDeletionConfirmationNotification.java +++ b/user-interface/src/main/java/life/qbic/datamanager/views/projects/purchase/PurchaseItemDeletionConfirmationNotification.java @@ -2,6 +2,7 @@ import com.vaadin.flow.component.html.Span; import life.qbic.datamanager.views.notifications.NotificationDialog; +import life.qbic.datamanager.views.notifications.NotificationLevel; /** * Warns the user that the file will be deleted from the server. @@ -11,7 +12,7 @@ public class PurchaseItemDeletionConfirmationNotification extends NotificationDialog { public PurchaseItemDeletionConfirmationNotification() { - super(Type.WARNING); + super(NotificationLevel.WARNING); withTitle("Offer will be deleted"); withContent(new Span( "Are you sure you want to delete this offer?")); diff --git a/user-interface/src/main/java/life/qbic/datamanager/views/projects/qualityControl/QCItemDeletionConfirmationNotification.java b/user-interface/src/main/java/life/qbic/datamanager/views/projects/qualityControl/QCItemDeletionConfirmationNotification.java index 31b8ab1bad..18ea175ece 100644 --- a/user-interface/src/main/java/life/qbic/datamanager/views/projects/qualityControl/QCItemDeletionConfirmationNotification.java +++ b/user-interface/src/main/java/life/qbic/datamanager/views/projects/qualityControl/QCItemDeletionConfirmationNotification.java @@ -2,6 +2,7 @@ import com.vaadin.flow.component.html.Span; import life.qbic.datamanager.views.notifications.NotificationDialog; +import life.qbic.datamanager.views.notifications.NotificationLevel; /** * Warns the user that the file will be deleted from the server. @@ -11,7 +12,7 @@ public class QCItemDeletionConfirmationNotification extends NotificationDialog { public QCItemDeletionConfirmationNotification() { - super(Type.WARNING); + super(NotificationLevel.WARNING); withTitle("Quality control will be deleted"); withContent(new Span( "Are you sure you want to delete this file?")); diff --git a/user-interface/src/main/resources/application.properties b/user-interface/src/main/resources/application.properties index b352f6da4f..a3ec599fa5 100644 --- a/user-interface/src/main/resources/application.properties +++ b/user-interface/src/main/resources/application.properties @@ -171,7 +171,7 @@ terminology.service.tib.endpoint.search=${TIB_SERVICE_API_SEARCH_ENDPOINT:/ts4ti spring.messages.encoding=UTF-8 spring.messages.cache-duration=1s spring.messages.fallback-to-system-locale=true -spring.messages.basename=messages.error-messages, messages.toast-notifications, messages.dialog-messages +spring.messages.basename=messages.error-messages, messages.toast-notifications, messages.dialog-notifications, messages.dialog-messages # you always have to escape single quotes by another single quote ' -> '' # https://www.mscharhag.com/java/resource-bundle-single-quote-escaping for reference spring.messages.always-use-message-format=true diff --git a/user-interface/src/main/resources/messages/dialog-messages.properties b/user-interface/src/main/resources/messages/dialog-messages.properties index d522b2072d..9686c007b3 100644 --- a/user-interface/src/main/resources/messages/dialog-messages.properties +++ b/user-interface/src/main/resources/messages/dialog-messages.properties @@ -2,9 +2,12 @@ ### Cancel Confirmation # Sometimes you want to support cancel confirmation for dialogs. You can choose to customize the # text shown in the cancel confirmation dialog. +## (dialog-key).cancel-confirmation.title -> the title of the dialog ## (dialog-key).cancel-confirmation.message.type -> can be text or html. MUST BE PROVIDED ## (dialog-key).cancel-confirmation.message.text -> the text or html to display ## (dialog-key).cancel-confirmation.confirm-text -> the text on the button that confirms the cancel operation +############################## + project.create.cancel-confirmation.title=Discard new project creation? project.create.cancel-confirmation.message.type=text project.create.cancel-confirmation.message.text=You will lose all the information entered for this project. diff --git a/user-interface/src/main/resources/messages/dialog-notifications.properties b/user-interface/src/main/resources/messages/dialog-notifications.properties new file mode 100644 index 0000000000..66caa79e06 --- /dev/null +++ b/user-interface/src/main/resources/messages/dialog-notifications.properties @@ -0,0 +1,15 @@ +############### Configuration of dialog text ############### +### Dialog Notifications +# Sometimes you want notifications to show up in dialogs. You can choose to customize the +# text shown in the dialog as well as the level of the notification. +## (dialog-key).notification.title -> The title to show. +## (dialog-key).notification.level -> the level of the notification info, success, warning or error +## (dialog-key).notification.message.type -> can be text or html. MUST BE PROVIDED +## (dialog-key).notification.message.text -> the text or html to display. MUST BE PROVIDED +## (dialog-key).notification.confirm-text -> the text on the button that confirms dialog +############################## +sample-batch.register.failure.title=Didn''t register sample batch. +sample-batch.register.failure.level=error +sample-batch.register.failure.message.type=text +sample-batch.register.failure.message.text=We are sorry! The sample batch registration failed. Please try again. +sample-batch.register.failure.confirm-text=Okay