On 06/24/2016 12:40 PM, Pavel Vomacka wrote:
> Hello,
> 
> please review attached patches, they add 'Delete Server' button.
> 

1. there is a whitespace warning while applying patch 63.

2. It breaks expectation of no_init.
Instead of
  var that = IPA.details_facet(spec);
Use
  var that = IPA.details_facet(spec, no_init);

Then rename:
  that.init_facet = function() {
ẗo
  that.init_servers_facet = function() {

Add there at beginning:
  that.init_details_facet


3. IPA.action and IPA.delete_action has the functionality of
server_delete_action build-in, including redirection to server search
page which is missing in this patch.

Updated patch with the issues fixed is attached.

I did not test final version of the patch because my testing env. died.
-- 
Petr Vobornik
From d0ea026cebcda0e301ed75b4dc53c78675c20ef0 Mon Sep 17 00:00:00 2001
From: Pavel Vomacka <pvoma...@redhat.com>
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
---
 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 a9776a5567adf1dcea7a4e62c89f90a573e9ca66..7e501eb3506587ea653497d2806938890066e4f0 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 49eca4de9d40a20b1aee593e32071c762ff052d1..c18f78cc316a77da46f14fa2b3bbbabe8ee09208 100644
--- a/install/ui/test/data/ipa_init.json
+++ b/install/ui/test/data/ipa_init.json
@@ -539,6 +539,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 5b0a3db3704aad4d68ceda629ecda721a7c01a8d..df577ebe25323acf2c2a4566b2724bc316593c6f 100644
--- a/ipaserver/plugins/internal.py
+++ b/ipaserver/plugins/internal.py
@@ -684,6 +684,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

Reply via email to