Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add download option to 'Console output', move 'View as plain text' and 'Copy' buttons to app bar #9169

Merged
merged 12 commits into from
May 22, 2024
25 changes: 21 additions & 4 deletions core/src/main/resources/hudson/model/Run/console.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,32 @@ THE SOFTWARE.
Displays the console output
-->
<?jelly escape-by-default='true'?>
<st:compress xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:i="jelly:fmt">
<st:compress xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:dd="/lib/layout/dropdowns">
janfaracik marked this conversation as resolved.
Show resolved Hide resolved
<l:layout title="${it.fullDisplayName} Console">
<st:include page="sidepanel.jelly" />
<l:breadcrumb title="${%Console Output}" />

<l:breadcrumb title="${%Console Output}" />

<l:main-panel>
<t:buildCaption>
<j:set var="controls">
<l:copyButton ref="out" label="${%Copy}" />
<l:overflowButton>
<dd:custom>
<a class="jenkins-dropdown__item" href="consoleText" download="${it.displayName}.txt">
Copy link
Contributor

@mawinter69 mawinter69 Apr 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it really useful to use the displayname here? If I choose a displayname that contains a / this wouldn't be saveable.
something like
${it.parent.name}-{it.number}.txt would guarantee a valid filename

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I choose a displayname that contains a / this wouldn't be saveable.

Per https://html.spec.whatwg.org/multipage/links.html#attr-hyperlink-download

The attribute may have a value; the value, if any, specifies the default filename that the author recommends for use in labeling the resource in a local file system. There are no restrictions on allowed values, but authors are cautioned that most file systems have limitations with regard to what punctuation is supported in filenames, and user agents are likely to adjust filenames accordingly.

Trying this PR and DOM editing in Firefox, I get the file foo_bar_#1.txt from the attribute value foo/bar/#1.txt.

(parent.fullName might still be better though. Unsure whether we should go for display names, there's arguments for and against IMO)

<div class="jenkins-dropdown__item__icon">
<l:icon src="symbol-download" />
</div>
${%Download}
</a>
</dd:custom>
<dd:item href="consoleText" text="${%View as plain text}" icon="symbol-document-text" />
</l:overflowButton>
</j:set>

<t:buildCaption controls="${controls}">
${%Console Output}
<l:copyButton message="${%successfullyCopied}" tooltip="${%clickToCopy}" ref="out"/>
</t:buildCaption>

<j:set var="threshold" value="${h.getSystemProperty('hudson.consoleTailKB')?:'150'}" />
<!-- Show at most last 150KB (can override with system property) unless consoleFull is set -->
<j:set var="offset" value="${empty(consoleFull) ? it.logText.length()-threshold*1024 : 0}" />
Expand Down
2 changes: 0 additions & 2 deletions core/src/main/resources/hudson/model/Run/console.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,3 @@
# THE SOFTWARE.

skipSome=Skipping {0,number,integer} KB.. <a href="{1}">Full Log</a>
clickToCopy=Click to copy
successfullyCopied=Copied to clipboard
7 changes: 7 additions & 0 deletions core/src/main/resources/lib/hudson/buildCaption.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ THE SOFTWARE.
-->
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<st:documentation>
<st:attribute name="controls">
Optional field to set controls in the app bar
</st:attribute>
</st:documentation>

<div class="jenkins-app-bar">
<div class="jenkins-app-bar__content jenkins-build-caption" data-status-url="${rootURL}/${it.url}statusIcon">
<l:icon alt="${it.iconColor.description}" src="symbol-status-${it.iconColor.iconName}"
Expand All @@ -47,6 +53,7 @@ THE SOFTWARE.
</div>
</j:if>
<st:adjunct includes="lib.hudson.build-caption"/>
<j:out value="${attrs.controls}" />
</div>
</div>
</j:jelly>
13 changes: 1 addition & 12 deletions core/src/main/resources/lib/hudson/project/console-link.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,5 @@ THE SOFTWARE.
<?jelly escape-by-default='true'?>
<!-- Displays a console link for a build. -->
<j:jelly xmlns:j="jelly:core" xmlns:l="/lib/layout">
<j:choose>
<j:when test="${it.logFile.length() > 200000}">
<!-- Show raw link directly so user need not click through live console page, though this is not so bad now as they would just see: Skipping nnn KB.. Full Log. -->
<l:task href="${h.getConsoleUrl(it) ?: (buildUrl.baseUrl + '/console')}" icon="icon-terminal icon-md" title="${%Console Output}"/>
<l:task href="${buildUrl.baseUrl}/consoleText" icon="icon-document icon-md" title="${%View as plain text}"/>
</j:when>
<j:otherwise>
<l:task icon="images/svgs/terminal.svg" href="${h.getConsoleUrl(it) ?: (buildUrl.baseUrl + '/console')}" title="${%Console Output}">
<l:task href="${buildUrl.baseUrl}/consoleText" icon="icon-document icon-md" title="${%View as plain text}"/>
</l:task>
</j:otherwise>
</j:choose>
<l:task href="${h.getConsoleUrl(it) ?: (buildUrl.baseUrl + '/console')}" icon="icon-terminal icon-md" title="${%Console Output}" />
</j:jelly>
6 changes: 5 additions & 1 deletion core/src/main/resources/lib/layout/copyButton.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ THE SOFTWARE.
<st:attribute name="clazz">
Additional CSS class names
</st:attribute>
<st:attribute name="label">
Optional label for the button, hides the tooltip if set
</st:attribute>
<st:attribute name="ref" use="required">
The id of the target element to be copied
@since 2.449
Expand All @@ -54,9 +57,10 @@ THE SOFTWARE.
text="${attrs.text}"
ref="${attrs.ref}"
message="${attrs.message ?: '%Copied'}"
tooltip="${attrs.tooltip ?: '%Copy'}"
tooltip="${attrs.label != null ? null : attrs.tooltip ?: '%Copy'}"
type="button">
<span class="jenkins-copy-button__icon" />
${attrs.label}
</button>

<st:adjunct includes="lib.layout.copyButton.copyButton"/>
Expand Down
Loading