From 6f4121ccbb83493463a1f05d8a24f46042e8bf1d Mon Sep 17 00:00:00 2001 From: Petr Vobornik Date: Jun 22 2012 08:45:06 +0000 Subject: Custom Web UI error message for IPA error 911 Error message for IPA error 911 is not very clear for end users. This patch changes the message and adds an advice how to get rid of the error. https://fedorahosted.org/freeipa/ticket/2778 --- diff --git a/install/ui/ipa.js b/install/ui/ipa.js index 6e86209..7667c76 100644 --- a/install/ui/ipa.js +++ b/install/ui/ipa.js @@ -491,6 +491,9 @@ IPA.command = function(spec) { that.retry = typeof spec.retry == 'undefined' ? true : spec.retry; that.error_message = spec.error_message || IPA.get_message('dialogs.batch_error_message', 'Some operations failed.'); + that.error_messages = $.ordered_map({ + 911: 'Missing HTTP referer.
You have to configure your browser to send HTTP referer header.' + }); that.get_command = function() { return (that.entity ? that.entity+'_' : '') + that.method; @@ -620,6 +623,13 @@ IPA.command = function(spec) { }; } + // custom messages for set of codes + var error_msg = that.error_messages.get(error_thrown.code); + if (error_msg) { + error_msg = error_msg.replace('${message}', error_thrown.message); + error_thrown.message = error_msg; + } + if (that.retry) { dialog_open.call(this, xhr, text_status, error_thrown); diff --git a/install/ui/jquery.ordered-map.js b/install/ui/jquery.ordered-map.js index 7c0f3fa..64cad6e 100755 --- a/install/ui/jquery.ordered-map.js +++ b/install/ui/jquery.ordered-map.js @@ -18,7 +18,7 @@ * along with this program. If not, see . */ -jQuery.ordered_map = jQuery.fn.ordered_map = function() { +jQuery.ordered_map = jQuery.fn.ordered_map = function(map) { var that = {}; @@ -49,6 +49,18 @@ jQuery.ordered_map = jQuery.fn.ordered_map = function() { that.map[key] = value; }; + that.put_map = function(map) { + + if (typeof map !== 'object') return; + + for (name in map) { + + if (map.hasOwnProperty(name)) { + that.put(name, map[name]); + } + } + }; + that.remove = function(key) { var i = that.get_key_index(key); @@ -105,5 +117,8 @@ jQuery.ordered_map = jQuery.fn.ordered_map = function() { return new_map; }; + that.put_map(map); + + return that; };