- Notifications
You must be signed in to change notification settings - Fork5.5k
Add save as menu option#3289
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes from1 commit
fd25ae1ee79a7f9b18d0784e565ceab1e7081c6eed0c81fc3File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -2858,6 +2858,7 @@ define([ | ||||
| $('<br/>') | ||||
| ).append( | ||||
| $('<input/>').attr('type','text').attr('size','25') | ||||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. This input area doesn't show up well for me. I think you're missing the
Also, I hope we can get rid of the inline styling a couple of lines below. | ||||
| .attr('data-testid', 'save-as') | ||||
| .addClass('form-control') | ||||
| ); | ||||
| @@ -2894,7 +2895,8 @@ define([ | ||||
| that.events.trigger('notebook_renamed.Notebook', data); | ||||
| },function(error) { | ||||
| const msg = i18n.msg._(error.message || 'Unknown error saving notebook'); | ||||
| $('.save-message').html(`<span style='color:red;'>${msg}</span>`); | ||||
| }); | ||||
| } | ||||
| that.contents.get(nb_path, {type: 'notebook'}).then(function(data) { | ||||
| ||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| from notebook.tests.selenium.utils import wait_for_selector | ||
| from selenium.webdriver.common.keys import Keys | ||
| from selenium.webdriver.support.ui import WebDriverWait | ||
| def wait_for_rename(browser, nbname, timeout=10): | ||
| wait = WebDriverWait(browser, timeout) | ||
| def notebook_renamed(browser): | ||
| elem = browser.find_element_by_id('notebook_name') | ||
| current_name = browser.execute_script('return arguments[0].innerText', elem) | ||
| return current_name == nbname | ||
| return wait.until(notebook_renamed) | ||
| def save_as(nb): | ||
| JS = 'Jupyter.notebook.save_notebook_as()' | ||
| return nb.browser.execute_script(JS) | ||
| def get_notebook_name(nb): | ||
| JS = 'return Jupyter.notebook.notebook_name' | ||
| return nb.browser.execute_script(JS) | ||
| def set_notebook_name(nb, name): | ||
| JS = 'Jupyter.notebook.rename("{}")'.format(name) | ||
| nb.browser.execute_script(JS) | ||
| def test_save_notebook_as(notebook): | ||
| # Set a name for comparison later | ||
| set_notebook_name(notebook, name="nb1.ipynb") | ||
| wait_for_rename(notebook.browser, "nb1") | ||
| assert get_notebook_name(notebook) == "nb1.ipynb" | ||
| # Wait for Save As modal, save | ||
| save_as(notebook) | ||
| wait_for_selector(notebook.browser, '.save-message') | ||
| inp = notebook.browser.find_element_by_xpath('//input[@data-testid="save-as"]') | ||
| inp.send_keys('new_notebook.ipynb') | ||
| inp.send_keys(Keys.RETURN) | ||
| wait_for_rename(notebook.browser, "new_notebook") | ||
| # Test that the name changed | ||
| assert get_notebook_name(notebook) == "new_notebook.ipynb" | ||
| # Test that address bar was updated (TODO: get the base url) | ||
| assert "new_notebook.ipynb" in notebook.browser.current_url |