Sha256: 01cbea977fb3ffe5dbd2daedaaea933580c169afe68185c8ac2f305222c86859

Contents?: true

Size: 1.35 KB

Versions: 64

Compression:

Stored size: 1.35 KB

Contents

class CamaleonCms::Admin::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

Version data entries

64 entries across 64 versions & 2 rubygems

Version Path
camaleon_cms-2.6.4 app/controllers/camaleon_cms/admin/plugins_controller.rb
camaleon_cms-2.6.3 app/controllers/camaleon_cms/admin/plugins_controller.rb
camaleon_cms-2.6.2 app/controllers/camaleon_cms/admin/plugins_controller.rb
camaleon_cms-2.6.1 app/controllers/camaleon_cms/admin/plugins_controller.rb
camaleon_cms-2.6.0.1 app/controllers/camaleon_cms/admin/plugins_controller.rb
camaleon_cms-2.6.0 app/controllers/camaleon_cms/admin/plugins_controller.rb
camaleon_cms-2.5.3.1 app/controllers/camaleon_cms/admin/plugins_controller.rb
camaleon_cms-2.5.3 app/controllers/camaleon_cms/admin/plugins_controller.rb
camaleon_cms-2.5.2 app/controllers/camaleon_cms/admin/plugins_controller.rb
camaleon_cms_rails6-2.5.0 app/controllers/camaleon_cms/admin/plugins_controller.rb
camaleon_cms-2.5.1 app/controllers/camaleon_cms/admin/plugins_controller.rb
camaleon_cms-2.5.0 app/controllers/camaleon_cms/admin/plugins_controller.rb
camaleon_cms-2.4.6.9 app/controllers/camaleon_cms/admin/plugins_controller.rb
camaleon_cms-2.4.6.8 app/controllers/camaleon_cms/admin/plugins_controller.rb
camaleon_cms-2.4.6.7 app/controllers/camaleon_cms/admin/plugins_controller.rb
camaleon_cms-2.4.6.6 app/controllers/camaleon_cms/admin/plugins_controller.rb
camaleon_cms-2.4.6.5 app/controllers/camaleon_cms/admin/plugins_controller.rb
camaleon_cms-2.4.6.4 app/controllers/camaleon_cms/admin/plugins_controller.rb
camaleon_cms-2.4.6.3 app/controllers/camaleon_cms/admin/plugins_controller.rb
camaleon_cms-2.4.6.2 app/controllers/camaleon_cms/admin/plugins_controller.rb