-
Notifications
You must be signed in to change notification settings - Fork 436
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use a decorator for determining tab visibility
- Loading branch information
1 parent
8fd9f75
commit 6f1561b
Showing
9 changed files
with
58 additions
and
16 deletions.
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
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,31 @@ | ||
class BsRequestActionTabVisibility | ||
CHANGES_TABS = [:submit, :maintenance_incident, :maintenance_release].freeze | ||
|
||
def initialize(bs_request_action) | ||
@action = bs_request_action | ||
end | ||
|
||
# Handle tabs visibility | ||
def visible(tab_name) | ||
case tab_name | ||
when :build_results, :rpm_lint | ||
source_package && !patchinfo_package | ||
when :changes | ||
(@action.type == :delete && @action.source_package) || @action.type.in?(CHANGES_TABS) | ||
when :mentioned_issues | ||
@action.type.in?(CHANGES_TABS) | ||
else | ||
true | ||
end | ||
end | ||
|
||
private | ||
|
||
def patchinfo_package | ||
@action.type.in?([:maintenance_incident, :maintenance_release]) && @action.source_package == 'patchinfo' | ||
end | ||
|
||
def source_package | ||
@action.source_project && @action.source_package | ||
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
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