Module: RailsApiKeys::UI::ApiKeysHelper
- Defined in:
- app/helpers/rails_api_keys/ui/api_keys_helper.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#rails_api_keys_ui_panel(api_keys:, create_path:, destroy_path:, raw_token: nil) ⇒ Object
Renders the embeddable API keys panel (list + create/reveal modals).
-
#rails_api_keys_ui_stylesheet ⇒ Object
Inlines the gem stylesheet once per render (no asset pipeline required).
Class Method Details
.stylesheet_contents ⇒ Object
38 39 40 |
# File 'app/helpers/rails_api_keys/ui/api_keys_helper.rb', line 38 def self.stylesheet_contents @stylesheet_contents ||= File.read(stylesheet_path).html_safe end |
Instance Method Details
#rails_api_keys_ui_panel(api_keys:, create_path:, destroy_path:, raw_token: nil) ⇒ Object
Renders the embeddable API keys panel (list + create/reveal modals).
Reads the reveal-once raw token from flash when raw_token is omitted.
14 15 16 17 18 19 20 21 22 |
# File 'app/helpers/rails_api_keys/ui/api_keys_helper.rb', line 14 def rails_api_keys_ui_panel(api_keys:, create_path:, destroy_path:, raw_token: nil) render partial: "rails_api_keys/ui/api_keys/panel", locals: { api_keys: api_keys, create_path: create_path, destroy_path: destroy_path, raw_token: raw_token.nil? ? flash[RailsApiKeys::UI.configuration.raw_token_flash_key] : raw_token } end |
#rails_api_keys_ui_stylesheet ⇒ Object
Inlines the gem stylesheet once per render (no asset pipeline required).
Disable with config.include_stylesheet = false when the host supplies styles.
26 27 28 29 30 31 32 |
# File 'app/helpers/rails_api_keys/ui/api_keys_helper.rb', line 26 def rails_api_keys_ui_stylesheet return "".html_safe unless RailsApiKeys::UI.configuration.include_stylesheet return "".html_safe if @_rails_api_keys_ui_stylesheet_rendered @_rails_api_keys_ui_stylesheet_rendered = true content_tag(:style, ApiKeysHelper.stylesheet_contents, type: "text/css") end |