Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#463/routes refactor #464

Merged
merged 27 commits into from
Mar 18, 2019
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d622af2
Fix(routes): Use member helper for vm actions
chrisma Mar 11, 2019
46f04df
Fix(routes): Readd constraint for vm resources
chrisma Mar 11, 2019
a85a479
Fix(routes): Add scope for Slack routes
chrisma Mar 11, 2019
2a5ab79
Fix(routes): Add comment for devise routes config
chrisma Mar 11, 2019
8752234
Fix(routes): Collapse member block for user resources
chrisma Mar 11, 2019
2bf645b
Fix(routes): Remove duplicated root routing, add comment
chrisma Mar 11, 2019
61e641e
Fix(routes): Use member block for notification resources
chrisma Mar 11, 2019
57b2c1c
Fix(routes): Move reject PATCH into requests resources block
chrisma Mar 11, 2019
f32fb07
Fix(routes): Move projects resources near other non-customized resources
chrisma Mar 11, 2019
9cc2049
Fix(routes): Move unconfigured resources to top of file
chrisma Mar 11, 2019
980c01a
Fix(routes): Add OS and request templates resources to 'vms' scope. M…
chrisma Mar 11, 2019
a1c6981
Fix(routes): Move requests resoures into 'vms' scope
chrisma Mar 11, 2019
807d216
Fix(routes): Move 'edit_config' and 'update_config' into 'vms' scope
chrisma Mar 11, 2019
b55f605
Fix(routes): Add '/vms/configs' and '/vms/requests' scopes
chrisma Mar 11, 2019
7acf15c
Fix(routes): Remove redundant params from OS and req. template routes
chrisma Mar 11, 2019
e7f674b
Refactor(routes): Restructure routes.rb and add explanatory comments
chrisma Mar 11, 2019
47a665e
Fix(routes.rb): Move operating_systems out of requests resources scope
chrisma Mar 11, 2019
ffdbb76
Fix(routes): Reorder OS routes. Add comment on order mattering here.
chrisma Mar 11, 2019
86d94c8
[CodeFactor] Apply fixes
code-factor Mar 11, 2019
e6caf0e
Revert "[CodeFactor] Apply fixes"
chrisma Mar 11, 2019
cd9a50a
Refactor(routes): Use %i syntax
chrisma Mar 11, 2019
5b7958c
Merge branch 'dev' into #463/routes_refactor
chrisma Mar 12, 2019
8e86696
Merge branch 'dev' into #463/routes_refactor
bdaase Mar 13, 2019
2973d41
Merge branch 'dev' into #463/routes_refactor
bdaase Mar 14, 2019
e815b59
Merge branch 'dev' into #463/routes_refactor
bdaase Mar 14, 2019
36c19ec
Fix(routes): rework hosts definition
chrisma Mar 15, 2019
4fc210b
Merge branch 'dev' into #463/routes_refactor
chrisma Mar 15, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 68 additions & 46 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,60 +2,82 @@

# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
Rails.application.routes.draw do
resources :app_settings, only: %i[update edit]
resources :operating_systems, path: '/vms/requests/operating_systems', except: :show
# You can specify what Rails should route '/' to with the root method
# https://guides.rubyonrails.org/routing.html#using-root
root 'landing#index'

resources :request_templates, path: '/vms/request_templates', except: :show
patch '/vms/requests/reject', to: 'requests#reject', as: 'reject'
resources :requests, path: '/vms/requests' do
post :push_to_git, on: :member
end
# '/dashboard'
get '/dashboard' => 'dashboard#index', as: :dashboard
krichly marked this conversation as resolved.
Show resolved Hide resolved
# '/app_settings/...'
resources :app_settings, only: %i[update edit]
# '/projects/...'
resources :projects, except: :destroy
# '/servers/...'
resources :servers
# '/hosts/...'
resources :hosts, only: %i[index show], constraints: { id: /.*/ }

# '/notifications/...'
resources :notifications, only: %i[index new create destroy] do
get :mark_as_read, on: :member
member do
get :mark_as_read
delete :destroy_and_redirect
end
get :has_any, on: :collection, to: 'notifications#any?'
delete :destroy_and_redirect, on: :member
end

get '/dashboard' => 'dashboard#index', as: :dashboard
root to: 'landing#index'

get '/hosts/:id' => 'hosts#show', constraints: { id: /.*/ }

get '/vms/configs/:id' => 'vms#edit_config', constraints: { id: /.*/ }, as: :edit_config
patch '/vms/configs/:id' => 'vms#update_config', constraints: { id: /.*/ }, as: :update_config

# move all vm actions under /vms/vm because a VM named requests might otherwise lead to issues!
post '/vms/vm/:id/change_power_state' => 'vms#change_power_state', constraints: { id: /.*/ }
post '/vms/vm/:id/suspend_vm' => 'vms#suspend_vm', constraints: { id: /.*/ }
post '/vms/vm/:id/shutdown_guest_os' => 'vms#shutdown_guest_os', constraints: { id: /.*/ }
post '/vms/vm/:id/reboot_guest_os' => 'vms#reboot_guest_os', constraints: { id: /.*/ }
post '/vms/vm/:id/reset_vm' => 'vms#reset_vm', constraints: { id: /.*/ }
post '/vms/vm/:id/request_vm_archivation' => 'vms#request_vm_archivation', constraints: { id: /.*/ }
post '/vms/vm/:id/archive_vm' => 'vms#archive_vm', constraints: { id: /.*/ }
post '/vms/vm/:id/request_vm_revive' => 'vms#request_vm_revive', constraints: { id: /.*/ }
post '/vms/vm/:id/revive_vm' => 'vms#revive_vm', constraints: { id: /.*/ }
post '/vms/vm/:id/stop_archiving' => 'vms#stop_archiving', constraints: { id: /.*/ }
resources :vms, except: %i[new create], path: 'vms/vm'

get 'slack/new' => 'slack#new', as: :new_slack
get 'slack/auth' => 'slack#update', as: :update_slack

devise_for :users,
path: 'users',
controllers: {
registrations: 'users/registrations',
omniauth_callbacks: 'users/omniauth_callbacks'
}
# '/slack/...'
scope 'slack' do
get 'new' => 'slack#new', as: :new_slack
get 'auth' => 'slack#update', as: :update_slack
end

resources :hosts, :servers
resources :users do
member do
patch :update_role
# https://guides.rubyonrails.org/routing.html#prefixing-the-named-route-helpers
# '/vms/...'
scope 'vms' do
# '/vms/request_templates/...'
resources :request_templates, except: :show
# '/vms/requests/operating_systems/...'
# Order matters here, as routes are matched from top to bottom
# If 'resources :requests' is first, it will attempt to match that
resources :operating_systems, path: 'requests/operating_systems', except: :show
krichly marked this conversation as resolved.
Show resolved Hide resolved
# '/vms/requests/...'
resources :requests do
post :push_to_git, on: :member
patch :reject, on: :collection
end
# '/vms/configs/:id'
scope 'configs' do
get ':id' => 'vms#edit_config', constraints: { id: /.*/ }, as: :edit_config
patch ':id' => 'vms#update_config', constraints: { id: /.*/ }, as: :update_config
end
# '/vms/vm'
# move all vm actions under /vms/vm because a VM named requests might otherwise lead to issues!
resources :vms, except: %i[new create], path: 'vm', constraints: { id: /.*/ } do
# https://guides.rubyonrails.org/routing.html#adding-member-routes
member do
post 'change_power_state'
post 'suspend_vm'
post 'shutdown_guest_os'
post 'reboot_guest_os'
post 'reset_vm'
post 'request_vm_archivation'
post 'archive_vm'
post 'request_vm_revive'
post 'revive_vm'
post 'stop_archiving'
end
end
end

resources :projects, only: %i[index show new edit create update]

root 'landing#index'
# '/users/...'
# https://github.com/plataformatec/devise#configuring-routes
devise_for :users, path: 'users',
chrisma marked this conversation as resolved.
Show resolved Hide resolved
controllers: {
registrations: 'users/registrations',
omniauth_callbacks: 'users/omniauth_callbacks'
}
resources :users do
patch :update_role, on: :member
end
end