Skip to content
Snippets Groups Projects
Commit fe13f110 authored by Douwe Maan's avatar Douwe Maan
Browse files

Create and use project path helpers that only need a project, no namespace

parent dc793933
No related branches found
No related tags found
No related merge requests found
Showing
with 68 additions and 68 deletions
Loading
Loading
@@ -15,7 +15,7 @@ class Projects::ServicesController < Projects::ApplicationController
 
def update
if @service.save(context: :manual_change)
redirect_to(namespace_project_settings_integrations_path(@project.namespace, @project), notice: success_message)
redirect_to(project_settings_integrations_path(@project), notice: success_message)
else
render 'edit'
end
Loading
Loading
Loading
Loading
@@ -30,7 +30,7 @@ class Projects::SnippetsController < Projects::ApplicationController
).execute
@snippets = @snippets.page(params[:page])
if @snippets.out_of_range? && @snippets.total_pages != 0
redirect_to namespace_project_snippets_path(page: @snippets.total_pages)
redirect_to project_snippets_path(@project, page: @snippets.total_pages)
end
end
 
Loading
Loading
@@ -79,7 +79,7 @@ class Projects::SnippetsController < Projects::ApplicationController
 
@snippet.destroy
 
redirect_to namespace_project_snippets_path(@project.namespace, @project), status: 302
redirect_to project_snippets_path(@project), status: 302
end
 
protected
Loading
Loading
@@ -90,6 +90,10 @@ class Projects::SnippetsController < Projects::ApplicationController
alias_method :awardable, :snippet
alias_method :spammable, :snippet
 
def spammable_path
project_snippet_path(@project, @snippet)
end
def authorize_read_project_snippet!
return render_404 unless can?(current_user, :read_project_snippet, @snippet)
end
Loading
Loading
Loading
Loading
@@ -35,7 +35,7 @@ class Projects::TagsController < Projects::ApplicationController
if result[:status] == :success
@tag = result[:tag]
 
redirect_to namespace_project_tag_path(@project.namespace, @project, @tag.name)
redirect_to project_tag_path(@project, @tag.name)
else
@error = result[:message]
@message = params[:message]
Loading
Loading
@@ -50,7 +50,7 @@ class Projects::TagsController < Projects::ApplicationController
respond_to do |format|
if result[:status] == :success
format.html do
redirect_to namespace_project_tags_path(@project.namespace, @project), status: 303
redirect_to project_tags_path(@project), status: 303
end
 
format.js
Loading
Loading
@@ -58,7 +58,7 @@ class Projects::TagsController < Projects::ApplicationController
@error = result[:message]
 
format.html do
redirect_to namespace_project_tags_path(@project.namespace, @project),
redirect_to project_tags_path(@project),
alert: @error, status: 303
end
 
Loading
Loading
Loading
Loading
@@ -16,7 +16,7 @@ class Projects::TreeController < Projects::ApplicationController
if tree.entries.empty?
if @repository.blob_at(@commit.id, @path)
return redirect_to(
namespace_project_blob_path(@project.namespace, @project,
project_blob_path(@project,
File.join(@ref, @path))
)
elsif @path.present?
Loading
Loading
@@ -37,8 +37,8 @@ class Projects::TreeController < Projects::ApplicationController
return render_404 unless @commit_params.values.all?
 
create_commit(Files::CreateDirService, success_notice: "The directory has been successfully created.",
success_path: namespace_project_tree_path(@project.namespace, @project, File.join(@branch_name, @dir_name)),
failure_path: namespace_project_tree_path(@project.namespace, @project, @ref))
success_path: project_tree_path(@project, File.join(@branch_name, @dir_name)),
failure_path: project_tree_path(@project, @ref))
end
 
private
Loading
Loading
Loading
Loading
@@ -7,7 +7,7 @@ class Projects::TriggersController < Projects::ApplicationController
layout 'project_settings'
 
def index
redirect_to namespace_project_settings_ci_cd_path(@project.namespace, @project)
redirect_to project_settings_ci_cd_path(@project)
end
 
def create
Loading
Loading
@@ -19,7 +19,7 @@ class Projects::TriggersController < Projects::ApplicationController
flash[:alert] = 'You could not create a new trigger.'
end
 
