https://fedorahosted.org/freeipa/ticket/1477

Redirection after updating empty DNS Record (which is deleted).
Added hook to details facet for post update operation.

Petr
>From aafbaf2464dcc16f552290f72424170c42055b45 Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvobo...@redhat.com>
Date: Fri, 22 Jul 2011 13:24:27 +0200
Subject: [PATCH] fixed empty dns record update

https://fedorahosted.org/freeipa/ticket/1477

Redirection after updating empty DNS Record (which is deleted).
Added hook to details facet for post update operation.
---
 install/ui/details.js      |    8 +++++++-
 install/ui/dns.js          |   34 +++++++++++++++++++++++++++++++++-
 ipalib/plugins/internal.py |    3 +++
 3 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/install/ui/details.js b/install/ui/details.js
index 50fccce4946b207999ef3f902b666a567b2b3e21..8e0edaab90d0e2ea1325761026a7d0403674e1b8 100644
--- a/install/ui/details.js
+++ b/install/ui/details.js
@@ -245,6 +245,7 @@ IPA.details_facet = function(spec) {
     var that = IPA.facet(spec);
 
     that.pre_execute_hook = spec.pre_execute_hook;
+    that.post_update_hook = spec.post_update_hook;
 
     that.label = spec.label || IPA.messages && IPA.messages.facets && IPA.messages.facets.details;
     that.facet_group = spec.facet_group || 'settings';
@@ -526,7 +527,12 @@ IPA.details_facet = function(spec) {
                 on_win(data, text_status, xhr);
             if (data.error)
                 return;
-
+            
+            if (that.post_update_hook) {
+                that.post_update_hook(data, text_status);
+                return;
+            }
+            
             var result = data.result.result;
             that.load(result);
         }
diff --git a/install/ui/dns.js b/install/ui/dns.js
index bba1e5cbf06cc7f8f2694db475b20750ad5673e1..7cef5ae72eda85a41c143e517db4191fd26976d9 100644
--- a/install/ui/dns.js
+++ b/install/ui/dns.js
@@ -265,7 +265,17 @@ IPA.entity_factories.dnsrecord = function() {
     return IPA.entity_builder().
         entity('dnsrecord').
         containing_entity('dnszone').
-        details_facet({
+        details_facet({            
+            post_update_hook:function(data){
+                var result = data.result.result;
+                 if (result.idnsname) {
+                    this.load(result);
+                } else {
+                    this.reset();
+                    var dialog = IPA.dnsrecord_redirection_dialog();                
+                    dialog.open(this.container);
+                }
+            },
             disable_breadcrumb: false,
             sections:[
                {
@@ -424,6 +434,28 @@ IPA.entity_factories.dnsrecord = function() {
         build();
 };
 
+IPA.dnsrecord_redirection_dialog = function(spec) {
+    spec = spec || {};    
+    spec.title = spec.title || IPA.messages.dialogs.redirection;  
+        
+    var that = IPA.dialog(spec);    
+    
+    that.create = function() {
+        $('<p/>', {
+            'text': IPA.messages.objects.dnsrecord.deleted_no_data
+        }).appendTo(that.container);
+        $('<p/>', {
+            'text': IPA.messages.objects.dnsrecord.redirection_dnszone
+        }).appendTo(that.container);
+    };
+    
+    that.add_button(IPA.messages.buttons.ok, function() {         
+        that.close();
+        IPA.nav.show_page('dnszone','default');       
+    });
+    return that;
+};
+
 IPA.dnsrecord_host_link_widget = function(spec){
     var that = IPA.entity_link_widget(spec);
     that.other_pkeys = function(){
diff --git a/ipalib/plugins/internal.py b/ipalib/plugins/internal.py
index 6f279834a91092b67434bffaabb8d381db16319b..8556d941c35af658c5b7460d1edc7ebcd8d6975e 100644
--- a/ipalib/plugins/internal.py
+++ b/ipalib/plugins/internal.py
@@ -160,6 +160,8 @@ class i18n_messages(Command):
             "dnsrecord": {
                 "type":_("Record Type"),
                 "data":_("Data"),
+                "deleted_no_data":_("DNS record was deleted because it contained no data."),
+                "redirection_dnszone":_("You will be redirected to DNS Zone."),
                 "title":_("Records for DNS Zone"),
                 },
             "entitle": {
@@ -348,6 +350,7 @@ class i18n_messages(Command):
             "dirty_message":_("This page has unsaved changes. Please save or revert."),
             "dirty_title":_("Dirty"),
             "hide_already_enrolled":_("Hide already enrolled."),
+            "redirection":_("Redirection"),
             "remove_empty":_("Select entries to be removed."),
             "remove_title":_("Remove ${entity}"),
             "prospective":_("Prospective"),
-- 
1.7.6

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to