diff options
author | Petr Vobornik <pvoborni@redhat.com> | 2011-08-05 17:12:21 +0200 |
---|---|---|
committer | Endi S. Dewata <edewata@redhat.com> | 2011-08-05 19:14:19 +0000 |
commit | 08905eb9a9039b38c032275a87b4f5602e5a63dd (patch) | |
tree | a566ca2e61144a2d5d98b751f56c9af125b367e3 /install/ui/ipa.js | |
parent | 966fbd6485f3e2a1bc7fa4c3f96fcb435daa553d (diff) | |
download | freeipa-08905eb9a9039b38c032275a87b4f5602e5a63dd.tar.gz freeipa-08905eb9a9039b38c032275a87b4f5602e5a63dd.tar.xz freeipa-08905eb9a9039b38c032275a87b4f5602e5a63dd.zip |
Fixed adding host without DNS reverse zone
https://fedorahosted.org/freeipa/ticket/1481
Shows status dialog instead of error dialog (error 4304 is treated like success).
Refactored error dialog.
Added generic message dialog (IPA.message_dialog)
Modified core tests to work with dialog.
Diffstat (limited to 'install/ui/ipa.js')
-rw-r--r-- | install/ui/ipa.js | 115 |
1 files changed, 64 insertions, 51 deletions
diff --git a/install/ui/ipa.js b/install/ui/ipa.js index 2f1c6969c..d53ee7b12 100644 --- a/install/ui/ipa.js +++ b/install/ui/ipa.js @@ -243,57 +243,13 @@ IPA.command = function(spec) { that.execute = function() { function dialog_open(xhr, text_status, error_thrown) { - - IPA.error_dialog = $('<div/>', { - id: 'error_dialog' - }); - - if (error_thrown.url) { - $('<p/>', { - text: 'URL: '+error_thrown.url - }).appendTo(IPA.error_dialog); - } - - $('<p/>', { - html: error_thrown.message - }).appendTo(IPA.error_dialog); - - function close() { - IPA.error_dialog.dialog('destroy'); - IPA.error_dialog.remove(); - IPA.error_dialog = null; - } - - var buttons = {}; - - /** - * When a user initially opens the Web UI without a Kerberos - * ticket, the messages including the button labels have not - * been loaded yet, so the button labels need default values. - */ - var label = IPA.messages.buttons ? IPA.messages.buttons.retry : 'Retry'; - buttons[label] = function() { - close(); - that.execute(); - }; - - label = IPA.messages.buttons ? IPA.messages.buttons.cancel : 'Cancel'; - buttons[label] = function() { - close(); - if (that.on_error) { - that.on_error.call(this, xhr, text_status, error_thrown); - } - }; - - IPA.error_dialog.dialog({ - modal: true, - title: error_thrown.name, - width: 400, - buttons: buttons, - close: function() { - close(); - } + var dialog = IPA.error_dialog({ + xhr: xhr, + text_status: text_status, + error_thrown: error_thrown, + command: that }); + dialog.open(); } function error_handler(xhr, text_status, error_thrown) { @@ -331,6 +287,7 @@ IPA.command = function(spec) { dialog_open.call(this, xhr, text_status, error_thrown); } else if (that.on_error) { + //custom error handling, maintaining AJAX call's context that.on_error.call(this, xhr, text_status, error_thrown); } } @@ -349,11 +306,13 @@ IPA.command = function(spec) { // error_handler() calls IPA.hide_activity_icon() error_handler.call(this, xhr, text_status, /* error_thrown */ { name: 'IPA Error '+data.error.code, - message: data.error.message + message: data.error.message, + data: data }); } else if (that.on_success) { IPA.hide_activity_icon(); + //custom success handling, maintaining AJAX call's context that.on_success.call(this, data, text_status, xhr); } } @@ -610,3 +569,57 @@ IPA.dirty_dialog = function(spec) { return that; }; + +IPA.error_dialog = function(spec) { + var that = IPA.dialog(spec); + + var init = function() { + spec = spec || {}; + + that.id = 'error_dialog'; + that.xhr = spec.xhr || {}; + that.text_status = spec.text_status || ''; + that.error_thrown = spec.error_thrown || {}; + that.command = spec.command; + that.title = spec.error_thrown.name; + }; + + that.create = function() { + if (that.error_thrown.url) { + $('<p/>', { + text: 'URL: '+that.error_thrown.url + }).appendTo(that.container); + } + + $('<p/>', { + html: that.error_thrown.message + }).appendTo(that.container); + }; + + that.create_buttons = function() { + /** + * When a user initially opens the Web UI without a Kerberos + * ticket, the messages including the button labels have not + * been loaded yet, so the button labels need default values. + */ + var label = IPA.messages.buttons ? IPA.messages.buttons.retry : 'Retry'; + + that.add_button(label, function() { + that.close(); + that.command.execute(); + }); + + label = IPA.messages.buttons ? IPA.messages.buttons.cancel : 'Cancel'; + that.add_button(label, function() { + that.close(); + if (that.command.retry && that.command.on_error) { + that.command.on_error(that.xhr, that.text_status, that.error_thrown); + } + }); + }; + + init(); + that.create_buttons(); + + return that; +}; |