Hello, please review attached patches, they add 'Delete Server' button.
-- Pavel^3 Vomacka
From d8100e60bb7cf248f65191223e3e11340372d193 Mon Sep 17 00:00:00 2001 From: Pavel Vomacka <pvoma...@redhat.com> Date: Fri, 24 Jun 2016 12:07:03 +0200 Subject: [PATCH 1/2] Add support to change button css class on confirm dialog Part of: https://fedorahosted.org/freeipa/ticket/5588 --- install/ui/src/freeipa/dialog.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/install/ui/src/freeipa/dialog.js b/install/ui/src/freeipa/dialog.js index 3d156ce10356d5f4f9ab506dfc924a01fd354ea3..4f376b14689b07ab8b5ac9a4c2d8f76919dfff28 100644 --- a/install/ui/src/freeipa/dialog.js +++ b/install/ui/src/freeipa/dialog.js @@ -185,6 +185,8 @@ IPA.dialog_button = function(spec) { that.visible = spec.visible !== undefined ? spec.visible : true; /** @property {boolean} enabled=true Button is enabled */ that.enabled = spec.enabled !== undefined ? spec.enabled : true; + /** @property {String} button's css classes */ + that.button_class = spec.button_class || 'btn btn-default'; /** @property {jQuery} element Button element */ that.element = null; @@ -495,6 +497,7 @@ IPA.dialog = function(spec) { var ui_button = IPA.button({ name: button.name, label: button.label, + button_class: button.button_class, disabled: !button.enabled, click: button.click }); @@ -1360,6 +1363,12 @@ IPA.confirm_dialog = function(spec) { /** @property {Function} cancel_label Cancel button label */ that.cancel_label = text.get(spec.cancel_label || '@i18n:buttons.cancel'); + /** @property {String} on_ok css class */ + that.ok_button_class = spec.ok_button_class || 'btn btn-default'; + + /** @property {String} on_cancel css class */ + that.cancel_button_class = spec.cancel_button_class || 'btn btn-default'; + /** * Dialog is confirmed * @protected @@ -1417,6 +1426,7 @@ IPA.confirm_dialog = function(spec) { that.create_button({ name: 'ok', label: that.ok_label, + button_class: that.ok_button_class, click: function() { that.on_confirm(); } @@ -1425,6 +1435,7 @@ IPA.confirm_dialog = function(spec) { that.create_button({ name: 'cancel', label: that.cancel_label, + button_class: that.cancel_button_class, click: function() { that.confirmed = false; that.close(); -- 2.5.5
From 8930ec7702ac3939e69c3ced5a1da806a81a8c87 Mon Sep 17 00:00:00 2001 From: Pavel Vomacka <pvoma...@redhat.com> Date: Fri, 24 Jun 2016 12:08:04 +0200 Subject: [PATCH 2/2] Add button for server-del command WebUI counterpart of: https://fedorahosted.org/freeipa/ticket/5588 --- install/ui/src/freeipa/topology.js | 85 +++++++++++++++++++++++++++++++++++++- install/ui/test/data/ipa_init.json | 4 ++ ipaserver/plugins/internal.py | 4 ++ 3 files changed, 92 insertions(+), 1 deletion(-) diff --git a/install/ui/src/freeipa/topology.js b/install/ui/src/freeipa/topology.js index a9776a5567adf1dcea7a4e62c89f90a573e9ca66..56c65c2dd87e59fe2614f0157e822dda3dbef631 100644 --- a/install/ui/src/freeipa/topology.js +++ b/install/ui/src/freeipa/topology.js @@ -222,6 +222,7 @@ return { }, { $type: 'details', + $factory: topology.servers_facet, disable_facet_tabs: true, sections: [ { @@ -253,6 +254,15 @@ return { } ] } + ], + actions: [ 'server_del' ], + control_buttons_right: [ + { + name: 'server_del', + label: '@i18n:objects.servers.remove_server', + icon: 'fa-exclamation-circle', + button_class: 'btn btn-danger' + } ] } ] @@ -458,6 +468,44 @@ topology.location_adapter = declare([mod_field.Adapter], { } }); +topology.servers_facet = function(spec, no_init) { + spec = spec || {}; + + var that = IPA.details_facet(spec); + + /** + * Creates buttons on the right side of facet. + */ + that.create_controls = function() { + + that.create_control_buttons(that.controls_left); + that.create_action_dropdown(that.controls_left); + + that.control_buttons = that.control_buttons_right; + that.create_control_buttons(that.controls_right); + }; + + /** + * Inits right facet buttons. + */ + that.init_facet = function() { + + var buttons_spec = { + $factory: IPA.control_buttons_widget, + name: 'control-buttons', + css_class: 'control-buttons', + buttons: spec.control_buttons_right + }; + + that.control_buttons_right = IPA.build(buttons_spec); + that.control_buttons_right.init(that); + }; + + if (!no_init) that.init_facet(); + + return that; +}; + topology.serverroles_search_facet = function(spec) { spec = spec || {}; @@ -657,6 +705,41 @@ topology.domainlevel_metadata = function(spec, context) { return spec; }; +topology.server_delete_action = function(spec) { + + spec = spec || {}; + spec.name = spec.name || 'server_del'; + + var that = IPA.action(spec); + + that.execute_action = function(facet) { + + var dialog = IPA.confirm_dialog({ + title: '@i18n:objects.servers.remove_server', + message: '@i18n:objects.servers.remove_server_msg', + ok_label: '@i18n:buttons.remove', + ok_button_class: 'btn btn-danger' + }); + + dialog.on_ok = function() { + + var pkey = facet.get_pkey(); + + var command = rpc.command({ + entity: facet.entity.name, + method: 'del', + args: [ pkey ] + }); + + command.execute(); + }; + + dialog.open(); + }; + + return that; +}; + /** * Set Domain Level Action * @@ -1396,6 +1479,7 @@ topology.register = function() { a.register('domainlevel_set', topology.domainlevel_set_action); a.register('segment_add', topology.add_segment_action); a.register('segment_del', topology.del_segment_action); + a.register('server_del', topology.server_delete_action); w.register('topology-graph', topology.TopologyGraphWidget); w.register('location_association_table', topology.location_association_table_widget); @@ -1404,7 +1488,6 @@ topology.register = function() { ctor: topology.TopologyGraphFacet, spec: topology.topology_graph_facet_spec }); - }; phases.on('registration', topology.register); diff --git a/install/ui/test/data/ipa_init.json b/install/ui/test/data/ipa_init.json index 1d7f5d883dd923dc5ad749b592e55f23e7d4771b..1f5cc49c2b17b836faf9e14ff70b7d5587141fea 100644 --- a/install/ui/test/data/ipa_init.json +++ b/install/ui/test/data/ipa_init.json @@ -531,6 +531,10 @@ "label": "Server Roles", "label_singular": "Server Role", }, + "servers": { + "remove_server": "Delete Server", + "remove_server_msg": "Deleting a server removes it permanently from the topology. Note that this is a non-reversible action." + }, "service": { "auth_indicators": "Authentication indicators", "auth_indicator": "Authentication indicator", diff --git a/ipaserver/plugins/internal.py b/ipaserver/plugins/internal.py index c0360567cbca883dda018a7a2f7f9f9536c3d118..39db7350813ad1305073a11067ee0093c793658c 100644 --- a/ipaserver/plugins/internal.py +++ b/ipaserver/plugins/internal.py @@ -670,6 +670,10 @@ class i18n_messages(Command): "label": _("Server Roles"), "label_singular": _("Server Role"), }, + "servers": { + "remove_server": _("Delete Server"), + "remove_server_msg": _("Deleting a server removes it permanently from the topology. Note that this is a non-reversible action.") + }, "service": { "auth_indicators": _("Authentication indicators"), "auth_indicator": _("Authentication indicator"), -- 2.5.5
-- Manage your subscription for the Freeipa-devel mailing list: https://www.redhat.com/mailman/listinfo/freeipa-devel Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code