-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new set of OpenSource icon using
oss-symbols-api-plugin
(#373)
- Loading branch information
Showing
14 changed files
with
432 additions
and
0 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
95 changes: 95 additions & 0 deletions
95
src/main/java/jenkins/plugins/foldericon/OpenSourceFolderIcon.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,95 @@ | ||
/* | ||
* The MIT License | ||
* | ||
* Copyright (c) 2024 | ||
* | ||
* 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 jenkins.plugins.foldericon; | ||
|
||
import com.cloudbees.hudson.plugins.folder.AbstractFolder; | ||
import com.cloudbees.hudson.plugins.folder.FolderIcon; | ||
import com.cloudbees.hudson.plugins.folder.FolderIconDescriptor; | ||
import edu.umd.cs.findbugs.annotations.NonNull; | ||
import hudson.Extension; | ||
import io.jenkins.plugins.oss.symbols.OpenSourceSymbols; | ||
import jenkins.model.Jenkins; | ||
import org.apache.commons.lang.StringUtils; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
|
||
/** | ||
* An Open Source Folder Icon. | ||
*/ | ||
public class OpenSourceFolderIcon extends FolderIcon { | ||
|
||
private static final String DEFAULT_ICON = "cdf-icon-color"; | ||
|
||
private final String ossicon; | ||
|
||
private AbstractFolder<?> owner; | ||
|
||
@DataBoundConstructor | ||
public OpenSourceFolderIcon(String ossicon) { | ||
this.ossicon = StringUtils.isEmpty(ossicon) ? DEFAULT_ICON : ossicon; | ||
} | ||
|
||
@Override | ||
protected void setOwner(AbstractFolder<?> folder) { | ||
this.owner = folder; | ||
} | ||
|
||
public String getOssicon() { | ||
return ossicon; | ||
} | ||
|
||
@Override | ||
public String getImageOf(String size) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String getIconClassName() { | ||
return OpenSourceSymbols.getIconClassName(getOssicon()); | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
if (owner != null) { | ||
return owner.getPronoun(); | ||
} else { | ||
return Messages.Folder_description(); | ||
} | ||
} | ||
|
||
@Override | ||
public DescriptorImpl getDescriptor() { | ||
return (DescriptorImpl) Jenkins.get().getDescriptorOrDie(getClass()); | ||
} | ||
|
||
@Extension | ||
public static class DescriptorImpl extends FolderIconDescriptor { | ||
|
||
@Override | ||
@NonNull | ||
public String getDisplayName() { | ||
return Messages.OpenSourceFolderIcon_description(); | ||
} | ||
} | ||
} |
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
45 changes: 45 additions & 0 deletions
45
src/main/resources/jenkins/plugins/foldericon/OpenSourceFolderIcon/config.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,45 @@ | ||
<!-- | ||
The MIT License | ||
Copyright (c) 2024 | ||
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. | ||
--> | ||
|
||
<?jelly escape-by-default='true'?> | ||
<j:jelly xmlns:j="jelly:core" xmlns:l="/lib/layout" xmlns:f="/lib/form"> | ||
<link rel="stylesheet" href="${rootURL}/plugin/custom-folder-icon/css/oss.css" type="text/css" /> | ||
<script src="${rootURL}/plugin/custom-folder-icon/js/oss-config.js" type="text/javascript" /> | ||
<j:invokeStatic var="openSourceIcons" method="getAvailableIcons" className="io.jenkins.plugins.oss.symbols.OpenSourceSymbols" /> | ||
<f:entry title="${%IconPreview}" help="${descriptor.getHelpFile('preview')}"> | ||
<l:icon id="oss-preview" src="${openSourceIcons.get(instance.ossicon ?: 'cdf-icon-color')}" title="${icon.key}" | ||
class="icon-xlg" /> | ||
</f:entry> | ||
<f:advanced title="${%AvailableIcons}${not empty openSourceIcons ? ' (' + openSourceIcons.size() + ')' : ''}"> | ||
<j:forEach var="icon" items="${openSourceIcons}"> | ||
<a id="select-oss-${icon.key}" class="oss-icon-selection" onclick="setOpenSourceIcon('${icon.key}')"> | ||
<l:icon id="oss-icon-${icon.key}" src="${icon.value}" title="${icon.key}" tooltip="${icon.key}" | ||
class="icon-md" /> | ||
</a> | ||
</j:forEach> | ||
</f:advanced> | ||
<f:entry field="ossicon"> | ||
<f:textbox id="oss-icon-name" value="${instance.ossicon}" clazz="oss-icon-name" /> | ||
</f:entry> | ||
</j:jelly> |
24 changes: 24 additions & 0 deletions
24
src/main/resources/jenkins/plugins/foldericon/OpenSourceFolderIcon/config.properties
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,24 @@ | ||
# The MIT License | ||
# | ||
# Copyright (c) 2024 | ||
# | ||
# 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. | ||
|
||
IconPreview=Icon preview | ||
AvailableIcons=Show all available icons |
27 changes: 27 additions & 0 deletions
27
src/main/resources/jenkins/plugins/foldericon/OpenSourceFolderIcon/help-preview.html
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,27 @@ | ||
<!-- | ||
The MIT License | ||
Copyright (c) 2024 | ||
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. | ||
--> | ||
|
||
<div> | ||
Use OpenSource tools icons provided by <a href="https://github.com/jenkinsci/oss-symbols-api-plugin" target="_blank">OSS Symbols API Plugin</a> as icon. | ||
</div> |
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,33 @@ | ||
/* | ||
* The MIT License | ||
* | ||
* Copyright (c) 2024 | ||
* | ||
* 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. | ||
*/ | ||
|
||
.oss-icon-name { | ||
display: none; | ||
} | ||
|
||
.oss-icon-selection { | ||
color: unset; | ||
cursor: pointer; | ||
text-decoration: none !important; | ||
} |
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,42 @@ | ||
/* | ||
* The MIT License | ||
* | ||
* Copyright (c) 2024 | ||
* | ||
* 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. | ||
*/ | ||
|
||
function setOpenSourceIcon(icon) { | ||
if (icon == null || icon === "") { | ||
return; | ||
} | ||
|
||
let iconName = document.getElementById("oss-icon-name"); | ||
iconName.setAttribute("value", icon); | ||
iconName.dispatchEvent(new Event("input")); | ||
|
||
let oldPreview = document.getElementById("oss-preview"); | ||
let selectedIcon = document.getElementById("oss-icon-" + icon); | ||
|
||
let newPreview = selectedIcon.cloneNode(true); | ||
newPreview.id = "oss-preview"; | ||
newPreview.classList.replace("icon-md", "icon-xlg"); | ||
|
||
oldPreview.parentElement.replaceChild(newPreview, oldPreview); | ||
} |
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
Oops, something went wrong.