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

feature: add visible option to tab #3017

Merged
merged 1 commit into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/avo/resources/items/tab.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class Avo::Resources::Items::Tab
include Avo::Concerns::HasItems
include Avo::Concerns::HasItemType
include Avo::Concerns::VisibleItems
include Avo::Concerns::IsVisible
include Avo::Concerns::VisibleInDifferentViews

delegate :items, :add_item, to: :items_holder
Expand All @@ -16,6 +17,7 @@ def initialize(name: nil, description: nil, view: nil, **args)
@items_holder = Avo::Resources::Items::Holder.new
@view = Avo::ViewInquirer.new view
@args = args
@visible = args[:visible]

post_initialize if respond_to?(:post_initialize)
end
Expand Down
10 changes: 10 additions & 0 deletions spec/features/avo/tabs_panels_and_sidebar_visibility_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
}
end
end

tab "Conditional hidden tab inside tabs", visible: -> { resource.record.name == "RSpec TabsPanelAndSidebarVisibility" } do
field :hidden_field_inside_tabs_inside_conditional_tab, as: :text
end
end
end
end
Expand All @@ -60,6 +64,9 @@
expect(page).to have_text "Hidden field inside tabs inside tab"
expect(page).to have_text "Hidden field inside tabs inside tab inside panel"
expect(page).to have_text "Hidden field inside sidebar"

expect(page).to have_text "Conditional hidden tab inside tabs"
expect(page).to have_text "Hidden field inside tabs inside conditional tab"
end
end

Expand All @@ -71,6 +78,9 @@
expect(page).not_to have_text "Hidden field inside tabs inside tab"
expect(page).not_to have_text "Hidden field inside tabs inside tab inside panel"
expect(page).not_to have_text "Hidden field inside sidebar"

expect(page).not_to have_text "Conditional hidden tab inside tabs"
expect(page).not_to have_text "Hidden field inside tabs inside conditional tab"
end
end
end
Expand Down
Loading