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

Create a new taglib to capture the save/apply bottom bar #9813

Merged
merged 7 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion core/src/main/java/hudson/logging/LogRecorder.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import hudson.remoting.VirtualChannel;
import hudson.slaves.ComputerListener;
import hudson.util.CopyOnWriteList;
import hudson.util.FormApply;
import hudson.util.FormValidation;
import hudson.util.HttpResponses;
import hudson.util.RingBufferLogHandler;
Expand Down Expand Up @@ -463,7 +464,7 @@

save();
if (oldFile != null) oldFile.delete();
rsp.sendRedirect2(redirect);
FormApply.success(redirect).generateResponse(req, rsp, null);

Check warning on line 467 in core/src/main/java/hudson/logging/LogRecorder.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 467 is not covered by tests
}

@RequirePOST
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/java/hudson/model/Computer.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
import hudson.util.DaemonThreadFactory;
import hudson.util.EditDistance;
import hudson.util.ExceptionCatchingThreadFactory;
import hudson.util.FormApply;
import hudson.util.Futures;
import hudson.util.IOUtils;
import hudson.util.NamingThreadFactory;
Expand Down Expand Up @@ -1512,7 +1513,7 @@ public void doConfigSubmit(StaplerRequest2 req, StaplerResponse2 rsp) throws IOE
}

// take the user back to the agent top page.
rsp.sendRedirect2("../" + result.getNodeName() + '/');
FormApply.success("../" + result.getNodeName() + '/').generateResponse(req, rsp, null);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/jenkins/model/Jenkins.java
Original file line number Diff line number Diff line change
Expand Up @@ -4159,7 +4159,7 @@ public synchronized void doConfigExecutorsSubmit(StaplerRequest2 req, StaplerRes

updateComputerList();

rsp.sendRedirect(req.getContextPath() + '/' + toComputer().getUrl()); // back to the computer page
FormApply.success(req.getContextPath() + '/' + toComputer().getUrl()).generateResponse(req, rsp, null);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,8 @@ THE SOFTWARE.
</div>
</f:repeatable>
</f:entry>

<f:bottomButtonBar>
<f:submit value="${%Save}" />
</f:bottomButtonBar>
<f:saveApplyBar/>
</f:form>
<st:adjunct includes="lib.form.confirm" />
</l:main-panel>
</l:layout>
</j:jelly>
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,8 @@ THE SOFTWARE.
<!-- main body of the configuration -->
<st:include it="${instance}" page="configure-entries.jelly" />

<j:if test="${h.hasPermission(it, it.CONFIGURE)}">
<f:bottomButtonBar>
<f:submit value="${%Save}"/>
</f:bottomButtonBar>
</j:if>
<f:saveApplyBar/>
Copy link
Member

Choose a reason for hiding this comment

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

This one is funny, after clicking Apply:

Screenshot 2024-10-11 at 14 49 59

Copy link
Member Author

Choose a reason for hiding this comment

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

</f:form>
<j:if test="${h.hasPermission(it, it.CONFIGURE)}">
<st:adjunct includes="lib.form.confirm" />
</j:if>
</l:main-panel>
</l:layout>
</j:jelly>
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,8 @@ THE SOFTWARE.
instances="${it.monitors}"
forceRowSet="true"/>

<l:hasAdministerOrManage>
<f:bottomButtonBar>
<f:submit value="${%Save}" />
<f:apply />
</f:bottomButtonBar>
</l:hasAdministerOrManage>
<f:saveApplyBar/>
</f:form>
<st:adjunct includes="lib.form.confirm" />
</l:main-panel>
</l:layout>
</j:jelly>
10 changes: 1 addition & 9 deletions core/src/main/resources/hudson/model/Job/configure.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,8 @@ THE SOFTWARE.
<!-- additional entries from derived classes -->
<st:include page="configure-entries.jelly" />

<j:if test="${h.hasPermission(it,it.CONFIGURE)}">
<f:bottomButtonBar>
<f:submit value="${%Save}" />
<f:apply value="${%Apply}" />
</f:bottomButtonBar>
</j:if>
<f:saveApplyBar/>
</f:form>
<j:if test="${h.hasPermission(it,it.CONFIGURE)}">
<st:adjunct includes="lib.form.confirm" />
</j:if>
</l:main-panel>
</l:layout>
</j:jelly>
11 changes: 1 addition & 10 deletions core/src/main/resources/hudson/model/Run/configure.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,8 @@ THE SOFTWARE.
<f:entry title="${%Description}" help="/help/run-config/description.html">
<f:textarea name="description" value="${it.description}" codemirror-mode="${app.markupFormatter.codeMirrorMode}" codemirror-config="${app.markupFormatter.codeMirrorConfig}" previewEndpoint="/markupFormatter/previewDescription"/>
</f:entry>

<j:if test="${h.hasPermission(it,it.UPDATE)}">
<f:bottomButtonBar>
<f:submit value="${%Save}" />
<f:apply />
</f:bottomButtonBar>
</j:if>
<f:saveApplyBar/>
</f:form>
<j:if test="${h.hasPermission(it,it.UPDATE)}">
<st:adjunct includes="lib.form.confirm" />
</j:if>
</l:main-panel>
</l:layout>
</j:jelly>
6 changes: 1 addition & 5 deletions core/src/main/resources/hudson/model/View/configure.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,8 @@ THE SOFTWARE.
</f:entry>
</f:section>

<f:bottomButtonBar>
<f:submit value="${%OK}" />
Copy link
Member Author

Choose a reason for hiding this comment

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

This effectively changes the label OK to Save. But I don't think there was any good reason for this label to differ from other screens.

<f:apply value="${%Apply}"/>
</f:bottomButtonBar>
<f:saveApplyBar/>
</f:form>
<st:adjunct includes="lib.form.confirm" />
</l:main-panel>
</l:layout>
</j:jelly>
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,8 @@ THE SOFTWARE.
</f:section>
</j:if>
</j:forEach>

<f:bottomButtonBar>
<f:submit value="${%Save}" />
<f:apply />
</f:bottomButtonBar>

<f:saveApplyBar/>
</f:form>
<st:adjunct includes="lib.form.confirm" />
</l:main-panel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,8 @@ THE SOFTWARE.
</div>
</j:otherwise>
</j:choose>

<f:bottomButtonBar>
<f:submit value="${%Save}" />
<f:apply />
</f:bottomButtonBar>

<f:saveApplyBar/>
</f:form>
<st:adjunct includes="lib.form.confirm" />
</l:main-panel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,8 @@ THE SOFTWARE.
</div>
</j:otherwise>
</j:choose>

<f:bottomButtonBar>
<f:submit value="${%Save}" />
<f:apply />
</f:bottomButtonBar>

<f:saveApplyBar/>
</f:form>
<st:adjunct includes="lib.form.confirm" />
</l:main-panel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,8 @@ THE SOFTWARE.
</div>
</j:otherwise>
</j:choose>

<f:bottomButtonBar>
<f:submit value="${%Save}" />
<f:apply />
</f:bottomButtonBar>

<f:saveApplyBar/>
</f:form>
<st:adjunct includes="lib.form.confirm" />
</l:main-panel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,7 @@ THE SOFTWARE.
</j:otherwise>
</j:choose>

<f:bottomButtonBar>
<f:submit value="${%Save}" />
<f:apply />
</f:bottomButtonBar>
<f:saveApplyBar/>
</f:form>
<st:adjunct includes="lib.form.confirm" />
</l:main-panel>
Expand Down
9 changes: 1 addition & 8 deletions core/src/main/resources/hudson/slaves/Cloud/configure.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,8 @@ THE SOFTWARE.
<!-- main body of the configuration -->
<st:include it="${instance}" page="config.jelly" optional="true"/>

<l:isAdmin>
<f:bottomButtonBar>
<f:submit value="${%Save}"/>
</f:bottomButtonBar>
</l:isAdmin>
<f:saveApplyBar/>
</f:form>
<l:isAdmin>
<st:adjunct includes="lib.form.confirm"/>
</l:isAdmin>
</l:main-panel>
</l:layout>
</j:jelly>
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ THE SOFTWARE.
</l:header>
</l:isAdmin>
<l:main-panel>
<j:set var="readOnlyMode" value="${!app.hasPermission(app.ADMINISTER)}"/>
<j:choose>
<j:when test="${it.cloudAvailable and it.hasClouds()}">
<l:app-bar title="${%Clouds}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,7 @@ THE SOFTWARE.
</f:rowSet>
</j:forEach>

<l:hasAdministerOrManage>
<f:bottomButtonBar>
<f:submit value="${%Save}" />
<f:apply />
</f:bottomButtonBar>
</l:hasAdministerOrManage>
<f:saveApplyBar/>
</f:form>

<l:hasAdministerOrManage>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,7 @@ THE SOFTWARE.

<f:descriptorList title="${%Node Properties}" descriptors="${h.getNodePropertyDescriptors(descriptor.clazz)}" field="nodeProperties" />

<l:hasPermission permission="${it.CONFIGURE}">
<f:bottomButtonBar>
<f:submit value="${%Save}"/>
</f:bottomButtonBar>
</l:hasPermission>
<f:saveApplyBar/>
Copy link
Member

Choose a reason for hiding this comment

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

Also funny:

Screenshot 2024-10-11 at 15 12 07

Copy link
Member Author

Choose a reason for hiding this comment

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

</f:form>
</l:main-panel>
</l:layout>
Expand Down
14 changes: 3 additions & 11 deletions core/src/main/resources/jenkins/model/Jenkins/configure.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ THE SOFTWARE.
<f:breadcrumb-config-outline title="${%System}" />

<l:main-panel>
<j:set var="readOnlyMode" value="${!h.hasPermission(app.MANAGE)}"/>
<l:app-bar title="${%System}" />

<div class="behavior-loading"><l:spinner text="${%LOADING}"/></div>
Expand All @@ -46,7 +47,6 @@ THE SOFTWARE.
</div>
</f:entry>
<f:entry title="${%System Message}" description="${%This message will be displayed at the top of the Jenkins main page. This can be useful for posting notifications to your users}">
<j:set var="readOnlyMode" value="${!h.hasPermission(app.MANAGE)}" />
<f:textarea name="system_message" value="${it.systemMessage}" disabled="${readOnlyMode?'true':null}" readonly="${readOnlyMode?'true':null}"
codemirror-mode="${app.markupFormatter.codeMirrorMode}" codemirror-config="${app.markupFormatter.codeMirrorConfig}" previewEndpoint="/markupFormatter/previewDescription"/>
</f:entry>
Expand All @@ -60,17 +60,9 @@ THE SOFTWARE.
<st:include page="${descriptor.globalConfigPage}" from="${descriptor}" />
</f:rowSet>
</j:forEach>

<l:hasAdministerOrManage>
<f:bottomButtonBar>
<f:submit value="${%Save}" />
<f:apply />
</f:bottomButtonBar>
</l:hasAdministerOrManage>
<j:set var="readOnlyMode" value="${!h.hasPermission(app.MANAGE)}"/>
Copy link
Member Author

@Vlatombe Vlatombe Oct 2, 2024

Choose a reason for hiding this comment

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

<f:saveApplyBar/>
</f:form>
<l:hasAdministerOrManage>
<st:adjunct includes="lib.form.confirm" />
</l:hasAdministerOrManage>
</l:main-panel>
</l:layout>
</j:jelly>
39 changes: 39 additions & 0 deletions core/src/main/resources/lib/form/saveApplyBar.jelly
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!--
The MIT License

Copyright (c) 2024, CloudBees, Inc.

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.
-->

<?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>
Creates the bottom bar for the "Save" and "Apply" buttons.
In read only mode (&lt;j:set var="readOnlyMode" value="true"/&gt;) the buttons are not displayed.
</st:documentation>

<j:if test="${!readOnlyMode}">
<f:bottomButtonBar>
<f:submit value="${%Save}" />
<f:apply/>
</f:bottomButtonBar>
<st:adjunct includes="lib.form.confirm" />
</j:if>
</j:jelly>
Loading