Skip to content

Commit

Permalink
Add warning when the source and tool output inputs are blank
Browse files Browse the repository at this point in the history
  • Loading branch information
Phillip Elliott committed Sep 4, 2018
1 parent e67a0e9 commit 7a09145
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public final class CodeDxConstants {
public static final String SETTINGS_SHA1_FINGERPRINT_KEY = "codedx.sha1Fingerprint";
public static final String SETTINGS_WAIT_FOR_RESULTS_KEY = "codedx.waitForResults";
public static final String SETTINGS_REPORT_ARCHIVE_NAME_KEY = "codedx.reportArchiveName";
public static final String SETTINGS_SOURCE_AND_BINARIES_WARNING_KEY = "codedx.sourceAndBinariesWarning";
public static final String SETTINGS_TOOL_OUTPUTS_WARNING_KEY = "codedx.toolOutputsWarning";

public static final String CRITICAL = "Critical";
public static final String HIGH = "High";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,14 @@ public String getWaitForResultsKey() {
public String getReportArchiveNameKey() {
return CodeDxConstants.SETTINGS_REPORT_ARCHIVE_NAME_KEY;
}

@NotNull
public String getSourceAndBinariesWarningKey() {
return CodeDxConstants.SETTINGS_SOURCE_AND_BINARIES_WARNING_KEY;
}

@NotNull
public String getToolOutputsWarningKey() {
return CodeDxConstants.SETTINGS_TOOL_OUTPUTS_WARNING_KEY;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,11 @@
<td>
<span>
<props:textProperty name="${constants.filesKey}" className="longField"></props:textProperty>
<span class="smallNote">Files relative to the working directory to zip and upload to Code Dx. Separate multiple files with a comma (,)</span>
</span>
<span>
<span class="error" id="${constants.sourceAndBinariesWarningKey}">Warning: No source and binaries specified</span>
</span>
<span class="smallNote">Files relative to the working directory to zip and upload to Code Dx. Separate multiple files with a comma (,)</span>
</td>
</tr>
<tr class="advancedSetting">
Expand All @@ -91,6 +94,9 @@
<props:textProperty name="${constants.toolOutputFilesKey}" className="longField"></props:textProperty>
<span class="smallNote">File paths can be absolute or relative to the working directory. Separate multiple files with a comma (,)</span>
</span>
<span>
<span class="error" id="${constants.toolOutputsWarningKey}">Warning: No tool output files specified</span>
</span>
</td>
</tr>
<tr>
Expand Down Expand Up @@ -252,12 +258,25 @@
});
}
function displayFileWarning($textBox, $warningLabel) {
var textValue = BS.Util.trimSpaces($textBox.val());
if(textValue) {
$warningLabel.hide();
} else {
$warningLabel.show();
}
}
$j(function() {
var isWaitForResults = $('codedx.waitForResults').checked;
var $url = $j(BS.Util.escapeId('${constants.codeDxUrlKey}'));
var $apiToken = $j(BS.Util.escapeId('${constants.codeDxAPITokenKey}'));
var $fingerprint = $j(BS.Util.escapeId('${constants.sha1FingerprintKey}'));
var $reload = $('reload');
var $sourceAndBinaries = $j(BS.Util.escapeId('${constants.filesKey}'));
var $toolOutputs = $j(BS.Util.escapeId('${constants.toolOutputFilesKey}'));
var $sourceAndBinariesWarning = $j(BS.Util.escapeId('${constants.sourceAndBinariesWarningKey}'));
var $toolOutputsWarning = $j(BS.Util.escapeId('${constants.toolOutputsWarningKey}'));
$('${constants.reportArchiveNameKey}').disabled = !isWaitForResults;
$('${constants.codeDxSeverityKey}').disabled = !isWaitForResults;
Expand All @@ -272,6 +291,13 @@
$apiToken.on('input', function() { getCodeDxProjects(false) });
$fingerprint.on('input', function() { getCodeDxProjects(false) });
$reload.on('click', function() { getCodeDxProjects(false) });
$sourceAndBinaries.on('input', function() { displayFileWarning($sourceAndBinaries, $sourceAndBinariesWarning) });
$toolOutputs.on('input', function() { displayFileWarning($toolOutputs, $toolOutputsWarning) });
setTimeout(function() {
$sourceAndBinaries.trigger('input');
$toolOutputs.trigger('input');
}, 1000);
});
</script>
</l:settingsGroup>

0 comments on commit 7a09145

Please sign in to comment.