Re: [Freeipa-devel] [PATCH] 779 webui: do not show closed dialog

2014-10-21 Thread Petr Vobornik

On 20.10.2014 22:07, Endi Sukma Dewata wrote:

On 10/20/2014 12:22 PM, Petr Vobornik wrote:

Fixes issues when dialog is not removed from `IPA.opened_dialogs`
registry when dialog.close() is called while the dialog is not shown,
i.e., while other dialog is shown. Without it, the dialog is could be
incorrectly displayed.

New dialog's property `opened` handles whether dialog is intended to be
opened.

How to test:

Add new host with IP address outside of managed reverse zones to get
error 4304.


Didn't have a chance to test it, but the code looks fine. ACK.
Perhaps the 'opened' property can be renamed to 'enabled' or something
like that to avoid confusions with 'is_shown'.



I've added ticket to commit message: 
https://fedorahosted.org/freeipa/ticket/4656


Pushed to:
master: 41a7d0bf472b21018715eedf0b4c56ccbeace1f1
ipa-4-1: d3de9c0ca1844a99b1d54952f6b4355e8c8188f8
--
Petr Vobornik

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


[Freeipa-devel] [PATCH] 779 webui: do not show closed dialog

2014-10-20 Thread Petr Vobornik
Fixes issues when dialog is not removed from `IPA.opened_dialogs` 
registry when dialog.close() is called while the dialog is not shown, 
i.e., while other dialog is shown. Without it, the dialog is could be 
incorrectly displayed.


New dialog's property `opened` handles whether dialog is intended to be 
opened.


How to test:

Add new host with IP address outside of managed reverse zones to get 
error 4304.

--
Petr Vobornik
From 4d6fea2d546aff8ee309b9e43dd6db8d7721770e Mon Sep 17 00:00:00 2001
From: Petr Vobornik pvobo...@redhat.com
Date: Mon, 20 Oct 2014 18:39:30 +0200
Subject: [PATCH] webui: do not show closed dialog

Fixes issues when dialog is not removed from `IPA.opened_dialogs` registry when dialog.close() is called while the dialog is not shown, i.e., while other dialog is shown. Without it, the dialog is could be incorrectly displayed.

New dialog's property `opened` handles whether dialog is intended to be opened.

How to test:

Add new host with IP address outside of managed reverse zones to get error 4304.
---
 install/ui/src/freeipa/dialog.js | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/install/ui/src/freeipa/dialog.js b/install/ui/src/freeipa/dialog.js
index c277518ac97d9c1eab04c397519fa17f8f564023..6cac66794c73beac971d42407d10e9fb0fce31f9 100644
--- a/install/ui/src/freeipa/dialog.js
+++ b/install/ui/src/freeipa/dialog.js
@@ -239,6 +239,16 @@ IPA.dialog = function(spec) {
 that.is_shown = false;
 
 /**
+ * Whether dialog should be opened.
+ *
+ * The actual display state is reflected in `is_shown` property. Dialog can
+ * be `opened` and not `is_shown` at the same time, eg., when other dialog
+ * is displayed. Opposite is invalid state.
+ * @property {boolean}
+ */
+that.opened = false;
+
+/**
  * Close dialog on Escape key press
  * @property {boolean} close_on_escape=true
  */
@@ -556,6 +566,7 @@ IPA.dialog = function(spec) {
 
 that.register_listeners();
 
+this.opened = true;
 this.emit('open', { source: that });
 topic.publish('dialog.open', { source: that });
 
@@ -571,6 +582,7 @@ IPA.dialog = function(spec) {
  * @param  {Function} clb Show callback, called when showing is complete.
  */
 that.show = function(clb) {
+if (!this.opened) return;
 that.is_shown = true;
 this.dom_node.one('shown.bs.modal', clb);
 
@@ -648,6 +660,12 @@ IPA.dialog = function(spec) {
 that.close = function() {
 
 that.remove_listeners();
+this.opened = false;
+
+if (!this.is_shown) {
+that.emit('closed', { source: that });
+topic.publish('dialog.closed', { source: that });
+}
 
 if (!that.dom_node) return;
 
-- 
1.9.3

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Re: [Freeipa-devel] [PATCH] 779 webui: do not show closed dialog

2014-10-20 Thread Endi Sukma Dewata

On 10/20/2014 12:22 PM, Petr Vobornik wrote:

Fixes issues when dialog is not removed from `IPA.opened_dialogs`
registry when dialog.close() is called while the dialog is not shown,
i.e., while other dialog is shown. Without it, the dialog is could be
incorrectly displayed.

New dialog's property `opened` handles whether dialog is intended to be
opened.

How to test:

Add new host with IP address outside of managed reverse zones to get
error 4304.


Didn't have a chance to test it, but the code looks fine. ACK.
Perhaps the 'opened' property can be renamed to 'enabled' or something 
like that to avoid confusions with 'is_shown'.


--
Endi S. Dewata

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel