-
Notifications
You must be signed in to change notification settings - Fork 85
Add copy error to clipboard button
#382
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
base: main
Are you sure you want to change the base?
Conversation
|
Cc @balajialg |
|
@jnywong That's great, Thank you! |
| const button = this.copyError; | ||
| button.onclick = async () => { | ||
| try { | ||
| await navigator.clipboard.writeText(errorText); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking about what other thing would be useful, can you also copy the nbgitpuller URL itself? that contains important and helpful info about the repo and branch that I think help a lot. But let's just copy the url - base_url (so just /git-sync?query-params) so we don't automatically include the username here, as that could be PII.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion.
Had a look at the query params used in the GitSync class
this.baseUrl = baseUrl;
this.repo = repo;
this.branch = branch;
this.depth = depth; // not currently used because of shallow clone https://github.com/jupyterhub/nbgitpuller/pull/117
this.targetpath = targetpath; // optional folder to clone into
this.redirectUrl = baseUrl + path;
this._xsrf = xsrf;and pulled out repo, branch and redirectUrl to insert into the error text. Now the terminal output prints this info in addition to the traceback log, that can be copied to clipboard:
Repository: https://github.com/data-8/textbook
Branch: gh-pages
Redirect URL: /tree/textbook/.
Traceback (most recent call last):
File "/Users/jnywong/Documents/github/nbgitpuller/nbgitpuller/handlers.py", line 87, in get
gp = GitPuller(repo, repo_dir, branch=branch, depth=depth, parent=self.settings['nbapp'])
File "/Users/jnywong/Documents/github/nbgitpuller/nbgitpuller/pull.py", line 81, in __init__
raise ValueError(f"Branch: {self.branch_name} -- not found in repo: {self.git_url}")
ValueError: Branch: gh-pages -- not found in repo: https://github.com/data-8/textbook
This PR adds a button to copy to clipboard the error log from the terminal output.
nbgitpuller-copy-error.mp4
Closes 2i2c-org/infrastructure#7083
More specific and user-friendly error responses for the top 3 failure modes to follow in a separate PR (as part of 2i2c-org/infrastructure#7085), which will rely less on the terminal window/traceback logs.