Commit 462b1ed9 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'dm-project-path-helpers-try-2' into 'master'

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

See merge request !12566
parents c4e3cd9d 873b4055
......@@ -40,14 +40,14 @@ class Admin::ProjectsController < Admin::ApplicationController
::Projects::TransferService.new(@project, current_user, params.dup).execute(namespace)
@project.reload
redirect_to admin_namespace_project_path(@project.namespace, @project)
redirect_to admin_project_path(@project)
end
def repository_check
RepositoryCheck::SingleRepositoryWorker.perform_async(@project.id)
redirect_to(
admin_namespace_project_path(@project.namespace, @project),
admin_project_path(@project),
notice: 'Repository check was triggered.'
)
end
......
......@@ -78,8 +78,7 @@ module CreatesCommit
end
def new_merge_request_path
namespace_project_new_merge_request_path(
@project_to_commit_into.namespace,
project_new_merge_request_path(
@project_to_commit_into,
merge_request: {
source_project_id: @project_to_commit_into.id,
......@@ -91,7 +90,7 @@ module CreatesCommit
end
def existing_merge_request_path
namespace_project_merge_request_path(@project.namespace, @project, @merge_request)
project_merge_request_path(@project, @merge_request)
end
def merge_request_exists?
......
......@@ -45,7 +45,7 @@ module MilestoneActions
def milestone_redirect_path
if @project
namespace_project_milestone_path(@project.namespace, @project, @milestone)
project_milestone_path(@project, @milestone)
elsif @group
group_milestone_path(@group, @milestone.safe_title, title: @milestone.title)
else
......
......@@ -2,6 +2,6 @@ module RepositorySettingsRedirect
extend ActiveSupport::Concern
def redirect_to_repository_settings(project)
redirect_to namespace_project_settings_repository_path(project.namespace, project)
redirect_to project_settings_repository_path(project)
end
end
......@@ -9,9 +9,9 @@ module SpammableActions
def mark_as_spam
if SpamService.new(spammable).mark_as_spam!
redirect_to spammable, notice: "#{spammable.spammable_entity_type.titlecase} was submitted to Akismet successfully."
redirect_to spammable_path, notice: "#{spammable.spammable_entity_type.titlecase} was submitted to Akismet successfully."
else
redirect_to spammable, alert: 'Error with Akismet. Please check the logs for more info.'
redirect_to spammable_path, alert: 'Error with Akismet. Please check the logs for more info.'
end
end
......@@ -25,7 +25,7 @@ module SpammableActions
def recaptcha_check_with_fallback(&fallback)
if spammable.valid?
redirect_to spammable
redirect_to spammable_path
elsif render_recaptcha?
ensure_spam_config_loaded!
......@@ -56,6 +56,10 @@ module SpammableActions
raise NotImplementedError, "#{self.class} does not implement #{__method__}"
end
def spammable_path
raise NotImplementedError, "#{self.class} does not implement #{__method__}"
end
def authorize_submit_spammable!
access_denied! unless current_user.admin?
end
......
......@@ -63,7 +63,7 @@ class InvitesController < ApplicationController
when Project
project = member.source
label = "project #{project.name_with_namespace}"
path = namespace_project_path(project.namespace, project)
path = project_path(project)
when Group
group = member.source
label = "group #{group.name}"
......
......@@ -76,13 +76,13 @@ class Projects::ApplicationController < ApplicationController
def require_non_empty_project
# Be sure to return status code 303 to avoid a double DELETE:
# http://api.rubyonrails.org/classes/ActionController/Redirecting.html
redirect_to namespace_project_path(@project.namespace, @project), status: 303 if @project.empty_repo?
redirect_to project_path(@project), status: 303 if @project.empty_repo?
end
def require_branch_head
unless @repository.branch_exists?(@ref)
redirect_to(
namespace_project_tree_path(@project.namespace, @project, @ref),
project_tree_path(@project, @ref),
notice: "This action is not allowed unless you are on a branch"
)
end
......
......@@ -46,7 +46,7 @@ class Projects::ArtifactsController < Projects::ApplicationController
def keep
build.keep_artifacts!
redirect_to namespace_project_job_path(project.namespace, project, build)
redirect_to project_job_path(project, build)
end
def latest_succeeded
......
......@@ -27,9 +27,9 @@ class Projects::BlobController < Projects::ApplicationController
def create
create_commit(Files::CreateService, success_notice: "The file has been successfully created.",
success_path: -> { namespace_project_blob_path(@project.namespace, @project, File.join(@branch_name, @file_path)) },
success_path: -> { project_blob_path(@project, File.join(@branch_name, @file_path)) },
failure_view: :new,
failure_path: namespace_project_new_blob_path(@project.namespace, @project, @ref))
failure_path: project_new_blob_path(@project, @ref))
end
def show
......@@ -63,7 +63,7 @@ class Projects::BlobController < Projects::ApplicationController
@path = params[:file_path] if params[:file_path].present?
create_commit(Files::UpdateService, success_path: -> { after_edit_path },
failure_view: :edit,
failure_path: namespace_project_blob_path(@project.namespace, @project, @id))
failure_path: project_blob_path(@project, @id))
rescue Files::UpdateService::FileChangedError
@conflict = true
......@@ -83,9 +83,9 @@ class Projects::BlobController < Projects::ApplicationController
def destroy
create_commit(Files::DeleteService, success_notice: "The file has been successfully deleted.",
success_path: -> { namespace_project_tree_path(@project.namespace, @project, @branch_name) },
success_path: -> { project_tree_path(@project, @branch_name) },
failure_view: :show,
failure_path: namespace_project_blob_path(@project.namespace, @project, @id))
failure_path: project_blob_path(@project, @id))
end
def diff
......@@ -118,7 +118,7 @@ class Projects::BlobController < Projects::ApplicationController
else
if tree = @repository.tree(@commit.id, @path)
if tree.entries.any?
return redirect_to namespace_project_tree_path(@project.namespace, @project, File.join(@ref, @path))
return redirect_to project_tree_path(@project, File.join(@ref, @path))
end
end
......@@ -143,10 +143,10 @@ class Projects::BlobController < Projects::ApplicationController
def after_edit_path
from_merge_request = MergeRequestsFinder.new(current_user, project_id: @project.id).execute.find_by(iid: params[:from_merge_request_iid])
if from_merge_request && @branch_name == @ref
diffs_namespace_project_merge_request_path(from_merge_request.target_project.namespace, from_merge_request.target_project, from_merge_request) +
diffs_project_merge_request_path(from_merge_request.target_project, from_merge_request) +
"##{hexdigest(@path)}"
else
namespace_project_blob_path(@project.namespace, @project, File.join(@branch_name, @path))
project_blob_path(@project, File.join(@branch_name, @path))
end
end
......
......@@ -52,7 +52,7 @@ class Projects::BranchesController < Projects::ApplicationController
redirect_to url_to_autodeploy_setup(project, branch_name),
notice: view_context.autodeploy_flash_notice(branch_name)
else
redirect_to namespace_project_tree_path(@project.namespace, @project, branch_name)
redirect_to project_tree_path(@project, branch_name)
end
else
@error = result[:message]
......@@ -62,7 +62,7 @@ class Projects::BranchesController < Projects::ApplicationController
format.json do
if result[:status] == :success
render json: { name: branch_name, url: namespace_project_tree_url(@project.namespace, @project, branch_name) }
render json: { name: branch_name, url: project_tree_url(@project, branch_name) }
else
render json: result[:messsage], status: :unprocessable_entity
end
......@@ -79,7 +79,7 @@ class Projects::BranchesController < Projects::ApplicationController
flash_type = result[:status] == :error ? :alert : :notice
flash[flash_type] = result[:message]
redirect_to namespace_project_branches_path(@project.namespace, @project), status: 303
redirect_to project_branches_path(@project), status: 303
end
format.js { render nothing: true, status: result[:return_code] }
......@@ -90,7 +90,7 @@ class Projects::BranchesController < Projects::ApplicationController
def destroy_all_merged
DeleteMergedBranchesService.new(@project, current_user).async_execute
redirect_to namespace_project_branches_path(@project.namespace, @project),
redirect_to project_branches_path(@project),
notice: 'Merged branches are being deleted. This can take some time depending on the number of branches. Please refresh the page to see changes.'
end
......@@ -106,8 +106,7 @@ class Projects::BranchesController < Projects::ApplicationController
end
def url_to_autodeploy_setup(project, branch_name)
namespace_project_new_blob_path(
project.namespace,
project_new_blob_path(
project,
branch_name,
file_name: '.gitlab-ci.yml',
......
......@@ -7,23 +7,23 @@ class Projects::BuildArtifactsController < Projects::ApplicationController
before_action :validate_artifacts!
def download
redirect_to download_namespace_project_job_artifacts_path(project.namespace, project, job)
redirect_to download_project_job_artifacts_path(project, job)
end
def browse
redirect_to browse_namespace_project_job_artifacts_path(project.namespace, project, job, path: params[:path])
redirect_to browse_project_job_artifacts_path(project, job, path: params[:path])
end
def file
redirect_to file_namespace_project_job_artifacts_path(project.namespace, project, job, path: params[:path])
redirect_to file_project_job_artifacts_path(project, job, path: params[:path])
end
def raw
redirect_to raw_namespace_project_job_artifacts_path(project.namespace, project, job, path: params[:path])
redirect_to raw_project_job_artifacts_path(project, job, path: params[:path])
end
def latest_succeeded
redirect_to latest_succeeded_namespace_project_artifacts_path(project.namespace, project, job, ref_name_and_path: params[:ref_name_and_path], job: params[:job])
redirect_to latest_succeeded_project_artifacts_path(project, job, ref_name_and_path: params[:ref_name_and_path], job: params[:job])
end
private
......
......@@ -2,15 +2,15 @@ class Projects::BuildsController < Projects::ApplicationController
before_action :authorize_read_build!
def index
redirect_to namespace_project_jobs_path(project.namespace, project)
redirect_to project_jobs_path(project)
end
def show
redirect_to namespace_project_job_path(project.namespace, project, job)
redirect_to project_job_path(project, job)
end
def raw
redirect_to raw_namespace_project_job_path(project.namespace, project, job)
redirect_to raw_project_job_path(project, job)
end
private
......
......@@ -80,16 +80,16 @@ class Projects::CommitController < Projects::ApplicationController
end
def successful_change_path
referenced_merge_request_url || namespace_project_commits_url(@project.namespace, @project, @branch_name)
referenced_merge_request_url || project_commits_url(@project, @branch_name)
end
def failed_change_path
referenced_merge_request_url || namespace_project_commit_url(@project.namespace, @project, params[:id])
referenced_merge_request_url || project_commit_url(@project, params[:id])
end
def referenced_merge_request_url
if merge_request = @commit.merged_merge_request(current_user)
namespace_project_merge_request_url(merge_request.target_project.namespace, merge_request.target_project, merge_request)
project_merge_request_url(merge_request.target_project, merge_request)
end
end
......
......@@ -31,9 +31,9 @@ class Projects::CompareController < Projects::ApplicationController
from: params[:from].presence,
to: params[:to].presence
}
redirect_to namespace_project_compare_index_path(@project.namespace, @project, from_to_vars)
redirect_to project_compare_index_path(@project, from_to_vars)
else
redirect_to namespace_project_compare_path(@project.namespace, @project,
redirect_to project_compare_path(@project,
params[:from], params[:to])
end
end
......
......@@ -63,7 +63,7 @@ class Projects::EnvironmentsController < Projects::ApplicationController
@environment = project.environments.create(environment_params)
if @environment.persisted?
redirect_to namespace_project_environment_path(project.namespace, project, @environment)
redirect_to project_environment_path(project, @environment)
else
render :new
end
......@@ -71,7 +71,7 @@ class Projects::EnvironmentsController < Projects::ApplicationController
def update
if @environment.update(environment_params)
redirect_to namespace_project_environment_path(project.namespace, project, @environment)
redirect_to project_environment_path(project, @environment)
else
render :edit
end
......@@ -86,7 +86,7 @@ class Projects::EnvironmentsController < Projects::ApplicationController
if stop_action
polymorphic_url([project.namespace.becomes(Namespace), project, stop_action])
else
namespace_project_environment_url(project.namespace, project, @environment)
project_environment_url(project, @environment)
end
respond_to do |format|
......
......@@ -44,12 +44,12 @@ class Projects::ForksController < Projects::ApplicationController
if @forked_project.saved? && @forked_project.forked?
if @forked_project.import_in_progress?
redirect_to namespace_project_import_path(@forked_project.namespace, @forked_project, continue: continue_params)
redirect_to project_import_path(@forked_project, continue: continue_params)
else
if continue_params
redirect_to continue_params[:to], notice: continue_params[:notice]
else
redirect_to namespace_project_path(@forked_project.namespace, @forked_project), notice: "The project '#{@forked_project.name}' was successfully forked."
redirect_to project_path(@forked_project), notice: "The project '#{@forked_project.name}' was successfully forked."
end
end
else
......
......@@ -29,7 +29,7 @@ class Projects::GraphsController < Projects::ApplicationController
end
def ci
redirect_to charts_namespace_project_pipelines_path(@project.namespace, @project)
redirect_to charts_project_pipelines_path(@project)
end
private
......
......@@ -22,7 +22,7 @@ class Projects::GroupLinksController < Projects::ApplicationController
flash[:alert] = 'Please select a group.'
end
redirect_to namespace_project_settings_members_path(project.namespace, project)
redirect_to project_settings_members_path(project)
end
def update
......@@ -36,7 +36,7 @@ class Projects::GroupLinksController < Projects::ApplicationController
respond_to do |format|
format.html do
redirect_to namespace_project_settings_members_path(project.namespace, project), status: 302
redirect_to project_settings_members_path(project), status: 302
end
format.js { head :ok }
end
......
......@@ -18,7 +18,7 @@ class Projects::HookLogsController < Projects::ApplicationController
set_hook_execution_notice(status, message)
redirect_to edit_namespace_project_hook_path(@project.namespace, @project, @hook)
redirect_to edit_project_hook_path(@project, @hook)
end
private
......
......@@ -17,7 +17,7 @@ class Projects::HooksController < Projects::ApplicationController
@hooks = @project.hooks.select(&:persisted?)
flash[:alert] = @hook.errors.full_messages.join.html_safe
end
redirect_to namespace_project_settings_integrations_path(@project.namespace, @project)
redirect_to project_settings_integrations_path(@project)
end
def edit
......@@ -26,7 +26,7 @@ class Projects::HooksController < Projects::ApplicationController
def update
if hook.update_attributes(hook_params)
flash[:notice] = 'Hook was successfully updated.'
redirect_to namespace_project_settings_integrations_path(@project.namespace, @project)
redirect_to project_settings_integrations_path(@project)
else
render 'edit'
end
......@@ -47,7 +47,7 @@ class Projects::HooksController < Projects::ApplicationController
def destroy
hook.destroy
redirect_to namespace_project_settings_integrations_path(@project.namespace, @project), status: 302
redirect_to project_settings_integrations_path(@project), status: 302
end
private
......
......@@ -17,7 +17,7 @@ class Projects::ImportsController < Projects::ApplicationController
@project.reload.import_schedule
end
redirect_to namespace_project_import_path(@project.namespace, @project)
redirect_to project_import_path(@project)
end
def show
......@@ -25,10 +25,10 @@ class Projects::ImportsController < Projects::ApplicationController
if continue_params
redirect_to continue_params[:to], notice: continue_params[:notice]
else
redirect_to namespace_project_path(@project.namespace, @project), notice: finished_notice
redirect_to project_path(@project), notice: finished_notice
end
elsif @project.import_failed?
redirect_to new_namespace_project_import_path(@project.namespace, @project)
redirect_to new_project_import_path(@project)
else
if continue_params && continue_params[:notice_now]
flash.now[:notice] = continue_params[:notice_now]
......@@ -50,19 +50,19 @@ class Projects::ImportsController < Projects::ApplicationController
def require_no_repo
if @project.repository_exists?
redirect_to namespace_project_path(@project.namespace, @project)
redirect_to project_path(@project)
end
end
def redirect_if_progress
if @project.import_in_progress?
redirect_to namespace_project_import_path(@project.namespace, @project)
redirect_to project_import_path(@project)
end
end
def redirect_if_no_import
if @project.repository_exists? && @project.no_import?
redirect_to namespace_project_path(@project.namespace, @project)
redirect_to project_path(@project)
end
end
end
......@@ -238,6 +238,10 @@ class Projects::IssuesController < Projects::ApplicationController
alias_method :awardable, :issue
alias_method :spammable, :issue
def spammable_path
project_issue_path(@project, @issue)
end
def authorize_update_issue!
return render_404 unless can?(current_user, :update_issue, @issue)
end
......
......@@ -38,7 +38,7 @@ class Projects::JobsController < Projects::ApplicationController
build.cancel if can?(current_user, :update_build, build)
end
redirect_to namespace_project_jobs_path(project.namespace, project)
redirect_to project_jobs_path(project)
end
def show
......@@ -108,7 +108,7 @@ class Projects::JobsController < Projects::ApplicationController
def erase
if @build.erase(erased_by: current_user)
redirect_to namespace_project_job_path(project.namespace, project, @build),
redirect_to project_job_path(project, @build),
notice: "Build has been successfully erased!"
else
respond_422
......@@ -137,6 +137,6 @@ class Projects::JobsController < Projects::ApplicationController
end
def build_path(build)
namespace_project_job_path(build.project.namespace, build.project, build)
project_job_path(build.project, build)
end
end
......@@ -33,7 +33,7 @@ class Projects::LabelsController < Projects::ApplicationController
if @label.valid?
respond_to do |format|
format.html { redirect_to namespace_project_labels_path(@project.namespace, @project) }
format.html { redirect_to project_labels_path(@project) }
format.json { render json: @label }
end
else
......@@ -51,7 +51,7 @@ class Projects::LabelsController < Projects::ApplicationController
@label = Labels::UpdateService.new(label_params).execute(@label)
if @label.valid?
redirect_to namespace_project_labels_path(@project.namespace, @project)
redirect_to project_labels_path(@project)
else
render :edit
end
......@@ -61,12 +61,11 @@ class Projects::LabelsController < Projects::ApplicationController
Gitlab::IssuesLabels.generate(@project)
if params[:redirect] == 'issues'
redirect_to namespace_project_issues_path(@project.namespace, @project)
redirect_to project_issues_path(@project)
elsif params[:redirect] == 'merge_requests'
redirect_to namespace_project_merge_requests_path(@project.namespace,
@project)
redirect_to project_merge_requests_path(@project)
else
redirect_to namespace_project_labels_path(@project.namespace, @project)
redirect_to project_labels_path(@project)
end
end
......@@ -74,7 +73,7 @@ class Projects::LabelsController < Projects::ApplicationController
@label.destroy
@labels = find_labels
redirect_to namespace_project_labels_path(@project.namespace, @project),
redirect_to project_labels_path(@project),
status: 302,
notice: 'Label was removed'
end
......@@ -114,7 +113,7 @@ class Projects::LabelsController < Projects::ApplicationController
return render_404 unless promote_service.execute(@label)
respond_to do |format|
format.html do
redirect_to(namespace_project_labels_path(@project.namespace, @project),
redirect_to(project_labels_path(@project),
notice: 'Label was promoted to a Group Label')
end
format.js
......@@ -125,7 +124,7 @@ class Projects::LabelsController < Projects::ApplicationController
respond_to do |format|
format.html do
redirect_to(namespace_project_labels_path(@project.namespace, @project),
redirect_to(project_labels_path(@project),
notice: 'Failed to promote label due to internal error. Please contact administrators.')
end
format.js
......
......@@ -16,12 +16,10 @@ class Projects::MattermostsController < Projects::ApplicationController
if result
flash[:notice] = 'This service is now configured'
redirect_to edit_namespace_project_service_path(
@project.namespace, @project, service)
redirect_to edit_project_service_path(@project, service)
else
flash[:alert] = message || 'Failed to configure service'
redirect_to new_namespace_project_mattermost_path(
@project.namespace, @project)
redirect_to new_project_mattermost_path(@project)
end
end
......
......@@ -52,7 +52,7 @@ class Projects::MergeRequests::ConflictsController < Projects::MergeRequests::Ap
flash[:notice] = 'All merge conflicts were resolved. The merge request can now be merged.'
render json: { redirect_to: namespace_project_merge_request_url(@project.namespace, @project, @merge_request, resolved_conflicts: true) }
render json: { redirect_to: project_merge_request_url(@project, @merge_request, resolved_conflicts: true) }
rescue Gitlab::Conflict::ResolutionError => e
render status: :bad_request, json: { message: e.message }
end
......
......@@ -211,21 +211,18 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
stop_url =
if environment.stop_action? && can?(current_user, :create_deployment, environment)
stop_namespace_project_environment_path(project.namespace, project, environment)
stop_project_environment_path(project, environment)
end
metrics_url =
if can?(current_user, :read_environment, environment) && environment.has_metrics?
metrics_namespace_project_environment_deployment_path(environment.project.namespace,
environment.project,
environment,
deployment)
metrics_project_environment_deployment_path(environment.project, environment, deployment)
end
{
id: environment.id,
name: environment.name,
url: namespace_project_environment_path(project.namespace, project, environment),
url: project_environment_path(project, environment),
metrics_url: metrics_url,
stop_url: stop_url,
external_url: environment.external_url,
......
......@@ -51,8 +51,7 @@ class Projects::MilestonesController < Projects::ApplicationController
@milestone = Milestones::CreateService.new(project, current_user, milestone_params).execute
if @milestone.save
redirect_to namespace_project_milestone_path(@project.namespace,
@project, @milestone)
redirect_to project_milestone_path(@project, @milestone)
else
render "new"
end
......@@ -65,8 +64,7 @@ class Projects::MilestonesController < Projects::ApplicationController
format.js
format.html do
if @milestone.valid?
redirect_to namespace_project_milestone_path(@project.namespace,
@project, @milestone)
redirect_to project_milestone_path(@project, @milestone)
else
render :edit
end
......
......@@ -8,8 +8,8 @@ class Projects::NetworkController < Projects::ApplicationController
before_action :assign_commit
def show
@url = namespace_project_network_path(@project.namespace, @project, @ref, @options.merge(format: :json))
@commit_url = namespace_project_commit_path(@project.namespace, @project, 'ae45ca32').gsub("ae45ca32", "%s")
@url = project_network_path(@project, @ref, @options.merge(format: :json))
@commit_url = project_commit_path(@project, 'ae45ca32').gsub("ae45ca32", "%s")
respond_to do |format|
format.html do
......
......@@ -15,7 +15,7 @@ class Projects::PagesController < Projects::ApplicationController
respond_to do |format|
format.html do
redirect_to namespace_project_pages_path(@project.namespace, @project),
redirect_to project_pages_path(@project),
status: 302,
notice: 'Pages were removed'
end
......
......@@ -16,7 +16,7 @@ class Projects::PagesDomainsController < Projects::ApplicationController
@domain = @project.pages_domains.create(pages_domain_params)
if @domain.valid?
redirect_to namespace_project_pages_path(@project.namespace, @project)
redirect_to project_pages_path(@project)
else
render 'new'
end
......@@ -27,7 +27,7 @@ class Projects::PagesDomainsController < Projects::ApplicationController
respond_to do |format|
format.html do
redirect_to namespace_project_pages_path(@project.namespace, @project),
redirect_to project_pages_path(@project),
status: 302,
notice: 'Domain was removed'
end
......
......@@ -34,7 +34,7 @@ class Projects::PipelineSchedulesController < Projects::ApplicationController
def update
if schedule.update(schedule_params)
redirect_to namespace_project_pipeline_schedules_path(@project.namespace.becomes(Namespace), @project)
redirect_to project_pipeline_schedules_path(@project)
else
render :edit
end
......
......@@ -60,7 +60,7 @@ class Projects::PipelinesController < Projects::ApplicationController
.execute(:web, ignore_skip_ci: true, save_on_errors: false)
if @pipeline.persisted?
redirect_to namespace_project_pipeline_path(project.namespace, project, @pipeline)
redirect_to project_pipeline_path(project, @pipeline)
else
render 'new'
end
......@@ -111,7 +111,7 @@ class Projects::PipelinesController < Projects::ApplicationController
respond_to do |format|
format.html do
redirect_back_or_default default: namespace_project_pipelines_path(project.namespace, project)
redirect_back_or_default default: project_pipelines_path(project)
end
format.json { head :no_content }
......@@ -123,7 +123,7 @@ class Projects::PipelinesController < Projects::ApplicationController
respond_to do |format|
format.html do
redirect_back_or_default default: namespace_project_pipelines_path(project.namespace, project)
redirect_back_or_default default: project_pipelines_path(project)
end
format.json { head :no_content }
......
......@@ -2,13 +2,13 @@ class Projects::PipelinesSettingsController < Projects::ApplicationController
before_action :authorize_admin_pipeline!
def show
redirect_to namespace_project_settings_ci_cd_path(@project.namespace, @project, params: params)
redirect_to project_settings_ci_cd_path(@project, params: params)
end
def update
if @project.update_attributes(update_params)
flash[:notice] = "Pipelines settings for '#{@project.name}' 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
......
......@@ -7,7 +7,7 @@ class Projects::ProjectMembersController < Projects::ApplicationController
def index
sort = params[:sort].presence || sort_value_name
redirect_to namespace_project_settings_members_path(@project.namespace, @project, sort: sort)
redirect_to project_settings_members_path(@project, sort: sort)
end
def update
......@@ -19,7 +19,7 @@ class Projects::ProjectMembersController < Projects::ApplicationController
end
def resend_invite
redirect_path = namespace_project_settings_members_path(@project.namespace, @project)
redirect_path = project_settings_members_path(@project)
@project_member = @project.project_members.find(params[:id])
......@@ -42,7 +42,7 @@ class Projects::ProjectMembersController < Projects::ApplicationController
return render_404
end
redirect_to(namespace_project_settings_members_path(project.namespace, project),
redirect_to(project_settings_members_path(project),
notice: notice)
end
......
......@@ -13,21 +13,21 @@ class Projects::RefsController < Projects::ApplicationController
new_path =
case params[:destination]
when "tree"
namespace_project_tree_path(@project.namespace, @project, @id)
project_tree_path(@project, @id)
when "blob"
namespace_project_blob_path(@project.namespace, @project, @id)
project_blob_path(@project, @id)
when "graph"
namespace_project_network_path(@project.namespace, @project, @id, @options)
project_network_path(@project, @id, @options)
when "graphs"
namespace_project_graph_path(@project.namespace, @project, @id)
project_graph_path(@project, @id)
when "find_file"
namespace_project_find_file_path(@project.namespace, @project, @id)
project_find_file_path(@project, @id)
when "graphs_commits"
commits_namespace_project_graph_path(@project.namespace, @project, @id)
commits_project_graph_path(@project, @id)
when "badges"
namespace_project_pipelines_settings_path(@project.namespace, @project, ref: @id)
project_pipelines_settings_path(@project, ref: @id)
else
namespace_project_commits_path(@project.namespace, @project, @id)
project_commits_path(@project, @id)
end
redirect_to new_path
......@@ -62,7 +62,7 @@ class Projects::RefsController < Projects::ApplicationController
offset = (@offset + @limit)
if contents.size > offset
@more_log_url = logs_file_namespace_project_ref_path(@project.namespace, @project, @ref, @path || '', offset: offset)
@more_log_url = logs_file_project_ref_path(@project, @ref, @path || '', offset: offset)
end
respond_to do |format|
......
......@@ -10,11 +10,11 @@ module Projects
def destroy
if image.destroy
redirect_to project_container_registry_path(@project),
redirect_to project_container_registry_index_path(@project),
status: 302,
notice: 'Image repository has been removed successfully!'
else
redirect_to project_container_registry_path(@project),
redirect_to project_container_registry_index_path(@project),
status: 302,
alert: 'Failed to remove image repository!'
end
......
......@@ -5,11 +5,11 @@ module Projects
def destroy
if tag.delete
redirect_to project_container_registry_path(@project),
redirect_to project_container_registry_index_path(@project),
status: 302,
notice: 'Registry tag has been removed successfully!'
else
redirect_to project_container_registry_path(@project),
redirect_to project_container_registry_index_path(@project),
status: 302,
alert: 'Failed to remove registry tag!'
end
......
......@@ -19,7 +19,7 @@ class Projects::ReleasesController < Projects::ApplicationController
release.destroy
end
redirect_to namespace_project_tag_path(@project.namespace, @project, @tag.name)
redirect_to project_tag_path(@project, @tag.name)
end
private
......
......@@ -5,7 +5,7 @@ class Projects::RunnersController < 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 edit
......@@ -49,7 +49,7 @@ class Projects::RunnersController < Projects::ApplicationController
def toggle_shared_runners
project.toggle!(:shared_runners_enabled)
redirect_to namespace_project_settings_ci_cd_path(@project.namespace, @project)
redirect_to project_settings_ci_cd_path(@project)
end
protected
......
......@@ -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
......
......@@ -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
......@@ -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
......@@ -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
......
......@@ -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]
......@@ -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
......@@ -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
......
......@@ -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?
......@@ -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
......
......@@ -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
......@@ -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
......@@ -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
......@@ -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
......@@ -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
......
......@@ -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
......@@ -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
......@@ -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
......@@ -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
......
......@@ -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
......@@ -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
......@@ -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
......@@ -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
......
......@@ -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
......
......@@ -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
......@@ -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)
......
......@@ -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])
......
......@@ -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
......@@ -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",
......@@ -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",
......@@ -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
......@@ -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
......
......@@ -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
......
......@@ -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)
......
......@@ -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: ''
......@@ -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
......@@ -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)
......@@ -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',
......@@ -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',
......@@ -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
......
......@@ -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
......@@ -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('/'))
)
......@@ -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"
)
......@@ -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)
......@@ -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
......
......@@ -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,
......
......@@ -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
}
......@@ -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
......@@ -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
......
......@@ -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
......
module EnvironmentsHelper
def environments_list_data
{
endpoint: namespace_project_environments_path(@project.namespace, @project, format: :json)
endpoint: project_environments_path(@project, format: :json)
}
end
end
......@@ -99,13 +99,12 @@ module EventsHelper
def event_feed_url(event)
if event.issue?
namespace_project_issue_url(event.project.namespace, event.project,
project_issue_url(event.project,
event.issue)
elsif event.merge_request?
namespace_project_merge_request_url(event.project.namespace,
event.project, event.merge_request)
project_merge_request_url(event.project, event.merge_request)
elsif event.commit_note?
namespace_project_commit_url(event.project.namespace, event.project,
project_commit_url(event.project,
event.note_target)
elsif event.note?
if event.note_target
......@@ -119,15 +118,15 @@ module EventsHelper
def push_event_feed_url(event)
if event.push_with_commits? && event.md_ref?
if event.commits_count > 1
namespace_project_compare_url(event.project.namespace, event.project,
project_compare_url(event.project,
from: event.commit_from, to:
event.commit_to)
else
namespace_project_commit_url(event.project.namespace, event.project,
project_commit_url(event.project,
id: event.commit_to)
end
else
namespace_project_commits_url(event.project.namespace, event.project,
project_commits_url(event.project,
event.ref_name)
end
end
......@@ -146,15 +145,9 @@ module EventsHelper
def event_note_target_path(event)
if event.commit_note?
namespace_project_commit_path(event.project.namespace,
event.project,
event.note_target,
anchor: dom_id(event.target))
project_commit_path(event.project, event.note_target, anchor: dom_id(event.target))
elsif event.project_snippet_note?
namespace_project_snippet_path(event.project.namespace,
event.project,
event.note_target,
anchor: dom_id(event.target))
project_snippet_path(event.project, event.note_target, anchor: dom_id(event.target))
else
polymorphic_path([event.project.namespace.becomes(Namespace),
event.project, event.note_target],
......
......@@ -4,7 +4,7 @@ module ExternalWikiHelper
if external_wiki_service
external_wiki_service.properties['external_wiki_url']
else
namespace_project_wiki_path(project.namespace, project, :home)
project_wiki_path(project, :home)
end
end
end
This diff is collapsed.
......@@ -26,9 +26,9 @@ module IssuablesHelper
project = issuable.project
if issuable.is_a?(MergeRequest)
namespace_project_merge_request_path(project.namespace, project, issuable.iid, :json)
project_merge_request_path(project, issuable.iid, :json)
else
namespace_project_issue_path(project.namespace, project, issuable.iid, :json)
project_issue_path(project, issuable.iid, :json)
end
end
......@@ -197,7 +197,7 @@ module IssuablesHelper
def issuable_initial_data(issuable)
data = {
endpoint: namespace_project_issue_path(@project.namespace, @project, issuable),
endpoint: project_issue_path(@project, issuable),
canUpdate: can?(current_user, :update_issue, issuable),
canDestroy: can?(current_user, :destroy_issue, issuable),
canMove: current_user ? issuable.can_move?(current_user) : false,
......@@ -295,7 +295,7 @@ module IssuablesHelper
mark_icon: (is_collapsed ? icon('check-square', class: 'todo-undone') : nil),
issuable_id: issuable.id,
issuable_type: issuable.class.name.underscore,
url: namespace_project_todos_path(@project.namespace, @project),
url: project_todos_path(@project),
delete_path: (dashboard_todo_path(todo) if todo),
placement: (is_collapsed ? 'left' : nil),
container: (is_collapsed ? 'body' : nil)
......
......@@ -150,7 +150,7 @@ module IssuesHelper
Gitlab::UrlBuilder.build(single_discussion.first_note)
else
project = merge_request.project
namespace_project_merge_request_path(project.namespace, project, merge_request)
project_merge_request_path(project, merge_request)
end
link_to link_text, path
......
......@@ -57,14 +57,14 @@ module LabelsHelper
def edit_label_path(label)
case label
when GroupLabel then edit_group_label_path(label.group, label)
when ProjectLabel then edit_namespace_project_label_path(label.project.namespace, label.project, label)
when ProjectLabel then edit_project_label_path(label.project, label)
end
end
def destroy_label_path(label)
case label
when GroupLabel then group_label_path(label.group, label)
when ProjectLabel then namespace_project_label_path(label.project.namespace, label.project, label)
when ProjectLabel then project_label_path(label.project, label)
end
end
......@@ -127,7 +127,7 @@ module LabelsHelper
project = @target_project || @project
if project
namespace_project_labels_path(project.namespace, project, :json)
project_labels_path(project, :json)
else
dashboard_labels_path(:json)
end
......@@ -149,8 +149,8 @@ module LabelsHelper
case label_subscription_status(label, project)
when 'group-level' then toggle_subscription_group_label_path(label.group, label)
when 'project-level' then toggle_subscription_namespace_project_label_path(project.namespace, project, label)
when 'unsubscribed' then toggle_subscription_namespace_project_label_path(project.namespace, project, label)
when 'project-level' then toggle_subscription_project_label_path(project, label)
when 'unsubscribed' then toggle_subscription_project_label_path(project, label)
end
end
......
module MergeRequestsHelper
def new_mr_path_from_push_event(event)
target_project = event.project.default_merge_request_target
namespace_project_new_merge_request_path(
event.project.namespace,
project_new_merge_request_path(
event.project,
new_mr_from_push_event(event, target_project)
)
......@@ -48,8 +47,8 @@ module MergeRequestsHelper
end
def mr_change_branches_path(merge_request)
namespace_project_new_merge_request_path(
@project.namespace, @project,
project_new_merge_request_path(
@project,
merge_request: {
source_project_id: merge_request.source_project_id,
target_project_id: merge_request.target_project_id,
......@@ -82,9 +81,7 @@ module MergeRequestsHelper
end
def merge_request_version_path(project, merge_request, merge_request_diff, start_sha = nil)
diffs_namespace_project_merge_request_path(
project.namespace, project, merge_request,
diff_id: merge_request_diff.id, start_sha: start_sha)
diffs_project_merge_request_path(project, merge_request, diff_id: merge_request_diff.id, start_sha: start_sha)
end
def version_index(merge_request_diff)
......
module MilestonesHelper
def milestones_filter_path(opts = {})
if @project
namespace_project_milestones_path(@project.namespace, @project, opts)
project_milestones_path(@project, opts)
elsif @group
group_milestones_path(@group, opts)
else
......@@ -11,7 +11,7 @@ module MilestonesHelper
def milestones_label_path(opts = {})
if @project
namespace_project_issues_path(@project.namespace, @project, opts)
project_issues_path(@project, opts)
elsif @group
issues_group_path(@group, opts)
else
......@@ -73,7 +73,7 @@ module MilestonesHelper
def milestones_filter_dropdown_path
project = @target_project || @project
if project
namespace_project_milestones_path(project.namespace, project, :json)
project_milestones_path(project, :json)
elsif @group
group_milestones_path(@group, :json)
else
......@@ -120,7 +120,7 @@ module MilestonesHelper
def milestone_merge_request_tab_path(milestone)
if @project
merge_requests_namespace_project_milestone_path(@project.namespace, @project, milestone, format: :json)
merge_requests_project_milestone_path(@project, milestone, format: :json)
elsif @group
merge_requests_group_milestone_path(@group, milestone.safe_title, title: milestone.title, format: :json)
else
......@@ -130,7 +130,7 @@ module MilestonesHelper
def milestone_participants_tab_path(milestone)
if @project
participants_namespace_project_milestone_path(@project.namespace, @project, milestone, format: :json)
participants_project_milestone_path(@project, milestone, format: :json)
elsif @group
participants_group_milestone_path(@group, milestone.safe_title, title: milestone.title, format: :json)
else
......@@ -140,7 +140,7 @@ module MilestonesHelper
def milestone_labels_tab_path(milestone)
if @project
labels_namespace_project_milestone_path(@project.namespace, @project, milestone, format: :json)
labels_project_milestone_path(@project, milestone, format: :json)
elsif @group
labels_group_milestone_path(@group, milestone.safe_title, title: milestone.title, format: :json)
else
......
......@@ -81,11 +81,11 @@ module NotesHelper
path_params = version_params.merge(anchor: discussion.line_code)
diffs_namespace_project_merge_request_path(discussion.project.namespace, discussion.project, discussion.noteable, path_params)
diffs_project_merge_request_path(discussion.project, discussion.noteable, path_params)
elsif discussion.for_commit?
anchor = discussion.line_code if discussion.diff_discussion?
namespace_project_commit_path(discussion.project.namespace, discussion.project, discussion.noteable, anchor: anchor)
project_commit_path(discussion.project, discussion.noteable, anchor: anchor)
end
end
......@@ -93,12 +93,7 @@ module NotesHelper
if @snippet.is_a?(PersonalSnippet)
snippet_notes_path(@snippet)
else
namespace_project_noteable_notes_path(
namespace_id: @project.namespace,
project_id: @project,
target_id: @noteable.id,
target_type: @noteable.class.name.underscore
)
project_noteable_notes_path(@project, target_id: @noteable.id, target_type: @noteable.class.name.underscore)
end
end
......@@ -106,7 +101,7 @@ module NotesHelper
if note.noteable.is_a?(PersonalSnippet)
snippet_note_path(note.noteable, note)
else
namespace_project_note_path(project.namespace, project, note)
project_note_path(project, note)
end
end
......
......@@ -347,8 +347,7 @@ module ProjectsHelper
def add_special_file_path(project, file_name:, commit_message: nil, branch_name: nil, context: nil)
commit_message ||= s_("CommitMessage|Add %{file_name}") % { file_name: file_name.downcase }
namespace_project_new_blob_path(
project.namespace,
project_new_blob_path(
project,
project.default_branch || 'master',
file_name: file_name,
......@@ -359,8 +358,7 @@ module ProjectsHelper
end
def add_koding_stack_path(project)
namespace_project_new_blob_path(
project.namespace,
project_new_blob_path(
project,
project.default_branch || 'master',
file_name: '.koding.yml',
......@@ -414,8 +412,7 @@ module ProjectsHelper
def contribution_guide_path(project)
if project && contribution_guide = project.repository.contribution_guide
namespace_project_blob_path(
project.namespace,
project_blob_path(
project,
tree_join(project.default_branch,
contribution_guide.name)
......@@ -445,7 +442,7 @@ module ProjectsHelper
def project_wiki_path_with_version(proj, page, version, is_newest)
url_params = is_newest ? {} : { version_id: version }
namespace_project_wiki_path(proj.namespace, proj, page, url_params)
project_wiki_path(proj, page, url_params)
end
def project_status_css_class(status)
......@@ -470,8 +467,7 @@ module ProjectsHelper
def filename_path(project, filename)
if project && blob = project.repository.send(filename)
namespace_project_blob_path(
project.namespace,
project_blob_path(
project,
tree_join(project.default_branch, blob.name)
)
......
......@@ -67,16 +67,16 @@ module SearchHelper
ref = @ref || @project.repository.root_ref
[
{ category: "Current Project", label: "Files", url: namespace_project_tree_path(@project.namespace, @project, ref) },
{ category: "Current Project", label: "Commits", url: namespace_project_commits_path(@project.namespace, @project, ref) },
{ category: "Current Project", label: "Network", url: namespace_project_network_path(@project.namespace, @project, ref) },
{ category: "Current Project", label: "Graph", url: namespace_project_graph_path(@project.namespace, @project, ref) },
{ category: "Current Project", label: "Issues", url: namespace_project_issues_path(@project.namespace, @project) },
{ category: "Current Project", label: "Merge Requests", url: namespace_project_merge_requests_path(@project.namespace, @project) },
{ category: "Current Project", label: "Milestones", url: namespace_project_milestones_path(@project.namespace, @project) },
{ category: "Current Project", label: "Snippets", url: namespace_project_snippets_path(@project.namespace, @project) },
{ category: "Current Project", label: "Members", url: namespace_project_settings_members_path(@project.namespace, @project) },
{ category: "Current Project", label: "Wiki", url: namespace_project_wikis_path(@project.namespace, @project) }
{ category: "Current Project", label: "Files", url: project_tree_path(@project, ref) },
{ category: "Current Project", label: "Commits", url: project_commits_path(@project, ref) },
{ category: "Current Project", label: "Network", url: project_network_path(@project, ref) },
{ category: "Current Project", label: "Graph", url: project_graph_path(@project, ref) },
{ category: "Current Project", label: "Issues", url: project_issues_path(@project) },
{ category: "Current Project", label: "Merge Requests", url: project_merge_requests_path(@project) },
{ category: "Current Project", label: "Milestones", url: project_milestones_path(@project) },
{ category: "Current Project", label: "Snippets", url: project_snippets_path(@project) },
{ category: "Current Project", label: "Members", url: project_settings_members_path(@project) },
{ category: "Current Project", label: "Wiki", url: project_wikis_path(@project) }
]
else
[]
......@@ -104,7 +104,7 @@ module SearchHelper
id: p.id,
value: "#{search_result_sanitize(p.name)}",
label: "#{search_result_sanitize(p.name_with_namespace)}",
url: namespace_project_path(p.namespace, p)
url: project_path(p)
}
end
end
......@@ -133,7 +133,7 @@ module SearchHelper
data: {
'project-id' => @project.id,
'username-params' => @users.to_json(only: [:id, :username]),
'base-endpoint' => namespace_project_path(@project.namespace, @project)
'base-endpoint' => project_path(@project)
}
}
end
......
module SnippetsHelper
def reliable_snippet_path(snippet, opts = nil)
if snippet.project_id?
namespace_project_snippet_path(snippet.project.namespace,
snippet.project, snippet, opts)
project_snippet_path(snippet.project, snippet, opts)
else
snippet_path(snippet, opts)
end
......@@ -10,7 +9,7 @@ module SnippetsHelper
def download_snippet_path(snippet)
if snippet.project_id
raw_namespace_project_snippet_path(@project.namespace, @project, snippet, inline: false)
raw_project_snippet_path(@project, snippet, inline: false)
else
raw_snippet_path(snippet, inline: false)
end
......@@ -21,7 +20,7 @@ module SnippetsHelper
# @returns String, path to snippet index
def subject_snippets_path(subject = nil, opts = nil)
if subject.is_a?(Project)
namespace_project_snippets_path(subject.namespace, subject, opts)
project_snippets_path(subject, opts)
else # assume subject === User
dashboard_snippets_path(opts)
end
......
......@@ -107,8 +107,7 @@ module TabHelper
def branches_tab_class
if current_controller?(:protected_branches) ||
current_controller?(:branches) ||
current_page?(namespace_project_repository_path(@project.namespace,
@project))
current_page?(project_repository_path(@project))
'active'
end
end
......
......@@ -10,7 +10,7 @@ module TagsHelper
}
options = exist_opts.merge(options)
namespace_project_tags_path(@project.namespace, @project, @id, options)
project_tags_path(@project, @id, options)
end
def tag_list(project)
......
......@@ -39,7 +39,7 @@ module TodosHelper
anchor = dom_id(todo.note) if todo.note.present?
if todo.for_commit?
namespace_project_commit_path(todo.project.namespace.becomes(Namespace), todo.project,
project_commit_path(todo.project,
todo.target, anchor: anchor)
else
path = [todo.project.namespace.becomes(Namespace), todo.project, todo.target]
......
......@@ -31,7 +31,7 @@ module Emails
setup_issue_mail(issue_id, recipient_id)
@label_names = label_names
@labels_url = namespace_project_labels_url(@project.namespace, @project)
@labels_url = project_labels_url(@project)
mail_answer_thread(@issue, issue_thread_options(updated_by_user_id, recipient_id))
end
......@@ -56,7 +56,7 @@ module Emails
def setup_issue_mail(issue_id, recipient_id)
@issue = Issue.find(issue_id)
@project = @issue.project
@target_url = namespace_project_issue_url(@project.namespace, @project, @issue)
@target_url = project_issue_url(@project, @issue)
@sent_notification = SentNotification.record(@issue, recipient_id, reply_key)
end
......
......@@ -22,7 +22,7 @@ module Emails
setup_merge_request_mail(merge_request_id, recipient_id)
@label_names = label_names
@labels_url = namespace_project_labels_url(@project.namespace, @project)
@labels_url = project_labels_url(@project)
mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, recipient_id))
end
......@@ -59,7 +59,7 @@ module Emails
def setup_merge_request_mail(merge_request_id, recipient_id)
@merge_request = MergeRequest.find(merge_request_id)
@project = @merge_request.project
@target_url = namespace_project_merge_request_url(@project.namespace, @project, @merge_request)
@target_url = project_merge_request_url(@project, @merge_request)
@sent_notification = SentNotification.record(@merge_request, recipient_id, reply_key)
end
......
......@@ -4,7 +4,7 @@ module Emails
setup_note_mail(note_id, recipient_id)
@commit = @note.noteable
@target_url = namespace_project_commit_url(*note_target_url_options)
@target_url = project_commit_url(*note_target_url_options)
mail_answer_thread(@commit, note_thread_options(recipient_id))
end
......@@ -12,7 +12,7 @@ module Emails
setup_note_mail(note_id, recipient_id)
@issue = @note.noteable
@target_url = namespace_project_issue_url(*note_target_url_options)
@target_url = project_issue_url(*note_target_url_options)
mail_answer_thread(@issue, note_thread_options(recipient_id))
end
......@@ -20,7 +20,7 @@ module Emails
setup_note_mail(note_id, recipient_id)
@merge_request = @note.noteable
@target_url = namespace_project_merge_request_url(*note_target_url_options)
@target_url = project_merge_request_url(*note_target_url_options)
mail_answer_thread(@merge_request, note_thread_options(recipient_id))
end
......@@ -28,7 +28,7 @@ module Emails
setup_note_mail(note_id, recipient_id)
@snippet = @note.noteable
@target_url = namespace_project_snippet_url(*note_target_url_options)
@target_url = project_snippet_url(*note_target_url_options)
mail_answer_thread(@snippet, note_thread_options(recipient_id))
end
......@@ -43,7 +43,7 @@ module Emails
private
def note_target_url_options
[@project.namespace, @project, @note.noteable, anchor: "note_#{@note.id}"]
[@project, @note.noteable, anchor: "note_#{@note.id}"]
end
def note_thread_options(recipient_id)
......
......@@ -3,7 +3,7 @@ module Emails
def project_was_moved_email(project_id, user_id, old_path_with_namespace)
@current_user = @user = User.find user_id
@project = Project.find project_id
@target_url = namespace_project_url(@project.namespace, @project)
@target_url = project_url(@project)
@old_path_with_namespace = old_path_with_namespace
mail(to: @user.notification_email,
subject: subject("Project was moved"))
......
class Notify < BaseMailer
include ActionDispatch::Routing::PolymorphicRoutes
include GitlabRoutingHelper
include Emails::Issues
include Emails::MergeRequests
......
......@@ -218,8 +218,7 @@ class Environment < ActiveRecord::Base
end
def etag_cache_key
Gitlab::Routing.url_helpers.namespace_project_environments_path(
project.namespace,
Gitlab::Routing.url_helpers.project_environments_path(
project,
format: :json)
end
......
......@@ -295,11 +295,7 @@ class Issue < ActiveRecord::Base
end
def expire_etag_cache
key = Gitlab::Routing.url_helpers.realtime_changes_namespace_project_issue_path(
project.namespace,
project,
self
)
key = Gitlab::Routing.url_helpers.realtime_changes_project_issue_path(project, self)
Gitlab::EtagCaching::Store.new.touch(key)
end
end
......@@ -330,8 +330,7 @@ class Note < ActiveRecord::Base
def expire_etag_cache
return unless for_issue?
key = Gitlab::Routing.url_helpers.namespace_project_noteable_notes_path(
noteable.project.namespace,
key = Gitlab::Routing.url_helpers.project_noteable_notes_path(
noteable.project,
target_type: noteable_type.underscore,
target_id: noteable.id
......
......@@ -675,7 +675,7 @@ class Project < ActiveRecord::Base
end
def web_url
Gitlab::Routing.url_helpers.namespace_project_url(self.namespace, self)
Gitlab::Routing.url_helpers.project_url(self)
end
def new_issue_address(author)
......@@ -851,7 +851,7 @@ class Project < ActiveRecord::Base
def avatar_url(**args)
# We use avatar_path instead of overriding avatar_url because of carrierwave.
# See https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/11001/diffs#note_28659864
avatar_path(args) || (Gitlab::Routing.url_helpers.namespace_project_avatar_url(namespace, self) if avatar_in_git)
avatar_path(args) || (Gitlab::Routing.url_helpers.project_avatar_url(self) if avatar_in_git)
end
# For compatibility with old code
......
......@@ -12,26 +12,26 @@ class GitlabIssueTrackerService < IssueTrackerService
end
def project_url
namespace_project_issues_url(project.namespace, project)
project_issues_url(project)
end
def new_issue_url
new_namespace_project_issue_url(namespace_id: project.namespace, project_id: project)
new_project_issue_url(project)
end
def issue_url(iid)
namespace_project_issue_url(namespace_id: project.namespace, project_id: project, id: iid)
project_issue_url(project, id: iid)
end
def project_path
namespace_project_issues_path(project.namespace, project)
project_issues_path(project)
end
def new_issue_path
new_namespace_project_issue_path(namespace_id: project.namespace, project_id: project)
new_project_issue_path(project)
end
def issue_path(iid)
namespace_project_issue_path(namespace_id: project.namespace, project_id: project, id: iid)
project_issue_path(project, id: iid)
end
end
......@@ -21,7 +21,7 @@ class IssueTrackerService < Service
end
def project_path
project_url
read_attribute(:project_url)
end
def new_issue_path
......
......@@ -152,8 +152,8 @@ class JiraService < IssueTrackerService
url: resource_url(user_path(author))
},
project: {
name: self.project.path_with_namespace,
url: resource_url(namespace_project_path(project.namespace, self.project))
name: project.path_with_namespace,
url: resource_url(namespace_project_path(project.namespace, project)) # rubocop:disable Cop/ProjectPathHelper
},
entity: {
name: noteable_type.humanize.downcase,
......
......@@ -31,7 +31,7 @@ class ProjectWiki
end
def web_url
Gitlab::Routing.url_helpers.namespace_project_wiki_url(@project.namespace, @project, :home)
Gitlab::Routing.url_helpers.project_wiki_url(@project, :home)
end
def url_to_repo
......
......@@ -20,30 +20,25 @@ class MergeRequestPresenter < Gitlab::View::Presenter::Delegated
def cancel_merge_when_pipeline_succeeds_path
if can_cancel_merge_when_pipeline_succeeds?(current_user)
cancel_merge_when_pipeline_succeeds_namespace_project_merge_request_path(
project.namespace,
project,
merge_request)
cancel_merge_when_pipeline_succeeds_project_merge_request_path(project, merge_request)
end
end
def create_issue_to_resolve_discussions_path
if can?(current_user, :create_issue, project) && project.issues_enabled?
new_namespace_project_issue_path(project.namespace,
project,
merge_request_to_resolve_discussions_of: iid)
new_project_issue_path(project, merge_request_to_resolve_discussions_of: iid)
end
end
def remove_wip_path
if can?(current_user, :update_merge_request, merge_request.project)
remove_wip_namespace_project_merge_request_path(project.namespace, project, merge_request)
remove_wip_project_merge_request_path(project, merge_request)
end
end
def merge_path
if can_be_merged_by?(current_user)
merge_namespace_project_merge_request_path(project.namespace, project, merge_request)
merge_project_merge_request_path(project, merge_request)
end
end
......@@ -55,7 +50,7 @@ class MergeRequestPresenter < Gitlab::View::Presenter::Delegated
notice_now: edit_in_new_fork_notice_now
}
namespace_project_forks_path(merge_request.project.namespace, merge_request.project,
project_forks_path(merge_request.project,
namespace_key: current_user.namespace.id,
continue: continue_params)
end
......@@ -69,7 +64,7 @@ class MergeRequestPresenter < Gitlab::View::Presenter::Delegated
notice_now: edit_in_new_fork_notice_now
}
namespace_project_forks_path(project.namespace, project,
project_forks_path(project,
namespace_key: current_user.namespace.id,
continue: continue_params)
end
......@@ -77,19 +72,19 @@ class MergeRequestPresenter < Gitlab::View::Presenter::Delegated
def conflict_resolution_path
if conflicts.can_be_resolved_in_ui? && conflicts.can_be_resolved_by?(current_user)
conflicts_namespace_project_merge_request_path(project.namespace, project, merge_request)
conflicts_project_merge_request_path(project, merge_request)
end
end
def target_branch_commits_path
if target_branch_exists?
namespace_project_commits_path(project.namespace, project, target_branch)
project_commits_path(project, target_branch)
end
end
def source_branch_path
if source_branch_exists?
namespace_project_branch_path(source_project.namespace, source_project, source_branch)
project_branch_path(source_project, source_branch)
end
end
......@@ -99,7 +94,7 @@ class MergeRequestPresenter < Gitlab::View::Presenter::Delegated
if source_branch_exists?
namespace = link_to(namespace, project_path(source_project))
branch = link_to(branch, namespace_project_commits_path(source_project.namespace, source_project, source_branch))
branch = link_to(branch, project_commits_path(source_project, source_branch))
end
if for_fork?
......@@ -136,7 +131,7 @@ class MergeRequestPresenter < Gitlab::View::Presenter::Delegated
merge_request: merge_request,
closes_issues: closing_issues
).assignable_issues
path = assign_related_issues_namespace_project_merge_request_path(project.namespace, project, merge_request)
path = assign_related_issues_project_merge_request_path(project, merge_request)
if issues.present?
pluralize_this_issue = issues.count > 1 ? "these issues" : "this issue"
link_to "Assign yourself to #{pluralize_this_issue}", path, method: :post
......
......@@ -6,10 +6,7 @@ class BuildActionEntity < Grape::Entity
end
expose :path do |build|
play_namespace_project_job_path(
build.project.namespace,
build.project,
build)
play_project_job_path(build.project, build)
end
expose :playable?, as: :playable
......
......@@ -9,24 +9,15 @@ class BuildArtifactEntity < Grape::Entity
expose :artifacts_expire_at, as: :expire_at
expose :path do |job|
download_namespace_project_job_artifacts_path(
project.namespace,
project,
job)
download_project_job_artifacts_path(project, job)
end
expose :keep_path, if: -> (*) { job.has_expiring_artifacts? } do |job|
keep_namespace_project_job_artifacts_path(
project.namespace,
project,
job)
keep_project_job_artifacts_path(project, job)
end
expose :browse_path do |job|
browse_namespace_project_job_artifacts_path(
project.namespace,
project,
job)
browse_project_job_artifacts_path(project, job)
end
private
......
......@@ -7,7 +7,7 @@ class BuildDetailsEntity < JobEntity
expose :erased_by, if: -> (*) { build.erased? }, using: UserEntity
expose :erase_path, if: -> (*) { build.erasable? && can?(current_user, :update_build, project) } do |build|
erase_namespace_project_job_path(project.namespace, project, build)
erase_project_job_path(project, build)
end
expose :merge_request, if: -> (*) { can?(current_user, :read_merge_request, build.merge_request) } do
......@@ -16,23 +16,23 @@ class BuildDetailsEntity < JobEntity
end
expose :path do |build|
namespace_project_merge_request_path(project.namespace, project, build.merge_request)
project_merge_request_path(project, build.merge_request)
end
end
expose :new_issue_path, if: -> (*) { can?(request.current_user, :create_issue, project) && build.failed? } do |build|
new_namespace_project_issue_path(project.namespace, project, issue: build_failed_issue_options)
new_project_issue_path(project, issue: build_failed_issue_options)
end
expose :raw_path do |build|
raw_namespace_project_job_path(project.namespace, project, build)
raw_project_job_path(project, build)
end
private
def build_failed_issue_options
{ title: "Build Failed ##{build.id}",
description: namespace_project_job_path(project.namespace, project, build) }
description: project_job_path(project, build) }
end
def current_user
......
......@@ -8,16 +8,10 @@ class CommitEntity < API::Entities::RepoCommit
end
expose :commit_url do |commit|
namespace_project_commit_url(
request.project.namespace,
request.project,
commit)
project_commit_url(request.project, commit)
end
expose :commit_path do |commit|
namespace_project_commit_path(
request.project.namespace,
request.project,
commit)
project_commit_path(request.project, commit)
end
end
......@@ -11,10 +11,7 @@ class DeploymentEntity < Grape::Entity
end
expose :ref_path do |deployment|
namespace_project_tree_path(
deployment.project.namespace,
deployment.project,
id: deployment.ref)
project_tree_path(deployment.project, id: deployment.ref)
end
end
......
......@@ -10,32 +10,20 @@ class EnvironmentEntity < Grape::Entity
expose :stop_action?
expose :metrics_path, if: -> (environment, _) { environment.has_metrics? } do |environment|
metrics_namespace_project_environment_path(
environment.project.namespace,
environment.project,
environment)
metrics_project_environment_path(environment.project, environment)
end
expose :environment_path do |environment|
namespace_project_environment_path(
environment.project.namespace,
environment.project,
environment)
project_environment_path(environment.project, environment)
end
expose :stop_path do |environment|
stop_namespace_project_environment_path(
environment.project.namespace,
environment.project,
environment)
stop_project_environment_path(environment.project, environment)
end
expose :terminal_path, if: ->(environment, _) { environment.has_terminals? } do |environment|
can?(request.current_user, :admin_environment, environment.project) &&
terminal_namespace_project_environment_path(
environment.project.namespace,
environment.project,
environment)
terminal_project_environment_path(environment.project, environment)
end
expose :created_at, :updated_at
......
......@@ -11,6 +11,6 @@ class IssueEntity < IssuableEntity
expose :labels, using: LabelEntity
expose :web_url do |issue|
namespace_project_issue_path(issue.project.namespace, issue.project, issue)
project_issue_path(issue.project, issue)
end
end
......@@ -99,9 +99,7 @@ class MergeRequestEntity < IssuableEntity
expose :new_blob_path do |merge_request|
if can?(current_user, :push_code, merge_request.project)
namespace_project_new_blob_path(merge_request.project.namespace,
merge_request.project,
merge_request.source_branch)
project_new_blob_path(merge_request.project, merge_request.source_branch)
end
end
......@@ -134,30 +132,19 @@ class MergeRequestEntity < IssuableEntity
end
expose :email_patches_path do |merge_request|
namespace_project_merge_request_path(merge_request.project.namespace,
merge_request.project,
merge_request,
format: :patch)
project_merge_request_path(merge_request.project, merge_request, format: :patch)
end
expose :plain_diff_path do |merge_request|
namespace_project_merge_request_path(merge_request.project.namespace,
merge_request.project,
merge_request,
format: :diff)
project_merge_request_path(merge_request.project, merge_request, format: :diff)
end
expose :status_path do |merge_request|
namespace_project_merge_request_path(merge_request.target_project.namespace,
merge_request.target_project,
merge_request,
format: :json)
project_merge_request_path(merge_request.target_project, merge_request, format: :json)
end
expose :ci_environments_status_path do |merge_request|
ci_environments_status_namespace_project_merge_request_path(merge_request.project.namespace,
merge_request.project,
merge_request)
ci_environments_status_project_merge_request_path(merge_request.project, merge_request)
end
expose :merge_commit_message_with_description do |merge_request|
......@@ -173,9 +160,7 @@ class MergeRequestEntity < IssuableEntity
end
expose :commit_change_content_path do |merge_request|
commit_change_content_namespace_project_merge_request_path(merge_request.project.namespace,
merge_request.project,
merge_request)
commit_change_content_project_merge_request_path(merge_request.project, merge_request)
end
private
......
......@@ -10,10 +10,7 @@ class PipelineEntity < Grape::Entity
expose :created_at, :updated_at
expose :path do |pipeline|
namespace_project_pipeline_path(
pipeline.project.namespace,
pipeline.project,
pipeline)
project_pipeline_path(pipeline.project, pipeline)
end
expose :flags do
......@@ -48,15 +45,11 @@ class PipelineEntity < Grape::Entity
expose :commit, using: CommitEntity
expose :retry_path, if: -> (*) { can_retry? } do |pipeline|
retry_namespace_project_pipeline_path(pipeline.project.namespace,
pipeline.project,
pipeline.id)
retry_project_pipeline_path(pipeline.project, pipeline)
end
expose :cancel_path, if: -> (*) { can_cancel? } do |pipeline|
cancel_namespace_project_pipeline_path(pipeline.project.namespace,
pipeline.project,
pipeline.id)
cancel_project_pipeline_path(pipeline.project, pipeline)
end
expose :yaml_errors, if: -> (pipeline, _) { pipeline.has_yaml_errors? }
......
......@@ -5,7 +5,7 @@ class ProjectEntity < Grape::Entity
expose :name
expose :full_path do |project|
namespace_project_path(project.namespace, project)
project_path(project)
end
expose :full_name do |project|
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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