redirect_to namespace_project_settings_ci_cd_path(@project.namespace, @project)
redirect_to project_settings_ci_cd_path(@project)
end
 
def take_ownership
Loading
Loading
@@ -29,7 +29,7 @@ class Projects::TriggersController < Projects::ApplicationController
flash[:alert] = 'You could not take ownership of trigger.'
end
 
redirect_to namespace_project_settings_ci_cd_path(@project.namespace, @project)
redirect_to project_settings_ci_cd_path(@project)
end
 
def edit
Loading
Loading
@@ -37,7 +37,7 @@ class Projects::TriggersController < Projects::ApplicationController
 
def update
if trigger.update(trigger_params)
redirect_to namespace_project_settings_ci_cd_path(@project.namespace, @project), notice: 'Trigger was successfully updated.'
redirect_to project_settings_ci_cd_path(@project), notice: 'Trigger was successfully updated.'
else
render action: "edit"
end
Loading
Loading
@@ -50,7 +50,7 @@ class Projects::TriggersController < Projects::ApplicationController
flash[:alert] = "Could not remove the trigger."
end
 
redirect_to namespace_project_settings_ci_cd_path(@project.namespace, @project), status: 302
redirect_to project_settings_ci_cd_path(@project), status: 302
end
 
private
Loading
Loading
Loading
Loading
@@ -4,7 +4,7 @@ class Projects::VariablesController < Projects::ApplicationController
layout 'project_settings'
 
def index
redirect_to namespace_project_settings_ci_cd_path(@project.namespace, @project)
redirect_to project_settings_ci_cd_path(@project)
end
 
def show
Loading
Loading
@@ -15,7 +15,7 @@ class Projects::VariablesController < Projects::ApplicationController
@variable = @project.variables.find(params[:id])
 
if @variable.update_attributes(project_params)
redirect_to namespace_project_variables_path(project.namespace, project), notice: 'Variable was successfully updated.'
redirect_to project_variables_path(project), notice: 'Variable was successfully updated.'
else
render action: "show"
end
Loading
Loading
@@ -26,7 +26,7 @@ class Projects::VariablesController < Projects::ApplicationController
 
if @variable.valid? && @project.variables << @variable
flash[:notice] = 'Variables were successfully updated.'
redirect_to namespace_project_settings_ci_cd_path(project.namespace, project)
redirect_to project_settings_ci_cd_path(project)
else
render "show"
end
Loading
Loading
@@ -36,7 +36,7 @@ class Projects::VariablesController < Projects::ApplicationController
@key = @project.variables.find(params[:id])
@key.destroy
 
redirect_to namespace_project_settings_ci_cd_path(project.namespace, project),
redirect_to project_settings_ci_cd_path(project),
status: 302,
notice: 'Variable was successfully removed.'
end
Loading
Loading
Loading
Loading
@@ -49,7 +49,7 @@ class Projects::WikisController < Projects::ApplicationController
 
if @page.valid?
redirect_to(
namespace_project_wiki_path(@project.namespace, @project, @page),
project_wiki_path(@project, @page),
notice: 'Wiki was successfully updated.'
)
else
Loading
Loading
@@ -62,7 +62,7 @@ class Projects::WikisController < Projects::ApplicationController
 
if @page.persisted?
redirect_to(
namespace_project_wiki_path(@project.namespace, @project, @page),
project_wiki_path(@project, @page),
notice: 'Wiki was successfully updated.'
)
else
Loading
Loading
@@ -75,7 +75,7 @@ class Projects::WikisController < Projects::ApplicationController
 
unless @page
redirect_to(
namespace_project_wiki_path(@project.namespace, @project, :home),
project_wiki_path(@project, :home),
notice: "Page not found"
)
end
Loading
Loading
@@ -85,7 +85,7 @@ class Projects::WikisController < Projects::ApplicationController
@page = @project_wiki.find_page(params[:id])
WikiPages::DestroyService.new(@project, current_user).execute(@page)
 
