From 06a7a1b3cb277284448dd8344940395f0b29cd70 Mon Sep 17 00:00:00 2001 From: Petr Vobornik Date: Mon, 10 Mar 2014 17:05:51 +0100 Subject: webui: replace IPA.command usage with rpc.command Replace all IPA.command, IPA.batch_command and IPA.concurrent_command usages by equivalents from rpc module. Reviewed-By: Adam Misnyovszki --- install/ui/doc/categories.json | 6 ++--- install/ui/src/freeipa/add.js | 10 ++++---- install/ui/src/freeipa/association.js | 23 +++++++++--------- install/ui/src/freeipa/automember.js | 9 ++++--- install/ui/src/freeipa/certificate.js | 11 +++++---- install/ui/src/freeipa/details.js | 34 +++++++++++++------------- install/ui/src/freeipa/dialogs/password.js | 5 ++-- install/ui/src/freeipa/dns.js | 27 +++++++++++---------- install/ui/src/freeipa/facet.js | 8 +++--- install/ui/src/freeipa/field.js | 9 ++++--- install/ui/src/freeipa/hbac.js | 3 ++- install/ui/src/freeipa/hbactest.js | 7 +++--- install/ui/src/freeipa/host.js | 9 ++++--- install/ui/src/freeipa/ipa.js | 38 +++++++++++++++-------------- install/ui/src/freeipa/rpc.js | 39 +++++++++++------------------- install/ui/src/freeipa/rule.js | 5 ++-- install/ui/src/freeipa/search.js | 13 +++++----- install/ui/src/freeipa/service.js | 5 ++-- install/ui/src/freeipa/sudo.js | 11 +++++---- install/ui/src/freeipa/user.js | 11 +++++---- install/ui/src/freeipa/widget.js | 7 +++--- install/ui/test/association_tests.js | 36 +++++++++++++++------------ install/ui/test/details_tests.js | 9 ++++--- install/ui/test/ipa_tests.js | 18 +++++++++----- ipatests/test_webui/ui_driver.py | 4 +-- 25 files changed, 189 insertions(+), 168 deletions(-) diff --git a/install/ui/doc/categories.json b/install/ui/doc/categories.json index f5df41926..2634986f2 100644 --- a/install/ui/doc/categories.json +++ b/install/ui/doc/categories.json @@ -7,9 +7,9 @@ "classes": [ "IPA.object", "IPA.observer", - "IPA.command", - "IPA.batch_command", - "IPA.concurrent_command", + "rpc.command", + "rpc.batch_command", + "rpc.concurrent_command", "entity.entity" ] }, diff --git a/install/ui/src/freeipa/add.js b/install/ui/src/freeipa/add.js index 22761c5ad..0a0942e97 100644 --- a/install/ui/src/freeipa/add.js +++ b/install/ui/src/freeipa/add.js @@ -19,8 +19,8 @@ * along with this program. If not, see . */ -define(['./ipa', './jquery', './navigation', './text', './field', './widget', './dialog'], - function(IPA, $, navigation, text) { +define(['./ipa', './jquery', './navigation', './rpc', './text', './field', './widget', './dialog'], + function(IPA, $, navigation, rpc, text) { /** * Entity adder dialog @@ -42,11 +42,11 @@ IPA.entity_adder_dialog = function(spec) { that.method = spec.method || 'add'; /** @property {Function} on_error Custom add error handler */ that.on_error = spec.on_error ; - /** @property {boolean} retry=true Allow retry on error (same as in IPA.command)*/ + /** @property {boolean} retry=true Allow retry on error (same as in rpc.command)*/ that.retry = typeof spec.retry !== 'undefined' ? spec.retry : true; /** * Add command - * @property {IPA.command} + * @property {rpc.command} * @protected */ that.command = null; @@ -184,7 +184,7 @@ IPA.entity_adder_dialog = function(spec) { var pkey_name = that.entity.metadata.primary_key; - var command = IPA.command({ + var command = rpc.command({ entity: that.entity.name, method: that.method, retry: that.retry diff --git a/install/ui/src/freeipa/association.js b/install/ui/src/freeipa/association.js index 0c337bdff..0eef1e8da 100644 --- a/install/ui/src/freeipa/association.js +++ b/install/ui/src/freeipa/association.js @@ -31,13 +31,14 @@ define([ './navigation', './phases', './reg', + './rpc', './spec_util', './text', './facet', './search', './dialog'], function(lang, Deferred, metadata_provider, IPA, $, navigation, - phases, reg, su, text) { + phases, reg, rpc, su, text) { /** * Association module @@ -93,7 +94,7 @@ IPA.serial_associator = function(spec) { return; } - var batch = IPA.batch_command({ + var batch = rpc.batch_command({ on_success: that.on_success, on_error: that.on_error }); @@ -105,7 +106,7 @@ IPA.serial_associator = function(spec) { options = {}; options[that.entity.name] = that.pkey; - command = IPA.command({ + command = rpc.command({ entity: that.other_entity.name, method: that.method, args: args, @@ -140,7 +141,7 @@ IPA.bulk_associator = function(spec) { return; } - var command = IPA.command({ + var command = rpc.command({ entity: that.entity.name, method: that.method, args: [that.pkey], @@ -313,7 +314,7 @@ IPA.association_adder_dialog = function(spec) { } } - IPA.command({ + rpc.command({ entity: that.other_entity.name, method: 'find', args: [that.get_filter()], @@ -668,7 +669,7 @@ IPA.association_table_widget = function (spec) { var pkey = that.facet.get_pkey(); - var command = IPA.command({ + var command = rpc.command({ entity: that.entity.name, method: that.add_method, args: [pkey], @@ -732,7 +733,7 @@ IPA.association_table_widget = function (spec) { var pkey = that.facet.get_pkey(); - var command = IPA.command({ + var command = rpc.command({ entity: that.entity.name, method: that.remove_method, args: [pkey], @@ -795,7 +796,7 @@ IPA.association_table_field = function (spec) { } var pkey = that.facet.get_pkey(); - IPA.command({ + rpc.command({ entity: that.entity.name, method: 'show', args: [pkey], @@ -1246,7 +1247,7 @@ exp.association_facet = IPA.association_facet = function (spec, no_init) { var pkeys = that.get_pkeys(); - var command = IPA.command({ + var command = rpc.command({ entity: that.entity.name, method: 'show', args: pkeys @@ -1407,7 +1408,7 @@ exp.attribute_facet = IPA.attribute_facet = function(spec, no_init) { var pkey = that.get_pkeys(); - var command = IPA.command({ + var command = rpc.command({ entity: that.entity.name, method: 'show', args: pkey @@ -1492,7 +1493,7 @@ exp.attribute_facet = IPA.attribute_facet = function(spec, no_init) { var pkey = that.get_pkeys(); - var command = IPA.command({ + var command = rpc.command({ entity: that.entity.name, method: that.remove_method, args: pkey, diff --git a/install/ui/src/freeipa/automember.js b/install/ui/src/freeipa/automember.js index 50fc69741..e9619b731 100644 --- a/install/ui/src/freeipa/automember.js +++ b/install/ui/src/freeipa/automember.js @@ -25,12 +25,13 @@ define([ './navigation', './phases', './reg', + './rpc', './text', './details', './search', './association', './entity'], - function(metadata_provider, IPA, $, navigation, phases, reg, text) { + function(metadata_provider, IPA, $, navigation, phases, reg, rpc, text) { var exp = IPA.automember = {}; @@ -524,7 +525,7 @@ IPA.automember.condition_widget = function(spec) { that.create_remove_command = function(values, on_success, on_error) { - var batch = IPA.batch_command({ + var batch = rpc.batch_command({ name: 'automember_remove_condition', on_success: on_success, on_error: on_error @@ -628,7 +629,7 @@ IPA.automember.default_group_widget = function(spec) { method = 'default_group_' + method; var command_name = that.entity.name + that.group_type + '_' + method; - var command = IPA.command({ + var command = rpc.command({ name: command_name, entity: that.entity.name, method: method, @@ -726,7 +727,7 @@ IPA.automember.rebuild_action = function(spec) { options['type'] = 'hostgroup'; } - var command = IPA.command({ + var command = rpc.command({ entity: 'automember', method: 'rebuild', options: options, diff --git a/install/ui/src/freeipa/certificate.js b/install/ui/src/freeipa/certificate.js index bd9f7459a..7a7ece0e1 100755 --- a/install/ui/src/freeipa/certificate.js +++ b/install/ui/src/freeipa/certificate.js @@ -27,9 +27,10 @@ define([ './menu', './phases', './reg', + './rpc', './text', './dialog'], - function(lang, metadata_provider, IPA, $, menu, phases, reg, text) { + function(lang, metadata_provider, IPA, $, menu, phases, reg, rpc, text) { var exp = IPA.cert = {}; @@ -517,7 +518,7 @@ IPA.cert.load_policy = function(spec) { }; that.load_revocation_reason = function(serial_number) { - IPA.command({ + rpc.command({ entity: 'cert', method: 'show', args: [serial_number], @@ -643,7 +644,7 @@ IPA.cert.request_action = function(spec) { message: request_message, request: function(values) { - IPA.command({ + rpc.command({ entity: 'cert', method: 'request', args: [values.request], @@ -702,7 +703,7 @@ IPA.cert.revoke_action = function(spec) { var certificate = facet.certificate; - IPA.command({ + rpc.command({ entity: 'cert', method: 'revoke', args: [certificate.serial_number], @@ -759,7 +760,7 @@ IPA.cert.restore_action = function(spec) { var certificate = facet.certificate; - IPA.command({ + rpc.command({ entity: 'cert', method: 'remove_hold', args: [certificate.serial_number], diff --git a/install/ui/src/freeipa/details.js b/install/ui/src/freeipa/details.js index 206b55ab8..8b3eddb1f 100644 --- a/install/ui/src/freeipa/details.js +++ b/install/ui/src/freeipa/details.js @@ -28,11 +28,12 @@ define([ './jquery', './phases', './reg', + './rpc', './spec_util', './text', './facet', './add'], - function(lang, builder, IPA, $, phases, reg, su, text) { + function(lang, builder, IPA, $, phases, reg, rpc, su, text) { /** * Details module @@ -825,7 +826,7 @@ exp.details_facet = IPA.details_facet = function(spec, no_init) { * Adds update info as command options * @protected * @param {details.update_info} update_info - * @param {IPA.command} command + * @param {rpc.command} command */ that.add_fields_to_command = function(update_info, command) { @@ -833,7 +834,7 @@ exp.details_facet = IPA.details_facet = function(spec, no_init) { var field_info = update_info.fields[i]; if (field_info.field.flags.indexOf('no_command') > -1) continue; var values = field_info.field.save(); - IPA.command_builder.add_field_option( + exp.command_builder.add_field_option( command, field_info.field, values); @@ -844,7 +845,7 @@ exp.details_facet = IPA.details_facet = function(spec, no_init) { * Create update command based on field part of update info * @protected * @param {details.update_info} update_info - * @return {IPA.command} + * @return {rpc.command} */ that.create_fields_update_command = function(update_info) { @@ -853,7 +854,7 @@ exp.details_facet = IPA.details_facet = function(spec, no_init) { var options = { all: true }; if (that.check_rights) options.rights = true; - var command = IPA.command({ + var command = rpc.command({ entity: that.entity.name, method: that.update_command_name, args: args, @@ -873,11 +874,11 @@ exp.details_facet = IPA.details_facet = function(spec, no_init) { * to reflect field part of update info (if present). * @protected * @param {details.update_info} update_info - * @return {IPA.batch_command} + * @return {rpc.batch_command} */ that.create_batch_update_command = function(update_info) { - var batch = IPA.batch_command({ + var batch = rpc.batch_command({ name: that.entity.name + '_details_update' }); @@ -915,7 +916,7 @@ exp.details_facet = IPA.details_facet = function(spec, no_init) { /** * Create update command * @protected - * @return {IPA.command/IPA.batch_command} + * @return {rpc.command|rpc.batch_command} */ that.create_update_command = function() { @@ -975,14 +976,14 @@ exp.details_facet = IPA.details_facet = function(spec, no_init) { /** * Create refresh command * @protected - * @return {IPA.command} + * @return {rpc.command} */ that.create_refresh_command = function() { var options = { all: true }; if (that.check_rights) options.rights = true; - var command = IPA.command({ + var command = rpc.command({ name: that.get_refresh_command_name(), entity: that.entity.name, method: 'show', @@ -1169,7 +1170,7 @@ exp.update_info = IPA.update_info = function(spec) { /** * Create new command info and add it to collection - * @param {IPA.command} command + * @param {rpc.command} command * @param {number} priority */ that.append_command = function (command, priority) { @@ -1191,7 +1192,7 @@ exp.command_info = IPA.command_info = function(spec) { /** * Command - * @property {IPA.command} + * @property {rpc.command} */ that.command = spec.command; @@ -1268,7 +1269,7 @@ exp.update_info_builder = IPA.update_info_builder = function() { /** * Create new command info - * @param {IPA.command} command + * @param {rpc.command} command * @param {number} priority * @return {details.command_info} */ @@ -1309,16 +1310,15 @@ exp.update_info_builder = IPA.update_info_builder = function() { * Field add/mod command builder * * @class details.command_builder - * @alternateClassName IPA.command_builder * @singleton */ -exp.command_builder = IPA.command_builder = function() { +exp.command_builder = function() { var that = IPA.object(); /** * Add option to command with field values - * @param {IPA.command} command + * @param {rpc.command} command * @param {IPA.field} field * @param {Array} values */ @@ -1790,7 +1790,7 @@ exp.object_action = IPA.object_action = function(spec) { var entity_name = facet.entity.name; var pkeys = facet.get_pkeys(); - IPA.command({ + rpc.command({ entity: entity_name, method: that.method, args: pkeys, diff --git a/install/ui/src/freeipa/dialogs/password.js b/install/ui/src/freeipa/dialogs/password.js index d0fdcc846..35f96e4b7 100644 --- a/install/ui/src/freeipa/dialogs/password.js +++ b/install/ui/src/freeipa/dialogs/password.js @@ -24,9 +24,10 @@ define([ '../ipa', '../phases', '../reg', + '../rpc', '../text', '../dialog'], - function(lang, builder, IPA, phases, reg, text) { + function(lang, builder, IPA, phases, reg, rpc, text) { var dialogs = {}; // dummy object /** @@ -211,7 +212,7 @@ dialogs.password.dialog = function(spec) { that.create_command = function() { var options = that.make_otions(); - var command = IPA.command({ + var command = rpc.command({ entity: that.entity.name, method: that.method, args: that.pkeys, diff --git a/install/ui/src/freeipa/dns.js b/install/ui/src/freeipa/dns.js index 3ef5620f4..1432eb910 100644 --- a/install/ui/src/freeipa/dns.js +++ b/install/ui/src/freeipa/dns.js @@ -28,12 +28,13 @@ define([ './menu', './phases', './reg', + './rpc', './text', './details', './search', './association', './entity'], - function(IPA, $, NET, navigation, menu, phases, reg, text) { + function(IPA, $, NET, navigation, menu, phases, reg, rpc, text) { var exp = IPA.dns = { zone_permission_name: 'Manage DNS zone ${dnszone}' @@ -340,7 +341,7 @@ IPA.dnszone_details_facet = function(spec, no_init) { var pkey = that.get_pkey(); - var batch = IPA.batch_command({ + var batch = rpc.batch_command({ name: 'dnszone_details_refresh' }); @@ -357,7 +358,7 @@ IPA.dnszone_details_facet = function(spec, no_init) { var permission_name = IPA.dns.zone_permission_name.replace('${dnszone}', pkey); - var permission_command = IPA.command({ + var permission_command = rpc.command({ entity: 'permission', method: 'show', args: [permission_name], @@ -595,7 +596,7 @@ IPA.dns.add_permission_action = function(spec) { var pkey = facet.get_pkey(); - var command = IPA.command({ + var command = rpc.command({ entity: 'dnszone', method: 'add_permission', args: [pkey], @@ -625,7 +626,7 @@ IPA.dns.remove_permission_action = function(spec) { var pkey = facet.get_pkey(); - var command = IPA.command({ + var command = rpc.command({ entity: 'dnszone', method: 'remove_permission', args: [pkey], @@ -668,7 +669,7 @@ IPA.dns.record_search_facet = function(spec) { that.get_records = function(pkeys, on_success, on_error) { - var batch = IPA.batch_command({ + var batch = rpc.batch_command({ name: that.get_records_command_name(), on_success: on_success, on_error: on_error @@ -679,7 +680,7 @@ IPA.dns.record_search_facet = function(spec) { for (var i=0; i} spec.commands - IPA commands to be executed + * @param {rpc.command[]} spec.commands - IPA commands to be executed * @param {Function} spec.on_success - callback function if command succeeds * @param {Function} spec.on_error - callback function if command fails */ @@ -471,12 +469,12 @@ rpc.batch_command = function(spec) { spec.method = 'batch'; - var that = IPA.command(spec); + var that = rpc.command(spec); - /** @property {IPA.command[]} commands Commands */ + /** @property {rpc.command[]} commands Commands */ that.commands = []; - /** @property {IPA.error_list} errors Errors */ - that.errors = IPA.error_list(); + /** @property {rpc.error_list} errors Errors */ + that.errors = rpc.error_list(); /** * Show error if some command fail @@ -487,7 +485,7 @@ rpc.batch_command = function(spec) { /** * Add command - * @param {IPA.command} command + * @param {rpc.command} command */ that.add_command = function(command) { that.commands.push(command); @@ -496,7 +494,7 @@ rpc.batch_command = function(spec) { /** * Add commands - * @param {IPA.command[]} commands + * @param {rpc.command[]} commands */ that.add_commands = function(commands) { for (var i=0; i 0) { //no need to delete if has no values - var command = IPA.command({ + var command = rpc.command({ entity: that.entity.name, method: that.widget.remove_method, args: that.facet.get_pkeys() diff --git a/install/ui/src/freeipa/search.js b/install/ui/src/freeipa/search.js index 394de3e8c..9400b6aec 100644 --- a/install/ui/src/freeipa/search.js +++ b/install/ui/src/freeipa/search.js @@ -26,10 +26,11 @@ define([ './jquery', './phases', './reg', + './rpc', './spec_util', './text', './facet'], - function(IPA, $, phases, reg, su, text, mod_facet) { + function(IPA, $, phases, reg, rpc, su, text, mod_facet) { var exp = {}; @@ -235,7 +236,7 @@ IPA.search_facet = function(spec, no_init) { var args = that.get_refresh_command_args(); - var command = IPA.command({ + var command = rpc.command({ name: that.get_search_command_name(), entity: that.managed_entity.name, method: 'find', @@ -312,12 +313,12 @@ IPA.search_deleter_dialog = function(spec) { that.pkey_prefix = spec.pkey_prefix || []; that.create_command = function() { - var batch = IPA.batch_command({ + var batch = rpc.batch_command({ error_message: '@i18n:search.partial_delete' }); for (var i=0; i. */ -define(['freeipa/ipa', 'freeipa/jquery', 'freeipa/dialog', 'freeipa/widget', - 'freeipa/details'], function(IPA, $) { +define([ + 'freeipa/ipa', + 'freeipa/jquery', + 'freeipa/rpc', + 'freeipa/dialog', + 'freeipa/widget', + 'freeipa/details'], + function(IPA, $, rpc) { return function() { module('ipa'); @@ -88,7 +94,7 @@ test("Testing IPA.get_member_attribute().", function() { "IPA.get_member_attribute(null, \"group\")"); }); -test("Testing successful IPA.command().", function() { +test("Testing successful rpc.command().", function() { var method = 'method'; var args = ['arg1', 'arg2', 'arg3']; @@ -138,7 +144,7 @@ test("Testing successful IPA.command().", function() { request.success(xhr, text_status, error_thrown); }; - IPA.command({ + rpc.command({ entity: object, method: method, args: args, @@ -164,7 +170,7 @@ test("Testing successful IPA.command().", function() { $.ajax = orig; }); -test("Testing unsuccessful IPA.command().", function() { +test("Testing unsuccessful rpc.command().", function() { var method = 'method'; var args = ['arg1', 'arg2', 'arg3']; @@ -209,7 +215,7 @@ test("Testing unsuccessful IPA.command().", function() { request.error(xhr, text_status, error_thrown); }; - IPA.command({ + rpc.command({ entity: object, method: method, args: args, diff --git a/ipatests/test_webui/ui_driver.py b/ipatests/test_webui/ui_driver.py index f0b9b4362..0e10c6b52 100644 --- a/ipatests/test_webui/ui_driver.py +++ b/ipatests/test_webui/ui_driver.py @@ -521,9 +521,9 @@ class UI_driver(object): var args = arguments[1]; var options = arguments[2]; var callback = arguments[arguments.length - 1]; - var IPA = require('freeipa/ipa'); + var rpc = require('freeipa/rpc'); - var cmd = IPA.command({ + var cmd = rpc.command({ method: method, args: args, options: options, -- cgit