You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2015/12/17 20:22:04 UTC

[17/50] [abbrv] allura git commit: [#7919] show Delete in nav bar option menus; use regular admin_modal for it

[#7919] show Delete in nav bar option menus; use regular admin_modal for it


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/2725acad
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/2725acad
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/2725acad

Branch: refs/heads/db/8034
Commit: 2725acad546d7132ca8b9ad4bae2d0f23892eae6
Parents: d365040
Author: Dave Brondsema <da...@brondsema.net>
Authored: Wed Dec 2 17:37:26 2015 -0500
Committer: Heith Seewald <he...@gmail.com>
Committed: Wed Dec 16 13:55:35 2015 -0600

----------------------------------------------------------------------
 Allura/allura/app.py                            | 18 +++---
 Allura/allura/ext/admin/admin_main.py           |  8 +--
 .../ext/admin/templates/project_tools.html      |  2 +-
 Allura/allura/lib/widgets/admin_widgets.py      | 33 -----------
 .../resources/js/admin_tool_delete_modal.js     | 47 ----------------
 Allura/allura/templates/app_admin_delete.html   | 58 ++++++++++++++++++++
 .../templates/jinja_master/sidebar_menu.html    |  3 -
 .../widgets/admin_tool_delete_modal.html        | 34 ------------
 .../tests/functional/test_neighborhood.py       |  1 +
 9 files changed, 71 insertions(+), 133 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/2725acad/Allura/allura/app.py
----------------------------------------------------------------------
diff --git a/Allura/allura/app.py b/Allura/allura/app.py
index 381661c..5ae34e1 100644
--- a/Allura/allura/app.py
+++ b/Allura/allura/app.py
@@ -45,7 +45,6 @@ from allura import model
 from allura.controllers import BaseController
 from allura.lib.decorators import require_post, memoize
 from allura.lib.utils import permanent_redirect, ConfigProxy
-from allura.lib.widgets import admin_widgets
 from allura import model as M
 
 log = logging.getLogger(__name__)
@@ -308,11 +307,6 @@ class Application(object):
         self.admin = DefaultAdminController(self)
 
     @LazyProperty
-    def admin_tool_delete_modal(self):
-        """Returns modal dialog widget for app's delete workflow"""
-        return admin_widgets.AdminToolDeleteModal()
-
-    @LazyProperty
     def sitemap(self):
         """Return a list of :class:`SitemapEntries <allura.app.SitemapEntry>`
         describing the page hierarchy provided by this Application.
@@ -660,11 +654,9 @@ class Application(object):
         if self.uninstallable and not anchored:
             return SitemapEntry(
                 label='Delete',
-                url='#',
-                className='admin_tool_delete_modal',
-                extra_html_attrs={
-                    'data-mount-point': self.config.options.mount_point,
-                })
+                url=self.admin_url + 'delete',
+                className='admin_modal',
+            )
 
     def handle_message(self, topic, message):
         """Handle incoming email msgs addressed to this tool.
@@ -899,6 +891,10 @@ class DefaultAdminController(BaseController, AdminControllerMixin):
             app=self.app,
             allow_config=has_access(self.app, 'configure')())
 
+    @expose('jinja:allura:templates/app_admin_delete.html')
+    def delete(self):
+        return dict(app=self.app)
+
     @expose()
     @require_post()
     def configure(self, **kw):

http://git-wip-us.apache.org/repos/asf/allura/blob/2725acad/Allura/allura/ext/admin/admin_main.py
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/admin/admin_main.py b/Allura/allura/ext/admin/admin_main.py
index b7d7685..c50a71a 100644
--- a/Allura/allura/ext/admin/admin_main.py
+++ b/Allura/allura/ext/admin/admin_main.py
@@ -44,7 +44,6 @@ from allura.controllers import BaseController
 from allura.lib.decorators import require_post
 from allura.tasks import export_tasks
 from allura.lib.widgets.project_list import ProjectScreenshots
-from allura.lib.widgets import admin_widgets
 
 from . import widgets as aw
 
@@ -55,7 +54,6 @@ log = logging.getLogger(__name__)
 class W:
     markdown_editor = ffw.MarkdownEdit()
     label_edit = ffw.LabelEdit()
-    mount_delete = admin_widgets.AdminToolDeleteModal()
     install_modal = ffw.Lightbox(
         name='install_modal', trigger='a.install_trig')
     explain_export_modal = ffw.Lightbox(
@@ -268,7 +266,6 @@ class ProjectAdminController(BaseController):
     def tools(self, page=None, limit=200, **kw):
         c.markdown_editor = W.markdown_editor
         c.label_edit = W.label_edit
-        c.mount_delete = W.mount_delete
         c.install_modal = W.install_modal
         c.page_list = W.page_list
         mounts = c.project.ordered_mounts()
@@ -900,9 +897,12 @@ class ProjectAdminRestController(BaseController):
         tool = c.project.app_instance(mount_point)
         if not mount_point or tool is None:
             raise exc.HTTPNotFound
+        admin_menu = tool.admin_menu()
+        if tool.admin_menu_delete_button:
+            admin_menu.append(tool.admin_menu_delete_button)
         return {
             'options': [dict(text=m.label, href=m.url, className=m.className)
-                        for m in tool.admin_menu()]
+                        for m in admin_menu]
         }
 
     @expose('json:')

http://git-wip-us.apache.org/repos/asf/allura/blob/2725acad/Allura/allura/ext/admin/templates/project_tools.html
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/admin/templates/project_tools.html b/Allura/allura/ext/admin/templates/project_tools.html
index 807828a..a78a916 100644
--- a/Allura/allura/ext/admin/templates/project_tools.html
+++ b/Allura/allura/ext/admin/templates/project_tools.html
@@ -104,6 +104,7 @@
                         <img src="{{ g.theme.app_icon_url('subproject', 48) }}" alt="">
                     </li>
                     <li>
+                        <!-- FIXME -->
                       <a href="#" data-mount-point="{{ mount['sub'].shortname }}"
                                   data-subproject="true"
                                   class="admin_tool_delete_modal">
@@ -119,7 +120,6 @@
 <div style="clear:both">
   {{c.page_list.display(page=page, limit=limit, count=total_mounts)}}
 </div>
-{{c.mount_delete.display()}}
 <div><!--dummy-->
 
 <h3 style="clear:left">Grouping</h3>

http://git-wip-us.apache.org/repos/asf/allura/blob/2725acad/Allura/allura/lib/widgets/admin_widgets.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/admin_widgets.py b/Allura/allura/lib/widgets/admin_widgets.py
deleted file mode 100644
index 6fe0f4f..0000000
--- a/Allura/allura/lib/widgets/admin_widgets.py
+++ /dev/null
@@ -1,33 +0,0 @@
-#       Licensed to the Apache Software Foundation (ASF) under one
-#       or more contributor license agreements.  See the NOTICE file
-#       distributed with this work for additional information
-#       regarding copyright ownership.  The ASF licenses this file
-#       to you under the Apache License, Version 2.0 (the
-#       "License"); you may not use this file except in compliance
-#       with the License.  You may obtain a copy of the License at
-#
-#         http://www.apache.org/licenses/LICENSE-2.0
-#
-#       Unless required by applicable law or agreed to in writing,
-#       software distributed under the License is distributed on an
-#       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-#       KIND, either express or implied.  See the License for the
-#       specific language governing permissions and limitations
-#       under the License.
-
-import ew.jinja2_ew as ew
-
-from allura.lib.widgets import form_fields as ffw
-
-
-class AdminToolDeleteModal(ffw.Lightbox):
-    defaults = dict(
-        ffw.Lightbox.defaults,
-        name='admin_tool_delete_modal',
-        trigger='a.admin_tool_delete_modal',
-        content_template='allura:templates/widgets/admin_tool_delete_modal.html')
-
-    def resources(self):
-        for r in super(AdminToolDeleteModal, self).resources():
-            yield r
-        yield ew.JSLink('js/admin_tool_delete_modal.js')

http://git-wip-us.apache.org/repos/asf/allura/blob/2725acad/Allura/allura/lib/widgets/resources/js/admin_tool_delete_modal.js
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/resources/js/admin_tool_delete_modal.js b/Allura/allura/lib/widgets/resources/js/admin_tool_delete_modal.js
deleted file mode 100644
index 211f5ed..0000000
--- a/Allura/allura/lib/widgets/resources/js/admin_tool_delete_modal.js
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
-       Licensed to the Apache Software Foundation (ASF) under one
-       or more contributor license agreements.  See the NOTICE file
-       distributed with this work for additional information
-       regarding copyright ownership.  The ASF licenses this file
-       to you under the Apache License, Version 2.0 (the
-       "License"); you may not use this file except in compliance
-       with the License.  You may obtain a copy of the License at
-
-         http://www.apache.org/licenses/LICENSE-2.0
-
-       Unless required by applicable law or agreed to in writing,
-       software distributed under the License is distributed on an
-       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-       KIND, either express or implied.  See the License for the
-       specific language governing permissions and limitations
-       under the License.
-*/
-$(function() {
-  var $form = $('#admin-tool-delete-modal-form');
-  $('a.admin_tool_delete_modal').click(function() {
-    var mount_point = $(this).data('mount-point');
-    var is_sub = $(this).data('subproject');
-    var prefix = is_sub ? 'subproject-0' : 'tool-0';
-    var mount_point_name = prefix + (is_sub ? '.shortname' : '.mount_point');
-    var delete_name = prefix + '.delete';
-    $form.find('.mount_point')
-         .attr('name', mount_point_name)
-         .val(mount_point);
-    $form.find('.delete-input').attr('name', delete_name);
-    var tool_label = 'this';
-    if (mount_point) {
-      tool_label = 'the "' + mount_point + '"';
-    }
-    var msg = 'Warning: This will destroy all data in ';
-    msg += tool_label;
-    msg += ' tool and is irreversible!';
-    $form.find('.warning-msg').text(msg);
-  });
-  $form.find('.delete-tool').click(function() {
-    if ($form.find('.mount_point').val()) {
-      $form.submit();
-    } else {
-      console.log('Do not know which tool to delete!');
-    }
-  });
-});

http://git-wip-us.apache.org/repos/asf/allura/blob/2725acad/Allura/allura/templates/app_admin_delete.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/app_admin_delete.html b/Allura/allura/templates/app_admin_delete.html
new file mode 100644
index 0000000..fe71b56
--- /dev/null
+++ b/Allura/allura/templates/app_admin_delete.html
@@ -0,0 +1,58 @@
+{#-
+       Licensed to the Apache Software Foundation (ASF) under one
+       or more contributor license agreements.  See the NOTICE file
+       distributed with this work for additional information
+       regarding copyright ownership.  The ASF licenses this file
+       to you under the Apache License, Version 2.0 (the
+       "License"); you may not use this file except in compliance
+       with the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+       Unless required by applicable law or agreed to in writing,
+       software distributed under the License is distributed on an
+       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+       KIND, either express or implied.  See the License for the
+       specific language governing permissions and limitations
+       under the License.
+-#}
+{% import 'allura:templates/jinja_master/lib.html' as lib with context %}
+
+<form method="POST"
+      action="{{c.project.url()}}admin/update_mounts"
+      id="admin-tool-delete-modal-form">
+<p>Warning: This will destroy all data in the '{{ app.config.options.mount_point }}' tool and is irreversible!</p>
+<hr>
+<p>
+  <input type="button" value="Delete" class="delete-tool">
+  <input type="button" value="Cancel" class="close">
+</p>
+<input type="hidden" class="mount_point">
+<input type="hidden" value="Delete" class="delete-input">
+{{lib.csrf_token()}}
+</form>
+
+
+<script type="text/javascript">
+$(function() {
+    var $form = $('#admin-tool-delete-modal-form');
+    var mount_point = '{{ app.config.options.mount_point }}';
+    var is_sub = $(this).data('subproject');
+
+    var prefix = is_sub ? 'subproject-0' : 'tool-0';
+    var mount_point_name = prefix + (is_sub ? '.shortname' : '.mount_point');
+    var delete_name = prefix + '.delete';
+    $form.find('.mount_point')
+         .attr('name', mount_point_name)
+         .val(mount_point);
+    $form.find('.delete-input').attr('name', delete_name);
+
+    $form.find('.delete-tool').click(function() {
+        if ($form.find('.mount_point').val()) {
+            $form.submit();
+        } else {
+            console.log('Do not know which tool to delete!');
+        }
+    });
+});
+</script>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/allura/blob/2725acad/Allura/allura/templates/jinja_master/sidebar_menu.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/jinja_master/sidebar_menu.html b/Allura/allura/templates/jinja_master/sidebar_menu.html
index 2cb433a..8d2831a 100644
--- a/Allura/allura/templates/jinja_master/sidebar_menu.html
+++ b/Allura/allura/templates/jinja_master/sidebar_menu.html
@@ -75,9 +75,6 @@
             {{sidebar_item(c.app.admin_menu_delete_button)}}
             {{sidebar_item(None)}}
           </div>
-          {% if c.app.admin_menu_delete_button %}
-            {{c.app.admin_tool_delete_modal.display()}}
-          {% endif %}
         {% endif %}
       {% endif %}
       {% for s in c.app.sidebar_menu() %}

http://git-wip-us.apache.org/repos/asf/allura/blob/2725acad/Allura/allura/templates/widgets/admin_tool_delete_modal.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/admin_tool_delete_modal.html b/Allura/allura/templates/widgets/admin_tool_delete_modal.html
deleted file mode 100644
index 692c582..0000000
--- a/Allura/allura/templates/widgets/admin_tool_delete_modal.html
+++ /dev/null
@@ -1,34 +0,0 @@
-{#-
-       Licensed to the Apache Software Foundation (ASF) under one
-       or more contributor license agreements.  See the NOTICE file
-       distributed with this work for additional information
-       regarding copyright ownership.  The ASF licenses this file
-       to you under the Apache License, Version 2.0 (the
-       "License"); you may not use this file except in compliance
-       with the License.  You may obtain a copy of the License at
-
-         http://www.apache.org/licenses/LICENSE-2.0
-
-       Unless required by applicable law or agreed to in writing,
-       software distributed under the License is distributed on an
-       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-       KIND, either express or implied.  See the License for the
-       specific language governing permissions and limitations
-       under the License.
--#}
-{% import 'allura:templates/jinja_master/lib.html' as lib with context %}
-
-<h1>Confirm Delete</h1>
-<form method="POST"
-      action="{{c.project.url()}}admin/update_mounts"
-      id="admin-tool-delete-modal-form">
-<p class="warning-msg">Warning: This will destroy all data in this tool and is irreversible!</p>
-<hr>
-<p>
-  <input type="button" value="Delete" class="delete-tool">
-  <input type="button" value="Cancel" class="close">
-</p>
-<input type="hidden" class="mount_point">
-<input type="hidden" value="Delete" class="delete-input">
-{{lib.csrf_token()}}
-</form>

http://git-wip-us.apache.org/repos/asf/allura/blob/2725acad/Allura/allura/tests/functional/test_neighborhood.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_neighborhood.py b/Allura/allura/tests/functional/test_neighborhood.py
index 593a34c..a218b68 100644
--- a/Allura/allura/tests/functional/test_neighborhood.py
+++ b/Allura/allura/tests/functional/test_neighborhood.py
@@ -173,6 +173,7 @@ class TestNeighborhood(TestController):
 
         r = self.app.get('/p/test/admin/tools')
         assert '<div class="fleft isnt_sorted">' in r
+        # FIXME
         delete_tool = r.html.findAll('a', {'class': 'admin_tool_delete_modal'})
         assert_equal(len(delete_tool), 1)