WebUI: Add support for suppressing warnings

Each command can have specified an array of warning codes which will
be suppressed and won't be shown.

For specifying this it is necessary to set command property
'supressed_warnings: [codes_of_warning]'

Part of: https://pagure.io/freeipa/issue/6618

Reviewed-By: Petr Vobornik <pvoborni@redhat.com>
This commit is contained in:
Pavel Vomacka
2017-03-17 15:10:42 +01:00
parent dd6b72e418
commit 7b3a10da70

View File

@@ -71,6 +71,12 @@ rpc.command = function(spec) {
/** @property {Object} options Option map */ /** @property {Object} options Option map */
that.options = $.extend({}, spec.options || {}); that.options = $.extend({}, spec.options || {});
/**
* @property {Array} suppress_warnings array of message codes which
* are suppressed
*/
that.suppress_warnings = spec.suppress_warnings || [];
/** /**
* Success handler * Success handler
* @property {Function} * @property {Function}
@@ -219,6 +225,7 @@ rpc.command = function(spec) {
for (var i=0,l=msgs.length; i<l; i++) { for (var i=0,l=msgs.length; i<l; i++) {
var msg = lang.clone(msgs[i]); var msg = lang.clone(msgs[i]);
if (that.suppress_warnings.indexOf(msg.code) > -1) continue;
// escape and reformat message // escape and reformat message
msg.message = util.beautify_message(msg.message); msg.message = util.beautify_message(msg.message);
IPA.notify(msg.message, msg.type); IPA.notify(msg.message, msg.type);