Lior Vernia has uploaded a new change for review. Change subject: webadmin: Validate no duplicate labels were input ......................................................................
webadmin: Validate no duplicate labels were input It was previously possible to supply the same label twice in the dialog, now this triggers a validation error. Change-Id: Ia58f0a84c3ef27300f22b68ea6a405c609cf8815 Bug-Url: https://bugzilla.redhat.com/1077098 Signed-off-by: Lior Vernia <lver...@redhat.com> --- M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/NicLabelModel.java M frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java 2 files changed, 11 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/11/26811/1 diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/NicLabelModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/NicLabelModel.java index 4e952e9..3a7fb53 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/NicLabelModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/NicLabelModel.java @@ -57,6 +57,7 @@ } public boolean validate() { + Set<String> editedLabels = new HashSet<String>(); boolean res = true; for (ListModel<String> labelModel : getItems()) { labelModel.validateSelectedItem(new IValidation[] { new AsciiNameValidation() }); @@ -69,6 +70,13 @@ .labelInUse(label, usingIface)); labelModel.setIsValid(false); } + + if (editedLabels.contains(label)) { + labelModel.getInvalidityReasons().add(ConstantsManager.getInstance().getConstants().duplicateLabel()); + labelModel.setIsValid(false); + } + editedLabels.add(label); + res &= labelModel.getIsValid(); } return res; diff --git a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java index 121babc..3f5e6da 100644 --- a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java +++ b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java @@ -1483,6 +1483,9 @@ @DefaultStringValue("Subnet Mask is not Valid") String subnetMaskIsNotValid(); + @DefaultStringValue("This label has already been specified in another entry.") + String duplicateLabel(); + // Fronted @DefaultStringValue("A Request to the Server failed with the following Status Code") String requestToServerFailedWithCode(); -- To view, visit http://gerrit.ovirt.org/26811 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia58f0a84c3ef27300f22b68ea6a405c609cf8815 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Lior Vernia <lver...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches