Commit b70b9628 authored by Sean McGivern's avatar Sean McGivern
Browse files

Merge branch 'dz-fix-admin-routes' into 'master'

Add support for nested groups to admin routing

See merge request !8008
parents 278baa5b d8b7df3c
......@@ -8,7 +8,7 @@
%span
Overview
= nav_link(controller: [:admin, :projects]) do
= link_to admin_namespaces_projects_path, title: 'Projects' do
= link_to admin_projects_path, title: 'Projects' do
%span
Projects
= nav_link(controller: :users) do
......
......@@ -116,7 +116,7 @@
.light-well.well-centered
%h4 Projects
.data
= link_to admin_namespaces_projects_path do
= link_to admin_projects_path do
%h1= number_with_delimiter(Project.cached_count)
%hr
= link_to('New Project', new_project_path, class: "btn btn-new")
......
......@@ -2,7 +2,7 @@
%li.group-row{ class: css_class }
.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'
.stats
%span
......
......@@ -2,7 +2,7 @@
%h3.page-title
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
Edit
%hr
......@@ -88,7 +88,7 @@
Read more about project permissions
%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
= users_select_tag(:user_ids, multiple: true, email_user: true, scope: :all)
%div.prepend-top-10
......
......@@ -7,7 +7,7 @@
%div{ class: container_class }
.top-area
.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-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'
......@@ -41,19 +41,19 @@
= button_tag "Search", class: "btn btn-primary btn-search"
%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
= link_to admin_namespaces_projects_path do
= link_to admin_projects_path do
All
= 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
= 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
= 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
.nav-controls
......
......@@ -2,7 +2,7 @@
#{@message}.
%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
You are receiving this message because you are a GitLab administrator for #{Gitlab.config.gitlab.url}.
#{@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
for #{Gitlab.config.gitlab.url}.
......@@ -28,9 +28,19 @@
resources :applications
resources :groups, constraints: { id: /[^\/]+/ } do
member do
resources :groups, only: [:index, :new, :create]
scope(path: 'groups/*id',
controller: :groups,
constraints: { id: Gitlab::Regex.namespace_route_regex }) do
scope(as: :group) do
put :members_update
get :edit, action: :edit
get '/', action: :show
patch '/', action: :update
put '/', action: :update
delete '/', action: :destroy
end
end
......@@ -50,14 +60,13 @@
resource :system_info, controller: 'system_info', only: [:show]
resources :requests_profiles, only: [:index, :show], param: :name, constraints: { name: /.+\.html/ }
resources :namespaces, path: '/projects', constraints: { id: /[a-zA-Z.0-9_\-]+/ }, only: [] do
root to: 'projects#index', as: :projects
resources :projects, only: [:index]
scope(path: 'projects/*namespace_id', as: :namespace) do
resources(:projects,
path: '/',
constraints: { id: /[a-zA-Z.0-9_\-]+/ },
only: [:index, :show]) do
root to: 'projects#show'
constraints: { id: Gitlab::Regex.project_route_regex },
only: [:show]) do
member do
put :transfer
......
......@@ -168,7 +168,7 @@ module SharedPaths
end
step 'I visit admin projects page' do
visit admin_namespaces_projects_path
visit admin_projects_path
end
step 'I visit admin users page' do
......
......@@ -21,7 +21,7 @@
scenario 'shows the visibility level radio populated with the group visibility_level value' do
group = create(:group, :private)
visit edit_admin_group_path(group)
visit admin_group_edit_path(group)
expect_selected_visibility(group.visibility_level)
end
......
......@@ -8,11 +8,11 @@
describe "GET /admin/projects" do
before do
visit admin_namespaces_projects_path
visit admin_projects_path
end
it "is ok" do
expect(current_path).to eq(admin_namespaces_projects_path)
expect(current_path).to eq(admin_projects_path)
end
it "has projects list" do
......@@ -22,7 +22,7 @@
describe "GET /admin/projects/:id" do
before do
visit admin_namespaces_projects_path
visit admin_projects_path
click_link "#{@project.name}"
end
......
......@@ -4,7 +4,7 @@
include AccessMatchers
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_denied_for :user }
......
......@@ -66,7 +66,8 @@
end
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
......@@ -119,3 +120,14 @@
expect(get("/admin/health_check")).to route_to('admin/health_check#show')
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