summaryrefslogtreecommitdiff
path: root/app/views
diff options
context:
space:
mode:
Diffstat (limited to 'app/views')
-rw-r--r--app/views/projects/_home_panel.html.haml40
-rw-r--r--app/views/projects/buttons/_fork.html.haml13
-rw-r--r--app/views/projects/buttons/_star.html.haml22
3 files changed, 47 insertions, 28 deletions
diff --git a/app/views/projects/_home_panel.html.haml b/app/views/projects/_home_panel.html.haml
index 6335d76ab81..2c32d9ccafe 100644
--- a/app/views/projects/_home_panel.html.haml
+++ b/app/views/projects/_home_panel.html.haml
@@ -8,35 +8,19 @@
.project-repo-buttons
- .inline.star.js-toggler-container{class: @show_star ? 'on' : ''}
- - if current_user
- = link_to_toggle_star('Star this project.', false)
- = link_to_toggle_star('Unstar this project.', true)
- - else
- = link_to new_user_session_path, class: 'btn star-btn has_tooltip', title: 'You must sign in to star a project' do
- %span
- = icon('star')
- Star
- %span.count
- = @project.star_count
+ = render 'projects/buttons/star'
+
- unless empty_repo
- - if current_user && can?(current_user, :fork_project, @project) && @project.namespace != current_user.namespace
- .inline.fork-buttons.prepend-left-10
- - if current_user.already_forked?(@project) && current_user.manageable_namespaces.size < 2
- = link_to namespace_project_path(current_user, current_user.fork_of(@project)), title: 'Go to your fork', class: 'btn' do
- = link_to_toggle_fork
- - else
- = link_to new_namespace_project_fork_path(@project.namespace, @project), title: "Fork project", class: 'btn' do
- = link_to_toggle_fork
- - elsif forked_from_project = @project.forked_from_project
- .inline.prepend-left-10
- = link_to project_path(forked_from_project), class: 'btn' do
- = icon("code-fork fw")
- Forked from
- = forked_from_project.namespace.try(:name)
+ = render 'projects/buttons/fork'
+
+ - if forked_from_project = @project.forked_from_project
+ = link_to project_path(forked_from_project), class: 'btn' do
+ = icon("code-fork fw")
+ Forked from
+ = forked_from_project.namespace.try(:name)
+
- if can? current_user, :download_code, @project
- .inline.prepend-left-10
- = link_to archive_namespace_project_repository_path(@project.namespace, @project, ref: @ref, format: 'zip'), class: 'btn', rel: 'nofollow' do
- %i.fa.fa-download
+ = link_to archive_namespace_project_repository_path(@project.namespace, @project, ref: @ref, format: 'zip'), class: 'btn', rel: 'nofollow' do
+ %i.fa.fa-download
= render "shared/clone_panel"
diff --git a/app/views/projects/buttons/_fork.html.haml b/app/views/projects/buttons/_fork.html.haml
new file mode 100644
index 00000000000..f0483c79edc
--- /dev/null
+++ b/app/views/projects/buttons/_fork.html.haml
@@ -0,0 +1,13 @@
+- if current_user && can?(current_user, :fork_project, @project)
+ - if current_user.already_forked?(@project) && current_user.manageable_namespaces.size < 2
+ = link_to namespace_project_path(current_user, current_user.fork_of(@project)), title: 'Go to your fork', class: 'btn' do
+ = icon('code-fork')
+ Fork
+ %span.count
+ = @project.forks_count
+ - else
+ = link_to new_namespace_project_fork_path(@project.namespace, @project), title: "Fork project", class: 'btn' do
+ = icon('code-fork')
+ Fork
+ %span.count
+ = @project.forks_count
diff --git a/app/views/projects/buttons/_star.html.haml b/app/views/projects/buttons/_star.html.haml
new file mode 100644
index 00000000000..89e3f4ac738
--- /dev/null
+++ b/app/views/projects/buttons/_star.html.haml
@@ -0,0 +1,22 @@
+- if current_user
+ = link_to toggle_star_namespace_project_path(@project.namespace, @project), class: 'btn toggle-star', method: :post, remote: true do
+ - if current_user.starred?(@project)
+ Unstar
+ - else
+ Star
+ %span.count
+ = @project.star_count
+- else
+ = link_to new_user_session_path, class: 'btn has_tooltip', title: 'You must sign in to star a project' do
+ = icon('star')
+ Star
+ %span.count
+ = @project.star_count
+
+:coffeescript
+ $('.project-home-panel .toggle-star').on 'ajax:success', (e, data, status, xhr) ->
+ $(@).replaceWith(data.html)
+ .on 'ajax:error', (e, xhr, status, error) ->
+ new Flash('Star toggle failed. Try again later.', 'alert')
+
+