Sha256: 5b8ef36985b3ec45d8049ac22598c4eb2b1a881434f43919914b6100f0c8a6d4

Contents?: true

Size: 1.03 KB

Versions: 51

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

module Motor
  class UiController < ApplicationController
    layout 'motor/application'

    helper_method :current_user, :current_ability, :cache_keys, :custom_html

    before_action :set_i18n_locale

    def index
      render_ui
    end

    def show
      render_ui
    end

    def new
      render_ui
    end

    private

    def render_ui
      Motor.reload! if Motor.development?

      Motor::Configs::SyncFromFile.call

      render :show
    end

    def custom_html
      Motor::Admin.config.custom_html.presence || begin
        configs = Motor::Configs::LoadFromCache.load_configs(cache_key: cache_keys[:configs])

        configs.find { |c| c.key == 'ui.custom_html' }&.value
      end
    end

    def set_i18n_locale
      configs = Motor::Configs::LoadFromCache.load_configs(cache_key: cache_keys[:configs])

      I18n.locale = configs.find { |c| c.key == 'language' }&.value&.to_sym || I18n.locale
    end

    def cache_keys
      @cache_keys ||= Configs::LoadFromCache.load_cache_keys
    end
  end
end

Version data entries

51 entries across 51 versions & 6 rubygems

Version Path
motor-admin-0.4.34 app/controllers/motor/ui_controller.rb
motor-admin-0.4.33 app/controllers/motor/ui_controller.rb
motor-admin-0.4.32 app/controllers/motor/ui_controller.rb
motor-admin-0.4.31 app/controllers/motor/ui_controller.rb
motor-admin-0.4.30 app/controllers/motor/ui_controller.rb
motor-admin-0.4.29 app/controllers/motor/ui_controller.rb
motor-admin-0.4.28 app/controllers/motor/ui_controller.rb
motor-admin-cstham8-0.4.35 app/controllers/motor/ui_controller.rb
motor-admin-cstham8-0.4.34 app/controllers/motor/ui_controller.rb
motor-admin-cstham8-0.4.33 app/controllers/motor/ui_controller.rb
motor-admin-cstham8-0.4.32 app/controllers/motor/ui_controller.rb
motor-admin-cstham8-0.4.31 app/controllers/motor/ui_controller.rb
motor-admin-cstham8-0.4.30 app/controllers/motor/ui_controller.rb
motor-admin-cstham8-0.4.29 app/controllers/motor/ui_controller.rb
motor-admin-cstham8-0.4.28 app/controllers/motor/ui_controller.rb
motor-admin-cstham8-0.4.27 app/controllers/motor/ui_controller.rb
motor-admin-0.4.27 app/controllers/motor/ui_controller.rb
motor-admin-unosquare-0.4.28 app/controllers/motor/ui_controller.rb
motor-admin-unosquare-0.4.27 app/controllers/motor/ui_controller.rb
motor-admin-pz-0.4.26 app/controllers/motor/ui_controller.rb