mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Better hbactest validation message
HBAC Test validation message contains all missing values in form of list of links instead of general 'missing values' message and redirection to first missing value's facet. When a link is clicked user is redirected to value's facet. https://fedorahosted.org/freeipa/ticket/2182
This commit is contained in:
@@ -664,5 +664,7 @@ IPA.message_dialog = function(spec) {
|
|||||||
|
|
||||||
init();
|
init();
|
||||||
|
|
||||||
|
that.message_dialog_create = that.create;
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -410,19 +410,6 @@ IPA.hbac.test_select_facet = function(spec) {
|
|||||||
that.validate = function(record) {
|
that.validate = function(record) {
|
||||||
if (record[that.name]) return true;
|
if (record[that.name]) return true;
|
||||||
|
|
||||||
var dialog = IPA.message_dialog({
|
|
||||||
title: IPA.messages.dialogs.validation_title,
|
|
||||||
message: IPA.messages.dialogs.validation_message
|
|
||||||
});
|
|
||||||
|
|
||||||
dialog.on_ok = function() {
|
|
||||||
var state = {};
|
|
||||||
state[that.entity.name+'-facet'] = that.name;
|
|
||||||
IPA.nav.push_state(state);
|
|
||||||
};
|
|
||||||
|
|
||||||
dialog.open();
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -691,22 +678,34 @@ IPA.hbac.test_run_facet = function(spec) {
|
|||||||
var command = IPA.command({ method: 'hbactest' });
|
var command = IPA.command({ method: 'hbactest' });
|
||||||
|
|
||||||
var options = {};
|
var options = {};
|
||||||
|
var validation_results = {
|
||||||
|
valid: true,
|
||||||
|
invalid_facets: []
|
||||||
|
};
|
||||||
|
|
||||||
var facet = that.entity.get_facet('user');
|
var facet = that.entity.get_facet('user');
|
||||||
facet.save(options);
|
facet.save(options);
|
||||||
if (!facet.validate(options)) return;
|
that.validate_facet(facet, options, validation_results);
|
||||||
|
|
||||||
facet = that.entity.get_facet('targethost');
|
facet = that.entity.get_facet('targethost');
|
||||||
facet.save(options);
|
facet.save(options);
|
||||||
if (!facet.validate(options)) return;
|
that.validate_facet(facet, options, validation_results);
|
||||||
|
|
||||||
facet = that.entity.get_facet('service');
|
facet = that.entity.get_facet('service');
|
||||||
facet.save(options);
|
facet.save(options);
|
||||||
if (!facet.validate(options)) return;
|
that.validate_facet(facet, options, validation_results);
|
||||||
|
|
||||||
facet = that.entity.get_facet('sourcehost');
|
facet = that.entity.get_facet('sourcehost');
|
||||||
facet.save(options);
|
facet.save(options);
|
||||||
if (!facet.validate(options)) return;
|
that.validate_facet(facet, options, validation_results);
|
||||||
|
|
||||||
|
if (!validation_results.valid) {
|
||||||
|
var dialog = IPA.hbac.validation_dialog({
|
||||||
|
validation_results: validation_results
|
||||||
|
});
|
||||||
|
dialog.open();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
facet = that.entity.get_facet('rules');
|
facet = that.entity.get_facet('rules');
|
||||||
facet.save(options);
|
facet.save(options);
|
||||||
@@ -721,6 +720,17 @@ IPA.hbac.test_run_facet = function(spec) {
|
|||||||
command.execute();
|
command.execute();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
that.validate_facet = function(facet, options, validation_results) {
|
||||||
|
|
||||||
|
var facet_valid = facet.validate(options);
|
||||||
|
|
||||||
|
validation_results.valid = facet_valid && validation_results.valid;
|
||||||
|
|
||||||
|
if (!facet_valid) {
|
||||||
|
validation_results.invalid_facets.push(facet);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
that.get_records_map = function(data) {
|
that.get_records_map = function(data) {
|
||||||
|
|
||||||
var records_map = $.ordered_map();
|
var records_map = $.ordered_map();
|
||||||
@@ -759,4 +769,64 @@ IPA.hbac.test_run_facet = function(spec) {
|
|||||||
return that;
|
return that;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
IPA.hbac.validation_dialog = function(spec) {
|
||||||
|
|
||||||
|
spec = spec || {};
|
||||||
|
spec.title = spec.title || IPA.messages.dialogs.validation_title;
|
||||||
|
spec.message = spec.message || IPA.messages.dialogs.validation_message;
|
||||||
|
|
||||||
|
var that = IPA.message_dialog(spec);
|
||||||
|
|
||||||
|
that.validation_results = spec.validation_results;
|
||||||
|
|
||||||
|
that.create = function() {
|
||||||
|
|
||||||
|
if (that.message) {
|
||||||
|
that.message_dialog_create();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (that.validation_results && that.validation_results.invalid_facets) {
|
||||||
|
var invalid_facets = that.validation_results.invalid_facets;
|
||||||
|
|
||||||
|
var ul;
|
||||||
|
|
||||||
|
if (invalid_facets.length > 0) {
|
||||||
|
var div = $('<div/>',{
|
||||||
|
text: IPA.messages.objects.hbactest.missing_values
|
||||||
|
}).appendTo(that.container);
|
||||||
|
ul = $('<ul/>').appendTo(that.container);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i=0; i<invalid_facets.length; i++) {
|
||||||
|
|
||||||
|
var facet = invalid_facets[i];
|
||||||
|
|
||||||
|
var li = $('<li />').appendTo(ul);
|
||||||
|
|
||||||
|
var metadata = IPA.get_command_option('hbactest', facet.name);
|
||||||
|
|
||||||
|
$('<a />', {
|
||||||
|
href: '#'+facet.name,
|
||||||
|
text: metadata.label,
|
||||||
|
click: function(facet) {
|
||||||
|
return function() {
|
||||||
|
that.redirect_to_facet(facet);
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
}(facet)
|
||||||
|
}).appendTo(li);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
that.redirect_to_facet = function(facet) {
|
||||||
|
that.close();
|
||||||
|
var state = {};
|
||||||
|
state[facet.entity.name+'-facet'] = facet.name;
|
||||||
|
IPA.nav.push_state(state);
|
||||||
|
};
|
||||||
|
|
||||||
|
return that;
|
||||||
|
};
|
||||||
|
|
||||||
IPA.register('hbactest', IPA.hbac.test_entity);
|
IPA.register('hbactest', IPA.hbac.test_entity);
|
||||||
|
|||||||
@@ -144,6 +144,7 @@
|
|||||||
+process user.js
|
+process user.js
|
||||||
+process group.js
|
+process group.js
|
||||||
+process hbac.js
|
+process hbac.js
|
||||||
|
+process hbactest.js
|
||||||
+process host.js
|
+process host.js
|
||||||
+process hostgroup.js
|
+process hostgroup.js
|
||||||
+process netgroup.js
|
+process netgroup.js
|
||||||
|
|||||||
@@ -267,6 +267,7 @@
|
|||||||
"include_enabled": "Include Enabled",
|
"include_enabled": "Include Enabled",
|
||||||
"label": "HBAC Test",
|
"label": "HBAC Test",
|
||||||
"matched": "Matched",
|
"matched": "Matched",
|
||||||
|
"missing_values": "Missing values: ",
|
||||||
"new_test": "New Test",
|
"new_test": "New Test",
|
||||||
"rules": "Rules",
|
"rules": "Rules",
|
||||||
"run_test": "Run Test",
|
"run_test": "Run Test",
|
||||||
|
|||||||
@@ -405,6 +405,7 @@ class i18n_messages(Command):
|
|||||||
"include_enabled": _("Include Enabled"),
|
"include_enabled": _("Include Enabled"),
|
||||||
"label": _("HBAC Test"),
|
"label": _("HBAC Test"),
|
||||||
"matched": _("Matched"),
|
"matched": _("Matched"),
|
||||||
|
"missing_values": _("Missing values: "),
|
||||||
"new_test": _("New Test"),
|
"new_test": _("New Test"),
|
||||||
"rules": _("Rules"),
|
"rules": _("Rules"),
|
||||||
"run_test": _("Run Test"),
|
"run_test": _("Run Test"),
|
||||||
|
|||||||
Reference in New Issue
Block a user