ofri masad has uploaded a new change for review.

Change subject: webadmin: Fix QoS empty selection bug
......................................................................

webadmin: Fix QoS empty selection bug

When selecting empty QoS in the network dialog, the selection changed
automatically to the first value in the list.

The bug was fixed. Added a new default value [Unlimited].

Change-Id: I056f3291298426ed71fd75052fc5bc977b1591e5
Signed-off-by: Ofri Masad <oma...@redhat.com>
---
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/EditNetworkModel.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/VnicProfileModel.java
M 
frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java
3 files changed, 19 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/72/18072/1

diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/EditNetworkModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/EditNetworkModel.java
index 8003578..6e6801d 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/EditNetworkModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/EditNetworkModel.java
@@ -88,11 +88,12 @@
                             getSelectedDc().getcompatibility_version(),
                             profileView, null, false);
 
-                    if (profileView.getNetworkQosName() != null && 
!profileView.getNetworkQosName().equals("")) { //$NON-NLS-1$
-                        NetworkQoS networkQoS = new NetworkQoS();
-                        networkQoS.setName(profileView.getNetworkQosName());
-                        editModel.getNetworkQoS().setSelectedItem(networkQoS);
-                    }
+                    NetworkQoS networkQoS = new NetworkQoS();
+                    networkQoS.setName(profileView.getNetworkQosName() == null
+                            ? 
ConstantsManager.getInstance().getConstants().unlimitedQoSTitle()
+                            : profileView.getNetworkQosName());
+                    editModel.getNetworkQoS().setSelectedItem(networkQoS);
+
                     editModel.getNetworkQoS().setIsChangable(false);
                     profilesModels.add(editModel);
                     editModel.getName().setIsChangable(false);
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/VnicProfileModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/VnicProfileModel.java
index d1a6781..c5cc626 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/VnicProfileModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/VnicProfileModel.java
@@ -226,7 +226,10 @@
         Network network = (Network) getNetwork().getSelectedItem();
         vnicProfile.setNetworkId(network != null ? network.getId() : null);
         NetworkQoS networkQoS = (NetworkQoS) getNetworkQoS().getSelectedItem();
-        vnicProfile.setNetworkQosId(networkQoS != null ? networkQoS.getId() : 
null);
+        vnicProfile.setNetworkQosId(networkQoS != null
+                && networkQoS.getId() != null
+                && !networkQoS.getId().equals(Guid.Empty)
+                ? networkQoS.getId() : null);
         vnicProfile.setPortMirroring((Boolean) getPortMirroring().getEntity());
 
         if (customPropertiesVisible) {
@@ -309,6 +312,10 @@
             {
                 ArrayList<NetworkQoS> networkQoSes =
                         (ArrayList<NetworkQoS>) ((VdcQueryReturnValue) 
ReturnValue).getReturnValue();
+                NetworkQoS none = new NetworkQoS();
+                
none.setName(ConstantsManager.getInstance().getConstants().unlimitedQoSTitle());
+                none.setId(Guid.Empty);
+                networkQoSes.add(0, none);
                 getNetworkQoS().setItems(networkQoSes);
                 setSelectedNetworkQoSId(selectedItemId);
             }
@@ -334,14 +341,15 @@
     }
 
     public void setSelectedNetworkQoSId(Guid networkQoSId) {
-        getNetworkQoS().setSelectedItem(null);
-        if (getNetworkQoS().getItems() != null && networkQoSId != null) {
+        if (networkQoSId != null) {
             for (Object item : getNetworkQoS().getItems()) {
                 if (((NetworkQoS)item).getId().equals(networkQoSId)) {
                     getNetworkQoS().setSelectedItem(item);
                     break;
                 }
             }
+        } else {
+            setSelectedNetworkQoSId(Guid.Empty);
         }
     }
 }
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 621fcbd..a61e8e1 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
@@ -2050,4 +2050,6 @@
     @DefaultStringValue("Cannot edit name in tree context")
     String cannotEditNameInTreeContext();
 
+    @DefaultStringValue("[Unlimited]")
+    String unlimitedQoSTitle();
 }


-- 
To view, visit http://gerrit.ovirt.org/18072
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I056f3291298426ed71fd75052fc5bc977b1591e5
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: ofri masad <oma...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to