[deploy] Move Admin interface paths (#9576)
* Move administrate to /resource_admin * Test fixes * Update docs
This commit is contained in:
parent
e5875d599c
commit
cda18d0aa4
31 changed files with 63 additions and 62 deletions
|
|
@ -4,7 +4,7 @@
|
|||
#
|
||||
# If you want to add pagination or other controller-level concerns,
|
||||
# you're free to overwrite the RESTful controller actions.
|
||||
module Admin
|
||||
module ResourceAdmin
|
||||
class ApplicationController < Administrate::ApplicationController
|
||||
include Pundit
|
||||
before_action :authorize_admin
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
module Admin
|
||||
class ArticlesController < Admin::ApplicationController
|
||||
module ResourceAdmin
|
||||
class ArticlesController < ResourceAdmin::ApplicationController
|
||||
def create
|
||||
resource = resource_class.new(resource_params)
|
||||
authorize_resource(resource)
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
module Admin
|
||||
class BadgeAchievementsController < Admin::ApplicationController
|
||||
module ResourceAdmin
|
||||
class BadgeAchievementsController < ResourceAdmin::ApplicationController
|
||||
# To customize the behavior of this controller,
|
||||
# you can overwrite any of the RESTful actions. For example:
|
||||
#
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
module Admin
|
||||
class BadgesController < Admin::ApplicationController
|
||||
module ResourceAdmin
|
||||
class BadgesController < ResourceAdmin::ApplicationController
|
||||
# To customize the behavior of this controller,
|
||||
# you can overwrite any of the RESTful actions. For example:
|
||||
#
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
module Admin
|
||||
class CollectionsController < Admin::ApplicationController
|
||||
module ResourceAdmin
|
||||
class CollectionsController < ResourceAdmin::ApplicationController
|
||||
# To customize the behavior of this controller,
|
||||
# simply overwrite any of the RESTful actions. For example:
|
||||
#
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
module Admin
|
||||
class CommentsController < Admin::ApplicationController
|
||||
module ResourceAdmin
|
||||
class CommentsController < ResourceAdmin::ApplicationController
|
||||
def update
|
||||
comment = Comment.find(params[:id])
|
||||
if comment.update(comment_params)
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
module Admin
|
||||
class DisplayAdsController < Admin::ApplicationController
|
||||
module ResourceAdmin
|
||||
class DisplayAdsController < ResourceAdmin::ApplicationController
|
||||
# To customize the behavior of this controller,
|
||||
# you can overwrite any of the RESTful actions. For example:
|
||||
#
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
module Admin
|
||||
class EmailMessagesController < Admin::ApplicationController
|
||||
module ResourceAdmin
|
||||
class EmailMessagesController < ResourceAdmin::ApplicationController
|
||||
# To customize the behavior of this controller,
|
||||
# simply overwrite any of the RESTful actions. For example:
|
||||
#
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
module Admin
|
||||
class FeedbackMessagesController < Admin::ApplicationController
|
||||
module ResourceAdmin
|
||||
class FeedbackMessagesController < ResourceAdmin::ApplicationController
|
||||
# To customize the behavior of this controller,
|
||||
# you can overwrite any of the RESTful actions. For example:
|
||||
#
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
module Admin
|
||||
class FollowsController < Admin::ApplicationController
|
||||
module ResourceAdmin
|
||||
class FollowsController < ResourceAdmin::ApplicationController
|
||||
# To customize the behavior of this controller,
|
||||
# simply overwrite any of the RESTful actions. For example:
|
||||
#
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
module Admin
|
||||
class HtmlVariantSuccessesController < Admin::ApplicationController
|
||||
module ResourceAdmin
|
||||
class HtmlVariantSuccessesController < ResourceAdmin::ApplicationController
|
||||
# Overwrite any of the RESTful controller actions to implement custom behavior
|
||||
# For example, you may want to send an email after a foo is updated.
|
||||
#
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
module Admin
|
||||
class HtmlVariantTrialsController < Admin::ApplicationController
|
||||
module ResourceAdmin
|
||||
class HtmlVariantTrialsController < ResourceAdmin::ApplicationController
|
||||
# Overwrite any of the RESTful controller actions to implement custom behavior
|
||||
# For example, you may want to send an email after a foo is updated.
|
||||
#
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
module Admin
|
||||
class HtmlVariantsController < Admin::ApplicationController
|
||||
module ResourceAdmin
|
||||
class HtmlVariantsController < ResourceAdmin::ApplicationController
|
||||
# To customize the behavior of this controller,
|
||||
# you can overwrite any of the RESTful actions. For example:
|
||||
#
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
module Admin
|
||||
class ListingCategoriesController < Admin::ApplicationController
|
||||
module ResourceAdmin
|
||||
class ListingCategoriesController < ResourceAdmin::ApplicationController
|
||||
# Overwrite any of the RESTful controller actions to implement custom behavior
|
||||
# For example, you may want to send an email after a foo is updated.
|
||||
#
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
module Admin
|
||||
class OrganizationsController < Admin::ApplicationController
|
||||
module ResourceAdmin
|
||||
class OrganizationsController < ResourceAdmin::ApplicationController
|
||||
# To customize the behavior of this controller,
|
||||
# simply overwrite any of the RESTful actions. For example:
|
||||
#
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
module Admin
|
||||
class PodcastEpisodesController < Admin::ApplicationController
|
||||
module ResourceAdmin
|
||||
class PodcastEpisodesController < ResourceAdmin::ApplicationController
|
||||
# To customize the behavior of this controller,
|
||||
# simply overwrite any of the RESTful actions. For example:
|
||||
#
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
module Admin
|
||||
class PodcastsController < Admin::ApplicationController
|
||||
module ResourceAdmin
|
||||
class PodcastsController < ResourceAdmin::ApplicationController
|
||||
def create
|
||||
resource = resource_class.new(resource_params)
|
||||
authorize_resource(resource)
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
module Admin
|
||||
class ReactionsController < Admin::ApplicationController
|
||||
module ResourceAdmin
|
||||
class ReactionsController < ResourceAdmin::ApplicationController
|
||||
# To customize the behavior of this controller,
|
||||
# simply overwrite any of the RESTful actions. For example:
|
||||
#
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
module Admin
|
||||
class SponsorshipsController < Admin::ApplicationController
|
||||
module ResourceAdmin
|
||||
class SponsorshipsController < ResourceAdmin::ApplicationController
|
||||
# To customize the behavior of this controller,
|
||||
# you can overwrite any of the RESTful actions. For example:
|
||||
#
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
module Admin
|
||||
class TagsController < Admin::ApplicationController
|
||||
module ResourceAdmin
|
||||
class TagsController < ResourceAdmin::ApplicationController
|
||||
def update
|
||||
@tag = Tag.find(params[:id])
|
||||
if @tag.update(tag_params) && @tag.errors.messages.blank?
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
module Admin
|
||||
class UsersController < Admin::ApplicationController
|
||||
module ResourceAdmin
|
||||
class UsersController < ResourceAdmin::ApplicationController
|
||||
def update
|
||||
user = User.find(params[:id])
|
||||
if user.errors.messages.blank? && user.update(user_params)
|
||||
flash[:notice] = "User successfully updated"
|
||||
redirect_to "/admin/users/#{params[:id]}"
|
||||
redirect_to "/ResourceAdmin/users/#{params[:id]}"
|
||||
else
|
||||
render :new, locals: { page: Administrate::Page::Form.new(dashboard, user) }
|
||||
end
|
||||
|
|
@ -106,7 +106,7 @@
|
|||
!url.href.includes('?preview=') && // Skip for preview pages.
|
||||
!url.href.includes('?signin') && // Don't run on sign in.
|
||||
|
||||
!url.href.includes('/admin') && // Don't fetch for administrate dashboard.
|
||||
!url.href.includes('/resource_admin') && // Don't fetch for administrate dashboard.
|
||||
!url.href.includes('/api/') && // Don't run on API endpoints.
|
||||
!url.href.includes('/embed/') && // Don't fetch for embeded content.
|
||||
!url.href.includes('/feed') && // Skip the RSS feed
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ Rails.application.routes.draw do
|
|||
mount FieldTest::Engine, at: "abtests"
|
||||
end
|
||||
|
||||
namespace :admin do
|
||||
namespace :resource_admin do
|
||||
# Check administrate gem docs
|
||||
DashboardManifest::DASHBOARDS.each do |dashboard_resource|
|
||||
resources dashboard_resource
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ credentials and third party services. Examples:
|
|||
Settings managed via ENVied can be found in
|
||||
[`Envfile`](https://github.com/forem/forem/blob/master/Envfile) (see
|
||||
[Configuring Environment Variables](../getting-started/config-env.md)) and
|
||||
viewed at `/internal/config` (see [Accessing the admin panel](./admin.md)):
|
||||
viewed at `/internal/config` (see [the Internal guide](../internal/readme.md)):
|
||||
|
||||

|
||||
|
||||
|
|
@ -38,9 +38,9 @@ Examples:
|
|||
These settings can be accessed via the
|
||||
[`SiteConfig`](https://github.com/forem/forem/blob/master/app/models/site_config.rb)
|
||||
object and viewed / modified via `/internal/config` (see
|
||||
[Accessing the admin panel](./admin.md)).
|
||||
[the Internal guide](../internal/readme.md)).
|
||||
|
||||

|
||||

|
||||
|
||||
## Vault
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ items:
|
|||
- fastly.md
|
||||
- roles.md
|
||||
- pusher.md
|
||||
- admin.md
|
||||
- resource-admin.md
|
||||
- previewing-emails.md
|
||||
- notification.md
|
||||
- scheduled-jobs.md
|
||||
|
|
|
|||
|
|
@ -1,18 +1,19 @@
|
|||
---
|
||||
title: Admin Panel
|
||||
title: Resource Admin Panel
|
||||
---
|
||||
|
||||
# What is the admin panel?
|
||||
# What is the resource admin panel?
|
||||
|
||||
The admin panel is a CRUD interface generated via the
|
||||
The resource admin panel is a CRUD interface generated via the
|
||||
[Administrate gem](https://github.com/thoughtbot/administrate). In production,
|
||||
this is generally not used often and will be deprecated in favor of the internal
|
||||
panel (`http://localhost:3000/internal/*`). For more details, see
|
||||
[the internal guide](/internal).
|
||||
|
||||
# Accessing the admin panel
|
||||
# Accessing the resource admin panel
|
||||
|
||||
There is an admin panel located at <http://localhost:3000/admin>.
|
||||
There is an resource admin panel located at
|
||||
<http://localhost:3000/resource_admin>.
|
||||
|
||||
To access the panel, you must be logged with a user with the `admin` role
|
||||
activated.
|
||||
|
|
@ -35,4 +36,4 @@ Loading development environment (Rails 5.2.3)
|
|||
```
|
||||
|
||||
Now you'll be able to access the
|
||||
[administration panel](http://localhost:3000/admin).
|
||||
[resource administration panel](http://localhost:3000/resource_admin).
|
||||
|
|
@ -72,4 +72,4 @@ User.joins(:roles).order(:id).group(:id).pluck(:id, :username, Arel.sql("array_a
|
|||
[2]: https://github.com/forem/forem/blob/master/app/models/role.rb
|
||||
[3]: https://github.com/forem/forem/search?q=has_role&unscoped_q=has_role
|
||||
[4]: https://stackoverflow.com/a/16096790/1511504
|
||||
[5]: /backend/admin
|
||||
[5]: /backend/resource-admin
|
||||
|
|
|
|||
|
|
@ -23,20 +23,20 @@ RSpec.describe "Admin::Podcasts", type: :request do
|
|||
|
||||
it "creates a podcast" do
|
||||
expect do
|
||||
post "/admin/podcasts", params: { podcast: valid_attributes }
|
||||
post "/resource_admin/podcasts", params: { podcast: valid_attributes }
|
||||
end.to change(Podcast, :count).by(1)
|
||||
end
|
||||
|
||||
it "enqueues a job after creating a podcast" do
|
||||
sidekiq_assert_enqueued_jobs(1, only: Podcasts::GetEpisodesWorker) do
|
||||
post "/admin/podcasts", params: { podcast: valid_attributes }
|
||||
post "/resource_admin/podcasts", params: { podcast: valid_attributes }
|
||||
end
|
||||
end
|
||||
|
||||
it "doesn't enqueue a job when creating an unpublished podcast" do
|
||||
valid_attributes[:published] = false
|
||||
sidekiq_assert_no_enqueued_jobs(only: Podcasts::GetEpisodesWorker) do
|
||||
post "/admin/podcasts", params: { podcast: valid_attributes }
|
||||
post "/resource_admin/podcasts", params: { podcast: valid_attributes }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -10,18 +10,18 @@ RSpec.describe "Admin dashboard is presented", type: :system do
|
|||
|
||||
it "loads the admin dashboard articles view", js: true do
|
||||
sign_in admin
|
||||
visit "/admin"
|
||||
visit "/resource_admin"
|
||||
expect(page).to have_content("Articles")
|
||||
end
|
||||
|
||||
it "loads the admin dashboard podcasts view", js: true do
|
||||
sign_in admin
|
||||
visit "/admin/podcasts"
|
||||
visit "/resource_admin/podcasts"
|
||||
expect(page).to have_content("Podcast Episodes")
|
||||
end
|
||||
|
||||
it "fails to load admin view for unauthorized users" do
|
||||
expect { visit "/admin" }.to raise_error(Pundit::NotAuthorizedError)
|
||||
expect { visit "/admin/podcasts" }.to raise_error(Pundit::NotAuthorizedError)
|
||||
expect { visit "/resource_admin" }.to raise_error(Pundit::NotAuthorizedError)
|
||||
expect { visit "/resource_admin/podcasts" }.to raise_error(Pundit::NotAuthorizedError)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue