Skip to content

Commit a4b67da

Browse files
Merge branch 'main' into start-ckhub-api-gha
2 parents 4d8edb9 + 2df859e commit a4b67da

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

.github/workflows/update-integration-tests.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ jobs:
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:

src/index.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff 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.

ui-tests/tests/jupytereverywhere.spec.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ declare global {
2020
async 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

142151
test.describe('Download', () => {

0 commit comments

Comments
 (0)