Skip to content

Commit

Permalink
Feature invalidation of distribution sets [UI part] (#1176)
Browse files Browse the repository at this point in the history
* Visualization of action/button invalidate DistributionSet

Signed-off-by: Markus Block <[email protected]>

* introduced two dialogs to confirm ds invalidation

Signed-off-by: Markus Block <[email protected]>

* fixed dialog titles appear centered and added manamgement classes

Signed-off-by: Markus Block <[email protected]>

* retrieving affected entities from repository

Signed-off-by: Markus Block <[email protected]>

* considered multiselection for invalidating dist sets

Signed-off-by: Markus Block <[email protected]>

* adapt style and tooltip of invalid distributions in grid

Signed-off-by: Markus Block <[email protected]>

* showing errors for actions not allowed for invalidate DS

Signed-off-by: Markus Block <[email protected]>

* enhanced error message with dist name and version

Signed-off-by: Markus Block <[email protected]>

* added ids to the labels to be used in tests

Signed-off-by: Markus Block <[email protected]>

* added support for overwriting entity specific edit behaviour

Signed-off-by: Markus Block <[email protected]>

* Fixed incorrect label for cancelled action due to invalidation of ds in
a rollout

Signed-off-by: Markus Block <[email protected]>

* Fixed error notification to not show "please try again" for an invalid
DS

Signed-off-by: Markus Block <[email protected]>

* fixed typo

Signed-off-by: Markus Block <[email protected]>

* fixed Sonar findings

Signed-off-by: Markus Block <[email protected]>

* remove DS of a copied Rollout in case the DS is invalidated

Signed-off-by: Markus Block <[email protected]>

* changed icon of RolloutActionStatus in case of stopped Rollout because
of invalidation of DS and DS wasn't yet assigned to target. This is to
distinguish from the case of not assigned DS because of duplicate DS
assignemnt

Signed-off-by: Markus Block <[email protected]>

* Prevent editing Metadata of invalid DS

Signed-off-by: Markus Block <[email protected]>

* show DS as invalidated in Rollout view

Signed-off-by: Markus Block <[email protected]>

* incorporated code review remarks

Signed-off-by: Markus Block <[email protected]>

* invalidated DS should be removed from the list of DS to be invalidated

Signed-off-by: Markus Block <[email protected]>

* fixed missing code due to merge

Signed-off-by: Markus Block <[email protected]>

* Fixed compile error due to rebase

Signed-off-by: Markus Block <[email protected]>
  • Loading branch information
blomark authored Oct 1, 2021
1 parent 825cb64 commit 56e4066
Show file tree
Hide file tree
Showing 34 changed files with 928 additions and 93 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.eclipse.hawkbit.ui.error.HawkbitUIErrorHandler;
import org.eclipse.hawkbit.ui.error.extractors.ConstraintViolationErrorExtractor;
import org.eclipse.hawkbit.ui.error.extractors.EntityNotFoundErrorExtractor;
import org.eclipse.hawkbit.ui.error.extractors.InvalidDistributionSetErrorExtractor;
import org.eclipse.hawkbit.ui.error.extractors.UiErrorDetailsExtractor;
import org.eclipse.hawkbit.ui.error.extractors.UploadErrorExtractor;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
Expand Down Expand Up @@ -49,7 +50,7 @@ public class MgmtUiConfiguration {

/**
* Permission checker for UI.
*
*
* @param permissionService
* PermissionService
*
Expand All @@ -63,7 +64,7 @@ SpPermissionChecker spPermissionChecker(final PermissionService permissionServic

/**
* Utility for Vaadin messages source.
*
*
* @param source
* Delegate MessageSource
*
Expand All @@ -77,7 +78,7 @@ VaadinMessageSource messageSourceVaadin(final MessageSource source) {

/**
* Localized system message provider bean.
*
*
* @param uiProperties
* UiProperties
* @param i18n
Expand All @@ -93,12 +94,12 @@ SystemMessagesProvider systemMessagesProvider(final UiProperties uiProperties, f

/**
* UI Error handler bean.
*
*
* @param i18n
* VaadinMessageSource
* @param uiErrorDetailsExtractor
* ui error details extractors
*
*
* @return UI Error handler
*/
@Bean
Expand All @@ -110,7 +111,7 @@ ErrorHandler uiErrorHandler(final VaadinMessageSource i18n,

/**
* UI Upload Error details extractor bean.
*
*
* @return UI Upload Error details extractor
*/
@Bean
Expand All @@ -120,7 +121,7 @@ UiErrorDetailsExtractor uploadErrorExtractor() {

/**
* UI ConstraintViolation Error details extractor bean.
*
*
* @param i18n
* VaadinMessageSource
* @return UI ConstraintViolation Error details extractor
Expand All @@ -132,7 +133,7 @@ UiErrorDetailsExtractor constraintViolationErrorExtractor(final VaadinMessageSou

/**
* UI Entity not found Error details extractor bean.
*
*
* @param i18n
* VaadinMessageSource
* @return UI EntityNotFound Error details extractor
Expand All @@ -142,6 +143,19 @@ UiErrorDetailsExtractor entityNotFoundErrorExtractor(final VaadinMessageSource i
return new EntityNotFoundErrorExtractor(i18n);
}

/**
* Details extractor bean for action not possible because of distribution
* set is invalid.
*
* @param i18n
* VaadinMessageSource
* @return UI invalid distributionset Error details extractor
*/
@Bean
UiErrorDetailsExtractor invalidDistributionSetErrorExtractor(final VaadinMessageSource i18n) {
return new InvalidDistributionSetErrorExtractor(i18n);
}

/**
* Vaadin4Spring servlet bean.
*
Expand All @@ -154,7 +168,7 @@ public VaadinServlet vaadinServlet() {

/**
* UI target entity mapper bean.
*
*
* @param i18n
* VaadinMessageSource
* @return UI target entity mapper
Expand All @@ -166,7 +180,7 @@ public TargetToProxyTargetMapper targetToProxyTargetMapper(final VaadinMessageSo

/**
* UI Management target data supplier bean.
*
*
* @param targetManagement
* TargetManagement
* @param targetToProxyTargetMapper
Expand All @@ -183,7 +197,7 @@ public TargetManagementStateDataSupplier targetManagementStateDataSupplier(final

/**
* UI Filter target data supplier bean.
*
*
* @param targetManagement
* TargetManagement
* @param targetToProxyTargetMapper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ public class CommonDialogWindow extends Window {
* Different kinds of confirm buttons
*/
public enum ConfirmStyle {
SAVE, OK
SAVE, OK, CONFIRM, NEXT
}

/**
* Constructor
*
*
* @param caption
* the caption
* @param content
Expand Down Expand Up @@ -189,7 +189,7 @@ private void createMandatoryLabel() {

/**
* Hide the line that explains the mandatory decorator
*
*
*/
public void hideMandatoryExplanation() {
if (mandatoryLabel != null) {
Expand Down Expand Up @@ -218,6 +218,14 @@ private void createSaveButton() {
confirmButton = SPUIComponentProvider.getButton(UIComponentIdProvider.SAVE_BUTTON,
i18n.getMessage(UIMessageIdProvider.BUTTON_SAVE), "", "", true, VaadinIcons.HARDDRIVE,
buttonDecorator);
} else if (confirmStyle == ConfirmStyle.NEXT) {
confirmButton = SPUIComponentProvider.getButton(UIComponentIdProvider.OK_BUTTON,
i18n.getMessage(UIMessageIdProvider.BUTTON_NEXT), "", ValoTheme.BUTTON_PRIMARY, false, null,
buttonDecorator);
} else if (confirmStyle == ConfirmStyle.CONFIRM) {
confirmButton = SPUIComponentProvider.getButton(UIComponentIdProvider.OK_BUTTON,
i18n.getMessage(UIMessageIdProvider.BUTTON_CONFIRM), "", ValoTheme.BUTTON_PRIMARY, false, null,
buttonDecorator);
} else {
confirmButton = SPUIComponentProvider.getButton(UIComponentIdProvider.OK_BUTTON,
i18n.getMessage(UIMessageIdProvider.BUTTON_OK), "", ValoTheme.BUTTON_PRIMARY, false, null,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/**
* Copyright (c) 2020 Bosch.IO GmbH and others.
*
* All rights reserved. This program and the accompanying materials
Expand Down Expand Up @@ -42,7 +42,7 @@
import com.vaadin.ui.Label;

/**
*
*
* Generate labels with icons according to entities' states
*
*/
Expand All @@ -63,7 +63,7 @@ public static class ActionStatusIconSupplier<E extends ProxyIdentifiableEntity>

/**
* constructor
*
*
* @param i18n
* message source for internationalization
* @param getEntityStatus
Expand Down Expand Up @@ -101,7 +101,7 @@ public static class RolloutStatusIconSupplier<E extends ProxyIdentifiableEntity>

/**
* constructor
*
*
* @param i18n
* message source for internationalization
* @param getEntityStatus
Expand Down Expand Up @@ -140,7 +140,7 @@ public static class RolloutGroupStatusIconSupplier<E extends ProxyIdentifiableEn

/**
* constructor
*
*
* @param i18n
* message source for internationalization
* @param getEntityStatus
Expand Down Expand Up @@ -177,7 +177,7 @@ public static class RolloutActionStatusIconSupplier<E extends ProxyIdentifiableE

/**
* constructor
*
*
* @param i18n
* message source for internationalization
* @param getEntityStatus
Expand Down Expand Up @@ -208,7 +208,7 @@ public Label getLabel(final E entity) {
if (optionalIcon.isPresent()) {
icon = getFontIconFromStatusMap(optionalIcon.get(), getEntityStatus.apply(entity), group.orElse(null));
} else {
icon = buildDefaultStatusIcon(group.orElse(null));
icon = buildStatusIcon(group.orElse(null));
}

return getLabel(entity, icon);
Expand All @@ -233,17 +233,23 @@ private static boolean isDownloadOnly(final RolloutGroup group) {
// Actions are not created for targets when rollout's status is
// READY and when duplicate assignment is done. In these cases
// display a appropriate status with description
private ProxyFontIcon buildDefaultStatusIcon(final RolloutGroup rolloutGroup) {
private ProxyFontIcon buildStatusIcon(final RolloutGroup rolloutGroup) {
if (rolloutGroup != null && rolloutGroup.getStatus() == RolloutGroupStatus.READY) {
return new ProxyFontIcon(VaadinIcons.BULLSEYE, SPUIStyleDefinitions.STATUS_ICON_LIGHT_BLUE,
i18n.getMessage(UIMessageIdProvider.TOOLTIP_ROLLOUT_GROUP_STATUS_PREFIX
+ RolloutGroupStatus.READY.toString().toLowerCase()));
} else if (rolloutGroup != null && rolloutGroup.getStatus() == RolloutGroupStatus.FINISHED) {
final DistributionSet dist = rolloutGroup.getRollout().getDistributionSet();
final String ds = HawkbitCommonUtil.getFormattedNameVersion(dist.getName(), dist.getVersion());

return new ProxyFontIcon(VaadinIcons.MINUS_CIRCLE, SPUIStyleDefinitions.STATUS_ICON_BLUE,
i18n.getMessage("message.dist.already.assigned", ds));
if (dist.isValid()) {
return new ProxyFontIcon(VaadinIcons.MINUS_CIRCLE, SPUIStyleDefinitions.STATUS_ICON_BLUE,
i18n.getMessage(UIMessageIdProvider.MESSAGE_DISTRIBUTION_ASSIGNED, ds));
} else {
// invalidated ds, finished rollout but ds wasn't assigned
// to target
return new ProxyFontIcon(VaadinIcons.BAN, SPUIStyleDefinitions.STATUS_ICON_BLUE,
i18n.getMessage(UIMessageIdProvider.MESSAGE_DISTRIBUTION_NOT_ASSIGNED, ds));
}
} else {
return generateUnknwonStateIcon();
}
Expand All @@ -264,7 +270,7 @@ public static class ActiveStatusIconSupplier<E extends ProxyIdentifiableEntity>

/**
* constructor
*
*
* @param i18n
* message source for internationalization
* @param getEntityStatus
Expand Down Expand Up @@ -298,7 +304,7 @@ public static class ActionTypeIconSupplier<E extends ProxyIdentifiableEntity>

/**
* constructor
*
*
* @param i18n
* message source for internationalization
* @param getEntityStatus
Expand Down Expand Up @@ -333,7 +339,7 @@ public static class TargetStatusIconSupplier<E extends ProxyIdentifiableEntity>

/**
* constructor
*
*
* @param i18n
* message source for internationalization
* @param getEntityStatus
Expand Down Expand Up @@ -366,7 +372,7 @@ public static class ProgressStatusIconSupplier<E extends ProxyIdentifiableEntity

/**
* constructor
*
*
* @param i18n
* message source for internationalization
* @param getEntityStatus
Expand All @@ -393,7 +399,7 @@ public static class TargetPollingStatusIconSupplier extends AbstractEntityStatus

/**
* constructor
*
*
* @param i18n
* message source for internationalization
* @param labelIdPrefix
Expand Down Expand Up @@ -424,7 +430,7 @@ public static class TimeforcedIconSupplier extends AbstractEntityStatusIconBuild

/**
* constructor
*
*
* @param i18n
* message source for internationalization
* @param labelIdPrefix
Expand Down Expand Up @@ -541,7 +547,7 @@ protected ProxyFontIcon generateUnknwonStateIcon() {

/**
* Generate a label from the entity according to its state
*
*
* @param entity
* to read the state from
* @return the label
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public ProxyDistributionSet map(final DistributionSet distributionSet) {
HawkbitCommonUtil.getFormattedNameVersion(distributionSet.getName(), distributionSet.getVersion()));
proxyDistribution.setIsComplete(distributionSet.isComplete());
proxyDistribution.setRequiredMigrationStep(distributionSet.isRequiredMigrationStep());
proxyDistribution.setIsValid(distributionSet.isValid());

final DistributionSetType type = distributionSet.getType();
final ProxyTypeInfo typeInfo = new ProxyTypeInfo(type.getId(), type.getName(), type.getKey());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public ProxyRollout map(final Rollout rollout) {
mapNamedEntityAttributes(rollout, proxyRollout);

final DistributionSet ds = rollout.getDistributionSet();
proxyRollout.setDsInfo(new ProxyDistributionSetInfo(ds.getId(), ds.getName(), ds.getVersion()));
proxyRollout.setDsInfo(new ProxyDistributionSetInfo(ds.getId(), ds.getName(), ds.getVersion(), ds.isValid()));
proxyRollout
.setNumberOfGroups(rollout.getRolloutGroupsCreated() > 0 ? rollout.getRolloutGroupsCreated() : null);
proxyRollout.setForcedTime(rollout.getForcedTime() > 0 ? rollout.getForcedTime() : null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public ProxyTargetFilterQuery map(final TargetFilterQuery targetFilterQuery) {
if (distributionSet != null) {
proxyTargetFilter.setAutoAssignmentEnabled(true);
proxyTargetFilter.setDistributionSetInfo(new ProxyDistributionSetInfo(distributionSet.getId(),
distributionSet.getName(), distributionSet.getVersion()));
distributionSet.getName(), distributionSet.getVersion(), distributionSet.isValid()));
proxyTargetFilter.setAutoAssignActionType(targetFilterQuery.getAutoAssignActionType());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public DistributionSetStatelessDataProvider(final DistributionSetManagement dist
@Override
protected Page<DistributionSet> loadBackendEntities(final PageRequest pageRequest, final String filter) {
final DistributionSetFilterBuilder builder = new DistributionSetFilterBuilder().setIsDeleted(false)
.setIsComplete(true);
.setIsComplete(true).setIsValid(true);

if (!StringUtils.isEmpty(filter)) {
builder.setFilterString(filter);
Expand Down
Loading

0 comments on commit 56e4066

Please sign in to comment.