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

Ways to disable 'Save'&'Save as' commands under 'File' menu #4600

Open
zzhangjii opened this issue May 17, 2018 · 4 comments
Open

Ways to disable 'Save'&'Save as' commands under 'File' menu #4600

zzhangjii opened this issue May 17, 2018 · 4 comments

Comments

@zzhangjii
Copy link

For Jupyterlab_Voyager project, we plan to use the native 'Save'&'Save as' buttons under 'File' menu to save current Voyager state.
Since the Voyager content is in vegalite form, when using other file types( csv/tsv...) as Voyager data source, we need to disable those native 'Save'&'Save as' buttons, otherwise it will ruin the original files. Here's a link for the detail design (issue44)

I checked inside Docmanger, the enable/disable of those two buttons is controlled by
const isEnabled = () => { const { currentWidget } = app.shell; return !!(currentWidget && docManager.contextForWidget(currentWidget)); };

this contextForWidget() is quite complex, I tried to modify the get context() inside voyager widget class but failed to make a difference.
I wonder if there's any way to achieve this without modifying the above function in JupyterLab itself.
Hope you guys can help me with it.
@ellisonbg @ian-r-rose

@ian-r-rose
Copy link
Member

Hi @zzhangjii, I'm not sure I understand what you mean by the "native" buttons. Can you elaborate?

It sounds to me like an alternative might be to implement toString and fromString fuctions for your data models that are able to serialize and deserialize them correctly.

@jasongrout
Copy link
Contributor

Technical question for those that know: can a viewer register as a read-only viewer? It may make sense to have that capability.

@ian-r-rose
Copy link
Member

I don't think so, but that would make sense.

@zzhangjii
Copy link
Author

zzhangjii commented May 17, 2018

Sorry, @ian-r-rose, I mean using the 'Save' and 'Save As...' buttons under 'File menu'.
My question is how to disable the buttons by modifying my extension.
for example: change some methods inside my class VoyagerPanel extends Widget implements DocumentRegistry.IReadyWidget

screen shot 2018-05-17 at 2 17 25 pm

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

No branches or pull requests

4 participants