Skip to content
This repository was archived by the owner on Jun 24, 2024. It is now read-only.

Commit f087868

Browse files
committed
0.1.79
1 parent ecb7ecf commit f087868

File tree

4 files changed

+74
-74
lines changed

4 files changed

+74
-74
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@aws/awsgluenotebooks-extensions",
3-
"version": "0.1.78",
3+
"version": "0.1.79",
44
"description": "A JupyterLab extension.",
55
"keywords": [
66
"amazon",

src/events.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -213,15 +213,16 @@ export const onNotebookEventReceived = (
213213
* Domain matcher; we check that the message we recieved is indeed coming from a Glue Studio notebook; if it's not we drop it
214214
* do an early return.
215215
*/
216-
const domainMatcher =
217-
/^(https:\/\/)(.*\.)?(console\.amazonaws\.cn|console\.aws\.amazon\.com|console\.amazonaws-us-gov\.com|.*notebookauthproxy\.gluestudio\.a2z\.org\.cn|.*notebookauthproxy\.gluestudio\.aws\.dev)(\/.*)?$/;
218-
219-
if (!domainMatcher.test(origin)) {
220-
fetch(
221-
`${origin}${jupyterConfigData.baseUrl}api/contents?unauthorizedOrigin&origin=${message.origin}`
222-
);
223-
return;
224-
}
216+
// NOTE: To be added back
217+
// const domainMatcher =
218+
// /^(https:\/\/)(.*\.)?(console\.amazonaws\.cn|console\.aws\.amazon\.com|console\.amazonaws-us-gov\.com|.*notebookauthproxy\.gluestudio\.a2z\.org\.cn|.*notebookauthproxy\.gluestudio\.aws\.dev)(\/.*)?$/;
219+
220+
// if (!domainMatcher.test(origin)) {
221+
// fetch(
222+
// `${origin}${jupyterConfigData.baseUrl}api/contents?unauthorizedOrigin&origin=${message.origin}`
223+
// );
224+
// return;
225+
// }
225226

226227
switch (type) {
227228
/**

src/index.ts

Lines changed: 61 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -48,72 +48,71 @@ const activate = (
4848
const temporaryScriptName = '/Untitled.ipynb';
4949
labShell.mode = 'single-document';
5050

51-
app.started
52-
.then(() => {
53-
// We are setting #glue-base because we don't want to create a jupyterlab override file for the theming
54-
// Instead we just have higher specificity and forget about the override; our theme will kick-in since it's all-in-one.
55-
// We can rework this later after release once we split this into multiple extensions.
56-
const body = document.querySelector('body');
51+
app.started.then(() => {
52+
// We are setting #glue-base because we don't want to create a jupyterlab override file for the theming
53+
// Instead we just have higher specificity and forget about the override; our theme will kick-in since it's all-in-one.
54+
// We can rework this later after release once we split this into multiple extensions.
55+
const body = document.querySelector('body');
56+
body?.classList.add('aws-fake-loader');
5757

58-
// Ensuring extension loads in an iframe within the AWS console context; otherwise do early return
59-
if (window.location === window.parent.location) {
60-
body.innerHTML = '';
61-
return;
62-
}
63-
64-
body?.setAttribute('id', 'glue-base');
65-
documentManager.createNew(temporaryScriptName, 'default', {
66-
name: kernels.gluePySpark
67-
});
68-
})
69-
.then(() => {
70-
/* Beware, horrible hacky implementation
71-
When launching the app from scratch the kernel will be selected when we create a new document but for some reason the kernel
72-
selector will still show up.
73-
74-
So this is what we do:
75-
1. When the app is started we add a class with visibility: hidden to the body. This will allow jupyter to still calculate the layout while not showing anything on-screen.
76-
2. Once the notebook has been attached we click on the modalOverlay programatically to dismiss it.
77-
3. Once the modal has been clicked we remove the visibility: hidden class.
58+
// Ensuring extension loads in an iframe within the AWS console context; otherwise do early return
59+
if (window.location === window.parent.location) {
60+
// NOTE: Te be enabled
61+
// body.innerHTML = '';
62+
return;
63+
}
64+
65+
body?.setAttribute('id', 'glue-base');
66+
documentManager.createNew(temporaryScriptName, 'default', {
67+
name: kernels.gluePySpark
68+
});
69+
});
70+
71+
notebookTracker.widgetAdded.connect(
72+
async (tracker: INotebookTracker, notebookPanel: NotebookPanel) => {
73+
/*
74+
Beware, horrible hacky implementation
75+
When launching the app from scratch the kernel will be selected when we create a new document but for some reason the kernel
76+
selector will still show up.
77+
78+
So this is what we do:
79+
1. When the app is started we add a class with visibility: hidden to the body. This will allow jupyter to still calculate the layout while not showing anything on-screen.
80+
2. Once the notebook has been attached we click on the modalOverlay programatically to dismiss it.
81+
3. Once the modal has been clicked we remove the visibility: hidden class.
7882
*/
7983
const body = document.querySelector('body');
80-
body?.classList.add('aws-fake-loader');
81-
82-
notebookTracker.widgetAdded.connect(
83-
async (tracker: INotebookTracker, notebookPanel: NotebookPanel) => {
84-
await notebookPanel.revealed;
85-
await notebookPanel.sessionContext.ready;
86-
const modalOverlay = document.querySelector(
87-
'.lm-Widget.p-Widget.jp-Dialog'
88-
) as HTMLElement | undefined;
89-
modalOverlay?.click();
90-
body.classList.remove('aws-fake-loader');
91-
92-
/**
93-
* Remove the "Save" button. We dont want the users saving to disk.
94-
*/
95-
const addBtnText = 'Save the notebook contents and create checkpoint';
96-
const addBtnSelector = `[title="${addBtnText}"]`;
97-
document.querySelector(addBtnSelector)?.parentElement?.remove();
98-
99-
const buttonContainer = document.querySelector(
100-
'.lm-Widget.p-Widget.jp-Toolbar-spacer.jp-Toolbar-item'
101-
);
102-
const downloadButton = document.createElement('button');
103-
downloadButton.innerText = 'Download';
104-
downloadButton.classList.add('glue__download-button');
105-
106-
downloadButton.onclick = () => onNotebookRequested(tracker);
107-
buttonContainer.appendChild(downloadButton);
108-
109-
/* NOTE: Try this if you need to run content programatically */
110-
// NotebookActions.run(
111-
// notebookPanel.content,
112-
// notebookPanel.sessionContext
113-
// );
114-
}
84+
await notebookPanel.revealed;
85+
await notebookPanel.sessionContext.ready;
86+
const modalOverlay = document.querySelector(
87+
'.lm-Widget.p-Widget.jp-Dialog'
88+
) as HTMLElement | undefined;
89+
modalOverlay?.click();
90+
body.classList.remove('aws-fake-loader');
91+
92+
/**
93+
* Remove the "Save" button. We dont want the users saving to disk.
94+
*/
95+
const addBtnText = 'Save the notebook contents and create checkpoint';
96+
const addBtnSelector = `[title="${addBtnText}"]`;
97+
document.querySelector(addBtnSelector)?.parentElement?.remove();
98+
99+
const buttonContainer = document.querySelector(
100+
'.lm-Widget.p-Widget.jp-Toolbar-spacer.jp-Toolbar-item'
115101
);
116-
});
102+
const downloadButton = document.createElement('button');
103+
downloadButton.innerText = 'Download';
104+
downloadButton.classList.add('glue__download-button');
105+
106+
downloadButton.onclick = () => onNotebookRequested(tracker);
107+
buttonContainer.appendChild(downloadButton);
108+
109+
/* NOTE: Try this if you need to run content programatically */
110+
// NotebookActions.run(
111+
// notebookPanel.content,
112+
// notebookPanel.sessionContext
113+
// );
114+
}
115+
);
117116

118117
/**
119118
* Every time the notebook changes we send it to Glue Studio to keep track of its state.

0 commit comments

Comments
 (0)