Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add configuration to control breadcrumb display #15

Merged
merged 1 commit into from
Feb 1, 2025

Conversation

thedumbtechguy
Copy link
Contributor

Breadcrumbs Configuration

Plutonium allows you to control the visibility of breadcrumbs both globally and per page type. The configuration is inheritable, allowing you to set defaults for groups of resources while maintaining the ability to override specific pages when needed.

Usage

class AdminResourceDefinition < Plutonium::Definition::Base
  # Disable breadcrumbs globally for this resource and its subclasses
  breadcrumbs false
end

class UserDefinition < Plutonium::Definition::Base
  # Disable breadcrumbs only for specific pages
  index_page_breadcrumbs false
  new_page_breadcrumbs false
  
  # Other pages will inherit from global setting (default: true)
end

class ProductDefinition < AdminResourceDefinition
  # Override parent's setting for specific pages
  show_page_breadcrumbs true
  edit_page_breadcrumbs true
end

Configuration Options

Setting Description Default
breadcrumbs Global setting for all pages true
index_page_breadcrumbs Control breadcrumbs on index page inherits from breadcrumbs
new_page_breadcrumbs Control breadcrumbs on new record page inherits from breadcrumbs
edit_page_breadcrumbs Control breadcrumbs on edit page inherits from breadcrumbs
show_page_breadcrumbs Control breadcrumbs on show page inherits from breadcrumbs
interactive_action_page_breadcrumbs Control breadcrumbs on interactive action pages inherits from breadcrumbs

Inheritance Rules

  1. Page-specific settings take precedence over the global setting
  2. If a page-specific setting is not defined, it falls back to the global breadcrumbs setting
  3. Both global and page-specific settings are inherited by subclasses
  4. Subclasses can override any setting without affecting the parent class

Examples

Basic Configuration

class ResourceDefinition < Plutonium::Definition::Base
  # Set global default
  breadcrumbs false
end

Mixed Configuration

class ComplexResourceDefinition < Plutonium::Definition::Base
  # Disable globally
  breadcrumbs false
  
  # Enable for specific pages
  show_page_breadcrumbs true
  edit_page_breadcrumbs true
end

Inherited Configuration

# Base admin configuration
class AdminResourceDefinition < Plutonium::Definition::Base
  breadcrumbs false
end

# Inherits no breadcrumbs from AdminResourceDefinition
class UserAdminDefinition < AdminResourceDefinition
  # Override just the show page
  show_page_breadcrumbs true
end

@thedumbtechguy
Copy link
Contributor Author

fixes: #12

@thedumbtechguy thedumbtechguy merged commit a32a03f into master Feb 1, 2025
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant