allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [08/50] [abbrv] allura git commit: [#7919] Move add-new-tool modals into the nav bar
Date Fri, 08 Jan 2016 19:30:13 GMT
[#7919] Move add-new-tool modals into the nav bar


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

Branch: refs/heads/master
Commit: 477f0b29cdb6b5e1f7f9507c7602f2e8cb921ddc
Parents: 2601b57
Author: Heith Seewald <heiths@gmail.com>
Authored: Fri Dec 4 15:52:02 2015 -0500
Committer: Dave Brondsema <dave@brondsema.net>
Committed: Fri Jan 8 14:06:14 2016 -0500

----------------------------------------------------------------------
 Allura/allura/ext/admin/admin_main.py           | 41 +++++++----
 .../admin/templates/project_install_tool.html   | 72 ++++++++++++++++++++
 .../ext/admin/templates/project_tools.html      | 38 -----------
 Allura/allura/model/project.py                  |  6 +-
 Allura/allura/public/nf/css/navbar.css          |  7 ++
 Allura/allura/public/nf/js/navbar.es6.js        | 15 ++--
 Allura/allura/public/nf/js/project_tools.js     | 30 +-------
 .../templates/app_admin_options_on_install.html | 31 ---------
 .../allura/templates/jinja_master/top_nav.html  |  2 +-
 9 files changed, 120 insertions(+), 122 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/477f0b29/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 c50a71a..6bb6b46 100644
--- a/Allura/allura/ext/admin/admin_main.py
+++ b/Allura/allura/ext/admin/admin_main.py
@@ -295,15 +295,6 @@ class ProjectAdminController(BaseController):
             flash('Invalid threshold', 'error')
         redirect('tools?limit=%s&page=%s' % (limit, page))
 
-    @expose('jinja:allura:templates/app_admin_options_on_install.html')
-    def options_on_install(self, tool_name):
-        """Renders form fields for options configuration on install"""
-        tool = [t['app'] for t in AdminApp.installable_tools_for(c.project)
-                if t['name'].lower() == tool_name.lower()]
-        if len(tool) == 1:
-            return {'options': tool[0].options_on_install()}
-        raise exc.HTTPNotFound
-
     @expose()
     @require_post()
     def update_labels(self, labels=None, **kw):
@@ -342,9 +333,27 @@ class ProjectAdminController(BaseController):
         redirect('tools')
 
     @without_trailing_slash
-    @expose('jinja:allura.ext.admin:templates/project_permissions.html')
-    def groups(self, **kw):
-        return dict()
+    @expose('jinja:allura.ext.admin:templates/project_install_tool.html')
+    def install_tool(self, tool_name=None, **kw):
+        if tool_name == 'subproject':
+            return dict(
+                    tool_name=tool_name,
+                    tool={
+                        'tool_label': 'Sub Project',
+                        'default_mount_label': 'SubProject',
+                        'default_mount_point': 'subproject'
+                    },
+                    total_mounts=999,  # FIXME
+                    options=[],
+            )
+
+        tool = g.entry_points['tool'][tool_name]
+        return dict(
+                tool_name=tool_name,
+                tool=tool,
+                total_mounts=999,  # FIXME
+                options=tool.options_on_install(),
+        )
 
     @expose()
     def _lookup(self, name, *remainder):
@@ -353,6 +362,12 @@ class ProjectAdminController(BaseController):
             raise exc.HTTPNotFound, name
         return app.admin, remainder
 
+
+    @without_trailing_slash
+    @expose('jinja:allura.ext.admin:templates/project_permissions.html')
+    def groups(self, **kw):
+        return dict()
+
     @expose()
     @require_post()
     @validate(W.metadata_admin, error_handler=overview)
@@ -715,6 +730,8 @@ class ProjectAdminController(BaseController):
     @expose()
     @require_post()
     def update_mounts(self, subproject=None, tool=None, new=None, page=0, limit=200, **kw):
+        if new and new['ep_name'] == u'subproject':
+            new['ep_name'] = ""
         try:
             new_app = self._update_mounts(subproject, tool, new, **kw)
             if new_app:

http://git-wip-us.apache.org/repos/asf/allura/blob/477f0b29/Allura/allura/ext/admin/templates/project_install_tool.html
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/admin/templates/project_install_tool.html b/Allura/allura/ext/admin/templates/project_install_tool.html
new file mode 100644
index 0000000..b4d560b
--- /dev/null
+++ b/Allura/allura/ext/admin/templates/project_install_tool.html
@@ -0,0 +1,72 @@
+<!DOCTYPE html>
+{% import 'allura:templates/jinja_master/lib.html' as lib with context %}
+
+{% set full_url = h.absurl(c.project.url()) %}
+
+<h1> Installing {{ tool.tool_label }} </h1>
+
+<form method="post" action="{{ full_url }}/admin/update_mounts" id="install_form">
+    <input type="hidden" name="new.ordinal" value="{{ total_mounts }}"/>
+    <input type="hidden" name="new.ep_name" class="new_ep_name" value="{{ tool_name }}">
+    <label class="grid-13" for="new.mount_label">Label</label>
+    <div class="grid-13"><input type="text" name="new.mount_label" class="new_mount_label"
+                                title="This will be the name displayed in your project toolbar."
+                                value="{{ tool.default_mount_label }}">
+    </div>
+    <label class="grid-13" for="new.mount_point">Url Path</label>
+    <div class="grid-13">
+        <input id="id_url_input" type="text" name="new.mount_point"
+               title="The url for this tool relative to {{ full_url }} " class="new_mount_point"
+               value="{{ tool.default_mount_point }}">
+        <p><span id="full-url-preview" data-url="{{ full_url }}"></span></p>
+    </div>
+    <div id="install_options">
+        {% for o in options %}
+          <label class="grid-13" for="{{o.name}}">{{o.label}}</label>
+          <div class="grid-13">
+            {% if o.ming_type.__name__ == 'bool' %}
+              <input {{o.render_attrs()}}id="{{o.name}}" name="{{o.name}}" type="checkbox"{{
' checked="checked"' if o.default}}>
+            {% else %}
+              <input {{o.render_attrs()}} id="{{o.name}}" name="{{o.name}}" value="{{o.default
or ''}}">
+            {% endif %}
+          </div>
+          {% if o.help_text %}
+            <div class="grid-13"><small>{{o.help_text}}</small></div>
+          {% endif %}
+        {% endfor %}
+    </div>
+    <div class="grid-13">&nbsp;</div>
+    <hr>
+    <div class="grid-13">&nbsp;</div>
+    <div class="grid-13">
+        <input type="submit" value="Save" name="new.install"> <a href="#" class="close
btn link">Cancel</a>
+    </div>
+    {{lib.csrf_token()}}
+</form>
+
+
+<script>
+    $('#admin_modal_title').hide();
+    var url_preview = $('#full-url-preview'); // "Preview Url Path" displayed on when creating
a new tool.
+
+    var full_url = $(url_preview).data().url; // Full url path of current project.
+
+    // Update the url path preview as they type.
+    $('#id_url_input').keyup(function(){
+        url_preview.html(full_url + '<strong style="color:orange">' + $(this).val()
+ "</strong>");
+    }).keyup();
+
+    // Set url_preview to the Url Path Defaults when creating a new tool.
+    // Add the link tool's 'nice name'.
+{#    defaults['external link'] = defaults.link#}
+{#    var tool_name = $.trim($(this).text().toLowerCase());#}
+{##}
+{#    // If a tool has a default url path, use it for an initial preview.#}
+{#    if (defaults[tool_name]) {#}
+{#        url_preview.html(full_url + '<strong class="url-keyword">' + defaults[tool_name].default_mount
+ "</strong>");#}
+{#    }#}
+{#    else {#}
+{#        // No defaults for this tool, so we use the base url to ensure the url_preview
is reset.#}
+{#        url_preview.html(full_url);#}
+{#    }#}
+</script>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/allura/blob/477f0b29/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 4b22bbe..7b2bc20 100644
--- a/Allura/allura/ext/admin/templates/project_tools.html
+++ b/Allura/allura/ext/admin/templates/project_tools.html
@@ -124,44 +124,6 @@
 </form>
 {% endblock %}
 
-{% block extra_js %}
-<script>
-    var defaults = {
-        {% for tool in installable_tools %}
-        '{{tool.name}}':{'default_label':'{{tool.app.default_mount_label}}','default_mount':'{{tool.app.default_mount_point}}'}{%
if not loop.last %},{% endif %}
-        {% endfor %}
-    };
-    var install_options_url = "{{ c.project.url().rstrip('/') }}/admin/options_on_install";
-</script>
-<script>
-/* Real-time preview of a Url Path (aka mount point). */
-
-    var url_preview = $('#full-url-preview'); // "Preview Url Path" displayed on when creating
a new tool.
-    var full_url = $(url_preview).data().url; // Full url path of current project.
-
-    // Update the url path preview as they type.
-    $('#id_url_input').keyup(function(){
-        url_preview.html(full_url + '<strong class="url-keyword">' + $(this).val()
+ "</strong>");
-    });
-
-    // Set url_preview to the Url Path Defaults when creating a new tool.
-    $('.installable_tool').find('a').on('click', function () {
-        // Add the link tool's 'nice name'.
-        defaults['external link'] = defaults.link
-        var tool_name = $.trim($(this).text().toLowerCase());
-
-        // If a tool has a default url path, use it for an initial preview.
-        if (defaults[tool_name]) {
-            url_preview.html(full_url + '<strong class="url-keyword">' + defaults[tool_name].default_mount
+ "</strong>");
-        }
-        else {
-            // No defaults for this tool, so we use the base url to ensure the url_preview
is reset.
-            url_preview.html(full_url);
-        }
-    });
-</script>
-{% endblock %}
-
 {% block extra_css %}
 <style type="text/css">
 .pad .fourcol .fleft {

http://git-wip-us.apache.org/repos/asf/allura/blob/477f0b29/Allura/allura/model/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index cafa8ad..158904a 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -643,8 +643,12 @@ class Project(SearchIndexable, MappedClass, ActivityNode, ActivityObject):
             children.append(entry)
 
         response = dict(grouping_threshold=grouping_threshold, menu=children)
+
         if admin_options:
-            response['installable_tools'] =[dict(text=t['tool_label'], href='#', tooltip=t['description'])
+            _href = '{}admin/install_tool?tool_name={}'
+            response['installable_tools'] = [dict(text=t['tool_label'],
+                                                  href=_href.format(self.url(), t['name']),
+                                                  tooltip=t['description'])
                                              for t in ProjectAdminRestController().installable_tools()['tools']]
         return response
 

http://git-wip-us.apache.org/repos/asf/allura/blob/477f0b29/Allura/allura/public/nf/css/navbar.css
----------------------------------------------------------------------
diff --git a/Allura/allura/public/nf/css/navbar.css b/Allura/allura/public/nf/css/navbar.css
index 381ea55..795bf54 100644
--- a/Allura/allura/public/nf/css/navbar.css
+++ b/Allura/allura/public/nf/css/navbar.css
@@ -291,3 +291,10 @@
 #top_nav_admin .tool_option > a {
     border-right: none !important;
 }
+
+/*.modal {*/
+    /*background-color: rgba(51, 51, 51, 0.94) !important;*/
+    /*border-radius: 12px !important;*/
+    /*background-image: none !important;*/
+    /*box-shadow: inset 0 1px 1px #aaaaaa,inset 0 -2px 20px rgba(96, 96, 96, 0.5),0 1px 5px
rgba(0, 0, 0, 0.4) !important;*/
+/*}*/

http://git-wip-us.apache.org/repos/asf/allura/blob/477f0b29/Allura/allura/public/nf/js/navbar.es6.js
----------------------------------------------------------------------
diff --git a/Allura/allura/public/nf/js/navbar.es6.js b/Allura/allura/public/nf/js/navbar.es6.js
index 96ec8eb..70b7d65 100644
--- a/Allura/allura/public/nf/js/navbar.es6.js
+++ b/Allura/allura/public/nf/js/navbar.es6.js
@@ -213,10 +213,6 @@ var ToggleAddNewTool = React.createClass({
             visible: !this.state.visible
         });
     },
-        handleOptionClick: function(event) {
-            console.log('event', event);
-        //this.props.onOptionClick(this.props.mount_point);
-    },
 
     render: function () {
         return (
@@ -227,8 +223,8 @@ var ToggleAddNewTool = React.createClass({
                 {this.state.visible &&
                 <ContextMenu
                     {...this.props}
-                    classes={['alt-context']}
-                    onOptionClick={this.handleOptionClick}
+                    classes={['admin_modal']}
+                    onOptionClick={this.handleToggle}
                     items={this.props.installableTools} />
                 }
             </div>
@@ -258,9 +254,9 @@ var NormalNavBar = React.createClass({
         );
     },
 
-    onOptionClick: function(e){
-        console.log(e);
-    },
+    //onOptionClick: function(e){
+    //    console.log(e);
+    //},
     render: function() {
         var listItems = this.props.items.map(this.buildMenu);
 
@@ -274,7 +270,6 @@ var NormalNavBar = React.createClass({
                 }
             }
         }
-        console.log("mount_points", mount_points);
         return (
             <ul
                 id="normal-nav-bar"

http://git-wip-us.apache.org/repos/asf/allura/blob/477f0b29/Allura/allura/public/nf/js/project_tools.js
----------------------------------------------------------------------
diff --git a/Allura/allura/public/nf/js/project_tools.js b/Allura/allura/public/nf/js/project_tools.js
index c235f05..ce8d28b 100644
--- a/Allura/allura/public/nf/js/project_tools.js
+++ b/Allura/allura/public/nf/js/project_tools.js
@@ -18,35 +18,7 @@
 */
 
 (function() {
-    // Install popup
-    var install_popup = $('#lightbox_install_modal');
-    var install_form = $('#install_form');
-    var new_ep_name = install_form.find('input.new_ep_name');
-    var new_mount_point = install_form.find('input.new_mount_point');
-    var new_mount_label = install_form.find('input.new_mount_label');
-    var install_tool_label = $('#install_tool_label');
-    var mount_point_rule_names = $('#install_form .mount-point-rule-names');
-    var install_options = $('#install_options');
-    install_popup.append(install_form.show());
-    $('a.install_trig').click(function () {
-        var datatool = $(this).data('tool');
-        if (datatool) {
-            var tool = defaults[datatool];
-            install_options.html('Loading options...');
-            $.get(install_options_url, {tool_name: datatool}, function (data) {
-                install_options.html(data);
-            });
-            install_tool_label.html(tool.default_label);
-            new_ep_name.val(datatool);
-            new_mount_point.val(tool.default_mount);
-            new_mount_label.val(tool.default_label);
-        } else {
-            install_tool_label.html("Subproject");
-            new_ep_name.val('');
-            new_mount_point.val('');
-            new_mount_label.val('');
-        }
-    });
+
     // sorting
     $('#sortable').sortable({items: ".fleft:not(.isnt_sorted)"}).bind( "sortupdate", function
(e) {
         var sortables = $('#sortable .fleft');

http://git-wip-us.apache.org/repos/asf/allura/blob/477f0b29/Allura/allura/templates/app_admin_options_on_install.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/app_admin_options_on_install.html b/Allura/allura/templates/app_admin_options_on_install.html
deleted file mode 100644
index 16b62b6..0000000
--- a/Allura/allura/templates/app_admin_options_on_install.html
+++ /dev/null
@@ -1,31 +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.
--#}
-{% for o in options %}
-  <label class="grid-13" for="{{o.name}}">{{o.label}}</label>
-  <div class="grid-13">
-    {% if o.ming_type.__name__ == 'bool' %}
-      <input {{o.render_attrs()}}id="{{o.name}}" name="{{o.name}}" type="checkbox"{{ '
checked="checked"' if o.default}}>
-    {% else %}
-      <input {{o.render_attrs()}} id="{{o.name}}" name="{{o.name}}" value="{{o.default
or ''}}">
-    {% endif %}
-  </div>
-  {% if o.help_text %}
-    <div class="grid-13"><small>{{o.help_text}}</small></div>
-  {% endif %}
-{% endfor %}

http://git-wip-us.apache.org/repos/asf/allura/blob/477f0b29/Allura/allura/templates/jinja_master/top_nav.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/jinja_master/top_nav.html b/Allura/allura/templates/jinja_master/top_nav.html
index 21bcb48..ce449ef 100644
--- a/Allura/allura/templates/jinja_master/top_nav.html
+++ b/Allura/allura/templates/jinja_master/top_nav.html
@@ -49,7 +49,7 @@
     {% do g.register_forge_js('js/build/transpiled.js') %} {# if we do more es6, we'll need
to register this in other places, or maybe even global #}
     <script>
     'use strict';
-    let _data = {{ h.escape_json(c.project.nav_data(admin_options=True))|safe  }};
+    var _data = {{ h.escape_json(c.project.nav_data(admin_options=True))|safe  }};
         $(document).ready(function () {
             $('#toggle-admin-btn').click(function () {
                 ReactDOM.render(React.createElement(Main, {


Mime
View raw message