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-70695] add copy to clipboard button for snippet generator #666

Merged
merged 4 commits into from
Dec 8, 2023

Conversation

mawinter69
Copy link
Contributor

this change adds a copy to clipboard button below the field with the generated code

See JENKINS-70695

  • 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

this change adds a copy to clipboard button below the field with the
generated code.
@mawinter69 mawinter69 requested a review from a team as a code owner March 1, 2023 11:57
@mawinter69
Copy link
Contributor Author

affects #599

Copy link
Member

@jglick jglick left a comment

Choose a reason for hiding this comment

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

Looks reasonable though IIUC it is tricky to test locally since only https-protocol pages will actually let you copy. https://github.com/jglick/jenkins-demo-reverse-proxy might help.

@mawinter69
Copy link
Contributor Author

As http://localhost is also considered secure, testing with mvn hpi:run works fine

@@ -21,6 +21,9 @@ function handlePrototype(url, crumb) {
if (response.ok) {
response.text().then((responseText) => {
document.getElementById('prototypeText').value = responseText;
copybutton = document.querySelector('.jenkins-copy-button');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could wrap that also in a check of isSecureContext to avoid showing the copy button when it will not work anyway

Copy link
Member

Choose a reason for hiding this comment

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

Probably not relevant for production uses.

@jglick
Copy link
Member

jglick commented Dec 8, 2023

testing with mvn hpi:run works fine

Ah TIL.

Copy link
Member

@jglick jglick left a comment

Choose a reason for hiding this comment

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

Ah I normally run with the wildcardDNS Maven property set which I guess deactivates the copy button. With that profile disabled I am able to test locally.

@@ -21,6 +21,9 @@ function handlePrototype(url, crumb) {
if (response.ok) {
response.text().then((responseText) => {
document.getElementById('prototypeText').value = responseText;
copybutton = document.querySelector('.jenkins-copy-button');
Copy link
Member

Choose a reason for hiding this comment

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

Probably not relevant for production uses.

@jglick jglick merged commit 3b5707f into jenkinsci:master Dec 8, 2023
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants