-
Notifications
You must be signed in to change notification settings - Fork 50
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
Hide tab-panels if project is on whitelist #59
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,8 @@ | |
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import static org.apache.commons.collections.CollectionUtils.isEmpty; | ||
|
||
/** | ||
* An {@link IssueTabPanel2 issue tab panel} for displaying all Gerrit code reviews related to this | ||
* issue. | ||
|
@@ -94,6 +96,9 @@ public ShowPanelReply showPanel(ShowPanelRequest arg0) { | |
isShowing = false; | ||
} | ||
|
||
if (configuration.getUseGerritProjectWhitelist() && ! isGerritProject(arg0.issue())) | ||
isShowing = false; | ||
|
||
return ShowPanelReply.create(isShowing); | ||
} | ||
|
||
|
@@ -166,4 +171,12 @@ private void setUsersForChangeApprovals(GerritChange change) { | |
} | ||
} | ||
} | ||
|
||
private boolean isGerritProject(final Issue issue) { | ||
if (issue.getProjectId() == null) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and here |
||
return false; | ||
|
||
return !isEmpty(configuration.getIdsOfKnownGerritProjects()) && | ||
configuration.getIdsOfKnownGerritProjects().contains(issue.getProjectId().toString()); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,8 @@ | |
import com.meetme.plugins.jira.gerrit.data.dto.GerritChange; | ||
import com.sonyericsson.hudson.plugins.gerrit.gerritevents.GerritQueryException; | ||
|
||
import static org.apache.commons.collections.CollectionUtils.isEmpty; | ||
|
||
public class SubtaskReviewsTabPanel extends AbstractIssueTabPanel2 implements IssueTabPanel2 { | ||
private final GerritConfiguration configuration; | ||
private final IssueReviewsManager reviewsManager; | ||
|
@@ -66,6 +68,9 @@ public ShowPanelReply showPanel(ShowPanelRequest request) { | |
if (isConfigurationReady()) { | ||
Collection<Issue> subtasks = request.issue().getSubTaskObjects(); | ||
show = subtasks != null && subtasks.size() > 0; | ||
|
||
if (configuration.getUseGerritProjectWhitelist() && ! isGerritProject(request.issue())) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here |
||
show = false; | ||
} | ||
|
||
return ShowPanelReply.create(show); | ||
|
@@ -81,4 +86,12 @@ private boolean isConfigurationReady() { | |
return configuration != null && configuration.getSshHostname() != null && configuration.getSshUsername() != null | ||
&& configuration.getSshPrivateKey() != null && configuration.getSshPrivateKey().exists(); | ||
} | ||
|
||
private boolean isGerritProject(final Issue issue) { | ||
if (issue.getProjectId() == null) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and here |
||
return false; | ||
|
||
return !isEmpty(configuration.getIdsOfKnownGerritProjects()) && | ||
configuration.getIdsOfKnownGerritProjects().contains(issue.getProjectId().toString()); | ||
} | ||
} |
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.
Please follow surrounding code styles: braces around multi-line if blocks, and no space after
!