File tree Expand file tree Collapse file tree 3 files changed +40
-2
lines changed Expand file tree Collapse file tree 3 files changed +40
-2
lines changed Original file line number Diff line number Diff line change 9090 cd ..
9191 jlpm install
9292 jlpm build:all
93- mv dist dist-test
9493
9594 - uses : jupyterlab/maintainer-tools/.github/actions/update-snapshots@v1
9695 with :
Original file line number Diff line number Diff line change @@ -229,6 +229,36 @@ const plugin: JupyterFrontEndPlugin<void> = {
229229 }
230230 }
231231 } ) ;
232+ /**
233+ * Add a custom Save and Share notebook command. This command
234+ * is activated only on key bindings (Accel S) and is used to
235+ * display the shareable link dialog after the notebook is
236+ * saved manually by the user.
237+ */
238+ commands . addCommand ( 'jupytereverywhere:save-and-share' , {
239+ label : 'Save and Share Notebook' ,
240+ execute : async ( ) => {
241+ const panel = readonlyTracker . currentWidget ?? tracker . currentWidget ;
242+ if ( ! panel ) {
243+ console . warn ( 'No active notebook to save' ) ;
244+ return ;
245+ }
246+ if ( panel . context . model . readOnly ) {
247+ console . info ( 'Notebook is read-only, skipping save-and-share.' ) ;
248+ return ;
249+ }
250+ manuallySharing . add ( panel ) ;
251+ await panel . context . save ( ) ;
252+ await handleNotebookSharing ( panel , sharingService , true ) ;
253+ }
254+ } ) ;
255+
256+ app . commands . addKeyBinding ( {
257+ command : 'jupytereverywhere:save-and-share' ,
258+ keys : [ 'Accel S' ] ,
259+ selector : '.jp-Notebook'
260+ } ) ;
261+
232262 /**
233263 * Add custom Create Copy notebook command
234264 * Note: this command is supported and displayed only for View Only notebooks.
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ declare global {
2020async function runCommand ( page : Page , command : string , args : JSONObject = { } ) {
2121 await page . evaluate (
2222 async ( { command, args } ) => {
23- await window . jupyterapp . commands . execute ( command , args ) ;
23+ window . jupyterapp . commands . execute ( command , args ) ;
2424 } ,
2525 { command, args }
2626 ) ;
@@ -137,6 +137,15 @@ test.describe('Sharing', () => {
137137 await runCommand ( page , 'jupytereverywhere:share-notebook' ) ;
138138 await expect ( dialog ) . toHaveCount ( 1 ) ;
139139 } ) ;
140+
141+ test ( 'Should show share dialog on Accel+S in interactive notebook' , async ( { page } ) => {
142+ await mockTokenRoute ( page ) ;
143+ await mockShareNotebookResponse ( page , 'e3b0c442-98fc-1fc2-9c9f-8b6d6ed08a1d' ) ;
144+ await runCommand ( page , 'jupytereverywhere:save-and-share' ) ;
145+ const dialog = page . locator ( '.jp-Dialog-content' ) ;
146+ await expect ( dialog ) . toBeVisible ( ) ;
147+ expect ( await dialog . screenshot ( ) ) . toMatchSnapshot ( 'share-dialog.png' ) ;
148+ } ) ;
140149} ) ;
141150
142151test . describe ( 'Download' , ( ) => {
You can’t perform that action at this time.
0 commit comments