Skip to content
This repository has been archived by the owner on Feb 16, 2023. It is now read-only.

Add context menus to sections containing runnable code cells #141

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

kgryte
Copy link
Member

@kgryte kgryte commented Jun 16, 2020

This PR should partially address #138 by

  • adding context menus to those ToC headings having notebook sections containing runnable code cells.
  • note that the context menus for running code cells only appear when the toolbar button for showing code snippets in the ToC sidebar is active. Making the context menus more generally available when not showing code snippets would require a more extensive refactor.

I recognize that this PR is not likely to be merged given jupyterlab/jupyterlab#8538; however, this PR may prove illustrative for demonstrating a path forward in core.

Demo

toc_extension_context_menus

Copy link
Member

@marthacryan marthacryan left a comment

Choose a reason for hiding this comment

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

Just tried this locally and it worked as expected! One behavior I'm noticing is that this doesn't run markdown cells - is that part of the limitations that required ToC to be in code snippet mode for this functionality to be available? I don't really think this is a big deal, just something I noticed while playing around with it - could be a nice touch. Also, I wonder if it'd be useful to have the same context menu appear for all toc items, but just have the "Run cell(s)" button be disabled for items without runnable code cells (for consistency). I could definitely see an argument for either side but thought I'd bring it up. Otherwise this looks good to me!

Comment on lines +59 to +68
/**
* Returns a component which renders a table of contents tree.
*
* @param props - component properties
* @returns component
*/
constructor(props: IProperties) {
super(props);
}

Copy link
Member

Choose a reason for hiding this comment

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

Does this need to be here?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, it is not necessary. I usually include it as a matter of course so that the constructor is documented and setup in the event that component is necessary (e.g., as in toc.tsx). I can remove, if this is a blocker.

@kgryte
Copy link
Member Author

kgryte commented Jul 27, 2020

@marthacryan Thanks for the review! Regarding Markdown cells, I did not think that adding the ability to run Markdown cells was necessary, as not clear to me what the purpose/use case of this would be. In what situation would a user want to run Markdown cells and how common would that be?

Re: context menu for all cells. Yes, probably. Otherwise, a user has to intuit why a context menu is possible for some ToC items, but not others. I did not include here, as I did not want an empty context menu for non-code cells. And I did not add a context menu with the item greyed out, as was not clear to me that this was better than not showing a context menu at all.

I can update this PR to accommodate either design pattern, if desired.

@marthacryan
Copy link
Member

@kgryte I'm sorry I forgot to follow up on this - just noticed as I was checking that everything would be in order to archive the repo. Would you be interested in moving this PR onto core? I can make the PR if you don't have time, but I think this is a good addition to the ToC!

@kgryte
Copy link
Member Author

kgryte commented Nov 20, 2020

I don't have time at the moment, and, if you have the bandwidth, go for it! :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants