[node-patches] Change in ovirt-node[master]: Rework the inputs on the RHN page a little

rbarry at redhat.com rbarry at redhat.com
Wed Aug 13 15:55:15 UTC 2014


Ryan Barry has uploaded a new change for review.

Change subject: Rework the inputs on the RHN page a little
......................................................................

Rework the inputs on the RHN page a little

Don't blindly set the text on input fields. Instead, we should
disable input fields and keep their value, passing it back in
if it's re-enabled. Additionally, this prevents getting into a
situation where bad input in rhn.url or rhn.ca can be marked as
valid by changing the type from Satellite to SAM, as well as
improperly marking the page as invalid if invalid input has been
entered into fields which are no longer active.

Change-Id: I977ac638914db789bc367a91cdbfda3851d2e4eb
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1064836
Signed-off-by: Ryan Barry <rbarry at redhat.com>
---
M src/ovirt/node/setup/rhn/rhn_page.py
1 file changed, 13 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/73/31473/1

diff --git a/src/ovirt/node/setup/rhn/rhn_page.py b/src/ovirt/node/setup/rhn/rhn_page.py
index 3aacb7e..29646f5 100644
--- a/src/ovirt/node/setup/rhn/rhn_page.py
+++ b/src/ovirt/node/setup/rhn/rhn_page.py
@@ -106,6 +106,7 @@
     _rhn_types = [("rhn", "RHN"),
                   ("satellite", "Satellite"),
                   ("sam", "SAM")]
+    _fields_enabled = False
 
     def __init__(self, app):
         super(Plugin, self).__init__(app)
@@ -236,15 +237,20 @@
     def on_change(self, changes):
         net_is_configured = NodeNetwork().is_configured()
         if "rhn.type" in changes and net_is_configured:
-            self.widgets["rhn.url"].enabled(False)
-            self.widgets["rhn.ca"].enabled(False)
             if (changes["rhn.type"] == "sam" or
-                    changes["rhn.type"] == "satellite"):
-                self.widgets["rhn.url"].enabled(True)
-                self.widgets["rhn.ca"].enabled(True)
+               changes["rhn.type"] == "satellite"):
+                if not self._fields_enabled:
+                    self._fields_enabled = True
+                    self.widgets["rhn.url"].enabled(True)
+                    self.widgets["rhn.ca"].enabled(True)
+                    self.stash_pop_change("rhn.url", reuse_old=True)
+                    self.stash_pop_change("rhn.ca", reuse_old=True)
             else:
-                self.widgets["rhn.url"].text("")
-                self.widgets["rhn.ca"].text("")
+                self._fields_enabled = False
+                self.widgets["rhn.url"].enabled(False)
+                self.widgets["rhn.ca"].enabled(False)
+                self.stash_change("rhn.url")
+                self.stash_change("rhn.ca")
 
     def on_merge(self, effective_changes):
         self.logger.debug("Saving RHN page")


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I977ac638914db789bc367a91cdbfda3851d2e4eb
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Ryan Barry <rbarry at redhat.com>



More information about the node-patches mailing list