Skip to content

Commit

Permalink
- correction of availability of script that was buggy (never false, n…
Browse files Browse the repository at this point in the history
…ot used in merge, not used in constructor)

- reorder toolbar icons / actions + consistent spacing + more information
  • Loading branch information
Wadeck committed Feb 13, 2018
1 parent 8589a22 commit b7316e4
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 35 deletions.
7 changes: 7 additions & 0 deletions src/main/java/org/jenkinsci/plugins/scriptler/SyncUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ public static void syncDirWithCfg(File scriptDirectory, ScriptlerConfiguration c
} else {
unavailableScripts.add(new Script(s.getId(), s.comment, false, false, false));
LOGGER.info("for repo '" + scriptDirectory.getAbsolutePath() + "' " + s + " is not available!");


// Script unavailableScript = new Script(s.getId(), s.getName(), s.comment, false, s.getParameters(), false);
// unavailableScript.setAvailable(false);
//
// unavailableScripts.add(unavailableScript);
// LOGGER.info("for repo '" + scriptDirectory.getAbsolutePath() + "' " + s + " is not available!");
}
}

Expand Down
18 changes: 10 additions & 8 deletions src/main/java/org/jenkinsci/plugins/scriptler/config/Script.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,38 +52,40 @@ public class Script implements Comparable<Script>, NamedResource {
* used to create/update a new script in the UI
*/
public Script(String id, String name, String comment, boolean nonAdministerUsing, Parameter[] parameters, boolean onlyMaster) {
this(id, name, comment, null, null, null, nonAdministerUsing, parameters, onlyMaster);
this(id, name, comment, true, null, null, null, nonAdministerUsing, parameters, onlyMaster);
}

/**
* used during plugin start to synchronize available scripts
*/
public Script(String id, String comment, boolean available, boolean nonAdministerUsing, boolean onlyMaster) {
this(id, id, comment, null, null, null, nonAdministerUsing, new Parameter[0], onlyMaster);
this(id, id, comment, available, null, null, null, nonAdministerUsing, new Parameter[0], onlyMaster);
}

/**
* Constructor to create a script imported from a foreign catalog.
*
*/
public Script(String id, String name, String comment, boolean available, String originCatalog, String originScript, String originDate, Parameter[] parameters) {
this(id, name, comment, originCatalog, originScript, originDate, false, parameters, false);
this(id, name, comment, available, originCatalog, originScript, originDate, false, parameters, false);
}

// Not used anymore
/**
* used to merge scripts
*/
public Script(String id, String name, String comment, boolean available, String originCatalog, String originScript, String originDate, boolean nonAdministerUsing, Parameter[] parameters, boolean onlyMaster) {
this(id, name, comment, originCatalog, originScript, originDate, nonAdministerUsing, parameters, onlyMaster);
public Script(String id, String name, String comment, String originCatalog, String originScript, String originDate, boolean nonAdministerUsing, Parameter[] parameters, boolean onlyMaster) {
this(id, name, comment, true, originCatalog, originScript, originDate, nonAdministerUsing, parameters, onlyMaster);
}

/**
* used to merge scripts
*/
public Script(String id, String name, String comment, String originCatalog, String originScript, String originDate, boolean nonAdministerUsing, Parameter[] parameters, boolean onlyMaster) {
public Script(String id, String name, String comment, boolean available, String originCatalog, String originScript, String originDate, boolean nonAdministerUsing, Parameter[] parameters, boolean onlyMaster) {
this.id = id;
this.name = name;
this.comment = comment;
this.available = available;
this.originCatalog = originCatalog;
this.originScript = originScript;
this.originDate = originDate;
Expand All @@ -93,7 +95,7 @@ public Script(String id, String name, String comment, String originCatalog, Stri
}

public Script copy() {
return new Script(id, name, comment, originCatalog, originScript, originDate, nonAdministerUsing, parameters, onlyMaster);
return new Script(id, name, comment, available, originCatalog, originScript, originDate, nonAdministerUsing, parameters, onlyMaster);
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public class ScriptHelper {
String src = IOUtils.toString(reader);
s.setScript(src);
} catch (IOException e) {
LOGGER.log(Level.SEVERE, Messages.scriptSourceNotFound(id), e);
LOGGER.log(Level.SEVERE, Messages.scriptSourceNotFound(id));
}
}
return s;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,47 +38,42 @@
<j:set var="approved" value="${i.approved}" />
<j:set var="t" value="${i.script}" />
<tr valign="center" style="border-top: 0px;">
<td class="pane scriptler-nowrap" width="104">
<td class="pane scriptler-toolbar" width="1%">
<j:choose>
<j:when test="${approved == null}">
<img width="16" height="16" title="${%scriptNotFound}" src="${imagesURL}/16x16/warning.png" class="scriptler-nomargin" />
<img width="16" height="16" title="${%fileNotAvailable}" src="${imagesURL}/16x16/red.gif" class="scriptler-icon-slot-first" />
</j:when>
<j:when test="${approved == true}">
<img width="16" height="16" title="${%scriptApproved}" src="${imagesURL}/16x16/accept.png" class="scriptler-nomargin" />
<img width="16" height="16" title="${%scriptApproved}" src="${imagesURL}/16x16/accept.png" class="scriptler-icon-slot-first" />
</j:when>
<j:otherwise>
<img width="16" height="16" title="${%scriptNotYetApproved}" src="${imagesURL}/16x16/lock.png" class="scriptler-nomargin"/>
<img width="16" height="16" title="${%scriptNotYetApproved}" src="${imagesURL}/16x16/warning.png" class="scriptler-icon-slot-first"/>
</j:otherwise>
</j:choose>
<j:choose>
<j:when test="${t.available == false}">
<img width="16" height="16" title="${%fileNotAvailable}" src="${imagesURL}/16x16/red.gif" class="scriptler-nomargin" />
<j:when test="${t.nonAdministerUsing}">
<img width="16" height="16" title="${%usableInBuildStep}" src="${imagesURL}/16x16/setting.png" class="scriptler-icon-slot" />
</j:when>
<j:otherwise>
<img width="16" height="16" src="${imagesURL}/16x16/empty.gif" class="scriptler-nomargin"/>
<img width="16" height="16" title="${%notUsableInBuildStep}" src="${imagesURL}/16x16/lock.png" class="scriptler-icon-slot" />
</j:otherwise>
</j:choose>
<l:hasPermission permission="${it.scriptlerRunScripts}">
<a href="runScript?id=${t.id}" class="scriptler-icon-slot">
<img width="16" height="16" title="${%run script} ${t.name}" src="${imagesURL}/16x16/terminal.gif" />
</a>
</l:hasPermission>
<l:hasPermission permission="${it.scriptlerConfigure}">
<a href="editScript?id=${t.id}" class="scriptler-link-button">
<a href="editScript?id=${t.id}" class="scriptler-link-button scriptler-icon-slot">
<img width="16" height="16" title="${%edit script} ${t.name}" src="${imagesURL }/16x16/document_edit.gif" />
</a>
<j:out value=" " />
<form method="post" action="removeScript" class="scriptler-inline" onclick="return confirmDelete('${t.name}')">
<form method="post" action="removeScript" class="scriptler-inline scriptler-icon-slot" onclick="return confirmDelete('${t.name}')">
<input type="hidden" name="id" value="${t.id}" />
<button type="submit" name="submit_param" value="submit_value" class="scriptler-link-button">
<img width="16" height="16" title="${%remove script} ${t.name}" src="${imagesURL}/16x16/edit-delete.gif" />
</button>
</form>
</l:hasPermission>
<l:hasPermission permission="${it.scriptlerRunScripts}">
<a href="runScript?id=${t.id}">
<img width="16" height="16" title="${%run script} ${t.name}" src="${imagesURL}/16x16/terminal.gif" />
</a>
</l:hasPermission>
<j:if test="${t.nonAdministerUsing}">
<j:out value=" " />
<img width="16" height="16" title="${%usableInBuildStep}" src="${imagesURL}/16x16/setting.png" />
</j:if>
</td>
<td class="pane-header">
${t.name}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ scriptdirectorytext=The scripts are saved at:
fileNotAvailable=This file is physically not available on the system.
noScriptsAvailable=Currently you do not have any scripts available. You can import scripts from a remote catalog or create your own.
usableInBuildStep=allowed to be used in Scriptler build step
scriptNotFound=Script not found
notUsableInBuildStep=not allowed to be used in Scriptler build step
scriptApproved=Script approved
scriptNotYetApproved=Script not yet approved, consider asking an administrator to approve it before use
12 changes: 6 additions & 6 deletions src/main/webapp/scriptler.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
color:red;
}

.scriptler-nowrap {
.scriptler-toolbar {
white-space: nowrap;
}

.scriptler-nowrap img {
margin-left: 5px;
.scriptler-toolbar .scriptler-icon-slot-first {
margin-left: 0px;
}

.scriptler-nowrap img.scriptler-nomargin {
margin-left: 0;
}
.scriptler-toolbar .scriptler-icon-slot {
margin-left: 8px;
}

0 comments on commit b7316e4

Please sign in to comment.