Skip to content
Permalink
Browse files

[JENKINS-19142] Prompt user whether to add the job to the current view (

#2529)

* [JENKINS-37857] Prompt user whether to add the job to the current view

* [JENKINS-37857] Fix review items from @daniel-beck
  • Loading branch information...
Vlatombe authored and oleg-nenashev committed Sep 9, 2016
1 parent 75745f0 commit f4c9eb0322f44d1f6b025a509fcae5a704bde666
@@ -302,17 +302,36 @@ public Boolean getStatusFilter() {
return statusFilter;
}

/**
* Determines the initial state of the checkbox.
*
* @return true when the view is empty or already contains jobs specified by name.
*/
@Restricted(NoExternalUse.class) // called from newJob_button-bar view
@SuppressWarnings("unused") // called from newJob_button-bar view
public boolean isAddToCurrentView() {
synchronized(this) {
return !jobNames.isEmpty() || // There are already items in this view specified by name
(jobFilters.isEmpty() && includePattern == null) // No other way to include items is used
;
}
}

@Override
@RequirePOST
public Item doCreateItem(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
JSONObject form = req.getSubmittedForm();
boolean addToCurrentView = form.has("addToCurrentView") && form.getBoolean("addToCurrentView");

This comment has been minimized.

Copy link
@alexellis

alexellis Feb 21, 2017

This causes breakage / regression. @daniel-beck @Vlatombe - https://issues.jenkins-ci.org/browse/JENKINS-41128?jql=text%20~%20%22createitem%20view%22

Do you have a temporary work-around that will satisfy this issue? How can I post an XML config.xml body while at the same-time submitting a form?

ItemGroup<? extends TopLevelItem> ig = getOwnerItemGroup();
if (ig instanceof ModifiableItemGroup) {
TopLevelItem item = ((ModifiableItemGroup<? extends TopLevelItem>)ig).doCreateItem(req, rsp);
if(item!=null) {
synchronized (this) {
jobNames.add(item.getRelativeNameFrom(getOwnerItemGroup()));
if (item!=null) {
if (addToCurrentView) {
synchronized (this) {
jobNames.add(item.getRelativeNameFrom(getOwnerItemGroup()));
}
owner.save();
}
owner.save();
}
return item;
}
@@ -0,0 +1,29 @@
<!--
The MIT License
Copyright (c) 2016, CloudBees
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" xmlns:i="jelly:fmt">
<button type="submit" id="ok-button">OK</button>
<f:checkbox title="${%Add to current view}" field="addToCurrentView" checked="${it.addToCurrentView}"/>
</j:jelly>
@@ -66,7 +66,7 @@ THE SOFTWARE.

<div class="footer">
<div class="btn-decorator">
<button type="submit" id="ok-button">OK</button>
<st:include page="newJobButtonBar.jelly"/>
</div>
</div>
</form>
@@ -0,0 +1,28 @@
<!--
The MIT License
Copyright (c) 2016, CloudBees
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" xmlns:i="jelly:fmt">
<button type="submit" id="ok-button">OK</button>
</j:jelly>
@@ -32,6 +32,12 @@
text-align: center;
z-index: 10;

input[type=checkbox] {
width: auto;
min-width: auto;
margin-right: 0px;
}

button[type=submit] {
padding: 5px 20px;
background-color: rgb(204, 221, 238);

0 comments on commit f4c9eb0

Please sign in to comment.
You can’t perform that action at this time.