lib/decidim/admin/engine.rb in decidim-admin-0.11.2 vs lib/decidim/admin/engine.rb in decidim-admin-0.12.0.pre

- old
+ new

@@ -29,22 +29,10 @@ initializer "decidim_admin.assets" do |app| app.config.assets.precompile += %w(decidim_admin_manifest.js) end - initializer "decidim_admin.inject_abilities_to_user" do |_app| - Decidim.configure do |config| - config.admin_abilities += [ - "Decidim::Admin::Abilities::AdminAbility", - "Decidim::Admin::Abilities::UserManagerAbility", - "Decidim::Admin::Abilities::ParticipatoryProcessAdminAbility", - "Decidim::Admin::Abilities::ParticipatoryProcessCollaboratorAbility", - "Decidim::Admin::Abilities::ParticipatoryProcessModeratorAbility" - ] - end - end - initializer "decidim_admin.menu" do Decidim.menu :admin_menu do |menu| menu.item I18n.t("menu.dashboard", scope: "decidim.admin"), decidim_admin.root_path, icon_name: "dashboard", @@ -54,45 +42,54 @@ menu.item I18n.t("menu.static_pages", scope: "decidim.admin"), decidim_admin.static_pages_path, icon_name: "book", position: 4, active: :inclusive, - if: can?(:read, Decidim::StaticPage) + if: allowed_to?(:read, :static_page) menu.item I18n.t("menu.users", scope: "decidim.admin"), - can?(:read, :admin_users) ? decidim_admin.users_path : decidim_admin.impersonatable_users_path, + allowed_to?(:read, :admin_user) ? decidim_admin.users_path : decidim_admin.impersonatable_users_path, icon_name: "person", position: 5, active: [%w(user_groups users managed_users impersonatable_users authorization_workflows).map { |segment| "/decidim/admin/#{segment}" }, []], - if: can?(:read, :admin_users) || can?(:read, :impersonatable_users) + if: allowed_to?(:read, :admin_user) || allowed_to?(:read, :managed_user) menu.item I18n.t("menu.newsletters", scope: "decidim.admin"), decidim_admin.newsletters_path, icon_name: "envelope-closed", position: 6, active: :inclusive, - if: can?(:index, Decidim::Newsletter) + if: allowed_to?(:index, :newsletter) menu.item I18n.t("menu.settings", scope: "decidim.admin"), decidim_admin.edit_organization_path, icon_name: "wrench", position: 7, - active: [%w(decidim/admin/organization decidim/admin/scopes decidim/admin/scope_types), []], - if: can?(:read, current_organization) + active: [ + %w( + decidim/admin/organization + decidim/admin/organization_appearance + decidim/admin/scopes + decidim/admin/scope_types + decidim/admin/areas decidim/admin/area_types + ), + [] + ], + if: allowed_to?(:update, :organization, organization: current_organization) menu.item I18n.t("menu.admin_log", scope: "decidim.admin"), decidim_admin.logs_path, icon_name: "dashboard", position: 10, active: [%w(decidim/admin/logs), []], - if: can?(:read, :admin_log) + if: allowed_to?(:read, :admin_log) menu.item I18n.t("menu.oauth_applications", scope: "decidim.admin"), decidim_admin.oauth_applications_path, icon_name: "dashboard", position: 11, active: [%w(decidim/admin/oauth_applications), []], - if: can?(:read, :oauth_applications) + if: allowed_to?(:read, :oauth_application) end end end end end