From 29bb9194a65fe85e61acb6f386c45cdc7f65cfcf Mon Sep 17 00:00:00 2001 From: Stefan Klotz <35995139+StefanKlt@users.noreply.github.com> Date: Fri, 4 Sep 2020 14:08:49 +0200 Subject: [PATCH] Improve and fix texts of confirmation popups in UI (#1002) * fix force action confirm text, add plural wording for multiple assigning Signed-off-by: Stefan Klotz * fix hard coded plural s on DeleteSupport Signed-off-by: Stefan Klotz * fix entity creation and deletion notification i18n Signed-off-by: Stefan Klotz * remove placeholder for optional plural s from UI messages Signed-off-by: Stefan Klotz * renaming Signed-off-by: Stefan Klotz --- .../ui/HawkbitEntityEventListener.java | 2 +- .../details/ArtifactDetailsGrid.java | 4 +- .../artifacts/smtable/SoftwareModuleGrid.java | 6 +-- .../smtype/filter/SMTypeFilterButtons.java | 13 +++-- .../detailslayout/MetaDataWindowGrid.java | 18 +++---- .../EntityModifiedEventPayloadIdentifier.java | 53 +++++++++---------- .../common/event/EventNotificationType.java | 43 +++++++++++++++ .../filterlayout/AbstractFilterButtons.java | 8 +-- .../ui/common/grid/AbstractDsGrid.java | 6 +-- .../ui/common/grid/support/DeleteSupport.java | 43 ++++++++------- .../DeploymentAssignmentSupport.java | 8 +-- ...ributionSetsToTargetAssignmentSupport.java | 19 ++++--- ...lesToDistributionSetAssignmentSupport.java | 7 ++- ...etsToDistributionSetAssignmentSupport.java | 15 ++++-- .../components/NotificationUnreadButton.java | 43 ++++++++------- .../disttype/filter/DSTypeFilterButtons.java | 11 ++-- .../ui/filtermanagement/TargetFilterGrid.java | 6 +-- .../actionhistory/ActionHistoryGrid.java | 4 +- .../dstag/filter/DistributionTagButtons.java | 25 +++++---- .../ui/management/targettable/TargetGrid.java | 4 +- .../filter/TargetTagFilterButtons.java | 9 +++- .../hawkbit/ui/push/HawkbitEventProvider.java | 15 +++--- .../ui/rollout/rollout/RolloutGrid.java | 4 +- .../src/main/resources/messages.properties | 41 ++++++++------ 24 files changed, 253 insertions(+), 154 deletions(-) create mode 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/event/EventNotificationType.java diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/HawkbitEntityEventListener.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/HawkbitEntityEventListener.java index 57999a22e..f824c582e 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/HawkbitEntityEventListener.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/HawkbitEntityEventListener.java @@ -117,7 +117,7 @@ public class HawkbitEntityEventListener { if (eventPayloadIdentifier.shouldBeDeffered()) { notificationUnreadButton.incrementUnreadNotification( - eventPayloadIdentifier.getEventTypeMessageKey(), remoteEventPayload); + eventPayloadIdentifier.getNotificationType(), remoteEventPayload); } else { eventBus.publish(EventTopics.ENTITY_MODIFIED, UI.getCurrent(), remoteEventPayload); } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/details/ArtifactDetailsGrid.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/details/ArtifactDetailsGrid.java index dd0b74639..ee671684f 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/details/ArtifactDetailsGrid.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/details/ArtifactDetailsGrid.java @@ -84,8 +84,8 @@ public class ArtifactDetailsGrid extends AbstractGrid { this.notification = notification; this.artifactManagement = artifactManagement; - this.artifactDeleteSupport = new DeleteSupport<>(this, i18n, notification, - i18n.getMessage("artifact.details.header"), ProxyArtifact::getFilename, this::artifactsDeletionCallback, + this.artifactDeleteSupport = new DeleteSupport<>(this, i18n, notification, "artifact.details.header", + "caption.artifacts", ProxyArtifact::getFilename, this::artifactsDeletionCallback, UIComponentIdProvider.ARTIFACT_DELETE_CONFIRMATION_DIALOG); setFilterSupport( diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleGrid.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleGrid.java index 618611786..b556b567b 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleGrid.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleGrid.java @@ -112,9 +112,9 @@ public class SoftwareModuleGrid extends AbstractGrid(this, i18n, notification, - i18n.getMessage("caption.software.module"), ProxySoftwareModule::getNameAndVersion, - this::deleteSoftwareModules, UIComponentIdProvider.SM_DELETE_CONFIRMATION_DIALOG); + this.swModuleDeleteSupport = new DeleteSupport<>(this, i18n, notification, "caption.software.module", + "caption.softwaremodules", ProxySoftwareModule::getNameAndVersion, this::deleteSoftwareModules, + UIComponentIdProvider.SM_DELETE_CONFIRMATION_DIALOG); setFilterSupport(new FilterSupport<>( new SoftwareModuleDataProvider(softwareModuleManagement, diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/filter/SMTypeFilterButtons.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/filter/SMTypeFilterButtons.java index 5d3ee04ec..b3323aeb1 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/filter/SMTypeFilterButtons.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/filter/SMTypeFilterButtons.java @@ -54,9 +54,9 @@ public class SMTypeFilterButtons extends AbstractTypeFilterButtons { * @param smTypeWindowBuilder * SmTypeWindowBuilder * @param typeFilterLayoutUiState - * TypeFilterLayoutUiState + * TypeFilterLayoutUiState * @param view - * EventView + * EventView */ public SMTypeFilterButtons(final UIEventBus eventBus, final VaadinMessageSource i18n, final UINotification uiNotification, final SpPermissionChecker permChecker, @@ -85,8 +85,13 @@ public class SMTypeFilterButtons extends AbstractTypeFilterButtons { } @Override - protected String getFilterButtonsType() { - return i18n.getMessage("caption.entity.software.module.type"); + protected String getMessageKeyEntityTypeSing() { + return "caption.entity.software.module.type"; + } + + @Override + protected String getMessageKeyEntityTypePlur() { + return "caption.entity.software.module.types"; } @Override diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/MetaDataWindowGrid.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/MetaDataWindowGrid.java index cb7931d21..a0fa5625d 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/MetaDataWindowGrid.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/MetaDataWindowGrid.java @@ -29,7 +29,7 @@ import org.vaadin.spring.events.EventBus.UIEventBus; * Grid for MetaData pop up layout. * * @param - * Generic type + * Generic type */ public class MetaDataWindowGrid extends AbstractGrid implements MasterEntityAwareComponent { private static final long serialVersionUID = 1L; @@ -44,17 +44,17 @@ public class MetaDataWindowGrid extends AbstractGrid implem * Constructor for MetaDataWindowGrid * * @param i18n - * VaadinMessageSource + * VaadinMessageSource * @param eventBus - * UIEventBus + * UIEventBus * @param permissionChecker - * SpPermissionChecker + * SpPermissionChecker * @param notification - * UINotification + * UINotification * @param dataProvider - * AbstractMetaDataDataProvider for filter support + * AbstractMetaDataDataProvider for filter support * @param itemsDeletionCallback - * Grid item deletion Call back for event listener + * Grid item deletion Call back for event listener * */ public MetaDataWindowGrid(final VaadinMessageSource i18n, final UIEventBus eventBus, @@ -63,8 +63,8 @@ public class MetaDataWindowGrid extends AbstractGrid implem final Predicate> itemsDeletionCallback) { super(i18n, eventBus, permissionChecker); - this.metaDataDeleteSupport = new DeleteSupport<>(this, i18n, notification, i18n.getMessage("caption.metadata"), - ProxyMetaData::getKey, itemsDeletionCallback, + this.metaDataDeleteSupport = new DeleteSupport<>(this, i18n, notification, "caption.metadata", + "caption.metadata.plur", ProxyMetaData::getKey, itemsDeletionCallback, UIComponentIdProvider.METADATA_DELETE_CONFIRMATION_DIALOG); setFilterSupport(new FilterSupport<>(dataProvider)); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/event/EntityModifiedEventPayloadIdentifier.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/event/EntityModifiedEventPayloadIdentifier.java index ab432f8b0..1f4bb49d1 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/event/EntityModifiedEventPayloadIdentifier.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/event/EntityModifiedEventPayloadIdentifier.java @@ -12,7 +12,6 @@ import java.util.Objects; import org.eclipse.hawkbit.ui.common.data.proxies.ProxyIdentifiableEntity; import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload.EntityModifiedEventType; -import org.springframework.util.StringUtils; import com.google.common.base.MoreObjects; @@ -23,15 +22,15 @@ public class EntityModifiedEventPayloadIdentifier { private final Class parentType; private final Class entityType; private final EntityModifiedEventType modifiedEventType; - private final String eventTypeMessageKey; + private final EventNotificationType notificationType; /** * Constructor for EntityModifiedEventPayloadIdentifier * * @param entityType - * Event payload of identifiable entity type + * Event payload of identifiable entity type * @param modifiedEventType - * EntityModifiedEventType + * EntityModifiedEventType */ public EntityModifiedEventPayloadIdentifier(final Class entityType, final EntityModifiedEventType modifiedEventType) { @@ -42,26 +41,26 @@ public class EntityModifiedEventPayloadIdentifier { * Constructor for EntityModifiedEventPayloadIdentifier * * @param entityType - * Event payload of identifiable entity type + * Event payload of identifiable entity type * @param modifiedEventType - * EntityModifiedEventType - * @param eventTypeMessageKey - * Key for event type message + * EntityModifiedEventType + * @param notificationType + * type of notification that is triggered by the event */ public EntityModifiedEventPayloadIdentifier(final Class entityType, - final EntityModifiedEventType modifiedEventType, final String eventTypeMessageKey) { - this(null, entityType, modifiedEventType, eventTypeMessageKey); + final EntityModifiedEventType modifiedEventType, final EventNotificationType notificationType) { + this(null, entityType, modifiedEventType, notificationType); } /** * Constructor for EntityModifiedEventPayloadIdentifier * * @param parentType - * Event payload of identifiable parent type + * Event payload of identifiable parent type * @param entityType - * Event payload of identifiable entity type + * Event payload of identifiable entity type * @param modifiedEventType - * EntityModifiedEventType + * EntityModifiedEventType */ public EntityModifiedEventPayloadIdentifier(final Class parentType, final Class entityType, @@ -73,21 +72,21 @@ public class EntityModifiedEventPayloadIdentifier { * Constructor for EntityModifiedEventPayloadIdentifier * * @param parentType - * Event payload of identifiable parent type + * Event payload of identifiable parent type * @param entityType - * Event payload of identifiable entity type + * Event payload of identifiable entity type * @param modifiedEventType - * EntityModifiedEventType - * @param eventTypeMessageKey - * Key for event type message + * EntityModifiedEventType + * @param notificationType + * type of notification that is triggered by the event */ public EntityModifiedEventPayloadIdentifier(final Class parentType, final Class entityType, final EntityModifiedEventType modifiedEventType, - final String eventTypeMessageKey) { + final EventNotificationType notificationType) { this.parentType = parentType; this.entityType = entityType; this.modifiedEventType = modifiedEventType; - this.eventTypeMessageKey = eventTypeMessageKey; + this.notificationType = notificationType; } /** @@ -112,10 +111,10 @@ public class EntityModifiedEventPayloadIdentifier { } /** - * @return Key of event type message + * @return type of notification */ - public String getEventTypeMessageKey() { - return eventTypeMessageKey; + public EventNotificationType getNotificationType() { + return notificationType; } /** @@ -123,14 +122,14 @@ public class EntityModifiedEventPayloadIdentifier { * false */ public boolean shouldBeDeffered() { - return !StringUtils.isEmpty(eventTypeMessageKey); + return notificationType != null; } /** * Static method for constructor EntityModifiedEventPayloadIdentifier * * @param eventPayload - * EntityModifiedEventPayload + * EntityModifiedEventPayload * * @return Payload identifier containing information about an modified event */ @@ -141,7 +140,7 @@ public class EntityModifiedEventPayloadIdentifier { @Override public int hashCode() { - // eventTypeMessageKey is omitted intentionally, because it is not + // notificationType is omitted intentionally, because it is not // relevant for event identification return getParentType() != null ? Objects.hash(getParentType().getName(), getEntityType().getName(), modifiedEventType) @@ -158,7 +157,7 @@ public class EntityModifiedEventPayloadIdentifier { } final EntityModifiedEventPayloadIdentifier other = (EntityModifiedEventPayloadIdentifier) obj; - // eventTypeMessageKey is omitted intentionally, because it is not + // notificationType is omitted intentionally, because it is not // relevant for event identification return Objects.equals(this.getParentType(), other.getParentType()) && Objects.equals(this.getEntityType(), other.getEntityType()) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/event/EventNotificationType.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/event/EventNotificationType.java new file mode 100644 index 000000000..13d438f56 --- /dev/null +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/event/EventNotificationType.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2020 Bosch.IO GmbH and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.eclipse.hawkbit.ui.common.event; + +/** + * Types of event notification that can be displayed in the UI + */ +public enum EventNotificationType { + // Target + TARGET_CREATED("event.notifcation.target.created", "event.notifcation.targets.created"), TARGET_DELETED( + "event.notifcation.target.deleted", "event.notifcation.targets.deleted"), + // Distribution set + DISTRIBUTIONSET_CREATED("event.notifcation.distributionset.created", + "event.notifcation.distributionsets.created"), DISTRIBUTIONSET_DELETED( + "event.notifcation.distributionset.deleted", "event.notifcation.distributionsets.deleted"), + // Software module + SOFTWAREMODULE_CREATED("event.notifcation.softwaremodule.created", + "event.notifcation.softwaremodules.created"), SOFTWAREMODULE_DELETED( + "event.notifcation.softwaremodule.deleted", "event.notifcation.softwaremodules.deleted"); + + private final String notificationMessageKeySing; + private final String notificationMessageKeyPlur; + + EventNotificationType(final String notificationMessageKeySing, final String notificationMessageKeyPlur) { + this.notificationMessageKeySing = notificationMessageKeySing; + this.notificationMessageKeyPlur = notificationMessageKeyPlur; + } + + public String getNotificationMessageKeySing() { + return notificationMessageKeySing; + } + + public String getNotificationMessageKeyPlur() { + return notificationMessageKeyPlur; + } + +} diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/filterlayout/AbstractFilterButtons.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/filterlayout/AbstractFilterButtons.java index ad1637775..9a1d21eec 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/filterlayout/AbstractFilterButtons.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/filterlayout/AbstractFilterButtons.java @@ -57,8 +57,8 @@ public abstract class AbstractFilterButtons exte final UINotification notification, final SpPermissionChecker permChecker) { super(i18n, eventBus, permChecker); - this.filterButtonDeleteSupport = new DeleteSupport<>(this, i18n, notification, getFilterButtonsType(), - ProxyFilterButton::getName, this::deleteFilterButtons, + this.filterButtonDeleteSupport = new DeleteSupport<>(this, i18n, notification, getMessageKeyEntityTypeSing(), + getMessageKeyEntityTypePlur(), ProxyFilterButton::getName, this::deleteFilterButtons, UIComponentIdProvider.FILTER_BUTTON_DELETE_CONFIRMATION_DIALOG); } @@ -75,7 +75,9 @@ public abstract class AbstractFilterButtons exte addStyleName(ValoTheme.TABLE_COMPACT); } - protected abstract String getFilterButtonsType(); + protected abstract String getMessageKeyEntityTypeSing(); + + protected abstract String getMessageKeyEntityTypePlur(); protected abstract boolean deleteFilterButtons(Collection filterButtonsToDelete); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/grid/AbstractDsGrid.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/grid/AbstractDsGrid.java index 8cb93b5f7..d7bc25e4e 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/grid/AbstractDsGrid.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/grid/AbstractDsGrid.java @@ -71,9 +71,9 @@ public abstract class AbstractDsGrid extends AbstractGrid(this, i18n, notification, - i18n.getMessage("distribution.details.header"), ProxyDistributionSet::getNameVersion, - this::deleteDistributionSets, UIComponentIdProvider.DS_DELETE_CONFIRMATION_DIALOG); + this.distributionDeleteSupport = new DeleteSupport<>(this, i18n, notification, "distribution.details.header", + "caption.distributionsets", ProxyDistributionSet::getNameVersion, this::deleteDistributionSets, + UIComponentIdProvider.DS_DELETE_CONFIRMATION_DIALOG); } @Override diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/grid/support/DeleteSupport.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/grid/support/DeleteSupport.java index 304519f25..3fc2da023 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/grid/support/DeleteSupport.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/grid/support/DeleteSupport.java @@ -38,7 +38,8 @@ public class DeleteSupport { private final Grid grid; private final VaadinMessageSource i18n; - private final String entityType; + private final String localizedEntityTypeSing; + private final String localizedEntityTypePlur; private final UINotification notification; private final Predicate> itemsDeletionCallback; private final String deletionWindowId; @@ -50,26 +51,30 @@ public class DeleteSupport { * Constructor for DeleteSupport * * @param grid - * Vaadin Grid + * Vaadin Grid * @param i18n - * VaadinMessageSource + * VaadinMessageSource * @param notification - * UINotification - * @param entityType - * Entity type + * UINotification + * @param messageKeyEntityTypeSing + * message key for the singular entity name for i18n + * @param messageKeyEntityTypePlur + * message key for the plural entity name for i18n * @param entityNameGenerator - * Entity name generator + * Entity name generator * @param itemsDeletionCallback - * Callback for delete event + * Callback for delete event * @param deletionWindowId - * Id of deletion Grid window + * Id of deletion Grid window */ public DeleteSupport(final Grid grid, final VaadinMessageSource i18n, final UINotification notification, - final String entityType, final Function entityNameGenerator, - final Predicate> itemsDeletionCallback, final String deletionWindowId) { + final String messageKeyEntityTypeSing, final String messageKeyEntityTypePlur, + final Function entityNameGenerator, final Predicate> itemsDeletionCallback, + final String deletionWindowId) { this.grid = grid; this.i18n = i18n; - this.entityType = entityType; + this.localizedEntityTypeSing = i18n.getMessage(messageKeyEntityTypeSing); + this.localizedEntityTypePlur = i18n.getMessage(messageKeyEntityTypePlur); this.entityNameGenerator = entityNameGenerator; this.notification = notification; this.itemsDeletionCallback = itemsDeletionCallback; @@ -80,14 +85,15 @@ public class DeleteSupport { * Open confirmation pop up window for delete action * * @param clickedItem - * Item selected for deletion + * Item selected for deletion */ public void openConfirmationWindowDeleteAction(final T clickedItem) { final Set itemsToBeDeleted = getItemsForDeletion(clickedItem); final int itemsToBeDeletedSize = itemsToBeDeleted.size(); final String clickedItemName = entityNameGenerator.apply(clickedItem); - final String confirmationCaption = i18n.getMessage("caption.entity.delete.action.confirmbox", entityType); + final String confirmationCaption = i18n.getMessage("caption.entity.delete.action.confirmbox", + localizedEntityTypeSing); final StringBuilder confirmationQuestionBuilder = new StringBuilder(); confirmationQuestionBuilder.append(createDeletionText(UIMessageIdProvider.MESSAGE_CONFIRM_DELETE_ENTITY, @@ -131,9 +137,9 @@ public class DeleteSupport { private String createDeletionText(final String messageId, final int itemsToBeDeletedSize, final String clickedItemName) { if (itemsToBeDeletedSize == 1) { - return i18n.getMessage(messageId, entityType, clickedItemName, ""); + return i18n.getMessage(messageId, localizedEntityTypeSing, clickedItemName); } else { - return i18n.getMessage(messageId, itemsToBeDeletedSize, entityType, "s"); + return i18n.getMessage(messageId, itemsToBeDeletedSize, localizedEntityTypePlur); } } @@ -157,7 +163,8 @@ public class DeleteSupport { } catch (final RuntimeException ex) { final String itemsToBeDeletedIds = itemsToBeDeleted.stream().map(ProxyIdentifiableEntity::getId) .map(String::valueOf).collect(Collectors.joining(",")); - LOG.warn("Deletion of {} with ids '{}' failed: {}", entityType, itemsToBeDeletedIds, ex.getMessage()); + LOG.warn("Deletion of {} with ids '{}' failed: {}", localizedEntityTypeSing, itemsToBeDeletedIds, + ex.getMessage()); } if (isDeletionSuccessfull) { @@ -171,7 +178,7 @@ public class DeleteSupport { * Sets the question to confirm the delete action * * @param confirmationQuestionDetailsGenerator - * Confirmation detail for delete action + * Confirmation detail for delete action */ public void setConfirmationQuestionDetailsGenerator( final Function confirmationQuestionDetailsGenerator) { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/grid/support/assignment/DeploymentAssignmentSupport.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/grid/support/assignment/DeploymentAssignmentSupport.java index 0794ee6b2..a36831c9c 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/grid/support/assignment/DeploymentAssignmentSupport.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/grid/support/assignment/DeploymentAssignmentSupport.java @@ -55,11 +55,11 @@ public abstract class DeploymentAssignmentSupport 1) { return i18n.getMessage(UIMessageIdProvider.MESSAGE_CONFIRM_ASSIGN_MULTIPLE_ENTITIES_TO_ENTITY, - sourceItemsToAssignCount, sourceEntityType(), targetEntityType(), targetItemName); + sourceItemsToAssignCount, sourceEntityTypePlur(), targetEntityType(), targetItemName); } return i18n.getMessage(UIMessageIdProvider.MESSAGE_CONFIRM_ASSIGN_MULTIPLE_ENTITIES_TO_ENTITY, - sourceEntityType(), sourceItemNames.get(0), targetEntityType(), targetItemName); + sourceEntityTypeSing(), sourceItemNames.get(0), targetEntityType(), targetItemName); } private ConfirmationDialog createConfirmationWindow(final String confirmationMessage, final Component content, @@ -73,7 +73,9 @@ public abstract class DeploymentAssignmentSupport remotelyOriginatedEventsStore; + private final transient Map remotelyOriginatedEventsStore; /** * Constructor. @@ -142,15 +143,18 @@ public class NotificationUnreadButton extends Button { return notificationsLayout; } - private Label buildEventNotificationLabel(final Entry remotelyOriginatedEvent) { + private Label buildEventNotificationLabel( + final Entry remotelyOriginatedEvent) { + final EventNotificationType notificationType = remotelyOriginatedEvent.getKey(); final int modifiedEntitiesCount = remotelyOriginatedEvent.getValue().getEntityIds().size(); - final StringBuilder notificationLabelBuilder = new StringBuilder(String.valueOf(modifiedEntitiesCount)); - - notificationLabelBuilder.append(" "); - final String pluralPrefix = modifiedEntitiesCount > 1 ? "s" : ""; - notificationLabelBuilder.append(i18n.getMessage(remotelyOriginatedEvent.getKey(), pluralPrefix)); - - return new Label(notificationLabelBuilder.toString()); + String message = ""; + if (modifiedEntitiesCount == 1) { + message = i18n.getMessage(notificationType.getNotificationMessageKeySing()); + } else { + message = i18n.getMessage(notificationType.getNotificationMessageKeyPlur(), + String.valueOf(modifiedEntitiesCount)); + } + return new Label(message); } private void dispatchEntityModifiedEvents() { @@ -167,21 +171,20 @@ public class NotificationUnreadButton extends Button { /** * Increments the unread notifications * - * @param entityNotificationMsgKey - * Key value for notification message + * @param notificationType + * notification type for message * @param eventPayload - * EntityModifiedEventPayload + * EntityModifiedEventPayload */ - public void incrementUnreadNotification(final String entityNotificationMsgKey, + public void incrementUnreadNotification(final EventNotificationType notificationType, final EntityModifiedEventPayload eventPayload) { - remotelyOriginatedEventsStore.merge(entityNotificationMsgKey, eventPayload, - (oldEventPayload, newEventPayload) -> { - // currently we do not support parent aware differed events, - // thus ignoring parentId of the incoming eventPayload - oldEventPayload.getEntityIds().addAll(newEventPayload.getEntityIds()); + remotelyOriginatedEventsStore.merge(notificationType, eventPayload, (oldEventPayload, newEventPayload) -> { + // currently we do not support parent aware differed events, + // thus ignoring parentId of the incoming eventPayload + oldEventPayload.getEntityIds().addAll(newEventPayload.getEntityIds()); - return oldEventPayload; - }); + return oldEventPayload; + }); unreadNotificationCounter += eventPayload.getEntityIds().size(); refreshCaption(); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/filter/DSTypeFilterButtons.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/filter/DSTypeFilterButtons.java index dd47cd1f9..0c74c0a01 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/filter/DSTypeFilterButtons.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/filter/DSTypeFilterButtons.java @@ -34,8 +34,6 @@ import com.vaadin.ui.Window; public class DSTypeFilterButtons extends AbstractTypeFilterButtons { private static final long serialVersionUID = 1L; - private static final String DS_SET_TYPE = "Distribution set Type"; - private final transient DistributionSetTypeManagement distributionSetTypeManagement; private final transient DsTypeWindowBuilder dsTypeWindowBuilder; private final transient SystemManagement systemManagement; @@ -81,8 +79,13 @@ public class DSTypeFilterButtons extends AbstractTypeFilterButtons { } @Override - protected String getFilterButtonsType() { - return DS_SET_TYPE; + protected String getMessageKeyEntityTypeSing() { + return "caption.entity.distribution.type"; + } + + @Override + protected String getMessageKeyEntityTypePlur() { + return "caption.entity.distribution.types"; } @Override diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterGrid.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterGrid.java index 2cb1c4347..9e049d33f 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterGrid.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterGrid.java @@ -99,9 +99,9 @@ public class TargetFilterGrid extends AbstractGrid(this, i18n, notification, - i18n.getMessage("caption.filter.custom"), ProxyTargetFilterQuery::getName, - this::targetFiltersDeletionCallback, UIComponentIdProvider.TARGET_FILTER_DELETE_CONFIRMATION_DIALOG); + this.targetFilterDeleteSupport = new DeleteSupport<>(this, i18n, notification, "caption.filter.custom", + "caption.filter.custom.plur", ProxyTargetFilterQuery::getName, this::targetFiltersDeletionCallback, + UIComponentIdProvider.TARGET_FILTER_DELETE_CONFIRMATION_DIALOG); setFilterSupport(new FilterSupport<>(new TargetFilterQueryDataProvider(targetFilterQueryManagement, new TargetFilterQueryToProxyTargetFilterMapper()))); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryGrid.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryGrid.java index d0c72dea5..7189c6250 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryGrid.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryGrid.java @@ -124,7 +124,7 @@ public class ActionHistoryGrid extends AbstractGrid { * Map entity id to proxy entity * * @param entityId - * Entity id + * Entity id * * @return Proxy action */ @@ -290,7 +290,7 @@ public class ActionHistoryGrid extends AbstractGrid { */ private void confirmAndForceAction(final Long actionId) { final ConfirmationDialog confirmDialog = new ConfirmationDialog(i18n, - i18n.getMessage(UIMessageIdProvider.BUTTON_OK), i18n.getMessage(UIMessageIdProvider.BUTTON_CANCEL), + i18n.getMessage("caption.force.action.confirmbox"), i18n.getMessage("message.force.action.confirm"), ok -> { if (ok) { forceActiveAction(actionId); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/filter/DistributionTagButtons.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/filter/DistributionTagButtons.java index 37b620d79..c38e6044d 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/filter/DistributionTagButtons.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/filter/DistributionTagButtons.java @@ -46,21 +46,21 @@ public class DistributionTagButtons extends AbstractTagFilterButtons { * Constructor for DistributionTagButtons * * @param eventBus - * UIEventBus + * UIEventBus * @param i18n - * VaadinMessageSource + * VaadinMessageSource * @param uiNotification - * UINotification + * UINotification * @param permChecker - * SpPermissionChecker + * SpPermissionChecker * @param distributionSetTagManagement - * DistributionSetTagManagement + * DistributionSetTagManagement * @param distributionSetManagement - * DistributionSetManagement + * DistributionSetManagement * @param dsTagWindowBuilder - * DsTagWindowBuilder + * DsTagWindowBuilder * @param distributionTagLayoutUiState - * TagFilterLayoutUiState + * TagFilterLayoutUiState */ public DistributionTagButtons(final UIEventBus eventBus, final VaadinMessageSource i18n, final UINotification uiNotification, final SpPermissionChecker permChecker, @@ -91,8 +91,13 @@ public class DistributionTagButtons extends AbstractTagFilterButtons { } @Override - protected String getFilterButtonsType() { - return i18n.getMessage(UIMessageIdProvider.CAPTION_DISTRIBUTION_TAG); + protected String getMessageKeyEntityTypeSing() { + return UIMessageIdProvider.CAPTION_DISTRIBUTION_TAG; + } + + @Override + protected String getMessageKeyEntityTypePlur() { + return "caption.entity.distribution.tags"; } @Override diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetGrid.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetGrid.java index 1253aa09a..f7ac75ce5 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetGrid.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetGrid.java @@ -147,8 +147,8 @@ public class TargetGrid extends AbstractGrid(this, i18n, notification, - i18n.getMessage("target.details.header"), ProxyTarget::getName, this::deleteTargets, + this.targetDeleteSupport = new DeleteSupport<>(this, i18n, notification, "target.details.header", + "caption.targets", ProxyTarget::getName, this::deleteTargets, UIComponentIdProvider.TARGET_DELETE_CONFIRMATION_DIALOG); this.pinSupport = new PinSupport<>(this::refreshItem, this::publishPinningChangedEvent, diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/filter/TargetTagFilterButtons.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/filter/TargetTagFilterButtons.java index ef7e9a7d7..0756fa198 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/filter/TargetTagFilterButtons.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/filter/TargetTagFilterButtons.java @@ -67,8 +67,13 @@ public class TargetTagFilterButtons extends AbstractTagFilterButtons { } @Override - protected String getFilterButtonsType() { - return i18n.getMessage(UIMessageIdProvider.CAPTION_TARGET_TAG); + protected String getMessageKeyEntityTypeSing() { + return UIMessageIdProvider.CAPTION_TARGET_TAG; + } + + @Override + protected String getMessageKeyEntityTypePlur() { + return "caption.entity.target.tags"; } @Override diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/HawkbitEventProvider.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/HawkbitEventProvider.java index 97e6f4de6..a563b5170 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/HawkbitEventProvider.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/HawkbitEventProvider.java @@ -48,6 +48,7 @@ import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTargetFilterQuery; import org.eclipse.hawkbit.ui.common.data.proxies.ProxyType; import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload.EntityModifiedEventType; import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayloadIdentifier; +import org.eclipse.hawkbit.ui.common.event.EventNotificationType; import org.eclipse.hawkbit.ui.push.event.ActionChangedEvent; import org.eclipse.hawkbit.ui.push.event.RolloutChangedEvent; import org.eclipse.hawkbit.ui.push.event.RolloutGroupChangedEvent; @@ -64,29 +65,27 @@ public class HawkbitEventProvider implements UIEventProvider { static { EVENTS.put(TargetCreatedEvent.class, new EntityModifiedEventPayloadIdentifier(ProxyTarget.class, - EntityModifiedEventType.ENTITY_ADDED, "target.created.event.container.notifcation.message")); + EntityModifiedEventType.ENTITY_ADDED, EventNotificationType.TARGET_CREATED)); EVENTS.put(TargetUpdatedEvent.class, new EntityModifiedEventPayloadIdentifier(ProxyTarget.class, EntityModifiedEventType.ENTITY_UPDATED)); EVENTS.put(TargetDeletedEvent.class, new EntityModifiedEventPayloadIdentifier(ProxyTarget.class, - EntityModifiedEventType.ENTITY_REMOVED, "target.deleted.event.container.notifcation.message")); + EntityModifiedEventType.ENTITY_REMOVED, EventNotificationType.TARGET_DELETED)); EVENTS.put(DistributionSetCreatedEvent.class, new EntityModifiedEventPayloadIdentifier(ProxyDistributionSet.class, - EntityModifiedEventType.ENTITY_ADDED, - "distribution.created.event.container.notifcation.message")); + EntityModifiedEventType.ENTITY_ADDED, EventNotificationType.DISTRIBUTIONSET_CREATED)); EVENTS.put(DistributionSetUpdatedEvent.class, new EntityModifiedEventPayloadIdentifier( ProxyDistributionSet.class, EntityModifiedEventType.ENTITY_UPDATED)); EVENTS.put(DistributionSetDeletedEvent.class, new EntityModifiedEventPayloadIdentifier(ProxyDistributionSet.class, - EntityModifiedEventType.ENTITY_REMOVED, - "distribution.deleted.event.container.notifcation.message")); + EntityModifiedEventType.ENTITY_REMOVED, EventNotificationType.DISTRIBUTIONSET_DELETED)); EVENTS.put(SoftwareModuleCreatedEvent.class, new EntityModifiedEventPayloadIdentifier(ProxySoftwareModule.class, - EntityModifiedEventType.ENTITY_ADDED, "software.module.created.event.container.notifcation.message")); + EntityModifiedEventType.ENTITY_ADDED, EventNotificationType.SOFTWAREMODULE_CREATED)); EVENTS.put(SoftwareModuleUpdatedEvent.class, new EntityModifiedEventPayloadIdentifier(ProxySoftwareModule.class, EntityModifiedEventType.ENTITY_UPDATED)); EVENTS.put(SoftwareModuleDeletedEvent.class, new EntityModifiedEventPayloadIdentifier(ProxySoftwareModule.class, - EntityModifiedEventType.ENTITY_REMOVED, "software.module.deleted.event.container.notifcation.message")); + EntityModifiedEventType.ENTITY_REMOVED, EventNotificationType.SOFTWAREMODULE_DELETED)); EVENTS.put(TargetTagCreatedEvent.class, new EntityModifiedEventPayloadIdentifier(ProxyTarget.class, ProxyTag.class, EntityModifiedEventType.ENTITY_ADDED)); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutGrid.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutGrid.java index b2466c936..87beb6315 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutGrid.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutGrid.java @@ -127,8 +127,8 @@ public class RolloutGrid extends AbstractGrid { this::mapIdToProxyEntity, this::getSelectedEntityIdFromUiState, this::setSelectedEntityIdToUiState)); getSelectionSupport().disableSelection(); - this.rolloutDeleteSupport = new DeleteSupport<>(this, i18n, uiNotification, - i18n.getMessage(ROLLOUT_CAPTION_MSG_KEY), ProxyRollout::getName, this::deleteRollout, + this.rolloutDeleteSupport = new DeleteSupport<>(this, i18n, uiNotification, ROLLOUT_CAPTION_MSG_KEY, + "caption.rollouts", ProxyRollout::getName, this::deleteRollout, UIComponentIdProvider.ROLLOUT_DELETE_CONFIRMATION_DIALOG); this.rolloutDeleteSupport.setConfirmationQuestionDetailsGenerator(this::getDeletionDetails); diff --git a/hawkbit-ui/src/main/resources/messages.properties b/hawkbit-ui/src/main/resources/messages.properties index f3d4208d1..c7d7cd04d 100644 --- a/hawkbit-ui/src/main/resources/messages.properties +++ b/hawkbit-ui/src/main/resources/messages.properties @@ -83,18 +83,18 @@ header.action.delete=Delete header.status=Status # event container -target.created.event.container.notifcation.message=target{0} created -target.deleted.event.container.notifcation.message=target{0} deleted -distribution.created.event.container.notifcation.message=distribution set{0} created -distribution.deleted.event.container.notifcation.message=distribution set{0} deleted -target.tag.created.event.container.notifcation.message=target tag{0} created -target.tag.deleted.event.container.notifcation.message=target tag{0} deleted -target.tag.updated.event.container.notifcation.message=target tag{0} changed -software.module.created.event.container.notifcation.message=software module{0} created -software.module.deleted.event.container.notifcation.message=software module{0} deleted -distribution.set.tag.created.event.container.notifcation.message=distribution set tag{0} created -distribution.set.tag.deleted.event.container.notifcation.message=distribution set tag{0} deleted -distribution.set.tag.updated.event.container.notifcation.message=distribution set tag{0} changed +event.notifcation.target.created = 1 target created +event.notifcation.target.deleted = 1 target deleted +event.notifcation.targets.created = {0} targets created +event.notifcation.targets.deleted = {0} targets deleted +event.notifcation.distributionset.created = 1 distribution set created +event.notifcation.distributionset.deleted = 1 distribution set deleted +event.notifcation.distributionsets.created = {0} distribution sets created +event.notifcation.distributionsets.deleted = {0} distribution sets deleted +event.notifcation.softwaremodule.created = 1 software module created +event.notifcation.softwaremodule.deleted = 1 software module deleted +event.notifcation.softwaremodules.created = {0} software modules created +event.notifcation.softwaremodules.deleted = {0} software modules deleted # Captions prefix with - caption caption.filter.by.type = Filter by type @@ -371,8 +371,8 @@ tooltip.in.time = In Time message.save.success = {0} saved successfully message.save.fail = {0} could not be saved, possibly due to invalid user input message.update.success = {0} updated successfully -message.delete.success = {0} {1}{2} deleted successfully -message.delete.fail = {0} {1}{2} deletion failed +message.delete.success = {0} {1} deleted successfully +message.delete.fail = {0} {1} deletion failed message.dist.pending.action = Target {0} is already assigned with distribution {1} . Pending for action message.empty.target.tags= No Tags Created message.empty.disttype.tags = No Distribution type tags created @@ -767,16 +767,27 @@ rollout.not.exists=Rollout {0} does not exist. Maybe the rollout was deleted. color.not.exists=There is no mapping for the provided colour {0} caption.entity.target.tag = Target Tag +caption.entity.target.tags = Target Tags caption.entity.distribution.tag = Distribution Tag +caption.entity.distribution.tags = Distribution Tags caption.entity.distribution.type = Distribution set Type +caption.entity.distribution.types = Distribution set Types caption.entity.software.module.type = Software Module Type +caption.entity.software.module.types = Software Module Types validator.textfield.min.length = Please enter a text consisting of at least one and a maximum of {0} characters. caption.entity.delete.action.confirmbox = Confirm Deletion -message.confirm.delete.entity = Are you sure you want to delete {0} {1}{2}? +message.confirm.delete.entity = Are you sure you want to delete {0} {1}? caption.entity.assign.action.confirmbox = Confirm Assignment message.confirm.assign.multiple.entities.to.entity = Are you sure you want to assign {0} {1} to {2} {3}? +caption.distributionsets = Distribution sets +caption.softwaremodules = Software Modules +caption.targets = Targets +caption.artifacts = Artifacts +caption.metadata.plur = Metadata +caption.rollouts = Rollouts +caption.filter.custom.plur = Custom Filters # character descriptions character.whitespace = whitespace