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

[FIXED JENKINS-35410] Improve User Experience #3

Merged
merged 1 commit into from Jun 7, 2016
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/main/java/hudson/plugins/batch_task/BatchTaskInvoker.java
Expand Up @@ -10,16 +10,20 @@
import hudson.model.Cause.UpstreamCause;
import hudson.model.CauseAction;
import hudson.model.Descriptor;
import hudson.model.Item;
import hudson.model.ItemGroup;
import hudson.model.Result;
import hudson.model.Run;
import hudson.tasks.BuildStepDescriptor;
import hudson.tasks.BuildStepMonitor;
import hudson.tasks.Notifier;
import hudson.tasks.Publisher;
import hudson.util.FormValidation;
import hudson.util.ListBoxModel;
import jenkins.model.Jenkins;
import net.sf.json.JSONObject;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
import org.kohsuke.stapler.AncestorInPath;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.QueryParameter;
Expand Down Expand Up @@ -139,6 +143,29 @@ public ListBoxModel doFillTaskItems(@QueryParameter String project, @AncestorInP
}
return r;
}

@Restricted(NoExternalUse.class)
public FormValidation doCheckProject(@QueryParameter String project) {
Copy link
Member

Choose a reason for hiding this comment

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

Please add Restricted(NoExternalUse) to such new validation hooks.
It prevents compatibility issues when you upgrade the stuff

if (project.startsWith("/")) {
return FormValidation.warning(Messages.BatchTaskInvoker_ForwardSlash());
Copy link
Member

Choose a reason for hiding this comment

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

Maybe it should be an error

}
Jenkins jenkins = Jenkins.getInstance();
if (jenkins != null) {
Item item = jenkins.getItemByFullName(project);
if (item == null) {
return FormValidation.warning(Messages.BatchTaskInvoker_NoSuchProject(project));
}
}
return FormValidation.ok();
}

@Restricted(NoExternalUse.class)
public FormValidation doCheckTask(@QueryParameter String project, @QueryParameter String task) {
Copy link
Member

Choose a reason for hiding this comment

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

same

if (!project.isEmpty() && task.isEmpty()) {
return FormValidation.warning(Messages.BatchTaskInvoker_NoBatchTaskExists(task));
}
return FormValidation.ok();
}
}
}

Expand Down
@@ -0,0 +1,11 @@
<div>
The <strong>Full project name</strong>

<p>
Copy link
Member

Choose a reason for hiding this comment

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

No closing tags. 🐜

Copy link
Member

Choose a reason for hiding this comment

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

it has been fixed

For jobs inside a folder it is always a path like <strong>foo/bar</strong>
Copy link
Member

Choose a reason for hiding this comment

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

NIT: maybe makes sense to reference other use-cases: E.g. multibranch projects, etc.

</p>

<p>
In Jenkins <strong>Full project name</strong> cannot start by "/"
</p>
</div>
Copy link
Member

Choose a reason for hiding this comment

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

NIT: missing line break

@@ -0,0 +1,7 @@
<div>
List of tasks contained on the Project.

<p>
Empty means there is not any task on the selected Project.
</p>
</div>
Copy link
Member

Choose a reason for hiding this comment

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

Good practice: add line breaks to last lines

Expand Up @@ -6,3 +6,4 @@ BatchTaskInvoker.NoSuchProject=No such project exists: {0}
BatchTaskInvoker.NoSuchTask=No such task exists: {0}. Perhaps you meant {1}
BatchTaskAction.DisplayName={0,choice,1#Task|1<Tasks}
BatchRunAction.DisplayName=Executed Tasks
BatchTaskInvoker.ForwardSlash=Project should be a Full Project Name which cannot start by /. Current settings may lead to the undefined behavior.