Sha256: a210df83340ed005a818ef34efc3adb887a11509a7d435f2343a3e2e0bd1d798

Contents?: true

Size: 1.53 KB

Versions: 11

Compression:

Stored size: 1.53 KB

Contents

module CamaleonCms
  module Admin
    class PluginsController < CamaleonCms::AdminController
      before_action :validate_role
      add_breadcrumb I18n.t('camaleon_cms.admin.sidebar.plugins')
      def index
        PluginRoutes.reload
      end

      def toggle
        status = params[:status].to_bool
        if status == true # to inactivate
          plugin = plugin_uninstall(params[:id])
          flash[:notice] = "Plugin \"#{plugin.title}\" #{t('camaleon_cms.admin.message.was_inactivated')}"
        end

        unless status # to activate
          plugin = plugin_install(params[:id])
          flash[:notice] = "Plugin \"#{plugin.title}\" #{t('camaleon_cms.admin.message.was_activated')}"
        end
        PluginRoutes.reload
        redirect_to action: :index
      end

      # permit to upgrade a plugin for a new version
      def upgrade
        plugin = plugin_upgrade(params[:plugin_id])
        flash[:notice] = "Plugin \"#{plugin.title}\" #{t('camaleon_cms.admin.message.was_upgraded')}"
        PluginRoutes.reload
        redirect_to action: :index
      end

      def destroy
        plugin = plugin_destroy(params[:id])
        if plugin.error
          flash[:notice] = "Plugin \"#{plugin.title}\" #{t('camaleon_cms.admin.message.was_removed')}"
        else
          flash[:error] = "Plugin \"#{plugin.title}\" #{t('camaleon_cms.admin.message.can_not_be_removed')}"
        end
        redirect_to action: :index
      end

      private

      def validate_role
        authorize! :manage, :plugins
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
camaleon_cms-2.9.0 app/controllers/camaleon_cms/admin/plugins_controller.rb
camaleon_cms-2.8.3 app/controllers/camaleon_cms/admin/plugins_controller.rb
camaleon_cms-2.8.2 app/controllers/camaleon_cms/admin/plugins_controller.rb
camaleon_cms-2.8.1 app/controllers/camaleon_cms/admin/plugins_controller.rb
camaleon_cms-2.8.0 app/controllers/camaleon_cms/admin/plugins_controller.rb
camaleon_cms-2.7.5 app/controllers/camaleon_cms/admin/plugins_controller.rb
camaleon_cms-2.7.4 app/controllers/camaleon_cms/admin/plugins_controller.rb
camaleon_cms-2.7.3 app/controllers/camaleon_cms/admin/plugins_controller.rb
camaleon_cms-2.7.2 app/controllers/camaleon_cms/admin/plugins_controller.rb
camaleon_cms-2.7.1 app/controllers/camaleon_cms/admin/plugins_controller.rb
camaleon_cms-2.7.0 app/controllers/camaleon_cms/admin/plugins_controller.rb