Removed unnecessary HBAC/sudo rule category modification.

Since the Add/Delete links in the association table are disabled when
the category is set to 'all', it's no longer necessary to check the
category before showing the add/delete dialogs and modify the category
before adding entries. Thus, the IPA.rule_association_table_widget is
no longer needed.

Ticket #1692
This commit is contained in:
Endi S. Dewata 2011-08-22 15:06:00 -05:00
parent 610faff6f3
commit 5f9fcd1be0
6 changed files with 40 additions and 134 deletions

View File

@ -350,32 +350,32 @@ IPA.association_table_widget = function (spec) {
that.table_create(container);
var button = IPA.action_button({
var remove_button = IPA.action_button({
name: 'remove',
label: IPA.messages.buttons.remove,
icon: 'remove-icon',
click: function() {
that.remove_handler();
if (!remove_button.hasClass('action-button-disabled')) {
that.remove_handler();
}
return false;
}
}).appendTo(that.buttons);
button = IPA.action_button({
var add_button = IPA.action_button({
name: 'add',
label: IPA.messages.buttons.add,
icon: 'add-icon',
click: function() {
that.add_handler();
if (!add_button.hasClass('action-button-disabled')) {
that.add_handler();
}
return false;
}
}).appendTo(that.buttons);
};
that.add_handler = function() {
if ($(this).hasClass('action-button-disabled')) {
return;
}
var facet = that.entity.get_facet();
if (facet.is_dirty()) {
@ -396,10 +396,6 @@ IPA.association_table_widget = function (spec) {
};
that.remove_handler = function() {
if ($(this).hasClass('action-button-disabled')) {
return;
}
var facet = that.entity.get_facet();
if (facet.is_dirty()) {
@ -838,7 +834,6 @@ IPA.association_facet = function (spec) {
that.facet_create_header(container);
that.pkey = IPA.nav.get_state(that.entity.name+'-pkey');
var other_label = IPA.metadata.objects[that.other_entity].label;
if (!that.read_only) {
that.remove_button = IPA.action_button({
@ -846,7 +841,9 @@ IPA.association_facet = function (spec) {
label: IPA.messages.buttons.remove,
icon: 'remove-icon',
click: function() {
that.show_remove_dialog();
if (!that.remove_button.hasClass('action-button-disabled')) {
that.show_remove_dialog();
}
return false;
}
}).appendTo(that.controls);
@ -856,7 +853,9 @@ IPA.association_facet = function (spec) {
label: IPA.messages.buttons.enroll,
icon: 'add-icon',
click: function() {
that.show_add_dialog();
if (!that.add_button.hasClass('action-button-disabled')) {
that.show_add_dialog();
}
return false;
}
}).appendTo(that.controls);

View File

@ -181,22 +181,20 @@ IPA.hbacrule_details_facet = function(spec) {
]
});
var category = section.add_field(IPA.radio_widget({
section.add_field(IPA.radio_widget({
name: 'usercategory'
}));
section.add_field(IPA.rule_association_table_widget({
section.add_field(IPA.association_table_widget({
id: that.entity.name+'-memberuser_user',
name: 'memberuser_user',
category: category,
add_method: 'add_user',
remove_method: 'remove_user',
add_title: IPA.messages.association.add.member,
remove_title: IPA.messages.association.remove.member
}));
section.add_field(IPA.rule_association_table_widget({
section.add_field(IPA.association_table_widget({
id: that.entity.name+'-memberuser_group',
name: 'memberuser_group',
category: category,
add_method: 'add_user',
remove_method: 'remove_user',
add_title: IPA.messages.association.add.member,
@ -222,22 +220,20 @@ IPA.hbacrule_details_facet = function(spec) {
]
});
var category = section.add_field(IPA.radio_widget({
section.add_field(IPA.radio_widget({
name: 'hostcategory'
}));
section.add_field(IPA.rule_association_table_widget({
section.add_field(IPA.association_table_widget({
id: that.entity.name+'-memberhost_host',
name: 'memberhost_host',
category: category,
add_method: 'add_host',
remove_method: 'remove_host',
add_title: IPA.messages.association.add.member,
remove_title: IPA.messages.association.remove.member
}));
section.add_field(IPA.rule_association_table_widget({
section.add_field(IPA.association_table_widget({
id: that.entity.name+'-memberhost_hostgroup',
name: 'memberhost_hostgroup',
category: category,
add_method: 'add_host',
remove_method: 'remove_host',
add_title: IPA.messages.association.add.member,
@ -264,22 +260,20 @@ IPA.hbacrule_details_facet = function(spec) {
]
});
var category = section.add_field(IPA.radio_widget({
section.add_field(IPA.radio_widget({
name: 'servicecategory'
}));
section.add_field(IPA.rule_association_table_widget({
section.add_field(IPA.association_table_widget({
id: that.entity.name+'-memberservice_hbacsvc',
name: 'memberservice_hbacsvc',
category: category,
add_method: 'add_service',
remove_method: 'remove_service',
add_title: IPA.messages.association.add.member,
remove_title: IPA.messages.association.remove.member
}));
section.add_field(IPA.rule_association_table_widget({
section.add_field(IPA.association_table_widget({
id: that.entity.name+'-memberservice_hbacsvcgroup',
name: 'memberservice_hbacsvcgroup',
category: category,
add_method: 'add_service',
remove_method: 'remove_service',
add_title: IPA.messages.association.add.member,
@ -305,22 +299,20 @@ IPA.hbacrule_details_facet = function(spec) {
]
});
var category = section.add_field(IPA.radio_widget({
section.add_field(IPA.radio_widget({
name: 'sourcehostcategory'
}));
section.add_field(IPA.rule_association_table_widget({
section.add_field(IPA.association_table_widget({
id: that.entity.name+'-sourcehost_host',
name: 'sourcehost_host',
category: category,
add_method: 'add_sourcehost',
remove_method: 'remove_sourcehost',
add_title: IPA.messages.association.add.sourcehost,
remove_title: IPA.messages.association.remove.sourcehost
}));
section.add_field(IPA.rule_association_table_widget({
section.add_field(IPA.association_table_widget({
id: that.entity.name+'-sourcehost_hostgroup',
name: 'sourcehost_hostgroup',
category: category,
add_method: 'add_sourcehost',
remove_method: 'remove_sourcehost',
add_title: IPA.messages.association.add.sourcehost,

View File

@ -130,15 +130,6 @@ body {
cursor: pointer;
}
.input_link_disabled {
cursor: default;
color:black;
}
.input_link_label {
}
.icon {
display: inline-block;
height: 16px;
@ -1034,7 +1025,7 @@ span.main-separator{
padding: 0 0.2em;
}
a.action-button-disabled {
.action-button-disabled {
color: gray;
cursor: default;
}

View File

@ -104,69 +104,3 @@ IPA.rule_details_section = function(spec) {
return that;
};
IPA.rule_association_table_widget = function(spec) {
spec = spec || {};
var that = IPA.association_table_widget(spec);
that.category = spec.category;
that.show_add_dialog = function() {
if (that.category) {
var values = that.category.save();
if (values[0] !== '') return;
}
that.association_table_widget_show_add_dialog();
};
that.show_remove_dialog = function() {
if (that.category) {
var values = that.category.save();
if (values[0] !== '') return;
}
that.association_table_widget_show_remove_dialog();
};
that.add = function(values, on_success, on_error) {
var pkey = IPA.nav.get_state(that.entity.name+'-pkey');
var batch = IPA.batch_command({
'on_success': on_success,
'on_error': on_error
});
var command;
if (that.category) {
command = IPA.command({
entity: that.entity.name,
method: 'mod',
args: [pkey],
options: {all: true, rights: true},
on_success: function() {
var record = {};
record[that.category.name] = [''];
that.category.load(record);
}
});
command.set_option(that.category.name, '');
batch.add_command(command);
}
command = IPA.command({
entity: that.entity.name,
method: that.add_method,
args: [pkey]
});
command.set_option(that.other_entity, values.join(','));
batch.add_command(command);
batch.execute();
};
return that;
};

View File

@ -146,10 +146,9 @@ IPA.search_facet = function(spec) {
label: IPA.messages.buttons.remove,
icon: 'remove-icon',
click: function() {
if (that.remove_button.hasClass('input_link_disabled')) {
return false;
if (!that.remove_button.hasClass('action-button-disabled')) {
that.remove();
}
that.remove();
return false;
}
}).appendTo(that.controls);
@ -181,9 +180,9 @@ IPA.search_facet = function(spec) {
if (that.remove_button) {
if (values.length === 0) {
that.remove_button.addClass('input_link_disabled');
that.remove_button.addClass('action-button-disabled');
} else {
that.remove_button.removeClass('input_link_disabled');
that.remove_button.removeClass('action-button-disabled');
}
}
};

View File

@ -180,7 +180,7 @@ IPA.sudorule_details_facet = function(spec) {
]
});
var category = section.add_field(IPA.radio_widget({
section.add_field(IPA.radio_widget({
entity: that.entity,
name: 'usercategory'
}));
@ -188,7 +188,6 @@ IPA.sudorule_details_facet = function(spec) {
id: that.entity.name+'-memberuser_user',
entity: that.entity,
name: 'memberuser_user',
category: category,
add_method: 'add_user',
remove_method: 'remove_user',
external: 'externaluser',
@ -199,7 +198,6 @@ IPA.sudorule_details_facet = function(spec) {
id: that.entity.name+'-memberuser_group',
entity: that.entity,
name: 'memberuser_group',
category: category,
add_method: 'add_user',
remove_method: 'remove_user',
add_title: IPA.messages.association.add.member,
@ -224,7 +222,7 @@ IPA.sudorule_details_facet = function(spec) {
]
});
var category = section.add_field(IPA.radio_widget({
section.add_field(IPA.radio_widget({
entity: that.entity,
name: 'hostcategory'
}));
@ -232,7 +230,6 @@ IPA.sudorule_details_facet = function(spec) {
id: that.entity.name+'-memberhost_host',
entity: that.entity,
name: 'memberhost_host',
category: category,
add_method: 'add_host',
remove_method: 'remove_host',
external: 'externalhost',
@ -243,7 +240,6 @@ IPA.sudorule_details_facet = function(spec) {
id: that.entity.name+'-memberhost_hostgroup',
entity: that.entity,
name: 'memberhost_hostgroup',
category: category,
add_method: 'add_host',
remove_method: 'remove_host',
add_title: IPA.messages.association.add.member,
@ -680,26 +676,24 @@ IPA.sudo.rule_details_command_section = function(spec) {
]
}));
that.add_field(IPA.rule_association_table_widget({
that.add_field(IPA.association_table_widget({
id: that.entity.name+'-memberallowcmd_sudocmd',
name: 'memberallowcmd_sudocmd',
category: that.category,
add_method: 'add_allow_command',
remove_method: 'remove_allow_command',
add_title: IPA.messages.association.add.memberallowcmd,
remove_title: IPA.messages.association.remove.memberallowcmd
}));
that.add_field(IPA.rule_association_table_widget({
that.add_field(IPA.association_table_widget({
id: that.entity.name+'-memberallowcmd_sudocmdgroup',
name: 'memberallowcmd_sudocmdgroup',
category: that.category,
add_method: 'add_allow_command',
remove_method: 'remove_allow_command',
add_title: IPA.messages.association.add.memberallowcmd,
remove_title: IPA.messages.association.remove.memberallowcmd
}));
that.add_field(IPA.rule_association_table_widget({
that.add_field(IPA.association_table_widget({
id: that.entity.name+'-memberdenycmd_sudocmd',
name: 'memberdenycmd_sudocmd',
add_method: 'add_deny_command',
@ -707,7 +701,7 @@ IPA.sudo.rule_details_command_section = function(spec) {
add_title: IPA.messages.association.add.memberdenycmd,
remove_title: IPA.messages.association.remove.memberdenycmd
}));
that.add_field(IPA.rule_association_table_widget({
that.add_field(IPA.association_table_widget({
id: that.entity.name+'-memberdenycmd_sudocmdgroup',
name: 'memberdenycmd_sudocmdgroup',
add_method: 'add_deny_command',
@ -834,7 +828,7 @@ IPA.sudo.rule_details_runas_section = function(spec) {
var that = IPA.details_section(spec);
function add_extra_fields(){
var category = that.add_field(
that.add_field(
IPA.radio_widget({
name: 'ipasudorunasusercategory',
options:[
@ -851,7 +845,6 @@ IPA.sudo.rule_details_runas_section = function(spec) {
that.add_field(IPA.sudorule_association_table_widget({
id: that.entity.name+'-runasruser_user',
name: 'ipasudorunas_user',
category: category,
add_method: 'add_runasuser',
remove_method: 'remove_runasuser',
add_title: IPA.messages.association.add.ipasudorunas,
@ -860,14 +853,13 @@ IPA.sudo.rule_details_runas_section = function(spec) {
that.add_field(IPA.sudorule_association_table_widget({
id: that.entity.name+'-runasuser_group',
name: 'ipasudorunas_group',
category: category,
add_method: 'add_runasuser',
remove_method: 'remove_runasuser',
add_title: IPA.messages.association.add.ipasudorunas,
remove_title: IPA.messages.association.remove.ipasudorunas
}));
category = that.add_field(
that.add_field(
IPA.radio_widget({
name: 'ipasudorunasgroupcategory',
options:[
@ -885,7 +877,6 @@ IPA.sudo.rule_details_runas_section = function(spec) {
that.add_field(IPA.sudorule_association_table_widget({
id: that.entity.name+'-runasgroup_group',
name: 'ipasudorunasgroup_group',
category: category,
add_method: 'add_runasgroup',
remove_method: 'remove_runasgroup',
add_title: IPA.messages.association.add.ipasudorunasgroup,
@ -1020,7 +1011,7 @@ IPA.sudorule_association_table_widget = function(spec) {
spec = spec || {};
var that = IPA.rule_association_table_widget(spec);
var that = IPA.association_table_widget(spec);
that.external = spec.external;