Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[JENKINS-39062] Move the GitHubRepositoryDescription column to github…
… branch source
- Loading branch information
Showing
6 changed files
with
225 additions
and
0 deletions.
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubOrgAction.java
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,69 @@ | ||
/* | ||
* The MIT License | ||
* | ||
* Copyright 2016 CloudBees, Inc. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
|
||
package org.jenkinsci.plugins.github_branch_source; | ||
|
||
import hudson.model.InvisibleAction; | ||
import java.io.IOException; | ||
import java.net.URL; | ||
import jenkins.branch.OrganizationFolder; | ||
import org.kohsuke.github.GHUser; | ||
|
||
/** | ||
* Invisible {@link OrganizationFolder} property that | ||
* retains information about GitHub organization. | ||
* | ||
* @author Kohsuke Kawaguchi | ||
*/ | ||
public class GitHubOrgAction extends InvisibleAction { | ||
private final URL url; | ||
private final String name; | ||
private final String avatar; | ||
|
||
public GitHubOrgAction(GHUser org) throws IOException { | ||
this(org.getHtmlUrl(), org.getName(), org.getAvatarUrl()); | ||
} | ||
|
||
public GitHubOrgAction(URL url, String name, String avatar) { | ||
this.url = url; | ||
this.name = name; | ||
this.avatar = avatar; | ||
} | ||
|
||
public GitHubOrgAction(GitHubOrgAction that) { | ||
this(that.getUrl(), that.getName(), that.getAvatar()); | ||
} | ||
|
||
public URL getUrl() { | ||
return url; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public String getAvatar() { | ||
return avatar; | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubRepoAction.java
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,68 @@ | ||
/* | ||
* The MIT License | ||
* | ||
* Copyright 2016 CloudBees, Inc. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
|
||
package org.jenkinsci.plugins.github_branch_source; | ||
|
||
import hudson.model.InvisibleAction; | ||
import java.net.URL; | ||
import jenkins.branch.MultiBranchProject; | ||
import org.kohsuke.github.GHRepository; | ||
|
||
/** | ||
* Invisible property on {@link MultiBranchProject} | ||
* that retains information about GitHub repository. | ||
* | ||
* @author Kohsuke Kawaguchi | ||
*/ | ||
public class GitHubRepoAction extends InvisibleAction { | ||
private final URL url; | ||
private final String description; | ||
private final String homepage; | ||
|
||
public GitHubRepoAction(GHRepository repo) { | ||
this(repo.getHtmlUrl(), repo.getDescription(), repo.getHomepage()); | ||
} | ||
|
||
public GitHubRepoAction(URL url, String description, String homepage) { | ||
this.url = url; | ||
this.description = description; | ||
this.homepage = homepage; | ||
} | ||
|
||
public GitHubRepoAction(GitHubRepoAction that) { | ||
this(that.getUrl(), that.getDescription(), that.getHomepage()); | ||
} | ||
|
||
public URL getUrl() { | ||
return url; | ||
} | ||
|
||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
public String getHomepage() { | ||
return homepage; | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
...in/java/org/jenkinsci/plugins/github_branch_source/GitHubRepositoryDescriptionColumn.java
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,67 @@ | ||
/* | ||
* The MIT License | ||
* | ||
* Copyright 2016 CloudBees, Inc. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
|
||
package org.jenkinsci.plugins.github_branch_source; | ||
|
||
import hudson.Extension; | ||
import hudson.model.Item; | ||
import hudson.model.Job; | ||
import hudson.views.ListViewColumn; | ||
import hudson.views.ListViewColumnDescriptor; | ||
import org.kohsuke.accmod.Restricted; | ||
import org.kohsuke.accmod.restrictions.NoExternalUse; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
|
||
/** | ||
* {@link ListViewColumn} that shows the description text of repository. | ||
* | ||
* @author Kohsuke Kawaguchi | ||
*/ | ||
public class GitHubRepositoryDescriptionColumn extends ListViewColumn { | ||
@DataBoundConstructor | ||
public GitHubRepositoryDescriptionColumn() { | ||
} | ||
|
||
@Restricted(NoExternalUse.class) | ||
@SuppressWarnings("unused") // used via Jelly EL binding | ||
public GitHubRepoAction getRepositoryOf(Item item) { | ||
if (item instanceof Job) { | ||
return ((Job) item).getAction(GitHubRepoAction.class); | ||
} | ||
return null; | ||
} | ||
|
||
@Extension | ||
public static class DescriptorImpl extends ListViewColumnDescriptor { | ||
@Override | ||
public String getDisplayName() { | ||
return Messages.GitHubRepositoryDescriptionColumn_DisplayName(); | ||
} | ||
|
||
@Override | ||
public boolean shownByDefault() { | ||
return false; | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...org/jenkinsci/plugins/github_branch_source/GitHubRepositoryDescriptionColumn/column.jelly
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,15 @@ | ||
<?jelly escape-by-default='true'?> | ||
<j:jelly xmlns:j="jelly:core"> | ||
<td> | ||
<j:set var="p" value="${col.getRepositoryOf(job)}"/> | ||
<j:choose> | ||
<j:when test="${p != null and p.homepage != null"> | ||
<a href="${p.homepage}">${p.description}</a> | ||
</j:when> | ||
<j:when test="${p != null and p.homepage == null}"> | ||
${p.description} | ||
</j:when> | ||
<j:otherwise/> | ||
</j:choose> | ||
</td> | ||
</j:jelly> |
4 changes: 4 additions & 0 deletions
4
...nkinsci/plugins/github_branch_source/GitHubRepositoryDescriptionColumn/columnHeader.jelly
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,4 @@ | ||
<?jelly escape-by-default='true'?> | ||
<j:jelly xmlns:j="jelly:core"> | ||
<th>${%Description}</th> | ||
</j:jelly> |
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