BigW Consortium Gitlab

Commit 1da71cc5 by Dmitriy Zaporozhets

Introduce shortcuts for routing helpers

parent cd6baa14
...@@ -24,6 +24,6 @@ class Projects::AvatarsController < Projects::ApplicationController ...@@ -24,6 +24,6 @@ class Projects::AvatarsController < Projects::ApplicationController
@project.save @project.save
@project.reset_events_cache @project.reset_events_cache
redirect_to edit_namespace_project_path(@project.namespace, @project) redirect_to edit_project_path(@project)
end end
end end
...@@ -7,7 +7,7 @@ class Projects::RepositoriesController < Projects::ApplicationController ...@@ -7,7 +7,7 @@ class Projects::RepositoriesController < Projects::ApplicationController
def create def create
@project.create_repository @project.create_repository
redirect_to namespace_project_path(@project.namespace, @project) redirect_to project_path(@project)
end end
def archive def archive
......
...@@ -23,7 +23,7 @@ class ProjectsController < ApplicationController ...@@ -23,7 +23,7 @@ class ProjectsController < ApplicationController
if @project.saved? if @project.saved?
redirect_to( redirect_to(
namespace_project_path(@project.namespace, @project), project_path(@project),
notice: 'Project was successfully created.' notice: 'Project was successfully created.'
) )
else else
...@@ -39,7 +39,7 @@ class ProjectsController < ApplicationController ...@@ -39,7 +39,7 @@ class ProjectsController < ApplicationController
flash[:notice] = 'Project was successfully updated.' flash[:notice] = 'Project was successfully updated.'
format.html do format.html do
redirect_to( redirect_to(
edit_namespace_project_path(@project.namespace, @project), edit_project_path(@project),
notice: 'Project was successfully updated.' notice: 'Project was successfully updated.'
) )
end end
...@@ -133,7 +133,7 @@ class ProjectsController < ApplicationController ...@@ -133,7 +133,7 @@ class ProjectsController < ApplicationController
@project.archive! @project.archive!
respond_to do |format| respond_to do |format|
format.html { redirect_to namespace_project_path(@project.namespace, @project) } format.html { redirect_to project_path(@project) }
end end
end end
...@@ -142,7 +142,7 @@ class ProjectsController < ApplicationController ...@@ -142,7 +142,7 @@ class ProjectsController < ApplicationController
@project.unarchive! @project.unarchive!
respond_to do |format| respond_to do |format|
format.html { redirect_to namespace_project_path(@project.namespace, @project) } format.html { redirect_to project_path(@project) }
end end
end end
......
# Shorter routing method for project and project items
module GitlabRoutingHelper
def project_path(project, *args)
namespace_project_path(project.namespace, project, *args)
end
def edit_project_path(project, *args)
edit_namespace_project_path(project.namespace, project, *args)
end
def issue_path(entity, *args)
namespace_project_issue_path(entity.project.namespace, entity.project, entity, *args)
end
def merge_request_path(entity, *args)
namespace_project_merge_request_path(entity.project.namespace, entity.project, entity, *args)
end
end
...@@ -46,7 +46,7 @@ module ProjectsHelper ...@@ -46,7 +46,7 @@ module ProjectsHelper
simple_sanitize(project.group.name), group_path(project.group) simple_sanitize(project.group.name), group_path(project.group)
) + ' / ' + ) + ' / ' +
link_to(simple_sanitize(project.name), link_to(simple_sanitize(project.name),
namespace_project_path(project.namespace, project)) project_path(project))
end end
else else
owner = project.namespace.owner owner = project.namespace.owner
...@@ -55,7 +55,7 @@ module ProjectsHelper ...@@ -55,7 +55,7 @@ module ProjectsHelper
simple_sanitize(owner.name), user_path(owner) simple_sanitize(owner.name), user_path(owner)
) + ' / ' + ) + ' / ' +
link_to(simple_sanitize(project.name), link_to(simple_sanitize(project.name),
namespace_project_path(project.namespace, project)) project_path(project))
end end
end end
end end
......
%h3.page-title %h3.page-title
Project: #{@project.name_with_namespace} Project: #{@project.name_with_namespace}
= link_to edit_namespace_project_path(@project.namespace, @project), class: "btn pull-right" do = link_to edit_project_path(@project), class: "btn pull-right" do
%i.fa.fa-pencil-square-o %i.fa.fa-pencil-square-o
Edit Edit
%hr %hr
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
%li %li
%span.light Name: %span.light Name:
%strong %strong
= link_to @project.name, namespace_project_path(@project.namespace, @project) = link_to @project.name, project_path(@project)
%li %li
%span.light Namespace: %span.light Namespace:
%strong %strong
......
= link_to namespace_project_path(project.namespace, project), class: dom_class(project) do = link_to project_path(project), class: dom_class(project) do
.dash-project-avatar .dash-project-avatar
= project_icon(project, alt: '', class: 'avatar project-avatar s40') = project_icon(project, alt: '', class: 'avatar project-avatar s40')
.dash-project-access-icon .dash-project-access-icon
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
= project_icon("#{project.namespace.to_param}/#{project.to_param}", alt: '', class: 'avatar project-avatar s60') = project_icon("#{project.namespace.to_param}/#{project.to_param}", alt: '', class: 'avatar project-avatar s60')
.project-access-icon .project-access-icon
= visibility_level_icon(project.visibility_level) = visibility_level_icon(project.visibility_level)
= link_to namespace_project_path(project.namespace, project), class: dom_class(project) do = link_to project_path(project), class: dom_class(project) do
%strong= project.name_with_namespace %strong= project.name_with_namespace
- if project.forked_from_project - if project.forked_from_project
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
.nothing-here-block This group has no projects yet .nothing-here-block This group has no projects yet
- projects.each do |project| - projects.each do |project|
%li.project-row %li.project-row
= link_to namespace_project_path(project.namespace, project), class: dom_class(project) do = link_to project_path(project), class: dom_class(project) do
.dash-project-avatar .dash-project-avatar
= project_icon(project, alt: '', class: 'avatar s40') = project_icon(project, alt: '', class: 'avatar s40')
.dash-project-access-icon .dash-project-access-icon
......
%ul.project-navigation.nav.nav-sidebar %ul.project-navigation.nav.nav-sidebar
- if @project_settings_nav - if @project_settings_nav
= nav_link do = nav_link do
= link_to namespace_project_path(@project.namespace, @project), title: 'Back to project', class: "" do = link_to project_path(@project), title: 'Back to project', class: "" do
%i.fa.fa-caret-square-o-left %i.fa.fa-caret-square-o-left
%span %span
Back to project Back to project
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
- else - else
= nav_link(path: 'projects#show', html_options: {class: "home"}) do = nav_link(path: 'projects#show', html_options: {class: "home"}) do
= link_to namespace_project_path(@project.namespace, @project), title: 'Project', class: 'shortcuts-project' do = link_to project_path(@project), title: 'Project', class: 'shortcuts-project' do
%i.fa.fa-dashboard %i.fa.fa-dashboard
%span %span
Project Project
...@@ -89,7 +89,7 @@ ...@@ -89,7 +89,7 @@
- if project_nav_tab? :settings - if project_nav_tab? :settings
= nav_link(html_options: {class: "#{project_tab_class} separate-item"}) do = nav_link(html_options: {class: "#{project_tab_class} separate-item"}) do
= link_to edit_namespace_project_path(@project.namespace, @project), title: 'Settings', class: "stat-tab tab no-highlight" do = link_to edit_project_path(@project), title: 'Settings', class: "stat-tab tab no-highlight" do
%i.fa.fa-cogs %i.fa.fa-cogs
%span %span
Settings Settings
%ul.project-settings-nav.sidebar-subnav %ul.project-settings-nav.sidebar-subnav
= nav_link(path: 'projects#edit') do = nav_link(path: 'projects#edit') do
= link_to edit_namespace_project_path(@project.namespace, @project), title: 'Project', class: "stat-tab tab " do = link_to edit_project_path(@project), title: 'Project', class: "stat-tab tab " do
%i.fa.fa-pencil-square-o %i.fa.fa-pencil-square-o
%span %span
Project Project
......
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
= link_to "Plain diff", namespace_project_commit_path(@project.namespace, @project, @commit, format: :diff), class: "btn btn-warning btn-small" = link_to "Plain diff", namespace_project_commit_path(@project.namespace, @project, @commit, format: :diff), class: "btn btn-warning btn-small"
= link_to "Email patch", namespace_project_commit_path(@project.namespace, @project, @commit, format: :patch), class: "btn btn-warning btn-small" = link_to "Email patch", namespace_project_commit_path(@project.namespace, @project, @commit, format: :patch), class: "btn btn-warning btn-small"
- elsif @merge_request && @merge_request.persisted? - elsif @merge_request && @merge_request.persisted?
= link_to "Plain diff", namespace_project_merge_request_path(@project.namespace, @project, @merge_request, format: :diff), class: "btn btn-warning btn-small" = link_to "Plain diff", merge_request_path(@merge_request, format: :diff), class: "btn btn-warning btn-small"
= link_to "Email patch", namespace_project_merge_request_path(@project.namespace, @project, @merge_request, format: :patch), class: "btn btn-warning btn-small" = link_to "Email patch", merge_request_path(@merge_request, format: :patch), class: "btn btn-warning btn-small"
%p %p
To preserve performance only To preserve performance only
%strong #{allowed_diff_size} of #{diffs.size} %strong #{allowed_diff_size} of #{diffs.size}
......
- content_for :note_actions do - content_for :note_actions do
- if can?(current_user, :modify_issue, @issue) - if can?(current_user, :modify_issue, @issue)
- if @issue.closed? - if @issue.closed?
= link_to 'Reopen Issue', namespace_project_issue_path(@project.namespace, @project, @issue, issue: {state_event: :reopen }, status_only: true), method: :put, class: "btn btn-grouped btn-reopen js-note-target-reopen", title: 'Reopen Issue' = link_to 'Reopen Issue', issue_path(@issue, issue: {state_event: :reopen }, status_only: true), method: :put, class: "btn btn-grouped btn-reopen js-note-target-reopen", title: 'Reopen Issue'
- else - else
= link_to 'Close Issue', namespace_project_issue_path(@project.namespace, @project, @issue, issue: {state_event: :close }, status_only: true), method: :put, class: "btn btn-grouped btn-close js-note-target-close", title: "Close Issue" = link_to 'Close Issue', issue_path(@issue, issue: {state_event: :close }, status_only: true), method: :put, class: "btn btn-grouped btn-close js-note-target-close", title: "Close Issue"
.row .row
%section.col-md-9 %section.col-md-9
.participants .participants
......
%li{ id: dom_id(issue), class: issue_css_classes(issue), url: namespace_project_issue_path(issue.project.namespace, issue.project, issue) } %li{ id: dom_id(issue), class: issue_css_classes(issue), url: issue_path(issue) }
- if controller.controller_name == 'issues' - if controller.controller_name == 'issues'
.issue-check .issue-check
= check_box_tag dom_id(issue,"selected"), nil, false, 'data-id' => issue.id, class: "selected_issue", disabled: !can?(current_user, :modify_issue, issue) = check_box_tag dom_id(issue,"selected"), nil, false, 'data-id' => issue.id, class: "selected_issue", disabled: !can?(current_user, :modify_issue, issue)
.issue-title .issue-title
%span.str-truncated %span.str-truncated
= link_to_gfm issue.title, namespace_project_issue_path(issue.project.namespace, issue.project, issue), class: "row_title" = link_to_gfm issue.title, issue_path(issue), class: "row_title"
.pull-right.light .pull-right.light
- if issue.closed? - if issue.closed?
%span %span
...@@ -41,9 +41,9 @@ ...@@ -41,9 +41,9 @@
.issue-actions .issue-actions
- if can? current_user, :modify_issue, issue - if can? current_user, :modify_issue, issue
- if issue.closed? - if issue.closed?
= link_to 'Reopen', namespace_project_issue_path(issue.project.namespace, issue.project, issue, issue: {state_event: :reopen }, status_only: true), method: :put, class: "btn btn-small btn-grouped reopen_issue btn-reopen", remote: true = link_to 'Reopen', issue_path(issue, issue: {state_event: :reopen }, status_only: true), method: :put, class: "btn btn-small btn-grouped reopen_issue btn-reopen", remote: true
- else - else
= link_to 'Close', namespace_project_issue_path(issue.project.namespace, issue.project, issue, issue: {state_event: :close }, status_only: true), method: :put, class: "btn btn-small btn-grouped close_issue btn-close", remote: true = link_to 'Close', issue_path(issue, issue: {state_event: :close }, status_only: true), method: :put, class: "btn btn-small btn-grouped close_issue btn-close", remote: true
= link_to edit_namespace_project_issue_path(issue.project.namespace, issue.project, issue), class: "btn btn-small edit-issue-link btn-grouped" do = link_to edit_namespace_project_issue_path(issue.project.namespace, issue.project, issue), class: "btn btn-small edit-issue-link btn-grouped" do
%i.fa.fa-pencil-square-o %i.fa.fa-pencil-square-o
Edit Edit
......
...@@ -17,9 +17,9 @@ ...@@ -17,9 +17,9 @@
New Issue New Issue
- if can?(current_user, :modify_issue, @issue) - if can?(current_user, :modify_issue, @issue)
- if @issue.closed? - if @issue.closed?
= link_to 'Reopen', namespace_project_issue_path(@project.namespace, @project, @issue, issue: {state_event: :reopen }, status_only: true), method: :put, class: "btn btn-grouped btn-reopen" = link_to 'Reopen', issue_path(@issue, issue: {state_event: :reopen }, status_only: true), method: :put, class: "btn btn-grouped btn-reopen"
- else - else
= link_to 'Close', namespace_project_issue_path(@project.namespace, @project, @issue, issue: {state_event: :close }, status_only: true), method: :put, class: "btn btn-grouped btn-close", title: "Close Issue" = link_to 'Close', issue_path(@issue, issue: {state_event: :close }, status_only: true), method: :put, class: "btn btn-grouped btn-close", title: "Close Issue"
= link_to edit_namespace_project_issue_path(@project.namespace, @project, @issue), class: "btn btn-grouped issuable-edit" do = link_to edit_namespace_project_issue_path(@project.namespace, @project, @issue), class: "btn btn-grouped issuable-edit" do
%i.fa.fa-pencil-square-o %i.fa.fa-pencil-square-o
......
- content_for :note_actions do - content_for :note_actions do
- if can?(current_user, :modify_merge_request, @merge_request) - if can?(current_user, :modify_merge_request, @merge_request)
- if @merge_request.open? - if @merge_request.open?
= link_to 'Close', namespace_project_merge_request_path(@project.namespace, @project, @merge_request, merge_request: {state_event: :close }), method: :put, class: "btn btn-grouped btn-close close-mr-link js-note-target-close", title: "Close merge request" = link_to 'Close', merge_request_path(@merge_request, merge_request: {state_event: :close }), method: :put, class: "btn btn-grouped btn-close close-mr-link js-note-target-close", title: "Close merge request"
- if @merge_request.closed? - if @merge_request.closed?
= link_to 'Reopen', namespace_project_merge_request_path(@project.namespace, @project, @merge_request, merge_request: {state_event: :reopen }), method: :put, class: "btn btn-grouped btn-reopen reopen-mr-link js-note-target-reopen", title: "Reopen merge request" = link_to 'Reopen', merge_request_path(@merge_request, merge_request: {state_event: :reopen }), method: :put, class: "btn btn-grouped btn-reopen reopen-mr-link js-note-target-reopen", title: "Reopen merge request"
.row .row
%section.col-md-9 %section.col-md-9
......
.merge-request{'data-url' => namespace_project_merge_request_path(@project.namespace, @project, @merge_request)} .merge-request{'data-url' => merge_request_path(@merge_request)}
.merge-request-details .merge-request-details
= render "projects/merge_requests/show/mr_title" = render "projects/merge_requests/show/mr_title"
%hr %hr
...@@ -28,8 +28,8 @@ ...@@ -28,8 +28,8 @@
Download as Download as
%span.caret %span.caret
%ul.dropdown-menu %ul.dropdown-menu
%li= link_to "Email Patches", namespace_project_merge_request_path(@project.namespace, @project, @merge_request, format: :patch) %li= link_to "Email Patches", merge_request_path(@merge_request, format: :patch)
%li= link_to "Plain Diff", namespace_project_merge_request_path(@project.namespace, @project, @merge_request, format: :diff) %li= link_to "Plain Diff", merge_request_path(@merge_request, format: :diff)
= render "projects/merge_requests/show/how_to_merge" = render "projects/merge_requests/show/how_to_merge"
= render "projects/merge_requests/show/state_widget" = render "projects/merge_requests/show/state_widget"
...@@ -37,12 +37,12 @@ ...@@ -37,12 +37,12 @@
- if @commits.present? - if @commits.present?
%ul.nav.nav-tabs.merge-request-tabs %ul.nav.nav-tabs.merge-request-tabs
%li.notes-tab{data: {action: 'notes'}} %li.notes-tab{data: {action: 'notes'}}
= link_to namespace_project_merge_request_path(@project.namespace, @project, @merge_request) do = link_to merge_request_path(@merge_request) do
%i.fa.fa-comments %i.fa.fa-comments
Discussion Discussion
%span.badge= @merge_request.mr_and_commit_notes.count %span.badge= @merge_request.mr_and_commit_notes.count
%li.commits-tab{data: {action: 'commits'}} %li.commits-tab{data: {action: 'commits'}}
= link_to namespace_project_merge_request_path(@project.namespace, @project, @merge_request), title: 'Commits' do = link_to merge_request_path(@merge_request), title: 'Commits' do
%i.fa.fa-history %i.fa.fa-history
Commits Commits
%span.badge= @commits.size %span.badge= @commits.size
......
...@@ -14,9 +14,9 @@ ...@@ -14,9 +14,9 @@
.issue-btn-group.pull-right .issue-btn-group.pull-right
- if can?(current_user, :modify_merge_request, @merge_request) - if can?(current_user, :modify_merge_request, @merge_request)
- if @merge_request.open? - if @merge_request.open?
= link_to 'Close', namespace_project_merge_request_path(@project.namespace, @project, @merge_request, merge_request: { state_event: :close }), method: :put, class: "btn btn-grouped btn-close", title: "Close merge request" = link_to 'Close', merge_request_path(@merge_request, merge_request: { state_event: :close }), method: :put, class: "btn btn-grouped btn-close", title: "Close merge request"
= link_to edit_namespace_project_merge_request_path(@project.namespace, @project, @merge_request), class: "btn btn-grouped issuable-edit", id: "edit_merge_request" do = link_to edit_namespace_project_merge_request_path(@project.namespace, @project, @merge_request), class: "btn btn-grouped issuable-edit", id: "edit_merge_request" do
%i.fa.fa-pencil-square-o %i.fa.fa-pencil-square-o
Edit Edit
- if @merge_request.closed? - if @merge_request.closed?
= link_to 'Reopen', namespace_project_merge_request_path(@project.namespace, @project, @merge_request, merge_request: {state_event: :reopen }), method: :put, class: "btn btn-grouped btn-reopen reopen-mr-link", title: "Close merge request" = link_to 'Reopen', merge_request_path(@merge_request, merge_request: {state_event: :reopen }), method: :put, class: "btn btn-grouped btn-reopen reopen-mr-link", title: "Close merge request"
%li{ id: dom_id(issue, 'sortable'), class: 'issue-row', 'data-iid' => issue.iid, 'data-url' => namespace_project_issue_path(@project.namespace, @project, issue) } %li{ id: dom_id(issue, 'sortable'), class: 'issue-row', 'data-iid' => issue.iid, 'data-url' => issue_path(issue) }
%span.str-truncated %span.str-truncated
= link_to [@project.namespace.becomes(Namespace), @project, issue] do = link_to [@project.namespace.becomes(Namespace), @project, issue] do
%span.cgray ##{issue.iid} %span.cgray ##{issue.iid}
......
%li{ id: dom_id(merge_request, 'sortable'), class: 'mr-row', 'data-iid' => merge_request.iid, 'data-url' => namespace_project_merge_request_path(@project.namespace, @project, merge_request) } %li{ id: dom_id(merge_request, 'sortable'), class: 'mr-row', 'data-iid' => merge_request.iid, 'data-url' => merge_request_path(merge_request) }
%span.str-truncated %span.str-truncated
= link_to [@project.namespace.becomes(Namespace), @project, merge_request] do = link_to [@project.namespace.becomes(Namespace), @project, merge_request] do
%span.cgray ##{merge_request.iid} %span.cgray ##{merge_request.iid}
......
...@@ -19,4 +19,4 @@ ...@@ -19,4 +19,4 @@
- if can? current_user, :remove_project, @project - if can? current_user, :remove_project, @project
.prepend-top-20 .prepend-top-20
= link_to 'Remove project', namespace_project_path(@project.namespace, @project), data: { confirm: remove_project_message(@project)}, method: :delete, class: "btn btn-remove pull-right" = link_to 'Remove project', project_path(@project), data: { confirm: remove_project_message(@project)}, method: :delete, class: "btn btn-remove pull-right"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment