allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [20/50] [abbrv] allura git commit: [#7919] Pass mount_point validation data into the initial toolbar
Date Thu, 17 Dec 2015 19:22:07 GMT
[#7919] Pass mount_point validation data into the initial toolbar


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

Branch: refs/heads/db/8034
Commit: 4389d9505dddf9cde3ec6fb43716ec4003710842
Parents: 4917b1a
Author: Heith Seewald <heiths@gmail.com>
Authored: Mon Dec 7 12:43:58 2015 -0500
Committer: Heith Seewald <heiths@gmail.com>
Committed: Wed Dec 16 13:55:36 2015 -0600

----------------------------------------------------------------------
 Allura/allura/public/nf/js/navbar.es6.js        | 32 ++++++++++++++------
 .../allura/templates/jinja_master/top_nav.html  |  5 ++-
 2 files changed, 26 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/4389d950/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 d917022..819bc2f 100644
--- a/Allura/allura/public/nf/js/navbar.es6.js
+++ b/Allura/allura/public/nf/js/navbar.es6.js
@@ -70,6 +70,27 @@ function getUrlByNode(node) {
     return node.props.children[0].props.url;
 }
 
+/**
+ * Returns all existing mount points for a given project.
+
+ * @constructor
+ * @param {array} items
+ * @returns {array}
+ */
+function getMountPoints(items) {
+    var existingTools = [];
+    for (let item of items) {
+        if (item.hasOwnProperty('mount_point') && item.mount_point !== null) {
+            existingTools.push(item.mount_point);
+        } else if (item.hasOwnProperty('children')) {
+            for (let child of item.children) {
+                existingTools.push(child.mount_point)
+            }
+        }
+    }
+    return existingTools;
+}
+
 const ToolsPropType = React.PropTypes.shape({
     mount_point: React.PropTypes.string,
     name: React.PropTypes.string.isRequired,
@@ -280,16 +301,7 @@ var NormalNavBar = React.createClass({
 
     render: function() {
         var listItems = this.props.items.map(this.buildMenu);
-        var existingTools = [];
-        for(let item of this.props.installableTools){
-            if(item.hasOwnProperty('mount_point') && item.mount_point !== null){
-                existingTools.push(item.mount_point);
-            } else if(item.hasOwnProperty('children')){
-                for(let child of item.children){
-                    existingTools.push(child.mount_point)
-                }
-            }
-        }
+        var existingTools = getMountPoints(this.props.items);
         return (
             <ul
                 id="normal-nav-bar"

http://git-wip-us.apache.org/repos/asf/allura/blob/4389d950/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 ce449ef..3d14c25 100644
--- a/Allura/allura/templates/jinja_master/top_nav.html
+++ b/Allura/allura/templates/jinja_master/top_nav.html
@@ -51,6 +51,7 @@
     'use strict';
     var _data = {{ h.escape_json(c.project.nav_data(admin_options=True))|safe  }};
         $(document).ready(function () {
+            var _existingTools = getMountPoints(_data['menu']);
             $('#toggle-admin-btn').click(function () {
                 ReactDOM.render(React.createElement(Main, {
                     initialData: _data
@@ -58,7 +59,9 @@
             });
 
             ReactDOM.render(React.createElement(ToggleAddNewTool, {
-                        installableTools: _data['installable_tools']
+                        installableTools: _data['installable_tools'],
+                        mountPointValidation:_existingTools
+
                     }), document.getElementById('add-tool-container'));
         });
     </script>


Mime
View raw message