Fix localisation in System Configuration View (#822)

* Fix localisation:
* Regenerate Key
* SSL Issuer Hash
* Rollouts Tooltip

Signed-off-by: Jeroen Laverman <jeroen.laverman@bosch-si.com>

* add final

Signed-off-by: Jeroen Laverman <jeroen.laverman@bosch-si.com>

* add parameter description

Signed-off-by: Jeroen Laverman <jeroen.laverman@bosch-si.com>

* Review findings

Signed-off-by: Jeroen Laverman <jeroen.laverman@bosch-si.com>

* remove TODO-ID

Signed-off-by: Jeroen Laverman <jeroen.laverman@bosch-si.com>
This commit is contained in:
Jeroen Laverman
2019-05-06 13:47:02 +02:00
committed by Dominic Schabel
parent 9884452ad4
commit b4ec3478c4
6 changed files with 59 additions and 17 deletions

View File

@@ -14,6 +14,7 @@ import java.util.Map.Entry;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus.Status; import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus.Status;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.vaadin.alump.distributionbar.gwt.client.GwtDistributionBar; import org.vaadin.alump.distributionbar.gwt.client.GwtDistributionBar;
/** /**
@@ -38,9 +39,12 @@ public final class DistributionBarHelper {
* @param statusTotalCountMap * @param statusTotalCountMap
* map with status and count * map with status and count
* *
* @param i18n
* the i18n
*
* @return string of format "status1:count,status2:count" * @return string of format "status1:count,status2:count"
*/ */
public static String getDistributionBarAsHTMLString(final Map<Status, Long> statusTotalCountMap) { public static String getDistributionBarAsHTMLString(final Map<Status, Long> statusTotalCountMap, final VaadinMessageSource i18n) {
final StringBuilder htmlString = new StringBuilder(); final StringBuilder htmlString = new StringBuilder();
final Map<Status, Long> statusMapWithNonZeroValues = getStatusMapWithNonZeroValues(statusTotalCountMap); final Map<Status, Long> statusMapWithNonZeroValues = getStatusMapWithNonZeroValues(statusTotalCountMap);
final Long totalValue = getTotalSizes(statusTotalCountMap); final Long totalValue = getTotalSizes(statusTotalCountMap);
@@ -51,7 +55,7 @@ public final class DistributionBarHelper {
htmlString.append(getParentDivStart()); htmlString.append(getParentDivStart());
for (final Map.Entry<Status, Long> entry : statusMapWithNonZeroValues.entrySet()) { for (final Map.Entry<Status, Long> entry : statusMapWithNonZeroValues.entrySet()) {
if (entry.getValue() > 0) { if (entry.getValue() > 0) {
htmlString.append(getPart(partIndex, entry.getKey(), entry.getValue(), totalValue, htmlString.append(getPart(partIndex, getLabel(entry.getKey(), i18n), entry.getValue(), totalValue,
statusMapWithNonZeroValues.size())); statusMapWithNonZeroValues.size()));
partIndex++; partIndex++;
} }
@@ -69,7 +73,7 @@ public final class DistributionBarHelper {
*/ */
public static Map<Status, Long> getStatusMapWithNonZeroValues(final Map<Status, Long> statusTotalCountMap) { public static Map<Status, Long> getStatusMapWithNonZeroValues(final Map<Status, Long> statusTotalCountMap) {
return statusTotalCountMap.entrySet().stream().filter(p -> p.getValue() > 0) return statusTotalCountMap.entrySet().stream().filter(p -> p.getValue() > 0)
.collect(Collectors.toMap(p -> p.getKey(), p -> p.getValue())); .collect(Collectors.toMap(Entry::getKey, Entry::getValue));
} }
/** /**
@@ -77,19 +81,54 @@ public final class DistributionBarHelper {
* *
* @param statusCountMap * @param statusCountMap
* map with status and count details * map with status and count details
*
* @param i18n
* the i18n
*
* @return tool tip * @return tool tip
*/ */
public static String getTooltip(final Map<Status, Long> statusCountMap) { public static String getTooltip(final Map<Status, Long> statusCountMap, final VaadinMessageSource i18n) {
final Map<Status, Long> nonZeroStatusCountMap = DistributionBarHelper final Map<Status, Long> nonZeroStatusCountMap = DistributionBarHelper
.getStatusMapWithNonZeroValues(statusCountMap); .getStatusMapWithNonZeroValues(statusCountMap);
final StringBuilder tooltip = new StringBuilder(); final StringBuilder tooltip = new StringBuilder();
for (final Entry<Status, Long> entry : nonZeroStatusCountMap.entrySet()) { for (final Entry<Status, Long> entry : nonZeroStatusCountMap.entrySet()) {
tooltip.append(entry.getKey().toString().toLowerCase()).append(" : ").append(entry.getValue()) tooltip.append(getLabel(entry.getKey(), i18n)).append(" : ").append(entry.getValue())
.append("<br>"); .append("<br>");
} }
return tooltip.toString(); return tooltip.toString();
} }
private static String getLabel(final Status status, final VaadinMessageSource i18n) {
String label;
switch (status) {
case SCHEDULED :
label = "label.scheduled";
break;
case RUNNING :
label = "label.running";
break;
case ERROR :
label = "label.error";
break;
case FINISHED :
label = "label.finished";
break;
case CANCELLED :
label = "label.cancelled";
break;
case NOTSTARTED :
label = "label.notStarted";
break;
default :
throw new IllegalStateException("The status " + status + " is not supported.");
}
return i18n.getMessage(label);
}
private static String getPartStyle(final int partIndex, final int noOfParts, final String customStyle) { private static String getPartStyle(final int partIndex, final int noOfParts, final String customStyle) {
final StringBuilder mainStyle = new StringBuilder(); final StringBuilder mainStyle = new StringBuilder();
final StringBuilder styleName = new StringBuilder(GwtDistributionBar.CLASSNAME); final StringBuilder styleName = new StringBuilder(GwtDistributionBar.CLASSNAME);
@@ -104,9 +143,9 @@ public final class DistributionBarHelper {
} }
mainStyle.append(styleName).append(" "); mainStyle.append(styleName).append(" ");
mainStyle.append(DISTRIBUTION_BAR_PART_MAIN_STYLE).append(" "); mainStyle.append(DISTRIBUTION_BAR_PART_MAIN_STYLE).append(" ");
mainStyle.append(DISTRIBUTION_BAR_PART_CLASSNAME_PREFIX + partIndex); mainStyle.append(DISTRIBUTION_BAR_PART_CLASSNAME_PREFIX).append(partIndex);
if (customStyle != null) { if (customStyle != null) {
mainStyle.append(" ").append("status-bar-part-" + customStyle); mainStyle.append(" ").append("status-bar-part-").append(customStyle);
} }
return mainStyle.toString(); return mainStyle.toString();
} }
@@ -120,10 +159,9 @@ public final class DistributionBarHelper {
return String.format(Locale.ENGLISH, "%.3f", val) + "%"; return String.format(Locale.ENGLISH, "%.3f", val) + "%";
} }
private static String getPart(final int partIndex, final Status status, final Long value, final Long totalValue, private static String getPart(final int partIndex, final String status, final Long value, final Long totalValue,
final int noOfParts) { final int noOfParts) {
final String partValue = status.toString().toLowerCase(); return "<div class=\"" + getPartStyle(partIndex, noOfParts, status) + "\" style=\"width: "
return "<div class=\"" + getPartStyle(partIndex, noOfParts, partValue) + "\" style=\"width: "
+ getPartWidth(value, totalValue, noOfParts) + ";\"><span class=\"" + getPartWidth(value, totalValue, noOfParts) + ";\"><span class=\""
+ DISTRIBUTION_BAR_PART_VALUE_CLASSNAME + "\">" + value + "</span></div>"; + DISTRIBUTION_BAR_PART_VALUE_CLASSNAME + "\">" + value + "</span></div>";
} }

View File

@@ -647,7 +647,7 @@ public class RolloutListGrid extends AbstractGrid<LazyQueryContainer> {
} else if (ROLLOUT_RENDERER_DATA.equals(cell.getPropertyId())) { } else if (ROLLOUT_RENDERER_DATA.equals(cell.getPropertyId())) {
description = ((RolloutRendererData) cell.getProperty().getValue()).getName(); description = ((RolloutRendererData) cell.getProperty().getValue()).getName();
} else if (SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS.equals(cell.getPropertyId())) { } else if (SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS.equals(cell.getPropertyId())) {
description = getTooltip(((TotalTargetCountStatus) cell.getValue()).getStatusTotalCountMap()); description = getTooltip(((TotalTargetCountStatus) cell.getValue()).getStatusTotalCountMap(), i18n);
} }
return description; return description;
@@ -799,7 +799,7 @@ public class RolloutListGrid extends AbstractGrid<LazyQueryContainer> {
@Override @Override
public String convertToPresentation(final TotalTargetCountStatus value, public String convertToPresentation(final TotalTargetCountStatus value,
final Class<? extends String> targetType, final Locale locale) { final Class<? extends String> targetType, final Locale locale) {
return DistributionBarHelper.getDistributionBarAsHTMLString(value.getStatusTotalCountMap()); return DistributionBarHelper.getDistributionBarAsHTMLString(value.getStatusTotalCountMap(), i18n);
} }
@Override @Override

View File

@@ -271,7 +271,7 @@ public class RolloutGroupListGrid extends AbstractGrid<LazyQueryContainer> {
return ((RolloutRendererData) cell.getProperty().getValue()).getName(); return ((RolloutRendererData) cell.getProperty().getValue()).getName();
} else if (SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS.equals(cell.getPropertyId())) { } else if (SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS.equals(cell.getPropertyId())) {
return DistributionBarHelper return DistributionBarHelper
.getTooltip(((TotalTargetCountStatus) cell.getValue()).getStatusTotalCountMap()); .getTooltip(((TotalTargetCountStatus) cell.getValue()).getStatusTotalCountMap(), i18n);
} }
return null; return null;
} }
@@ -326,7 +326,7 @@ public class RolloutGroupListGrid extends AbstractGrid<LazyQueryContainer> {
@Override @Override
public String convertToPresentation(final TotalTargetCountStatus value, public String convertToPresentation(final TotalTargetCountStatus value,
final Class<? extends String> targetType, final Locale locale) { final Class<? extends String> targetType, final Locale locale) {
return DistributionBarHelper.getDistributionBarAsHTMLString(value.getStatusTotalCountMap()); return DistributionBarHelper.getDistributionBarAsHTMLString(value.getStatusTotalCountMap(), i18n);
} }
@Override @Override

View File

@@ -49,9 +49,9 @@ public class CertificateAuthenticationConfigurationItem extends AbstractBooleanT
final HorizontalLayout caRootAuthorityLayout = new HorizontalLayout(); final HorizontalLayout caRootAuthorityLayout = new HorizontalLayout();
caRootAuthorityLayout.setSpacing(true); caRootAuthorityLayout.setSpacing(true);
final Label caRootAuthorityLabel = new LabelBuilder().name("SSL Issuer Hash:").buildLabel(); final Label caRootAuthorityLabel = new LabelBuilder().name(i18n.getMessage("label.configuration.auth.hashField")).buildLabel();
caRootAuthorityLabel.setDescription( caRootAuthorityLabel.setDescription(
"The SSL Issuer iRules.X509 hash, to validate against the controller request certifcate."); i18n.getMessage("label.configuration.auth.hashField.tooltip"));
caRootAuthorityLabel.setWidthUndefined(); caRootAuthorityLabel.setWidthUndefined();
caRootAuthorityTextField = new TextFieldBuilder(TenantConfiguration.VALUE_MAX_SIZE).buildTextComponent(); caRootAuthorityTextField = new TextFieldBuilder(TenantConfiguration.VALUE_MAX_SIZE).buildTextComponent();

View File

@@ -58,7 +58,7 @@ public class GatewaySecurityTokenAuthenticationConfigurationItem extends Abstrac
detailLayout = new VerticalLayout(); detailLayout = new VerticalLayout();
detailLayout.setImmediate(true); detailLayout.setImmediate(true);
final Button gatewaytokenBtn = SPUIComponentProvider.getButton("TODO-ID", "Regenerate Key", "", final Button gatewaytokenBtn = SPUIComponentProvider.getButton(null, i18n.getMessage("configuration.button.regenerateKey"), "",
ValoTheme.BUTTON_TINY + " " + "redicon", true, null, SPUIButtonStyleSmall.class); ValoTheme.BUTTON_TINY + " " + "redicon", true, null, SPUIButtonStyleSmall.class);
gatewaytokenBtn.setImmediate(true); gatewaytokenBtn.setImmediate(true);
gatewaytokenBtn.setIcon(FontAwesome.REFRESH); gatewaytokenBtn.setIcon(FontAwesome.REFRESH);

View File

@@ -213,6 +213,7 @@ label.filter.custom = Custom
label.target.filter.truncated={0} targets has been truncated in the list due the target size limit of {1}, use filters to reduce the targets to be shown label.target.filter.truncated={0} targets has been truncated in the list due the target size limit of {1}, use filters to reduce the targets to be shown
label.inactive = In-active label.inactive = In-active
label.finished = Finished label.finished = Finished
label.notStarted = Not Started
label.error = Error label.error = Error
label.warning = Warning label.warning = Warning
label.running = Running label.running = Running
@@ -232,6 +233,8 @@ label.target.attributes.update.pending = Update pending..
label.target.lastpolldate = Last poll : label.target.lastpolldate = Last poll :
label.tag.name = Tag name label.tag.name = Tag name
label.configuration.auth.header = Allow targets to authenticate via a certificate authenticated by a reverse proxy label.configuration.auth.header = Allow targets to authenticate via a certificate authenticated by a reverse proxy
label.configuration.auth.hashField = SSL Issuer Hash
label.configuration.auth.hashField.tooltip = The SSL Issuer iRules.X509 hash, to validate against the controller request certificate.
label.configuration.auth.gatewaytoken = Allow a gateway to authenticate and manage multiple targets through a gateway security token label.configuration.auth.gatewaytoken = Allow a gateway to authenticate and manage multiple targets through a gateway security token
label.configuration.auth.targettoken = Allow targets to authenticate directly with their target security token label.configuration.auth.targettoken = Allow targets to authenticate directly with their target security token
label.configuration.repository.autoclose.action = Autoclose running actions when a new distribution set is assigned label.configuration.repository.autoclose.action = Autoclose running actions when a new distribution set is assigned
@@ -548,6 +551,7 @@ configuration.defaultdistributionset.title=Distribution Configuration
configuration.defaultdistributionset.select.label=Select the default distribution set type: configuration.defaultdistributionset.select.label=Select the default distribution set type:
configuration.savebutton.tooltip=Save Configurations configuration.savebutton.tooltip=Save Configurations
configuration.cancellbutton.tooltip=Cancel Configurations configuration.cancellbutton.tooltip=Cancel Configurations
configuration.button.regenerateKey = Regenerate Key
configuration.authentication.title=Authentication Configuration configuration.authentication.title=Authentication Configuration
configuration.repository.title=Repository Configuration configuration.repository.title=Repository Configuration
configuration.polling.title=Polling Configuration configuration.polling.title=Polling Configuration