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-73885] Remove inline onclick handler from script removal form #120

Merged
merged 1 commit into from
Oct 10, 2024

Conversation

yaroslavafenkin
Copy link
Contributor

https://issues.jenkins.io/browse/JENKINS-73885

Testing done

I went to the Scriptler management screen as an admin user, added new script, then removed it. CSP plugin is installed in my Jenkins instance, and it registered multiple CSP violations before the change. After the change the list is clear.

https://www.loom.com/share/690a3867e06a42e7ba160f31701eb38c?sid=2a371698-8b64-4aa2-ad62-83c1d0e9e2ad

https://www.loom.com/share/0336da4251ad4419986f6559771494b7?sid=761d9c6b-69a5-490d-b401-d057646e63cb

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

e.preventDefault();
}
}));
});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Content of the script before the change for easier visual comparison:

function confirmDelete(element) {
  var name = element.getAttribute('data-name');
  if (confirm("Sure you want to delete ["+name+"]?")) {
    return true;
  }else{
    return false;
  }
}

removeScriptButtons.forEach(button => button.addEventListener("click", (e) => {
const name = e.currentTarget.getAttribute('data-name');
if (!confirm("Sure you want to delete [" + name + "]?")) {
e.preventDefault();
Copy link
Contributor Author

@yaroslavafenkin yaroslavafenkin Oct 9, 2024

Choose a reason for hiding this comment

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

We don't have to do anything if confirm is true, just let the form get submitted. If it was cancelled we prevent the form submission. So I thought reverting the if makes sense here.

Copy link
Member

@basil basil left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

@basil basil added the internal label Oct 9, 2024
@basil basil requested a review from a team October 9, 2024 23:33
yaroslavafenkin added a commit to yaroslavafenkin/acceptance-test-harness that referenced this pull request Oct 10, 2024
@yaroslavafenkin
Copy link
Contributor Author

ATH passed: jenkinsci/acceptance-test-harness#1778

@basil basil merged commit a157cb6 into jenkinsci:main Oct 10, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants