Commit d8b7df3c authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Add support for nested groups to admin routing

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 3f768f9a
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
%span %span
Overview Overview
= nav_link(controller: [:admin, :projects]) do = nav_link(controller: [:admin, :projects]) do
= link_to admin_namespaces_projects_path, title: 'Projects' do = link_to admin_projects_path, title: 'Projects' do
%span %span
Projects Projects
= nav_link(controller: :users) do = nav_link(controller: :users) do
......
...@@ -116,7 +116,7 @@ ...@@ -116,7 +116,7 @@
.light-well.well-centered .light-well.well-centered
%h4 Projects %h4 Projects
.data .data
= link_to admin_namespaces_projects_path do = link_to admin_projects_path do
%h1= number_with_delimiter(Project.cached_count) %h1= number_with_delimiter(Project.cached_count)
%hr %hr
= link_to('New Project', new_project_path, class: "btn btn-new") = link_to('New Project', new_project_path, class: "btn btn-new")
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
%li.group-row{ class: css_class } %li.group-row{ class: css_class }
.controls .controls
= link_to 'Edit', edit_admin_group_path(group), id: "edit_#{dom_id(group)}", class: 'btn' = link_to 'Edit', admin_group_edit_path(group), id: "edit_#{dom_id(group)}", class: 'btn'
= link_to 'Delete', [:admin, group], data: { confirm: "Are you sure you want to remove #{group.name}?" }, method: :delete, class: 'btn btn-remove' = link_to 'Delete', [:admin, group], data: { confirm: "Are you sure you want to remove #{group.name}?" }, method: :delete, class: 'btn btn-remove'
.stats .stats
%span %span
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
%h3.page-title %h3.page-title
Group: #{@group.name} Group: #{@group.name}
= link_to edit_admin_group_path(@group), class: "btn pull-right" do = link_to admin_group_edit_path(@group), class: "btn pull-right" do
%i.fa.fa-pencil-square-o %i.fa.fa-pencil-square-o
Edit Edit
%hr %hr
...@@ -88,7 +88,7 @@ ...@@ -88,7 +88,7 @@
Read more about project permissions Read more about project permissions
%strong= link_to "here", help_page_path("user/permissions"), class: "vlink" %strong= link_to "here", help_page_path("user/permissions"), class: "vlink"
= form_tag members_update_admin_group_path(@group), id: "new_project_member", class: "bulk_import", method: :put do = form_tag admin_group_members_update_path(@group), id: "new_project_member", class: "bulk_import", method: :put do
%div %div
= users_select_tag(:user_ids, multiple: true, email_user: true, scope: :all) = users_select_tag(:user_ids, multiple: true, email_user: true, scope: :all)
%div.prepend-top-10 %div.prepend-top-10
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
%div{ class: container_class } %div{ class: container_class }
.top-area .top-area
.prepend-top-default .prepend-top-default
= form_tag admin_namespaces_projects_path, method: :get do |f| = form_tag admin_projects_path, method: :get do |f|
.search-holder .search-holder
.search-field-holder .search-field-holder
= search_field_tag :name, params[:name], class: "form-control search-text-input js-search-input", id: "dashboard_search", autofocus: true, spellcheck: false, placeholder: 'Search by name' = search_field_tag :name, params[:name], class: "form-control search-text-input js-search-input", id: "dashboard_search", autofocus: true, spellcheck: false, placeholder: 'Search by name'
...@@ -41,19 +41,19 @@ ...@@ -41,19 +41,19 @@
= button_tag "Search", class: "btn btn-primary btn-search" = button_tag "Search", class: "btn btn-primary btn-search"
%ul.nav-links %ul.nav-links
- opts = params[:visibility_level].present? ? {} : { page: admin_namespaces_projects_path } - opts = params[:visibility_level].present? ? {} : { page: admin_projects_path }
= nav_link(opts) do = nav_link(opts) do
= link_to admin_namespaces_projects_path do = link_to admin_projects_path do
All All
= nav_link(html_options: { class: params[:visibility_level] == Gitlab::VisibilityLevel::PRIVATE.to_s ? 'active' : '' }) do = nav_link(html_options: { class: params[:visibility_level] == Gitlab::VisibilityLevel::PRIVATE.to_s ? 'active' : '' }) do
= link_to admin_namespaces_projects_path(visibility_level: Gitlab::VisibilityLevel::PRIVATE) do = link_to admin_projects_path(visibility_level: Gitlab::VisibilityLevel::PRIVATE) do
Private Private
= nav_link(html_options: { class: params[:visibility_level] == Gitlab::VisibilityLevel::INTERNAL.to_s ? 'active' : '' }) do = nav_link(html_options: { class: params[:visibility_level] == Gitlab::VisibilityLevel::INTERNAL.to_s ? 'active' : '' }) do
= link_to admin_namespaces_projects_path(visibility_level: Gitlab::VisibilityLevel::INTERNAL) do = link_to admin_projects_path(visibility_level: Gitlab::VisibilityLevel::INTERNAL) do
Internal Internal
= nav_link(html_options: { class: params[:visibility_level] == Gitlab::VisibilityLevel::PUBLIC.to_s ? 'active' : '' }) do = nav_link(html_options: { class: params[:visibility_level] == Gitlab::VisibilityLevel::PUBLIC.to_s ? 'active' : '' }) do
= link_to admin_namespaces_projects_path(visibility_level: Gitlab::VisibilityLevel::PUBLIC) do = link_to admin_projects_path(visibility_level: Gitlab::VisibilityLevel::PUBLIC) do
Public Public
.nav-controls .nav-controls
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#{@message}. #{@message}.
%p %p
= link_to "See the affected projects in the GitLab admin panel", admin_namespaces_projects_url(last_repository_check_failed: 1) = link_to "See the affected projects in the GitLab admin panel", admin_projects_url(last_repository_check_failed: 1)
%p %p
You are receiving this message because you are a GitLab administrator for #{Gitlab.config.gitlab.url}. You are receiving this message because you are a GitLab administrator for #{Gitlab.config.gitlab.url}.
#{@message}. #{@message}.
\ \
View details: #{admin_namespaces_projects_url(last_repository_check_failed: 1)} View details: #{admin_projects_url(last_repository_check_failed: 1)}
You are receiving this message because you are a GitLab administrator You are receiving this message because you are a GitLab administrator
for #{Gitlab.config.gitlab.url}. for #{Gitlab.config.gitlab.url}.
...@@ -28,9 +28,19 @@ namespace :admin do ...@@ -28,9 +28,19 @@ namespace :admin do
resources :applications resources :applications
resources :groups, constraints: { id: /[^\/]+/ } do resources :groups, only: [:index, :new, :create]
member do
scope(path: 'groups/*id',
controller: :groups,
constraints: { id: Gitlab::Regex.namespace_route_regex }) do
scope(as: :group) do
put :members_update put :members_update
get :edit, action: :edit
get '/', action: :show
patch '/', action: :update
put '/', action: :update
delete '/', action: :destroy
end end
end end
...@@ -50,14 +60,13 @@ namespace :admin do ...@@ -50,14 +60,13 @@ namespace :admin do
resource :system_info, controller: 'system_info', only: [:show] resource :system_info, controller: 'system_info', only: [:show]
resources :requests_profiles, only: [:index, :show], param: :name, constraints: { name: /.+\.html/ } resources :requests_profiles, only: [:index, :show], param: :name, constraints: { name: /.+\.html/ }
resources :namespaces, path: '/projects', constraints: { id: /[a-zA-Z.0-9_\-]+/ }, only: [] do resources :projects, only: [:index]
root to: 'projects#index', as: :projects
scope(path: 'projects/*namespace_id', as: :namespace) do
resources(:projects, resources(:projects,
path: '/', path: '/',
constraints: { id: /[a-zA-Z.0-9_\-]+/ }, constraints: { id: Gitlab::Regex.project_route_regex },
only: [:index, :show]) do only: [:show]) do
root to: 'projects#show'
member do member do
put :transfer put :transfer
......
...@@ -168,7 +168,7 @@ module SharedPaths ...@@ -168,7 +168,7 @@ module SharedPaths
end end
step 'I visit admin projects page' do step 'I visit admin projects page' do
visit admin_namespaces_projects_path visit admin_projects_path
end end
step 'I visit admin users page' do step 'I visit admin users page' do
......
...@@ -21,7 +21,7 @@ feature 'Admin Groups', feature: true do ...@@ -21,7 +21,7 @@ feature 'Admin Groups', feature: true do
scenario 'shows the visibility level radio populated with the group visibility_level value' do scenario 'shows the visibility level radio populated with the group visibility_level value' do
group = create(:group, :private) group = create(:group, :private)
visit edit_admin_group_path(group) visit admin_group_edit_path(group)
expect_selected_visibility(group.visibility_level) expect_selected_visibility(group.visibility_level)
end end
......
...@@ -8,11 +8,11 @@ describe "Admin::Projects", feature: true do ...@@ -8,11 +8,11 @@ describe "Admin::Projects", feature: true do
describe "GET /admin/projects" do describe "GET /admin/projects" do
before do before do
visit admin_namespaces_projects_path visit admin_projects_path
end end
it "is ok" do it "is ok" do
expect(current_path).to eq(admin_namespaces_projects_path) expect(current_path).to eq(admin_projects_path)
end end
it "has projects list" do it "has projects list" do
...@@ -22,7 +22,7 @@ describe "Admin::Projects", feature: true do ...@@ -22,7 +22,7 @@ describe "Admin::Projects", feature: true do
describe "GET /admin/projects/:id" do describe "GET /admin/projects/:id" do
before do before do
visit admin_namespaces_projects_path visit admin_projects_path
click_link "#{@project.name}" click_link "#{@project.name}"
end end
......
...@@ -4,7 +4,7 @@ describe "Admin::Projects", feature: true do ...@@ -4,7 +4,7 @@ describe "Admin::Projects", feature: true do
include AccessMatchers include AccessMatchers
describe "GET /admin/projects" do describe "GET /admin/projects" do
subject { admin_namespaces_projects_path } subject { admin_projects_path }
it { is_expected.to be_allowed_for :admin } it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_denied_for :user } it { is_expected.to be_denied_for :user }
......
...@@ -66,7 +66,8 @@ describe Admin::ProjectsController, "routing" do ...@@ -66,7 +66,8 @@ describe Admin::ProjectsController, "routing" do
end end
it "to #show" do it "to #show" do
expect(get("/admin/projects/gitlab")).to route_to('admin/projects#show', namespace_id: 'gitlab') expect(get("/admin/projects/gitlab/gitlab-ce")).to route_to('admin/projects#show', namespace_id: 'gitlab', id: 'gitlab-ce')
expect(get("/admin/projects/gitlab/subgroup/gitlab-ce")).to route_to('admin/projects#show', namespace_id: 'gitlab/subgroup', id: 'gitlab-ce')
end end
end end
...@@ -119,3 +120,14 @@ describe Admin::HealthCheckController, "routing" do ...@@ -119,3 +120,14 @@ describe Admin::HealthCheckController, "routing" do
expect(get("/admin/health_check")).to route_to('admin/health_check#show') expect(get("/admin/health_check")).to route_to('admin/health_check#show')
end end
end end
describe Admin::GroupsController, "routing" do
it "to #index" do
expect(get("/admin/groups")).to route_to('admin/groups#index')
end
it "to #show" do
expect(get("/admin/groups/gitlab")).to route_to('admin/groups#show', id: 'gitlab')
expect(get("/admin/groups/gitlab/subgroup")).to route_to('admin/groups#show', id: 'gitlab/subgroup')
end
end
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