summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-12-24 20:34:19 +0100
committerDouwe Maan <douwe@gitlab.com>2015-12-24 20:34:19 +0100
commit43a3a401bdffaab2baf87f6c68f9a34a33f5b36d (patch)
tree7c4ddd70328573b0b4aa02c309bba57aed2d1758 /app
parent396c5c97ddbbe0744d9c27d855c22e2a57546ea1 (diff)
parente3befaed82f9aa52c79a1d4c437fe4fc63f8d07a (diff)
downloadgitlab-ce-43a3a401bdffaab2baf87f6c68f9a34a33f5b36d.tar.gz
Merge branch 'master' into mention-all
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/awards_handler.coffee28
-rw-r--r--app/assets/javascripts/project.js.coffee5
-rw-r--r--app/assets/javascripts/star.js.coffee22
-rw-r--r--app/assets/stylesheets/pages/projects.scss75
-rw-r--r--app/controllers/projects_controller.rb2
-rw-r--r--app/models/ability.rb16
-rw-r--r--app/models/identity.rb1
-rw-r--r--app/views/explore/projects/index.html.haml2
-rw-r--r--app/views/explore/projects/starred.html.haml2
-rw-r--r--app/views/explore/projects/trending.html.haml2
-rw-r--r--app/views/projects/_home_panel.html.haml5
-rw-r--r--app/views/projects/buttons/_fork.html.haml5
-rw-r--r--app/views/projects/buttons/_star.html.haml22
-rw-r--r--app/views/shared/_clone_panel.html.haml29
14 files changed, 181 insertions, 35 deletions
diff --git a/app/assets/javascripts/awards_handler.coffee b/app/assets/javascripts/awards_handler.coffee
index 392440a2b00..04bf5cc7bb5 100644
--- a/app/assets/javascripts/awards_handler.coffee
+++ b/app/assets/javascripts/awards_handler.coffee
@@ -10,6 +10,7 @@ class @AwardsHandler
if $(".emoji-menu").is(":visible")
$(".emoji-menu").hide()
+ @renderFrequentlyUsedBlock()
@setupSearch()
addAward: (emoji) ->
@@ -20,6 +21,8 @@ class @AwardsHandler
$(".emoji-menu").hide()
addAwardToEmojiBar: (emoji) ->
+ @addEmojiToFrequentlyUsedList(emoji)
+
emoji = @normilizeEmojiName(emoji)
if @exist(emoji)
if @isActive(emoji)
@@ -117,6 +120,29 @@ class @AwardsHandler
normilizeEmojiName: (emoji) ->
@aliases[emoji] || emoji
+ addEmojiToFrequentlyUsedList: (emoji) ->
+ frequently_used_emojis = @getFrequentlyUsedEmojis()
+ frequently_used_emojis.push(emoji)
+ $.cookie('frequently_used_emojis', frequently_used_emojis.join(","), { expires: 365 })
+
+ getFrequentlyUsedEmojis: ->
+ frequently_used_emojis = ($.cookie('frequently_used_emojis') || "").split(",")
+
+ frequently_used_emojis = ["thumbsup", "thumbsdown"].concat(frequently_used_emojis)
+
+ _.compact(_.uniq(frequently_used_emojis))
+
+ renderFrequentlyUsedBlock: ->
+ frequently_used_emojis = @getFrequentlyUsedEmojis()
+
+ ul = $("<ul>")
+
+ for emoji in frequently_used_emojis
+ do (emoji) ->
+ $(".emoji-menu-content [data-emoji='#{emoji}']").closest("li").clone().appendTo(ul)
+
+ $("input.emoji-search").after(ul).after($("<h5>").text("Frequently used"))
+
setupSearch: ->
$("input.emoji-search").keyup (ev) =>
term = $(ev.target).val()
@@ -125,7 +151,7 @@ class @AwardsHandler
$("ul.emoji-search,h5.emoji-search").remove()
if term
- # Generate search result block
+ # Generate a search result block
h5 = $("<h5>").text("Search results").addClass("emoji-search")
found_emojis = @searchEmojis(term).show()
ul = $("<ul>").addClass("emoji-search").append(found_emojis)
diff --git a/app/assets/javascripts/project.js.coffee b/app/assets/javascripts/project.js.coffee
index 1f221945c06..d7a658f8faa 100644
--- a/app/assets/javascripts/project.js.coffee
+++ b/app/assets/javascripts/project.js.coffee
@@ -1,7 +1,7 @@
class @Project
constructor: ->
# Git protocol switcher
- $('.js-protocol-switch').click ->
+ $('ul.clone-options-dropdown a').click ->
return if $(@).hasClass('active')
@@ -10,7 +10,8 @@ class @Project
# Add the active class for the clicked button
$(@).toggleClass('active')
- url = $(@).data('clone')
+ url = $("#project_clone").val()
+ console.log("url",url)
# Update the input field
$('#project_clone').val(url)
diff --git a/app/assets/javascripts/star.js.coffee b/app/assets/javascripts/star.js.coffee
new file mode 100644
index 00000000000..d849b2e7950
--- /dev/null
+++ b/app/assets/javascripts/star.js.coffee
@@ -0,0 +1,22 @@
+class @Star
+ constructor: ->
+ $('.project-home-panel .toggle-star').on('ajax:success', (e, data, status, xhr) ->
+ $this = $(this)
+ $starSpan = $this.find('span')
+ $starIcon = $this.find('i')
+
+ toggleStar = (isStarred) ->
+ $this.parent().find('span.count').text data.star_count
+ if isStarred
+ $starSpan.removeClass('starred').text 'Star'
+ $starIcon.removeClass('fa-star').addClass 'fa-star-o'
+ else
+ $starSpan.addClass('starred').text 'Unstar'
+ $starIcon.removeClass('fa-star-o').addClass 'fa-star'
+ return
+
+ toggleStar $starSpan.hasClass('starred')
+ return
+ ).on 'ajax:error', (e, xhr, status, error) ->
+ new Flash('Star toggle failed. Try again later.', 'alert')
+ return \ No newline at end of file
diff --git a/app/assets/stylesheets/pages/projects.scss b/app/assets/stylesheets/pages/projects.scss
index 3917efeecdb..cff3edb7ed2 100644
--- a/app/assets/stylesheets/pages/projects.scss
+++ b/app/assets/stylesheets/pages/projects.scss
@@ -91,21 +91,83 @@
}
}
- .input-group {
+ .git-clone-holder {
display: inline-table;
position: relative;
- top: 17px;
}
.project-repo-buttons {
margin-top: 12px;
margin-bottom: 0px;
+ .count-buttons {
+ display: block;
+ margin-bottom: 12px;
+ }
+
.btn {
@include btn-gray;
-
+ text-transform: none;
+ }
+ .count-with-arrow {
+ display: inline-block;
+ position: relative;
+ margin-left: 4px;
+
+ .arrow {
+ &:before {
+ content: '';
+ display: inline-block;
+ position: absolute;
+ width: 0;
+ height: 0;
+ border-color: transparent;
+ border-style: solid;
+ top: 50%;
+ left: 0;
+ margin-top: -6px;
+ border-width: 7px 5px 7px 0;
+ border-right-color: #dce0e5;
+ }
+
+ &:after {
+ content: '';
+ position: absolute;
+ width: 0;
+ height: 0;
+ border-color: transparent;
+ border-style: solid;
+ top: 50%;
+ left: 1px;
+ margin-top: -9px;
+ border-width: 10px 7px 10px 0;
+ border-right-color: #FFF;
+ }
+ }
.count {
+ @include btn-gray;
display: inline-block;
+ background: white;
+ border-radius: 2px;
+ border-width: 1px;
+ border-style: solid;
+ font-size: 13px;
+ font-weight: 600;
+ line-height: 20px;
+ padding: 11px 16px;
+ letter-spacing: .4px;
+ padding: 10px;
+ text-align: center;
+ vertical-align: middle;
+ touch-action: manipulation;
+ cursor: pointer;
+ background-image: none;
+ white-space: nowrap;
+ margin: 0 11px 0px 4px;
+
+ &:hover {
+ background: #FFF;
+ }
}
}
}
@@ -125,6 +187,13 @@
margin-right: 45px;
}
+ .clone-options {
+ display: table-cell;
+ a.btn {
+ width: 100%;
+ }
+ }
+
.form-control {
cursor: auto;
@extend .monospace;
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 682dbf2766a..3004722bce0 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -171,7 +171,7 @@ class ProjectsController < ApplicationController
@project.reload
render json: {
- html: view_to_html_string("projects/buttons/_star")
+ star_count: @project.star_count
}
end
diff --git a/app/models/ability.rb b/app/models/ability.rb
index cd5ae0fb0fd..1b3ee757040 100644
--- a/app/models/ability.rb
+++ b/app/models/ability.rb
@@ -132,14 +132,14 @@ class Ability
end
def public_project_rules
- project_guest_rules + [
+ @public_project_rules ||= project_guest_rules + [
:download_code,
:fork_project
]
end
def project_guest_rules
- [
+ @project_guest_rules ||= [
:read_project,
:read_wiki,
:read_issue,
@@ -157,7 +157,7 @@ class Ability
end
def project_report_rules
- project_guest_rules + [
+ @project_report_rules ||= project_guest_rules + [
:create_commit_status,
:read_commit_statuses,
:download_code,
@@ -170,7 +170,7 @@ class Ability
end
def project_dev_rules
- project_report_rules + [
+ @project_dev_rules ||= project_report_rules + [
:admin_merge_request,
:create_merge_request,
:create_wiki,
@@ -181,7 +181,7 @@ class Ability
end
def project_archived_rules
- [
+ @project_archived_rules ||= [
:create_merge_request,
:push_code,
:push_code_to_protected_branches,
@@ -191,7 +191,7 @@ class Ability
end
def project_master_rules
- project_dev_rules + [
+ @project_master_rules ||= project_dev_rules + [
:push_code_to_protected_branches,
:update_project_snippet,
:update_merge_request,
@@ -206,7 +206,7 @@ class Ability
end
def project_admin_rules
- project_master_rules + [
+ @project_admin_rules ||= project_master_rules + [
:change_namespace,
:change_visibility_level,
:rename_project,
@@ -332,7 +332,7 @@ class Ability
end
if snippet.public? || snippet.internal?
- rules << :read_personal_snippet
+ rules << :read_personal_snippet
end
rules
diff --git a/app/models/identity.rb b/app/models/identity.rb
index ad60154be71..8bcdc194953 100644
--- a/app/models/identity.rb
+++ b/app/models/identity.rb
@@ -12,6 +12,7 @@
class Identity < ActiveRecord::Base
include Sortable
+ include CaseSensitivity
belongs_to :user
validates :provider, presence: true
diff --git a/app/views/explore/projects/index.html.haml b/app/views/explore/projects/index.html.haml
index 76bdd68fd76..b9a958fbe7b 100644
--- a/app/views/explore/projects/index.html.haml
+++ b/app/views/explore/projects/index.html.haml
@@ -6,7 +6,7 @@
- else
= render 'explore/head'
-.gray-content-block.clearfix
+.gray-content-block.clearfix.second-block
= render 'filter'
= render 'projects', projects: @projects
= paginate @projects, theme: "gitlab"
diff --git a/app/views/explore/projects/starred.html.haml b/app/views/explore/projects/starred.html.haml
index e30c3633223..95d46e331f8 100644
--- a/app/views/explore/projects/starred.html.haml
+++ b/app/views/explore/projects/starred.html.haml
@@ -7,7 +7,7 @@
= render 'explore/head'
.explore-trending-block
- .gray-content-block
+ .gray-content-block.second-block
.pull-right
= render 'explore/projects/dropdown'
.oneline
diff --git a/app/views/explore/projects/trending.html.haml b/app/views/explore/projects/trending.html.haml
index 1412b19acde..fa0b718e48b 100644
--- a/app/views/explore/projects/trending.html.haml
+++ b/app/views/explore/projects/trending.html.haml
@@ -7,7 +7,7 @@
= render 'explore/head'
.explore-trending-block
- .gray-content-block
+ .gray-content-block.second-block
.pull-right
= render 'explore/projects/dropdown'
.oneline
diff --git a/app/views/projects/_home_panel.html.haml b/app/views/projects/_home_panel.html.haml
index c1669ac046b..e92115b9b98 100644
--- a/app/views/projects/_home_panel.html.haml
+++ b/app/views/projects/_home_panel.html.haml
@@ -27,7 +27,7 @@
= icon('rss')
.project-repo-buttons
- .split-one
+ .split-one.count-buttons
= render 'projects/buttons/star'
= render 'projects/buttons/fork'
@@ -38,3 +38,6 @@
= render 'projects/buttons/dropdown'
= render 'projects/buttons/notifications'
+
+:coffeescript
+ new Star() \ No newline at end of file
diff --git a/app/views/projects/buttons/_fork.html.haml b/app/views/projects/buttons/_fork.html.haml
index 2d3abf09051..133531887a2 100644
--- a/app/views/projects/buttons/_fork.html.haml
+++ b/app/views/projects/buttons/_fork.html.haml
@@ -4,10 +4,15 @@
= link_to namespace_project_path(current_user, current_user.fork_of(@project)), title: 'Go to your fork', class: 'btn has_tooltip' do
= icon('code-fork fw')
Fork
+ %div.count-with-arrow
+ %span.arrow
%span.count
= @project.forks_count
- else
= link_to new_namespace_project_fork_path(@project.namespace, @project), title: "Fork project", class: 'btn has_tooltip' do
= icon('code-fork fw')
+ Fork
+ %div.count-with-arrow
+ %span.arrow
%span.count
= @project.forks_count
diff --git a/app/views/projects/buttons/_star.html.haml b/app/views/projects/buttons/_star.html.haml
index 41a3ec6d90f..21ba426aaa1 100644
--- a/app/views/projects/buttons/_star.html.haml
+++ b/app/views/projects/buttons/_star.html.haml
@@ -1,19 +1,21 @@
- if current_user
= link_to toggle_star_namespace_project_path(@project.namespace, @project), class: 'btn star-btn toggle-star has_tooltip', method: :post, remote: true, title: "Star project" do
- = icon('star fw')
- %span.count
+ - if current_user.starred?(@project)
+ = icon('star fw')
+ %span.starred Unstar
+ - else
+ = icon('star-o fw')
+ %span Star
+ %div.count-with-arrow
+ %span.arrow
+ %span.count.star-count
= @project.star_count
- :javascript
- $('.project-home-panel .toggle-star').on('ajax:success', function (e, data, status, xhr) {
- $(this).replaceWith(data.html);
- })
- .on('ajax:error', function (e, xhr, status, error) {
- new Flash('Star toggle failed. Try again later.', 'alert');
- });
-
- else
= link_to new_user_session_path, class: 'btn has_tooltip star-btn', title: 'You must sign in to star a project' do
= icon('star fw')
+ Star
+ %div.count-with-arrow
+ %span.arrow
%span.count
= @project.star_count
diff --git a/app/views/shared/_clone_panel.html.haml b/app/views/shared/_clone_panel.html.haml
index edb5778f424..687a59c270f 100644
--- a/app/views/shared/_clone_panel.html.haml
+++ b/app/views/shared/_clone_panel.html.haml
@@ -1,10 +1,27 @@
- project = project || @project
-.git-clone-holder.input-group
- .input-group-addon.git-protocols
- .input-group-btn
- = ssh_clone_button(project)
- .input-group-btn
- = http_clone_button(project)
+
+.git-clone-holder
+ .btn-group.clone-options
+ %a#clone-dropdown.clone-dropdown-btn.btn{href: '#', 'data-toggle' => 'dropdown'}
+ %span
+ = default_clone_protocol.upcase
+ = icon('angle-down')
+ %ul.dropdown-menu.dropdown-menu-right.clone-options-dropdown
+ %li
+ %a#ssh-selector{href: @project.ssh_url_to_repo}
+ SSH
+ %li
+ %a#http-selector{href: @project.http_url_to_repo}
+ HTTPS
+
= text_field_tag :project_clone, default_url_to_repo(project), class: "js-select-on-focus form-control", readonly: true
.input-group-btn
= clipboard_button(clipboard_target: '#project_clone')
+
+:javascript
+ $('ul.clone-options-dropdown a').on('click',function(e){
+ e.preventDefault();
+ var $this = $(this);
+ $('a.clone-dropdown-btn span').text($this.text());
+ $('#project_clone').val($this.attr('href'));
+ });