diff options
Diffstat (limited to 'config/routes/project.rb')
-rw-r--r-- | config/routes/project.rb | 291 |
1 files changed, 157 insertions, 134 deletions
diff --git a/config/routes/project.rb b/config/routes/project.rb index 93d746f3282..d44ff62bc2a 100644 --- a/config/routes/project.rb +++ b/config/routes/project.rb @@ -26,24 +26,150 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do module: :projects, as: :project) do - resources :autocomplete_sources, only: [] do - collection do - get 'members' - get 'issues' - get 'merge_requests' - get 'labels' - get 'milestones' - get 'commands' - get 'snippets' + # Begin of the /-/ scope. + # Use this scope for all new project routes. + scope '-' do + get 'archive/*id', constraints: { format: Gitlab::PathRegex.archive_formats_regex, id: /.+?/ }, to: 'repositories#archive', as: 'archive' + + resources :jobs, only: [:index, :show], constraints: { id: /\d+/ } do + collection do + resources :artifacts, only: [] do + collection do + get :latest_succeeded, + path: '*ref_name_and_path', + format: false + end + end + end + + member do + get :status + post :cancel + post :unschedule + post :retry + post :play + post :erase + get :trace, defaults: { format: 'json' } + get :raw + get :terminal + get '/terminal.ws/authorize', to: 'jobs#terminal_websocket_authorize', constraints: { format: nil } + end + + resource :artifacts, only: [] do + get :download + get :browse, path: 'browse(/*path)', format: false + get :file, path: 'file/*path', format: false + get :raw, path: 'raw/*path', format: false + post :keep + end + end + + namespace :ci do + resource :lint, only: [:show, :create] end + + namespace :settings do + get :members, to: redirect("%{namespace_id}/%{project_id}/project_members") + + resource :ci_cd, only: [:show, :update], controller: 'ci_cd' do + post :reset_cache + put :reset_registration_token + end + + resource :operations, only: [:show, :update] + resource :integrations, only: [:show] + + resource :repository, only: [:show], controller: :repository do + post :create_deploy_token, path: 'deploy_token/create' + post :cleanup + end + end + + resources :autocomplete_sources, only: [] do + collection do + get 'members' + get 'issues' + get 'merge_requests' + get 'labels' + get 'milestones' + get 'commands' + get 'snippets' + end + end + + resources :project_members, except: [:show, :new, :edit], constraints: { id: %r{[a-zA-Z./0-9_\-#%+]+} }, concerns: :access_requestable do + collection do + delete :leave + + # Used for import team + # from another project + get :import + post :apply_import + end + + member do + post :resend_invite + end + end + + resources :deploy_keys, constraints: { id: /\d+/ }, only: [:index, :new, :create, :edit, :update] do + member do + put :enable + put :disable + end + end + + resources :deploy_tokens, constraints: { id: /\d+/ }, only: [] do + member do + put :revoke + end + end + + resources :milestones, constraints: { id: /\d+/ } do + member do + post :promote + put :sort_issues + put :sort_merge_requests + get :merge_requests + get :participants + get :labels + end + end + + resources :labels, except: [:show], constraints: { id: /\d+/ } do + collection do + post :generate + post :set_priorities + end + + member do + post :promote + post :toggle_subscription + delete :remove_priority + end + end + + resources :services, constraints: { id: %r{[^/]+} }, only: [:edit, :update] do + member do + put :test + end + end + + resources :boards, only: [:index, :show], constraints: { id: /\d+/ } + resources :releases, only: [:index] + resources :forks, only: [:index, :new, :create] + resources :group_links, only: [:index, :create, :update, :destroy], constraints: { id: /\d+/ } + + resource :import, only: [:new, :create, :show] + resource :avatar, only: [:show, :destroy] end + # End of the /-/ scope. # # Templates # get '/templates/:template_type/:key' => 'templates#show', as: :template, constraints: { key: %r{[^/]+} } - resource :avatar, only: [:show, :destroy] resources :commit, only: [:show], constraints: { id: /\h{7,40}/ } do member do get :branches @@ -70,12 +196,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do end end - resources :services, constraints: { id: %r{[^/]+} }, only: [:edit, :update] do - member do - put :test - end - end - resource :mattermost, only: [:new, :create] namespace :prometheus do @@ -84,28 +204,11 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do end end - resources :deploy_keys, constraints: { id: /\d+/ }, only: [:index, :new, :create, :edit, :update] do - member do - put :enable - put :disable - end - end - - resources :deploy_tokens, constraints: { id: /\d+/ }, only: [] do - member do - put :revoke - end - end - - resources :releases, only: [:index] - resources :forks, only: [:index, :new, :create] - resource :import, only: [:new, :create, :show] - resources :merge_requests, concerns: :awardable, except: [:new, :create], constraints: { id: /\d+/ } do member do get :commit_change_content post :merge - post :cancel_merge_when_pipeline_succeeds + post :cancel_auto_merge get :pipeline_status get :ci_environments_status post :toggle_subscription @@ -267,47 +370,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do resources :functions, only: [:index] end - scope '-' do - get 'archive/*id', constraints: { format: Gitlab::PathRegex.archive_formats_regex, id: /.+?/ }, to: 'repositories#archive', as: 'archive' - - resources :jobs, only: [:index, :show], constraints: { id: /\d+/ } do - collection do - resources :artifacts, only: [] do - collection do - get :latest_succeeded, - path: '*ref_name_and_path', - format: false - end - end - end - - member do - get :status - post :cancel - post :unschedule - post :retry - post :play - post :erase - get :trace, defaults: { format: 'json' } - get :raw - get :terminal - get '/terminal.ws/authorize', to: 'jobs#terminal_websocket_authorize', constraints: { format: nil } - end - - resource :artifacts, only: [] do - get :download - get :browse, path: 'browse(/*path)', format: false - get :file, path: 'file/*path', format: false - get :raw, path: 'raw/*path', format: false - post :keep - end - end - - namespace :ci do - resource :lint, only: [:show, :create] - end - end - draw :legacy_builds resources :hooks, only: [:index, :create, :edit, :update, :destroy], constraints: { id: /\d+/ } do @@ -337,31 +399,8 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do end end - resources :milestones, constraints: { id: /\d+/ } do - member do - post :promote - put :sort_issues - put :sort_merge_requests - get :merge_requests - get :participants - get :labels - end - end - - resources :labels, except: [:show], constraints: { id: /\d+/ } do - collection do - post :generate - post :set_priorities - end - - member do - post :promote - post :toggle_subscription - delete :remove_priority - end - end - get :issues, to: 'issues#calendar', constraints: lambda { |req| req.format == :ics } + resources :issues, concerns: :awardable, constraints: { id: /\d+/ } do member do post :toggle_subscription @@ -373,29 +412,13 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do post :create_merge_request get :discussions, format: :json end + collection do post :bulk_update post :import_csv end end - resources :project_members, except: [:show, :new, :edit], constraints: { id: %r{[a-zA-Z./0-9_\-#%+]+} }, concerns: :access_requestable do - collection do - delete :leave - - # Used for import team - # from another project - get :import - post :apply_import - end - - member do - post :resend_invite - end - end - - resources :group_links, only: [:index, :create, :update, :destroy], constraints: { id: /\d+/ } - resources :notes, only: [:create, :destroy, :update], concerns: :awardable, constraints: { id: /\d+/ } do member do delete :delete_attachment @@ -406,8 +429,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do get 'noteable/:target_type/:target_id/notes' => 'notes#index', as: 'noteable_notes' - resources :boards, only: [:index, :show], constraints: { id: /\d+/ } - resources :todos, only: [:create] resources :uploads, only: [:create] do @@ -442,18 +463,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do end end end - namespace :settings do - get :members, to: redirect("%{namespace_id}/%{project_id}/project_members") - resource :ci_cd, only: [:show, :update], controller: 'ci_cd' do - post :reset_cache - put :reset_registration_token - end - resource :integrations, only: [:show] - resource :repository, only: [:show], controller: :repository do - post :create_deploy_token, path: 'deploy_token/create' - post :cleanup - end - end resources :error_tracking, only: [:index], controller: :error_tracking do collection do @@ -465,10 +474,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do # its preferable to keep it below all other project routes draw :wiki draw :repository - - namespace :settings do - resource :operations, only: [:show, :update] - end end resources(:projects, @@ -493,4 +498,22 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do end end end + + # Legacy routes. + # Introduced in 12.0. + # Should be removed after 12.1 + scope(path: '*namespace_id', + as: :namespace, + namespace_id: Gitlab::PathRegex.full_namespace_route_regex) do + scope(path: ':project_id', + constraints: { project_id: Gitlab::PathRegex.project_route_regex }, + module: :projects, + as: :project) do + Gitlab::Routing.redirect_legacy_paths(self, :settings, :branches, :tags, + :network, :graphs, :autocomplete_sources, + :project_members, :deploy_keys, :deploy_tokens, + :labels, :milestones, :services, :boards, :releases, + :forks, :group_links, :import, :avatar) + end + end end |