diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2016-04-21 16:34:00 +0200 |
---|---|---|
committer | Jacob Schatz <jschatz1@gmail.com> | 2016-04-28 16:13:48 -0400 |
commit | 0426647069397d57d46c66de41c8fa4fad65e0bb (patch) | |
tree | d91b1c5f48e5481f1fd4ed6034925b4d00bd7ead /app/assets | |
parent | ed08bfdc26557b4d364dc18299bb21a8be195be6 (diff) | |
download | gitlab-ce-0426647069397d57d46c66de41c8fa4fad65e0bb.tar.gz |
Load the "New Branch" button asynchronously
This button depends on Issue#can_be_worked_on? which in turn depends on
Issue#related_branches. By rendering this button asynchronously we can
finally remove all usages of Issue#related_branches and
Issue#referenced_merge_requests from the issues "show" page.
Diffstat (limited to 'app/assets')
-rw-r--r-- | app/assets/javascripts/issue.js.coffee | 23 | ||||
-rw-r--r-- | app/assets/stylesheets/framework/buttons.scss | 4 |
2 files changed, 27 insertions, 0 deletions
diff --git a/app/assets/javascripts/issue.js.coffee b/app/assets/javascripts/issue.js.coffee index c7d74a12f99..157361404e0 100644 --- a/app/assets/javascripts/issue.js.coffee +++ b/app/assets/javascripts/issue.js.coffee @@ -12,6 +12,7 @@ class @Issue @initMergeRequests() @initRelatedBranches() + @initCanCreateBranch() initTaskList: -> $('.detail-page-description .js-task-list-container').taskList('enable') @@ -92,3 +93,25 @@ class @Issue .success (data) -> if 'html' of data $container.html(data.html) + + initCanCreateBranch: -> + $container = $('div#new-branch') + + # If the user doesn't have the required permissions the container isn't + # rendered at all. + return unless $container + + $.getJSON($container.data('path')) + .error -> + $container.find('.checking').hide() + $container.find('.unavailable').show() + + new Flash('Failed to check if a new branch can be created.', 'alert') + .success (data) -> + if data.can_create_branch + $container.find('.checking').hide() + $container.find('.available').show() + $container.find('a').attr('disabled', false) + else + $container.find('.checking').hide() + $container.find('.unavailable').show() diff --git a/app/assets/stylesheets/framework/buttons.scss b/app/assets/stylesheets/framework/buttons.scss index 18a74fe21a0..062da397b6b 100644 --- a/app/assets/stylesheets/framework/buttons.scss +++ b/app/assets/stylesheets/framework/buttons.scss @@ -139,6 +139,10 @@ pointer-events: auto !important; } + &[disabled] { + pointer-events: none !important; + } + .caret { margin-left: 5px; } |