From 87fa3286994697a4619c8aae9e3cd16fa216f52b Mon Sep 17 00:00:00 2001 From: Jonathan Curran Date: Mon, 9 Jul 2018 14:34:37 -0600 Subject: [PATCH] Save notebook before publishing (#33) Before this PR we incorrectly assumed the notebook was saved and the latest changes would make it to the server. This PR fixes that incorrect assumption and saves the notebook before we attempt to publish. --- rsconnect/static/connect.js | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/rsconnect/static/connect.js b/rsconnect/static/connect.js index 8b03fa23..775e4962 100644 --- a/rsconnect/static/connect.js +++ b/rsconnect/static/connect.js @@ -850,11 +850,24 @@ define([ window.RSConnect = config; } - if (Object.keys(config.servers).length === 0) { - showAddServerDialog(false).then(showSelectServerDialog); - } else { - showSelectServerDialog(config.previousServerId); - } + // save before publishing so the server can pick up changes + Jupyter.notebook + .save_notebook() + .then(function() { + if (Object.keys(config.servers).length === 0) { + showAddServerDialog(false).then(showSelectServerDialog); + } else { + showSelectServerDialog(config.previousServerId); + } + }).catch(function(err) { + // unlikely but possible if we aren't able to save + debug.error("Failed to save notebook:", err); + Dialog.modal({ + title: 'rsconnect-jupyter', + body: 'Failed to save this notebook. Error: ' + err, + buttons: {Ok: {class: 'btn-primary'}} + }); + }); } return {