-
Notifications
You must be signed in to change notification settings - Fork 61
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
SP-62 Feature/product taxon tabs extensibility #274
Merged
Merged
Changes from all commits
Commits
Show all changes
98 commits
Select commit
Hold shift + click to select a range
4002e57
Lay groundwork for order tabs builder
tomdonarski 9ee43d7
Lay groundwork for tab's root item
tomdonarski b90bcb6
Add test for adding to root already appended item
tomdonarski 38fa683
Remove unnecessary tests
tomdonarski 485ee96
Add test for tab class.
tomdonarski cbe0e80
Accommodate text variable in tab class
tomdonarski d0cade7
Facilitate tab url
tomdonarski 941d186
Add partial_name to tabs attributes
tomdonarski 65de37e
Add css classes to tab attributes
tomdonarski 55abda6
Add methods for building particular tabs
tomdonarski 8eca944
Add Proc handling for url attribute
tomdonarski 3370768
Facilitate check for active css class.
tomdonarski a27ea5e
Include module providing availability_check
tomdonarski c47c921
Initialize cart tab
tomdonarski 9e33d66
Build cart tab
tomdonarski 38b2f1c
Fix initialization
tomdonarski 9699a26
Fix - use existing attribute
tomdonarski 413e034
Improve variable naming
tomdonarski 2911f84
Fix test setup
tomdonarski 0a8ffdd
Fix test description
tomdonarski 743a569
Add test for checking if tab is active
tomdonarski 9c988fb
Add method for checking access to class index
tomdonarski 5eebf1c
Populate tab building steps
tomdonarski 94b9950
Unify naming of currently selected partials
tomdonarski d6fd48c
Remove dependency on unnecessary attribute
tomdonarski c93c192
Cleanup test setup
tomdonarski e013c04
Facilitate .complete? check.
tomdonarski 059f77a
Fix variable naming in root
tomdonarski a37a98b
Populate root with tabs.
tomdonarski d35cfff
Fix variable naming
tomdonarski 4563657
Lint fixes
tomdonarski a700610
Lint fixes
tomdonarski 4833d37
Build admin order_tabs upon initialization
tomdonarski 2293024
Use order_tabs defined on boot
tomdonarski 4ac6845
Fix - pass correct argument
tomdonarski 08018a9
Rename text to name
tomdonarski e180d72
Incorporate translators
tomdonarski c6e0a7b
Use path instead of url
tomdonarski f1828e3
Fix appending css active class
tomdonarski 6bb3ddf
Migrate user tabs from view to separate class
tomdonarski e65ea17
Migrate product tabs from view to separate class
tomdonarski 5cc8bc3
Disable variables set up in the engine
tomdonarski 57af58a
Move attributes to config.
tomdonarski a60a413
Adjust default tab builders to use config
tomdonarski e44c65d
Change back partial current attribute
tomdonarski 5b001f1
Supply configs in builders with partial_name
tomdonarski f845daf
Fix active check to use partial_name.
tomdonarski 235fb56
Enable variables set up in the engine
tomdonarski 2e48d2e
Lint fix
tomdonarski 7c8c182
Lint fixes
tomdonarski 50f449e
Use global scope
tomdonarski 9ad49dd
Refactor order_tabs_builder
tomdonarski 109faee
Refactor product_tabs_builder.
tomdonarski 3a6ad94
Disable class length cop
tomdonarski 3fb2c43
Add missing data_hook attribute
tomdonarski 759fce6
Use more descriptive namespace
tomdonarski 4ca9106
Group tabs together in the app config
tomdonarski 1569d11
Embed default translation mechanism in tab
tomdonarski 5e923d8
Remove custom translations
tomdonarski 31d41c3
Add missing .complete? checks
tomdonarski 934e845
Introduce TabBuilder.
tomdonarski 3b36fb9
Fix .complete? check
tomdonarski 57e054f
Lint fix
tomdonarski e489e1a
Improve formatting
tomdonarski 6c2f96c
Remove unnecessary test
tomdonarski 6d34140
Cleanup tab test
tomdonarski 94b4157
Refactor test to meet rubocop expectations
tomdonarski 68026ae
Spell fix
tomdonarski b7903a3
Add missing tests
tomdonarski 2075114
Adhere to naming convention in tests
tomdonarski 63e847e
Cleanup - remove superfluous method
tomdonarski dbccb04
Rename an attribute
tomdonarski 474be4c
Fix spec after renaming an attribute
tomdonarski 927d42f
Create common abstraction for
tomdonarski c47e0ec
Add missing test
tomdonarski 60db052
Remove superfluous methods
tomdonarski 4902cff
Abstract away #child_with_key? method
tomdonarski c354d4a
Simplify setup
tomdonarski 699e886
Abstract away #remove method
tomdonarski 25f6970
Abstract away #item_for_key method
tomdonarski c6d901a
Abstract away #insert_before method
tomdonarski af2e2fa
Abstract away #insert_after method
tomdonarski 8430877
Remove superfluous method
tomdonarski b1c9aeb
Equalize spec setup
tomdonarski 57d6c65
Remove superfluous test
tomdonarski f19f5d9
Equalize root specs
tomdonarski b458feb
Introduce a shared abstraction for ability checks
tomdonarski 40a4e5e
Lint fix
tomdonarski e198cb6
Abstract away common tests to shared examples
tomdonarski 3af140a
Remove tab css data from configuration,
tomdonarski 35a3b96
Fix spec.
tomdonarski 0c66363
Move 'add' method to a separate module,
tomdonarski 925e58d
Split shared examples
tomdonarski a7fdd65
Include item appendage module in Root and Section
tomdonarski 763aad1
Contain all item manipulation behaviour
tomdonarski c55de0a
Add back deleted method
tomdonarski b2e42db
Add missing spec for 'add_to_section'
tomdonarski 21e4db5
Lint fix
tomdonarski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
module Spree | ||
module Admin | ||
module ItemManager | ||
def add(item) | ||
raise KeyError, "Item with key #{item.key} already exists" if index_for_key(item.key) | ||
|
||
@items << item | ||
end | ||
|
||
def child_with_key?(key) | ||
index_for_key(key).present? | ||
end | ||
|
||
def remove(item_key) | ||
item_index = index_for_key!(item_key) | ||
|
||
@items.delete_at(item_index) | ||
end | ||
|
||
def item_for_key(key) | ||
@items.find { |e| e.key == key } | ||
end | ||
|
||
def insert_before(item_key, item_to_add) | ||
item_index = index_for_key!(item_key) | ||
|
||
@items.insert(item_index, item_to_add) | ||
end | ||
|
||
def insert_after(item_key, item_to_add) | ||
item_index = index_for_key!(item_key) | ||
|
||
@items.insert(item_index + 1, item_to_add) | ||
end | ||
|
||
private | ||
|
||
def index_for_key(key) | ||
@items.index { |e| e.key == key } | ||
end | ||
|
||
def index_for_key!(key) | ||
item_index = index_for_key(key) | ||
raise KeyError, "Item not found for key #{key}" unless item_index | ||
|
||
item_index | ||
end | ||
end | ||
end | ||
end |
22 changes: 0 additions & 22 deletions
22
app/models/spree/admin/main_menu/availability_builder_methods.rb
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
module Spree | ||
module Admin | ||
module PermissionChecks | ||
def with_availability_check(availability_check) | ||
@availability_check = availability_check | ||
self | ||
end | ||
|
||
def with_manage_ability_check(*classes) | ||
@availability_check = ->(ability, _current) { classes.any? { |c| ability.can?(:manage, c) } } | ||
self | ||
end | ||
|
||
def with_admin_ability_check(*classes) | ||
@availability_check = ->(ability, _current) { classes.any? { |c| ability.can?(:admin, c) } } | ||
self | ||
end | ||
|
||
def with_index_ability_check(*classes) | ||
@availability_check = ->(ability, _current) { classes.any? { |c| ability.can?(:index, c) } } | ||
self | ||
end | ||
|
||
def with_update_ability_check | ||
@availability_check = ->(ability, resource) { ability.can?(:update, resource) } | ||
self | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module Spree | ||
module Admin | ||
module Tabs | ||
module ConditionalChecker | ||
def with_active_check | ||
@active_check = ->(current_tab, text) { current_tab == text } | ||
self | ||
end | ||
|
||
def with_completed_check | ||
@completed_check = ->(resource) { resource.completed? } | ||
self | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module Spree | ||
module Admin | ||
module Tabs | ||
module DataHook | ||
def with_data_hook(data_hook) | ||
@data_hook = data_hook | ||
self | ||
end | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This hasn't been used anywhere. Moreover,
add_item
is not defined anywhere. Even if it's a typo, and should beadd_item
the whole does whatadd
method (defined inSection
class) does.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not used in our code, because it's a method for extension developers who need to add a custom item to the admin panel main menu. That's not a reason to delete it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may have missed a test for this one, but let's just fix the implementation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added it back, and wrote a test for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect, thanks!