redirect_to namespace_project_wiki_path(@project.namespace, @project, :home),
redirect_to project_wiki_path(@project, :home),
status: 302,
notice: "Page was successfully deleted"
end
Loading
Loading
Loading
Loading
@@ -92,7 +92,7 @@ class ProjectsController < Projects::ApplicationController
 
def show
if @project.import_in_progress?
redirect_to namespace_project_import_path(@project.namespace, @project)
redirect_to project_import_path(@project)
return
end
 
Loading
Loading
Loading
Loading
@@ -44,7 +44,7 @@ class SearchController < ApplicationController
query = params[:search].strip.downcase
found_by_commit_sha = Commit.valid_hash?(query) && only_commit.sha.start_with?(query)
 
redirect_to namespace_project_commit_path(@project.namespace, @project, only_commit) if found_by_commit_sha
redirect_to project_commit_path(@project, only_commit) if found_by_commit_sha
end
end
end
Loading
Loading
@@ -107,6 +107,10 @@ class SnippetsController < ApplicationController
alias_method :awardable, :snippet
alias_method :spammable, :snippet
 
def spammable_path
snippet_path(@snippet)
end
def authorize_read_snippet!
return if can?(current_user, :read_personal_snippet, @snippet)
 
Loading
Loading
Loading
Loading
@@ -7,7 +7,7 @@ module AwardEmojiHelper
if awardable.for_personal_snippet?
toggle_award_emoji_snippet_note_path(awardable.noteable, awardable)
else
toggle_award_emoji_namespace_project_note_path(@project.namespace, @project, awardable.id)
toggle_award_emoji_project_note_path(@project, awardable.id)
end
else
url_for([:toggle_award_emoji, @project.namespace.becomes(Namespace), @project, awardable])
Loading
Loading
Loading
Loading
@@ -9,7 +9,7 @@ module BlobHelper
end
 
def edit_path(project = @project, ref = @ref, path = @path, options = {})
namespace_project_edit_blob_path(project.namespace, project,
project_edit_blob_path(project,
tree_join(ref, path),
options[:link_opts])
end
Loading
Loading
@@ -33,7 +33,7 @@ module BlobHelper
notice: edit_in_new_fork_notice,
notice_now: edit_in_new_fork_notice_now
}
fork_path = namespace_project_forks_path(project.namespace, project, namespace_key: current_user.namespace.id, continue: continue_params)
fork_path = project_forks_path(project, namespace_key: current_user.namespace.id, continue: continue_params)
 
button_tag 'Edit',
class: "#{common_classes} js-edit-blob-link-fork-toggler",
Loading
Loading
@@ -62,7 +62,7 @@ module BlobHelper
notice: edit_in_new_fork_notice + " Try to #{action} this file again.",
notice_now: edit_in_new_fork_notice_now
}
fork_path = namespace_project_forks_path(project.namespace, project, namespace_key: current_user.namespace.id, continue: continue_params)
fork_path = project_forks_path(project, namespace_key: current_user.namespace.id, continue: continue_params)
 
button_tag label,
class: "#{common_classes} js-edit-blob-link-fork-toggler",
Loading
Loading
@@ -120,15 +120,15 @@ module BlobHelper
 
def blob_raw_url
if @build && @entry
raw_namespace_project_job_artifacts_path(@project.namespace, @project, @build, path: @entry.path)
raw_project_job_artifacts_path(@project, @build, path: @entry.path)
elsif @snippet
if @snippet.project_id
raw_namespace_project_snippet_path(@project.namespace, @project, @snippet)
raw_project_snippet_path(@project, @snippet)
else
raw_snippet_path(@snippet)
end
elsif @blob
namespace_project_raw_path(@project.namespace, @project, @id)
project_raw_path(@project, @id)
end
end
 
Loading
Loading
@@ -279,12 +279,12 @@ module BlobHelper
options = []
 
if can?(current_user, :create_issue, project)
options << link_to("submit an issue", new_namespace_project_issue_path(project.namespace, project))
options << link_to("submit an issue", new_project_issue_path(project))
end
 
merge_project = can?(current_user, :create_merge_request, project) ? project : (current_user && current_user.fork_of(project))
if merge_project
options << link_to("create a merge request", namespace_project_new_merge_request_path(project.namespace, project))
options << link_to("create a merge request", project_new_merge_request_path(project))
end
 
options
Loading
Loading
Loading
Loading
@@ -3,12 +3,12 @@ module BoardsHelper
board = @board || @boards.first
 
{
endpoint: namespace_project_boards_path(@project.namespace, @project),
endpoint: project_boards_path(@project),
board_id: board.id,
disabled: "#{!can?(current_user, :admin_list, @project)}",
issue_link_base: namespace_project_issues_path(@project.namespace, @project),
issue_link_base: project_issues_path(@project),
root_path: root_path,
bulk_update_path: bulk_update_namespace_project_issues_path(@project.namespace, @project),
bulk_update_path: bulk_update_project_issues_path(@project),
default_avatar: image_path(default_avatar)
}
end
Loading
Loading
Loading
Loading
@@ -7,7 +7,7 @@ module BranchesHelper
 
options = exist_opts.merge(options)
 
namespace_project_branches_path(@project.namespace, @project, @id, options)
project_branches_path(@project, @id, options)
end
 
def can_push_branch?(project, branch_name)
Loading
Loading
Loading
Loading
@@ -20,8 +20,8 @@ module BuildsHelper
 
def javascript_build_options
{
page_url: namespace_project_job_url(@project.namespace, @project, @build),
build_url: namespace_project_job_url(@project.namespace, @project, @build, :json),
page_url: project_job_url(@project, @build),
build_url: project_job_url(@project, @build, :json),
build_status: @build.status,
build_stage: @build.stage,
log_state: ''
Loading
Loading
@@ -31,7 +31,7 @@ module BuildsHelper
def build_failed_issue_options
{
title: "Build Failed ##{@build.id}",
description: namespace_project_job_url(@project.namespace, @project, @build)
description: project_job_url(@project, @build)
}
end
end
Loading
Loading
@@ -8,7 +8,7 @@
module CiStatusHelper
def ci_status_path(pipeline)
project = pipeline.project
namespace_project_pipeline_path(project.namespace, project, pipeline)
project_pipeline_path(project, pipeline)
end
 
def ci_label_for_status(status)
Loading
Loading
@@ -99,10 +99,7 @@ module CiStatusHelper
 
def render_project_pipeline_status(pipeline_status, tooltip_placement: 'auto left')
project = pipeline_status.project
path = pipelines_namespace_project_commit_path(
project.namespace,
project,
pipeline_status.sha)
path = pipelines_project_commit_path(project, pipeline_status.sha)
 
render_status_with_link(
'commit',
Loading
Loading
@@ -113,10 +110,7 @@ module CiStatusHelper
 
def render_commit_status(commit, ref: nil, tooltip_placement: 'auto left')
project = commit.project
path = pipelines_namespace_project_commit_path(
project.namespace,
project,
commit)
path = pipelines_project_commit_path(project, commit)
 
render_status_with_link(
'commit',
Loading
Loading
@@ -127,7 +121,7 @@ module CiStatusHelper
 
def render_pipeline_status(pipeline, tooltip_placement: 'auto left')
project = pipeline.project
path = namespace_project_pipeline_path(project.namespace, project, pipeline)
path = project_pipeline_path(project, pipeline)
render_status_with_link('pipeline', pipeline.status, path, tooltip_placement: tooltip_placement)
end
 
Loading
Loading
Loading
Loading
@@ -30,7 +30,7 @@ module CommitsHelper
crumbs = content_tag(:li) do
link_to(
@project.path,
namespace_project_commits_path(@project.namespace, @project, @ref)
project_commits_path(@project, @ref)
)
end
 
Loading
Loading
@@ -42,8 +42,7 @@ module CommitsHelper
# The text is just the individual part, but the link needs all the parts before it
link_to(
part,
namespace_project_commits_path(
@project.namespace,
project_commits_path(
@project,
tree_join(@ref, parts[0..i].join('/'))
)
Loading
Loading
@@ -86,20 +85,20 @@ module CommitsHelper
if @path.blank?
return link_to(
_("Browse Files"),
namespace_project_tree_path(project.namespace, project, commit),
project_tree_path(project, commit),
class: "btn btn-default"
)
elsif @repo.blob_at(commit.id, @path)
return link_to(
_("Browse File"),
namespace_project_blob_path(project.namespace, project,
project_blob_path(project,
tree_join(commit.id, @path)),
class: "btn btn-default"
)
elsif @path.present?
return link_to(
_("Browse Directory"),
namespace_project_tree_path(project.namespace, project,
project_tree_path(project,
tree_join(commit.id, @path)),
class: "btn btn-default"
)
Loading
Loading
@@ -165,7 +164,7 @@ module CommitsHelper
notice: "#{edit_in_new_fork_notice} Try to #{action} this commit again.",
notice_now: edit_in_new_fork_notice_now
}
fork_path = namespace_project_forks_path(@project.namespace, @project,
fork_path = project_forks_path(@project,
namespace_key: current_user.namespace.id,
continue: continue_params)
 
Loading
Loading
@@ -175,7 +174,7 @@ module CommitsHelper
 
def view_file_button(commit_sha, diff_new_path, project)
link_to(
namespace_project_blob_path(project.namespace, project,
project_blob_path(project,
tree_join(commit_sha, diff_new_path)),
class: 'btn view-file js-view-file'
) do
Loading
Loading
Loading
Loading
@@ -9,8 +9,7 @@ module CompareHelper
end
 
def create_mr_path(from = params[:from], to = params[:to], project = @project)
namespace_project_new_merge_request_path(
project.namespace,
project_new_merge_request_path(
project,
merge_request: {
source_branch: to,
Loading
Loading
Loading
Loading
@@ -103,18 +103,18 @@ module DiffHelper
end
 
def diff_file_blob_raw_path(diff_file)
namespace_project_raw_path(@project.namespace, @project, tree_join(diff_file.content_sha, diff_file.file_path))
project_raw_path(@project, tree_join(diff_file.content_sha, diff_file.file_path))
end
 
def diff_file_old_blob_raw_path(diff_file)
sha = diff_file.old_content_sha
return unless sha
namespace_project_raw_path(@project.namespace, @project, tree_join(diff_file.old_content_sha, diff_file.old_path))
project_raw_path(@project, tree_join(diff_file.old_content_sha, diff_file.old_path))
end
 
def diff_file_html_data(project, diff_file_path, diff_commit_id)
{
blob_diff_path: namespace_project_blob_diff_path(project.namespace, project,
blob_diff_path: project_blob_diff_path(project,
tree_join(diff_commit_id, diff_file_path)),
view: diff_view
}
Loading
Loading
@@ -142,7 +142,7 @@ module DiffHelper
diff_file = viewer.diff_file
options = []
 
blob_url = namespace_project_blob_path(@project.namespace, @project, tree_join(diff_file.content_sha, diff_file.file_path))
blob_url = project_blob_path(@project, tree_join(diff_file.content_sha, diff_file.file_path))
options << link_to('view the blob', blob_url)
 
options
Loading
Loading
@@ -163,17 +163,17 @@ module DiffHelper
end
 
def commit_diff_whitespace_link(project, commit, options)
url = namespace_project_commit_path(project.namespace, project, commit.id, params_with_whitespace)
url = project_commit_path(project, commit.id, params_with_whitespace)
toggle_whitespace_link(url, options)
end
 
def diff_merge_request_whitespace_link(project, merge_request, options)
url = diffs_namespace_project_merge_request_path(project.namespace, project, merge_request, params_with_whitespace)
url = diffs_project_merge_request_path(project, merge_request, params_with_whitespace)
toggle_whitespace_link(url, options)
end
 
def diff_compare_whitespace_link(project, from, to, options)
url = namespace_project_compare_path(project.namespace, project, from, to, params_with_whitespace)
url = project_compare_path(project, from, to, params_with_whitespace)
toggle_whitespace_link(url, options)
end
 
Loading
Loading
Loading
Loading
@@ -8,7 +8,7 @@ module EnvironmentHelper
def environment_link_for_build(project, build)
environment = environment_for_build(project, build)
if environment
link_to environment.name, namespace_project_environment_path(project.namespace, project, environment)
link_to environment.name, project_environment_path(project, environment)
else
content_tag :span, build.expanded_environment_name
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment