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

[JENKINS-71737] Fix redirect when submitting cloud changes #8310

Closed
wants to merge 31 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
081cadd
Fix redirect when submitting cloud changes
car-roll Jul 28, 2023
cb2a5fd
update comment
car-roll Jul 29, 2023
1741953
test cloud name change
car-roll Aug 11, 2023
a0a3e9c
add separate page for cloud rename
car-roll Aug 15, 2023
3d50865
tests cloud name change
car-roll Aug 15, 2023
29ad035
block using apply in cloud rename
car-roll Aug 15, 2023
ff3cbba
fix comments
car-roll Aug 15, 2023
dbf61fd
Merge branch 'master' into redirect-cloud-name-change
car-roll Aug 15, 2023
108bc22
Remove rename change, block apply when changing name
car-roll Aug 16, 2023
cc7c4e1
Revert "Remove rename change, block apply when changing name"
car-roll Aug 17, 2023
e3ef831
Add Renamable interface, generalize TransientActionFactoryImpl
car-roll Aug 26, 2023
7a96cd6
change isNameEditable default to true
car-roll Aug 30, 2023
b8e7f84
update jelly
car-roll Aug 30, 2023
aec2de1
add check for improper name change
car-roll Aug 31, 2023
d5b6dcd
hide sidepanel link if name not editable
car-roll Aug 31, 2023
a57343c
remove unnecessary sidepanel link
car-roll Sep 1, 2023
73f451e
Merge branch 'master' into redirect-cloud-name-change
car-roll Sep 6, 2023
b7eed6f
update Renamable javadoc
car-roll Sep 7, 2023
6c561f7
silently block renaming in config page
car-roll Sep 8, 2023
10ea3dd
Merge branch 'master' into redirect-cloud-name-change
car-roll Sep 8, 2023
92489f1
update test
car-roll Sep 8, 2023
b6e2fde
pass name field during cloud creation
car-roll Sep 9, 2023
5bb029f
chnage cloudName to name in _new.jelly
car-roll Sep 9, 2023
63c3633
change to invisible text box
car-roll Sep 11, 2023
bf62fc2
remove cloudName from Cloud formdata
car-roll Sep 11, 2023
1024b9e
add cloudName back to formData
car-roll Sep 12, 2023
4b89c49
cleanup
car-roll Sep 12, 2023
8c3d6c6
add name fields to config form data
car-roll Sep 12, 2023
231db94
remove cloudName from new cloud form data
car-roll Sep 13, 2023
13bab6c
save to disk when changing name
car-roll Sep 19, 2023
e933c51
Merge branch 'master' into redirect-cloud-name-change
car-roll Sep 20, 2023
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
4 changes: 2 additions & 2 deletions core/src/main/java/hudson/slaves/Cloud.java
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,8 @@ public HttpResponse doConfigSubmit(StaplerRequest req, StaplerResponse rsp) thro
}
j.clouds.replace(this, result);
j.save();
// take the user back to the cloud top page.
return FormApply.success(".");
// take the user back to the root clouds page.
return FormApply.success("..");
car-roll marked this conversation as resolved.
Show resolved Hide resolved
}

public Cloud reconfigure(@NonNull final StaplerRequest req, JSONObject form) throws Descriptor.FormException {
Expand Down
23 changes: 22 additions & 1 deletion test/src/test/java/hudson/slaves/CloudTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.model.Action;
import hudson.model.Computer;
import hudson.model.Descriptor;
import hudson.model.Label;
import hudson.security.Permission;
import hudson.security.SidACL;
Expand All @@ -21,13 +22,16 @@
import jenkins.model.Jenkins;
import jenkins.model.TransientActionFactory;
import org.acegisecurity.acls.sid.Sid;
import org.htmlunit.html.HtmlForm;
import org.htmlunit.html.HtmlPage;
import org.htmlunit.html.HtmlTextInput;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.Issue;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.TestExtension;
import org.jvnet.hudson.test.WithoutJenkins;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.StaplerResponse;

public class CloudTest {
Expand Down Expand Up @@ -85,9 +89,22 @@ public void cloudNameIsEncodedInGetUrl() {
assertEquals("Cloud name is encoded in Cloud#getUrl", "cloud/..%2F..%2Fgibberish/", aCloud.getUrl());
}

@Test
public void changeCloudName() throws Exception {
ACloud aCloud = new ACloud("a", "0");
j.jenkins.clouds.add(aCloud);
HtmlForm form = j.createWebClient().goTo(aCloud.getUrl() + "configure").getFormByName("config");
HtmlTextInput input = form.getInputByName("_.name");
input.setText("b");
j.submit(form);
ACloud actual = j.jenkins.clouds.get(ACloud.class);
assertEquals("b", actual.getDisplayName());
}

public static final class ACloud extends AbstractCloudImpl {

protected ACloud(String name, String instanceCapStr) {
@DataBoundConstructor
public ACloud(String name, String instanceCapStr) {
super(name, instanceCapStr);
}

Expand All @@ -98,6 +115,10 @@ protected ACloud(String name, String instanceCapStr) {
@Override public boolean canProvision(Label label) {
return false;
}

@TestExtension
public static class DescriptorImpl extends Descriptor<Cloud> {
}
}

@TestExtension
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form">
<f:entry title="${%Name}" field="name">
<f:textbox />
</f:entry>
</j:jelly>
Loading