Skip to content

Commit 7a09145

Browse files
author
Phillip Elliott
committed
Add warning when the source and tool output inputs are blank
1 parent e67a0e9 commit 7a09145

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

codedx-teamcity-plugin-common/src/main/java/com/avi/codedx/common/CodeDxConstants.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ public final class CodeDxConstants {
1717
public static final String SETTINGS_SHA1_FINGERPRINT_KEY = "codedx.sha1Fingerprint";
1818
public static final String SETTINGS_WAIT_FOR_RESULTS_KEY = "codedx.waitForResults";
1919
public static final String SETTINGS_REPORT_ARCHIVE_NAME_KEY = "codedx.reportArchiveName";
20+
public static final String SETTINGS_SOURCE_AND_BINARIES_WARNING_KEY = "codedx.sourceAndBinariesWarning";
21+
public static final String SETTINGS_TOOL_OUTPUTS_WARNING_KEY = "codedx.toolOutputsWarning";
2022

2123
public static final String CRITICAL = "Critical";
2224
public static final String HIGH = "High";

codedx-teamcity-plugin-server/src/main/java/com/avi/codedx/server/CodeDxConstantsBean.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,14 @@ public String getWaitForResultsKey() {
7373
public String getReportArchiveNameKey() {
7474
return CodeDxConstants.SETTINGS_REPORT_ARCHIVE_NAME_KEY;
7575
}
76+
77+
@NotNull
78+
public String getSourceAndBinariesWarningKey() {
79+
return CodeDxConstants.SETTINGS_SOURCE_AND_BINARIES_WARNING_KEY;
80+
}
81+
82+
@NotNull
83+
public String getToolOutputsWarningKey() {
84+
return CodeDxConstants.SETTINGS_TOOL_OUTPUTS_WARNING_KEY;
85+
}
7686
}

codedx-teamcity-plugin-server/src/main/resources/buildServerResources/editCodeDxParams.jsp

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,11 @@
6767
<td>
6868
<span>
6969
<props:textProperty name="${constants.filesKey}" className="longField"></props:textProperty>
70+
<span class="smallNote">Files relative to the working directory to zip and upload to Code Dx. Separate multiple files with a comma (,)</span>
71+
</span>
72+
<span>
73+
<span class="error" id="${constants.sourceAndBinariesWarningKey}">Warning: No source and binaries specified</span>
7074
</span>
71-
<span class="smallNote">Files relative to the working directory to zip and upload to Code Dx. Separate multiple files with a comma (,)</span>
7275
</td>
7376
</tr>
7477
<tr class="advancedSetting">
@@ -91,6 +94,9 @@
9194
<props:textProperty name="${constants.toolOutputFilesKey}" className="longField"></props:textProperty>
9295
<span class="smallNote">File paths can be absolute or relative to the working directory. Separate multiple files with a comma (,)</span>
9396
</span>
97+
<span>
98+
<span class="error" id="${constants.toolOutputsWarningKey}">Warning: No tool output files specified</span>
99+
</span>
94100
</td>
95101
</tr>
96102
<tr>
@@ -252,12 +258,25 @@
252258
});
253259
}
254260
261+
function displayFileWarning($textBox, $warningLabel) {
262+
var textValue = BS.Util.trimSpaces($textBox.val());
263+
if(textValue) {
264+
$warningLabel.hide();
265+
} else {
266+
$warningLabel.show();
267+
}
268+
}
269+
255270
$j(function() {
256271
var isWaitForResults = $('codedx.waitForResults').checked;
257272
var $url = $j(BS.Util.escapeId('${constants.codeDxUrlKey}'));
258273
var $apiToken = $j(BS.Util.escapeId('${constants.codeDxAPITokenKey}'));
259274
var $fingerprint = $j(BS.Util.escapeId('${constants.sha1FingerprintKey}'));
260275
var $reload = $('reload');
276+
var $sourceAndBinaries = $j(BS.Util.escapeId('${constants.filesKey}'));
277+
var $toolOutputs = $j(BS.Util.escapeId('${constants.toolOutputFilesKey}'));
278+
var $sourceAndBinariesWarning = $j(BS.Util.escapeId('${constants.sourceAndBinariesWarningKey}'));
279+
var $toolOutputsWarning = $j(BS.Util.escapeId('${constants.toolOutputsWarningKey}'));
261280
262281
$('${constants.reportArchiveNameKey}').disabled = !isWaitForResults;
263282
$('${constants.codeDxSeverityKey}').disabled = !isWaitForResults;
@@ -272,6 +291,13 @@
272291
$apiToken.on('input', function() { getCodeDxProjects(false) });
273292
$fingerprint.on('input', function() { getCodeDxProjects(false) });
274293
$reload.on('click', function() { getCodeDxProjects(false) });
294+
$sourceAndBinaries.on('input', function() { displayFileWarning($sourceAndBinaries, $sourceAndBinariesWarning) });
295+
$toolOutputs.on('input', function() { displayFileWarning($toolOutputs, $toolOutputsWarning) });
296+
297+
setTimeout(function() {
298+
$sourceAndBinaries.trigger('input');
299+
$toolOutputs.trigger('input');
300+
}, 1000);
275301
});
276302
</script>
277303
</l:settingsGroup>

0 commit comments

Comments
 (0)