From 7f4de88ea1da11d4111a917672c0cb7ab9866c90 Mon Sep 17 00:00:00 2001 From: Pavel Vomacka Date: Fri, 24 Jun 2016 12:08:04 +0200 Subject: [PATCH] Add button for server-del command WebUI counterpart of: https://fedorahosted.org/freeipa/ticket/5588 Reviewed-By: Petr Vobornik --- install/ui/src/freeipa/topology.js | 65 +++++++++++++++++++++++++++++- install/ui/test/data/ipa_init.json | 4 ++ ipaserver/plugins/internal.py | 4 ++ 3 files changed, 72 insertions(+), 1 deletion(-) diff --git a/install/ui/src/freeipa/topology.js b/install/ui/src/freeipa/topology.js index a9776a556..7e501eb35 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,30 @@ return { } ] } + ], + actions: [ + { + $factory: IPA.delete_action, + name: 'server_del', + method: 'del', + label: '@i18n:objects.servers.remove_server', + needs_confirm: true, + confirm_msg: '@i18n:objects.servers.remove_server_msg', + confirm_dialog: { + $factory: IPA.confirm_dialog, + title: '@i18n:objects.servers.remove_server', + ok_label: '@i18n:buttons.remove', + ok_button_class: 'btn btn-danger' + } + } + ], + control_buttons_right: [ + { + name: 'server_del', + label: '@i18n:objects.servers.remove_server', + icon: 'fa-exclamation-circle', + button_class: 'btn btn-danger' + } ] } ] @@ -458,6 +483,45 @@ topology.location_adapter = declare([mod_field.Adapter], { } }); +topology.servers_facet = function(spec, no_init) { + spec = spec || {}; + + var that = IPA.details_facet(spec, no_init); + + /** + * 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_servers_facet = function() { + + that.init_details_facet(); + 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_servers_facet(); + + return that; +}; + topology.serverroles_search_facet = function(spec) { spec = spec || {}; @@ -1404,7 +1468,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 dbbce26d9..8768766ed 100644 --- a/install/ui/test/data/ipa_init.json +++ b/install/ui/test/data/ipa_init.json @@ -545,6 +545,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": { "certificate": "Service Certificate", "delete_key_unprovision": "Delete Key, Unprovision", diff --git a/ipaserver/plugins/internal.py b/ipaserver/plugins/internal.py index 8048b2295..5c1cfb885 100644 --- a/ipaserver/plugins/internal.py +++ b/ipaserver/plugins/internal.py @@ -690,6 +690,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": { "certificate": _("Service Certificate"), "delete_key_unprovision": _("Delete Key, Unprovision"),