Skip to content

Commit

Permalink
Overhaul ui-samples as the Jenkins Design Library (#14)
Browse files Browse the repository at this point in the history
Co-authored-by: Alex <brandes.alexander@web.de>
Co-authored-by: Tim Jacomb <21194782+timja@users.noreply.github.com>
Co-authored-by: Tim Jacomb <timjacomb1+github@gmail.com>
  • Loading branch information
4 people authored Mar 29, 2022
1 parent 84aef4e commit 57437b2
Show file tree
Hide file tree
Showing 149 changed files with 2,329 additions and 1,097 deletions.
7 changes: 7 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
root = true

[*.{jelly, js, html, less, css, hbs}]
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
.settings/
.idea/
.DS_Store
*.iml
18 changes: 9 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ THE SOFTWARE.
<relativePath />
</parent>

<groupId>org.jenkins-ci.main</groupId> <!-- historical -->
<artifactId>ui-samples-plugin</artifactId> <!-- historical -->
<groupId>io.jenkins.plugins</groupId>
<artifactId>design-library</artifactId>
<version>${revision}${changelist}</version>
<packaging>hpi</packaging>

<name>Jenkins UI sample plugin</name>
<description>Demonstration of UI controls available in Jenkins based on Stapler, Jelly, Groovy, etc.</description>
<url>https://github.com/ui-samples-plugin</url>
<name>Jenkins Design Library</name>
<description>Demonstration of UI controls available in Jenkins and guidance on how to use them</description>
<url>https://github.com/jenkinsci/ui-samples-plugin</url>

<properties>
<revision>2.1</revision>
<changelist>-SNAPSHOT</changelist>
<gitHubRepo>github.com/ui-samples-plugin</gitHubRepo>
<gitHubRepo>jenkinsci/ui-samples-plugin</gitHubRepo>
<jenkins.version>2.339</jenkins.version>
<java.level>8</java.level>
</properties>
Expand Down Expand Up @@ -90,9 +90,9 @@ THE SOFTWARE.
</build>

<scm>
<connection>scm:git:https://${gitHubRepo}</connection>
<developerConnection>scm:git:https://${gitHubRepo}</developerConnection>
<url>https://${gitHubRepo}</url>
<connection>scm:git:https://github.com/${gitHubRepo}</connection>
<developerConnection>scm:git:https://github.com/${gitHubRepo}</developerConnection>
<url>https://github.com/${gitHubRepo}</url>
<tag>${scmTag}</tag>
</scm>

Expand Down
21 changes: 21 additions & 0 deletions src/main/java/io/jenkins/plugins/designlibrary/AppBar.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package io.jenkins.plugins.designlibrary;

import hudson.Extension;

@Extension
public class AppBar extends UISample {
@Override
public String getDisplayName() {
return "App bars";
}

@Override
public String getIconFileName() {
return "symbol-app-bar";
}

@Extension
public static final class DescriptorImpl extends UISampleDescriptor {
}
}

19 changes: 19 additions & 0 deletions src/main/java/io/jenkins/plugins/designlibrary/Buttons.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package io.jenkins.plugins.designlibrary;

import hudson.Extension;

/**
* @author Kohsuke Kawaguchi
*/
@Extension
public class Buttons extends UISample {
@Override
public String getIconFileName() {
return "symbol-buttons";
}

@Extension
public static final class DescriptorImpl extends UISampleDescriptor {
}
}

19 changes: 19 additions & 0 deletions src/main/java/io/jenkins/plugins/designlibrary/Checkboxes.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package io.jenkins.plugins.designlibrary;

import hudson.Extension;

/**
* @author Kohsuke Kawaguchi
*/
@Extension
public class Checkboxes extends UISample {
@Override
public String getIconFileName() {
return "symbol-checkboxes";
}

@Extension
public static final class DescriptorImpl extends UISampleDescriptor {
}
}

25 changes: 25 additions & 0 deletions src/main/java/io/jenkins/plugins/designlibrary/Colors.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package io.jenkins.plugins.designlibrary;

import hudson.Extension;

import java.util.Arrays;
import java.util.List;

@Extension
public class Colors extends UISample {
@Override
public String getIconFileName() {
return "symbol-colors";
}

public List<String> getColors() {
// Uncomment these once these colors are in core
// return Arrays.asList("red", "green", "orange", "yellow", "blue", "indigo", "violet");
return Arrays.asList("red", "green", "orange");
}

@Extension
public static final class DescriptorImpl extends UISampleDescriptor {
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* THE SOFTWARE.
*/

package jenkins.plugins.ui_samples;
package io.jenkins.plugins.designlibrary;

import com.google.common.collect.ImmutableList;
import hudson.Extension;
Expand All @@ -45,19 +45,10 @@

@Extension public final class HeteroList extends UISample {

@Override public String getDescription() {
return "Show a heterogeneous list of subitems with different data bindings for radio buttons and checkboxes";
}

@Override public List<SourceFile> getSourceFiles() {
return super.getSourceFiles();
// TODO add others
}

@Extension public static final class DescriptorImpl extends UISampleDescriptor {}

public XmlFile getConfigFile() {
return new XmlFile(new File(Jenkins.getInstance().getRootDir(), "stuff.xml"));
return new XmlFile(new File(Jenkins.get().getRootDir(), "stuff.xml"));
}

private Config config;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package io.jenkins.plugins.designlibrary;

import hudson.Extension;

/**
* @author Kohsuke Kawaguchi
*/
@Extension
public class InpageNavigationWithBreadcrumb extends UISample {
@Extension
public static final class DescriptorImpl extends UISampleDescriptor {
}
}


Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package jenkins.plugins.ui_samples;
package io.jenkins.plugins.designlibrary;

import hudson.Extension;
import org.kohsuke.stapler.bind.JavaScriptMethod;
Expand All @@ -12,18 +12,18 @@
@Extension
public class JavaScriptProxy extends UISample {
private int i;

@Override
public String getDescription() {
return "Use JavaScript proxy objects to access server-side Java objects from inside the browser.";
public String getDisplayName() {
return "JavaScript Proxy";
}

/**
* The annotation exposes this method to JavaScript proxy.
*/
@JavaScriptMethod
public int increment(int n) {
return i+=n;
return i += n;
}

@Extension
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package jenkins.plugins.ui_samples;
package io.jenkins.plugins.designlibrary;

import hudson.Extension;
import jenkins.model.ModelObjectWithChildren;
Expand All @@ -10,10 +10,10 @@
* @author Kohsuke Kawaguchi
*/
@Extension
public class NavigationContextMenu extends UISample implements ModelObjectWithContextMenu, ModelObjectWithChildren {
public class Links extends UISample implements ModelObjectWithContextMenu, ModelObjectWithChildren {
@Override
public String getDescription() {
return "Integrate with navigational context menu to provider quick access around object graph";
public String getIconFileName() {
return "symbol-links";
}

/**
Expand All @@ -28,18 +28,18 @@ public ContextMenu doContextMenu(StaplerRequest request, StaplerResponse respons
// otherwise you can also programatically create them.
// see the javadoc for various convenience methods to add items
return new ContextMenu()
.add("http://jenkins-ci.org/","Jenkins project")
.add("http://www.cloudbees.com/","CloudBees")
.add(new MenuItem().withContextRelativeUrl("/").withStockIcon("gear.png").withDisplayName("top page"));
.add(new MenuItem().withContextRelativeUrl("/").withIconClass("icon-up").withDisplayName("Back to Dashboard"))
.add("https://www.jenkins.io/","Jenkins project")
.add("https://plugins.jenkins.io/","Plugin documentation");
}
}

public ContextMenu doChildrenContextMenu(StaplerRequest request, StaplerResponse response) throws Exception {
// You implement this method in much the same way you do doContextMenu
return new ContextMenu()
.add("http://yahoo.com/","Yahoo")
.add("http://google.com/","Google")
.add("http://microsoft.com/","Microsoft");
.add("https://yahoo.com/","Yahoo")
.add("https://google.com/","Google")
.add("https://microsoft.com/","Microsoft");
}

@Extension
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/io/jenkins/plugins/designlibrary/Notifications.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package io.jenkins.plugins.designlibrary;

import hudson.Extension;

/**
* @author Kohsuke Kawaguchi
*/
@Extension
public class Notifications extends UISample {
@Override
public String getIconFileName() {
return "symbol-notifications";
}

@Extension
public static final class DescriptorImpl extends UISampleDescriptor {
}
}


Original file line number Diff line number Diff line change
@@ -1,49 +1,34 @@
/*
* The MIT License
*
* Copyright 2012 Jesse Glick.
*
* 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.ui_samples;
package io.jenkins.plugins.designlibrary;

import hudson.Extension;
import java.util.LinkedList;
import java.util.List;
import jenkins.util.ProgressiveRendering;
import net.sf.json.JSON;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

@Extension
public class ProgressivelyRendered extends UISample {
import java.util.LinkedList;
import java.util.List;

@Override public String getDescription() {
return "Shows how to use progressively rendered content to avoid overloading the server with a slow HTTP request.";
/**
* @author Kohsuke Kawaguchi
*/
@Extension
public class Progress extends UISample {
@Override
public String getIconFileName() {
return "symbol-progress";
}

public ProgressiveRendering factor(final String numberS) {
return new ProgressiveRendering() {
final List<Integer> newFactors = new LinkedList<Integer>();
@Override protected void compute() throws Exception {
int number = Integer.parseInt(numberS); // try entering a nonnumeric value!
int number;
try {
number = Integer.parseInt(numberS); // try entering a nonnumeric value!
} catch (NumberFormatException e) {
number = Integer.MAX_VALUE;
}
// Deliberately inefficient:
for (int i = 1; i <= number; i++) {
if (canceled()) {
Expand Down Expand Up @@ -72,6 +57,7 @@ public ProgressiveRendering factor(final String numberS) {
}

@Extension
public static final class DescriptorImpl extends UISampleDescriptor {}

public static final class DescriptorImpl extends UISampleDescriptor {
}
}

24 changes: 24 additions & 0 deletions src/main/java/io/jenkins/plugins/designlibrary/Radios.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package io.jenkins.plugins.designlibrary;

import hudson.Extension;
import jenkins.model.Jenkins;

import java.util.ArrayList;
import java.util.List;

@Extension
public class Radios extends UISample {
@Override
public String getIconFileName() {
return "symbol-radios";
}

public List<UISample> getRadios() {
return new ArrayList<>(Jenkins.get().getExtensionList(UISample.class)).subList(0, 4);
}

@Extension
public static final class DescriptorImpl extends UISampleDescriptor {
}
}

Loading

0 comments on commit 57437b2

Please sign in to comment.