jenkins icon indicating copy to clipboard operation
jenkins copied to clipboard

[JENKINS-60866] Remove inline JS from configure-common

Open daniel-beck opened this issue 2 years ago • 1 comments

See JENKINS-60866.

This wasn't really straightforward:

  • One fairly central form validation method took a displayUrl argument instead of value. When fixing that up, I kept the old argument for compatibility.
  • Add support for passing arbitrary additional parameters to form validation by defining data-checkurlextra-KEY attributes, whose value is the value being sent. This can be an alternative to additional form elements like done in https://github.com/jenkinsci/jenkins/pull/6859

I'm not really happy with how this went, so alternative suggestions are welcome.

Proposed changelog entries

  • Developer: Allow passing additional parameters to modern (non-JS) form validation using data-checkurlextra-KEY attributes.

Proposed upgrade guidelines

N/A

Submitter checklist

  • [ ] (If applicable) Jira issue is well described
  • [ ] Changelog entries and upgrade guidelines are appropriate for the audience affected by the change (users or developer, depending on the change) and are in the imperative mood. Examples
    • Fill-in the Proposed changelog entries section only if there are breaking changes or other changes which may require extra steps from users during the upgrade
  • [ ] Appropriate autotests or explanation to why this change has no tests
  • [ ] New public classes, fields, and methods are annotated with @Restricted or have @since TODO Javadoc, as appropriate.
  • [ ] New deprecations are annotated with @Deprecated(since = "TODO") or @Deprecated(forRemoval = true, since = "TODO") if applicable.
  • [ ] For dependency updates: links to external changelogs and, if possible, full diffs

Desired reviewers

@mention

Maintainer checklist

Before the changes are marked as ready-for-merge:

  • [ ] There are at least 2 approvals for the pull request and no outstanding requests for change
  • [ ] Conversations in the pull request are over OR it is explicit that a reviewer does not block the change
  • [ ] Changelog entries in the PR title and/or Proposed changelog entries are accurate, human-readable, and in the imperative mood
  • [ ] Proper changelog labels are set so that the changelog can be generated automatically
  • [ ] If the change needs additional upgrade steps from users, upgrade-guide-needed label is set and there is a Proposed upgrade guidelines section in the PR title. (example)
  • [ ] If it would make sense to backport the change to LTS, a Jira issue must exist, be a Bug or Improvement, and be labeled as lts-candidate to be considered (see query).

daniel-beck avatar Jul 16 '22 13:07 daniel-beck

Please take a moment and address the merge conflicts of your pull request. Thanks!

github-actions[bot] avatar Aug 25 '22 20:08 github-actions[bot]

Please take a moment and address the merge conflicts of your pull request. Thanks!

github-actions[bot] avatar May 09 '23 14:05 github-actions[bot]

How about just adding a doCheckDisplayNameOrNull method in the AbstractProjectDecriptor in a similar way as folders are doing it?

public FormValidation doCheckDisplayNameOrNull(@AncestorInPath AbstractProject project, @QueryParameter String value) {
  return Jenkins.get().doCheckDisplayName(value, project.getName());
}

Alternatively allow parameter renaming in the checkDependsOn via so you can write

  checkUrl="${rootURL}/checkDisplayName" checkDependsOn="displayName:displayNameOrNull jobName:name"

mawinter69 avatar Jan 14 '24 15:01 mawinter69

How about just adding a doCheckDisplayNameOrNull method in the AbstractProjectDecriptor in a similar way as folders are doing it?

I like this suggestion, assuming it works out as well as I hope. Thanks! I will take a look when I have some time (or feel free to propose an alternative to this PR yourself).

daniel-beck avatar Jan 14 '24 18:01 daniel-beck

Superseded by #8866.

daniel-beck avatar Jan 15 '24 11:01 daniel-beck