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

Freeze: frozen cells are always unlocked when notebook is loaded #975

Closed
yacchin1205 opened this issue Apr 24, 2017 · 3 comments
Closed

Comments

@yacchin1205
Copy link
Contributor

migrate_state function always unlocks an editable attribute, because the code below is executed even if there are no cell.metadata.run_control.read_only.

cell.metadata.editable = !cell.metadata.run_control.read_only;

https://github.com/ipython-contrib/jupyter_contrib_nbextensions/blob/master/src/jupyter_contrib_nbextensions/nbextensions/freeze/main.js#L59

As a result, the editable metadata is set to true, and the get_state function returns normal for the cell after reloaded.

I assume that it is executed only when the metadata has run_control.read_only (with old metadata format).

@jcb91
Copy link
Member

jcb91 commented Apr 24, 2017

Yes, you're absolutely right, it should have read something more like

if (cell.metadata.run_control.read_only === true) {
    cell.metadata.editable = false;
}

@yacchin1205
Copy link
Contributor Author

@jcb91 Thank you for reviewing! I've sent the PR.

I also found the error below, it seems that there are no checking whether the attribute is defined... the PR includes its fix also.

[Freeze] Error: TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at set_state (main.js?v=20170424120221:115)
    at initialize_states (main.js?v=20170424120221:154)
    at do_stuff_with_config (main.js?v=20170424120221:191)

@jcb91
Copy link
Member

jcb91 commented Apr 25, 2017

Thanks!

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

No branches or pull requests

2 participants