Fixed action panel queries

Previously the queries for action panel were done globally. Since each
entity container has its own action panel, the queries will return multiple
results. This is fixed by qualifying the query to run within the entity
container.

The query has also been moved into ipa_facet.get_action_panel(). Entities
that do not have their own entity container (e.g. HBAC services and service
groups) will need to override this method to get the action panel from the
right entity container (e.g. HBAC rules).

The facet.setup_views() has been renamed to facet.create_action_panel().
New test data for SUDO rules have been added.
This commit is contained in:
Endi S. Dewata authored and Adam Young committed 2010-11-22 15:28:42 -05:00
1 parent 861a0fdba9
commit 27d8529a84
12 files changed
+216 -99

No files matched your search

+10 -16
View File
@@ -241,6 +241,7 @@ function ipa_association_widget(spec) {
var that = ipa_table_widget(spec);
that.facet = spec.facet;
that.other_entity = spec.other_entity;
that.superior_create = that.superior('create');
@@ -257,11 +258,10 @@ function ipa_association_widget(spec) {
that.superior_create(container);
var entity_container = $('#' + that.entity_name);
var action_panel = $('.action-panel', entity_container);
var action_panel = that.facet.get_action_panel();
var ul = $('ul', action_panel);
var li = $('<li/>').appendTo(ul);
var li = $('<li/>').prependTo(ul);
// creating generic buttons for layout
$('<input/>', {
@@ -282,7 +282,8 @@ function ipa_association_widget(spec) {
that.table_setup(container);
// replacing generic buttons with ipa_button and setting click handler
var action_panel = $('.action-panel');
var action_panel = that.facet.get_action_panel();
var button = $('input[name=remove]', action_panel);
button.replaceWith(ipa_button({
'label': button.val(),
@@ -428,19 +429,10 @@ function ipa_association_facet(spec) {
that.create = function(container) {
that.pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
that.other_entity =
$.bbq.getState(that.entity_name + '-enroll', true) || '';
that.other_entity = $.bbq.getState(that.entity_name + '-enroll', true) || '';
var label = IPA.metadata[that.other_entity] ? IPA.metadata[that.other_entity].label : that.other_entity;
that.table = ipa_association_widget({
'id': that.entity_name+'-'+that.other_entity,
'name': 'association',
'label': label,
'entity_name': that.entity_name,
'other_entity': that.other_entity
});
//TODO I18N
var header_message = that.other_entity + '(s) enrolled in ' +
that.entity_name + ' ' + that.pkey;
@@ -449,12 +441,14 @@ function ipa_association_facet(spec) {
'id': that.entity_name+'-'+that.other_entity,
html: $('<h2/>',{ html: header_message })
}).appendTo(container);
that.table = ipa_association_widget({
'id': that.entity_name+'-'+that.other_entity,
'name': that.other_entity,
'label': IPA.metadata[that.other_entity].label,
'label': label,
'entity_name': that.entity_name,
'other_entity': that.other_entity
'other_entity': that.other_entity,
'facet': that
});
var span = $('<span/>', { 'name': 'association' }).appendTo(container);
+1 -2
View File
@@ -454,8 +454,7 @@ function ipa_details_create(container)
'class': 'content'
}).appendTo(container);
var entity_container = $('#' + that.entity_name);
var action_panel = $('.action-panel', entity_container);
var action_panel = that.get_action_panel();
var ul = $('ul', action_panel);
var buttons = $('<li/>', {
+32 -25
View File
@@ -44,7 +44,7 @@ function ipa_facet(spec) {
that._entity_name = entity_name;
});
that.setup_views = ipa_facet_setup_views;
that.create_action_panel = ipa_facet_create_action_panel;
that.superior = function(name) {
var method = that[name];
@@ -66,6 +66,14 @@ function ipa_facet(spec) {
function load() {
}
that.get_client_area = function() {
return $('#' + that.entity_name+' .client');
};
that.get_action_panel = function() {
return $('#' + that.entity_name+' .action-panel');
};
that.facet_init = that.init;
that.facet_create = that.create;
that.facet_setup = that.setup;
@@ -325,7 +333,7 @@ function ipa_entity_setup(container) {
container.empty();
facet.setup_views(container);
facet.create_action_panel(container);
facet.create(container);
container.children().last().addClass('client');
facet.setup(container);
@@ -333,7 +341,16 @@ function ipa_entity_setup(container) {
}
function action_panel(entity_name){
function ipa_facet_create_action_panel(container) {
var that = this;
var entity_name = that.entity_name;
var action_panel = $('<div/>', {
"class": "action-panel",
html: $('<h3>Actions</h3>')
}).appendTo(container);
function build_link(other_facet,label,other_entity){
var li = $('<li/>', {
@@ -345,7 +362,7 @@ function action_panel(entity_name){
if($(this).hasClass('entity-facet-disabled')){
return false;
}
var this_pkey = $('.action-panel input[id=pkey]').val();
var this_pkey = $('input[id=pkey]', action_panel).val();
IPA.switch_and_show_page(
entity_name, other_facet_name,
this_pkey, other_entity);
@@ -357,19 +374,15 @@ function action_panel(entity_name){
return li;
}
var div = $('<div/>', {
"class":"action-panel",
html: $('<h3>Actions</h3>')
});
/*Note, for debugging purposes, it is useful to set var pkey_type = 'text';*/
var pkey_type = 'hidden';
$('<input/>',
{'type': pkey_type,
id:'pkey',
name:'pkey'}).appendTo(div);
$('<input/>', {
'type': pkey_type,
id:'pkey',
name:'pkey'
}).appendTo(action_panel);
var ul = $('<ul/>', {'class': 'action'}).appendTo(div);
var ul = $('<ul/>', {'class': 'action'}).appendTo(action_panel);
var entity = IPA.get_entity(entity_name);
var facet_name = ipa_current_facet(entity);
@@ -380,6 +393,7 @@ function action_panel(entity_name){
if (other_facet.label) {
ul.append(build_link(other_facet,other_facet.label));
} else { // For now empty label indicates an association facet
var attribute_members = IPA.metadata[entity_name].attribute_members;
for (var attribute_member in attribute_members) {
@@ -392,19 +406,12 @@ function action_panel(entity_name){
}
}
}
/*When we land on the search page, disable all facets
that require a pkey until one is selected*/
if (facet_name === 'search'){
$('.entity-facet', div).addClass('entity-facet-disabled');
$('.entity-facet', action_panel).addClass('entity-facet-disabled');
}
return div;
return action_panel;
}
function ipa_facet_setup_views(container) {
var facet = this;
var entity_name = facet.entity_name;
action_panel(entity_name).appendTo(container);
}
+26 -16
View File
@@ -120,31 +120,18 @@ function ipa_hbac_search_facet(spec) {
'label': 'Cull Disabled Rules'
}));
*/
var entity_container = $('#' + that.entity_name);
var action_panel = $('.action-panel', entity_container);
var action_panel = that.get_action_panel();
var ul = $('ul', action_panel);
$('<li/>', {
title: 'hbacsvc',
text: 'HBAC Services',
'click': function() {
var state = {};
state['entity'] = 'hbacsvc';
nav_push_state(state);
return false;
}
text: 'HBAC Services'
}).appendTo(ul);
$('<li/>', {
title: 'hbacsvcgroup',
text: 'HBAC Service Groups',
'click': function() {
var state = {};
state['entity'] = 'hbacsvcgroup';
nav_push_state(state);
return false;
}
text: 'HBAC Service Groups'
}).appendTo(ul);
that.search_facet_create(container);
@@ -156,6 +143,29 @@ function ipa_hbac_search_facet(spec) {
};
that.setup = function(container) {
that.search_facet_setup(container);
var action_panel = that.get_action_panel();
var li = $('li[title=hbacsvc]', action_panel);
li.click(function() {
var state = {};
state['entity'] = 'hbacsvc';
nav_push_state(state);
return false;
});
li = $('li[title=hbacsvcgroup]', action_panel);
li.click(function() {
var state = {};
state['entity'] = 'hbacsvcgroup';
nav_push_state(state);
return false;
});
};
return that;
}
+11 -10
View File
@@ -26,8 +26,6 @@ function ipa_hbacsvc() {
'name': 'hbacsvc'
});
that.superior_init = that.superior('init');
that.init = function() {
var dialog = ipa_hbacsvc_add_dialog({
@@ -49,7 +47,7 @@ function ipa_hbacsvc() {
});
that.add_facet(facet);
that.superior_init();
that.entity_init();
};
return that;
@@ -82,22 +80,21 @@ function ipa_hbacsvc_search_facet(spec) {
var that = ipa_search_facet(spec);
that.superior_init = that.superior('init');
that.superior_create = that.superior('create');
that.superior_setup = that.superior('setup');
that.get_action_panel = function() {
return $('#hbac .action-panel');
};
that.init = function() {
that.create_column({name:'cn', label:'Service', primary_key: true});
that.create_column({name:'description', label:'Description'});
that.superior_init();
that.search_facet_init();
};
that.create = function(container) {
var entity_container = $('#' + that.entity_name);
var action_panel = $('.action-panel', entity_container);
var action_panel = that.get_action_panel();
var ul = $('ul', action_panel);
@@ -123,7 +120,7 @@ function ipa_hbacsvc_search_facet(spec) {
}
}).appendTo(ul);
that.superior_create(container);
that.search_facet_create(container);
// TODO: replace with IPA.metadata[that.entity_name].label
container.children().last().prepend(
@@ -149,6 +146,10 @@ function ipa_hbacsvc_details_facet(spec) {
that.superior_create = that.superior('create');
that.superior_setup = that.superior('setup');
that.get_action_panel = function() {
return $('#hbac .action-panel');
};
that.init = function() {
var section = ipa_details_list_section({
+26 -15
View File
@@ -26,8 +26,6 @@ function ipa_hbacsvcgroup() {
'name': 'hbacsvcgroup'
});
that.superior_init = that.superior('init');
that.init = function() {
that.create_association({
@@ -55,12 +53,12 @@ function ipa_hbacsvcgroup() {
});
that.add_facet(facet);
facet = ipa_association_facet({
facet = ipa_hbacsvcgroup_association_facet({
'name': 'associate'
});
that.add_facet(facet);
that.superior_init();
that.entity_init();
};
return that;
@@ -93,22 +91,21 @@ function ipa_hbacsvcgroup_search_facet(spec) {
var that = ipa_search_facet(spec);
that.superior_init = that.superior('init');
that.superior_create = that.superior('create');
that.superior_setup = that.superior('setup');
that.get_action_panel = function() {
return $('#hbac .action-panel');
};
that.init = function() {
that.create_column({name:'cn', label:'Group', primary_key: true});
that.create_column({name:'description', label:'Description'});
that.superior_init();
that.search_facet_init();
};
that.create = function(container) {
var entity_container = $('#' + that.entity_name);
var action_panel = $('.action-panel', entity_container);
var action_panel = that.get_action_panel();
var ul = $('ul', action_panel);
@@ -134,7 +131,8 @@ function ipa_hbacsvcgroup_search_facet(spec) {
}
}).appendTo(ul);
that.superior_create(container);
that.search_facet_create(container);
// TODO: replace with IPA.metadata[that.entity_name].label
container.children().last().prepend(
$('<h2/>', { 'html': 'HBAC Service Groups' }));
@@ -152,9 +150,9 @@ function ipa_hbacsvcgroup_details_facet(spec) {
var that = ipa_details_facet(spec);
that.superior_init = that.superior('init');
that.superior_create = that.superior('create');
that.superior_setup = that.superior('setup');
that.get_action_panel = function() {
return $('#hbac .action-panel');
};
that.init = function() {
@@ -167,7 +165,20 @@ function ipa_hbacsvcgroup_details_facet(spec) {
section.create_field({ 'name': 'cn', 'label': 'Name' });
section.create_field({ 'name': 'description', 'label': 'Description' });
that.superior_init();
that.details_facet_init();
};
return that;
}
function ipa_hbacsvcgroup_association_facet(spec) {
spec = spec || {};
var that = ipa_association_facet(spec);
that.get_action_panel = function() {
return $('#hbac .action-panel');
};
return that;
+16 -14
View File
@@ -28,7 +28,7 @@ function ipa_search_widget(spec) {
var that = ipa_table_widget(spec);
that.superior_create = that.superior('create');
that.facet = spec.facet;
that.create = function(container) {
@@ -52,8 +52,7 @@ function ipa_search_widget(spec) {
'value': 'Find'
}).appendTo(search_filter);
var entity_container = $('#' + that.entity_name);
var action_panel = $('.action-panel', entity_container);
var action_panel = that.facet.get_action_panel();
var ul = $('ul', action_panel);
var li = $('<li/>').prependTo(ul);
@@ -78,7 +77,7 @@ function ipa_search_widget(spec) {
'class': 'search-results'
}).appendTo(container);
that.superior_create(container);
that.table_create(container);
};
that.setup = function(container) {
@@ -95,8 +94,7 @@ function ipa_search_widget(spec) {
});
button.replaceWith(that.find_button);
var entity_container = $('#' + that.entity_name);
var action_panel = $('.action-panel', entity_container);
var action_panel = that.facet.get_action_panel();
var search_buttons = $('.search-buttons', action_panel);
button = $('input[name=remove]', search_buttons);
@@ -143,19 +141,21 @@ function ipa_search_widget(spec) {
count += 1;
pkey = $(this).val();
});
var action_panel = that.facet.get_action_panel();
if(count == 1){
$('.action-panel li.entity-facet').
$('li.entity-facet', action_panel).
removeClass('entity-facet-disabled');
var state = {};
$('.action-panel input[id=pkey]').val(pkey);
$('input[id=pkey]', action_panel).val(pkey);
}else{
$('.action-panel li.entity-facet').
$('li.entity-facet', action_panel).
addClass('entity-facet-disabled');
$('.action-panel input').val(null);
$('input', action_panel).val(null);
}
return false;
}
};
that.remove = function(container) {
@@ -262,7 +262,7 @@ function ipa_search_facet(spec) {
var that = ipa_facet(spec);
that.init = spec.init || init;
that.create = spec.create || ipa_search_facet_create;
that.create = spec.create || create;
that.setup = spec.setup || setup;
that.refresh = spec.refresh || refresh;
@@ -306,7 +306,8 @@ function ipa_search_facet(spec) {
that.table = ipa_search_widget({
'id': that.entity_name+'-search',
'name': 'search', 'label': IPA.metadata[that.entity_name].label,
'entity_name': that.entity_name
'entity_name': that.entity_name,
'facet': that
});
for (var i=0; i<that.columns.length; i++) {
@@ -327,7 +328,7 @@ function ipa_search_facet(spec) {
return filter != that.filter;
};
function ipa_search_facet_create(container) {
function create(container) {
container.attr('title', that.entity_name);
@@ -357,6 +358,7 @@ function ipa_search_facet(spec) {
that.search_facet_init = that.init;
that.search_facet_create = that.create;
that.search_facet_setup = that.setup;
return that;
}
@@ -0,0 +1,9 @@
{
"error": null,
"id": 0,
"result": {
"result": true,
"summary": "Removed kerberos key from \"test/dev.example.com@DEV.EXAMPLE.COM\"",
"value": "test/dev.example.com@DEV.EXAMPLE.COM"
}
}
@@ -0,0 +1,24 @@
{
"error": null,
"id": 0,
"result": {
"result": {
"cn": [
"test"
],
"description": [
"test"
],
"dn": "ipauniqueid=94ef3550-f443-11df-a2aa-00163e72f2d9,cn=sudorules,dc=dev,dc=example,dc=com",
"ipauniqueid": [
"94ef3550-f443-11df-a2aa-00163e72f2d9"
],
"objectclass": [
"ipaassociation",
"ipasudorule"
]
},
"summary": "Added sudo rule \"test\"",
"value": "test"
}
}
@@ -0,0 +1,9 @@
{
"error": null,
"id": 0,
"result": {
"result": true,
"summary": null,
"value": "test"
}
}
@@ -0,0 +1,51 @@
{
"error": null,
"id": 0,
"result": {
"result": {
"attributelevelrights": {
"aci": "rscwo",
"cmdcategory": "rscwo",
"cn": "rscwo",
"description": "rscwo",
"externalhost": "rscwo",
"externaluser": "rscwo",
"hostcategory": "rscwo",
"hostmask": "rscwo",
"ipaenabledflag": "rscwo",
"ipasudoopt": "rscwo",
"ipasudorunas": "rscwo",
"ipasudorunasextgroup": "rscwo",
"ipasudorunasextuser": "rscwo",
"ipasudorunasgroup": "rscwo",
"ipasudorunasgroupcategory": "rscwo",
"ipasudorunasusercategory": "rscwo",
"ipauniqueid": "rsc",
"memberallowcmd": "rscwo",
"memberdenycmd": "rscwo",
"memberhost": "rscwo",
"memberuser": "rscwo",
"nsaccountlock": "rscwo",
"usercategory": "rscwo"
},
"cmdcategory": [
"all"
],
"cn": [
"test"
],
"description": [
"Test Rule"
],
"ipauniqueid": [
"94ef3550-f443-11df-a2aa-00163e72f2d9"
],
"objectclass": [
"ipaassociation",
"ipasudorule"
]
},
"summary": null,
"value": "test"
}
}
+1 -1
View File
@@ -101,7 +101,7 @@ test('Testing ipa_facet_setup_views().', function() {
counter++;
};
facet.setup_views(container);
facet.create_action_panel(container);
//Container now has two divs, one for the action panel one for content
var list = container.children().last().children();