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

Add 'open file' command to context menu on diff tab #1135

Merged
merged 6 commits into from
Jul 9, 2022

Conversation

BoscoCHW
Copy link
Contributor

@BoscoCHW BoscoCHW commented Jun 15, 2022

Fixes #941

@github-actions
Copy link

Binder 👈 Launch a binder notebook on branch BoscoCHW/jupyterlab-git/feature-941

@BoscoCHW
Copy link
Contributor Author

@fcollonval

I successfully implemented opening a diff-ed file from the context menu. However, since the tab element of the diff window does not have a custom class, I cannot select only the diff tabs to add the command. I am unable to add a class to the diff tab also. Please let me know what I can do. Thank you!

@fcollonval
Copy link
Member

@BoscoCHW I looked for a solution, you can add a class to the diff widget title that will allow to set a more specific context menu selector.

You can add a class using diffWidget.title.className = '...'; at

diffWidget.title.closable = true;

@BoscoCHW BoscoCHW changed the title attempting to add a command to context menu but not successful Add 'open file' command to context menu on diff tab Jun 20, 2022
@BoscoCHW
Copy link
Contributor Author

@fcollonval
Hi, I successfully implemented a more specific context menu selector. The 'Open File' command only show up on diff tabs. Please let me know if there are any other changes to make on this PR.

@BoscoCHW BoscoCHW marked this pull request as ready for review June 22, 2022 20:56
Copy link
Member

@fcollonval fcollonval left a comment

Choose a reason for hiding this comment

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

Thanks @BoscoCHW

Two minor suggestions and we are good to go.

src/commandsAndMenu.tsx Outdated Show resolved Hide resolved
src/commandsAndMenu.tsx Show resolved Hide resolved
@fcollonval
Copy link
Member

@BoscoCHW I took the liberty to improve a bit your PR to open the file even if it is not in the status file list (aka when the file is not being modified). And I extended the diff widget API to get access to the diff model. That allows a more reliable access to the filename than reading the title attribute of the HTML node.

@fcollonval fcollonval merged commit 985d163 into jupyterlab:master Jul 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Open the diffed file from the diff tab context menu and/or toolbar
2 participants