Fix applyExplorerBindings call in Portal (#408)
This commit is contained in:
parent
f1db1ed978
commit
a14d20a88e
|
@ -156,6 +156,7 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
npm ci
|
npm ci
|
||||||
npm start &
|
npm start &
|
||||||
|
node utils/cleanupDBs.js
|
||||||
npm run wait-for-server
|
npm run wait-for-server
|
||||||
npm run test:e2e
|
npm run test:e2e
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
|
@ -41,12 +41,13 @@ export function useKnockoutExplorer(config: ConfigContext, explorerParams: Explo
|
||||||
if (config) {
|
if (config) {
|
||||||
if (config.platform === Platform.Hosted) {
|
if (config.platform === Platform.Hosted) {
|
||||||
await configureHosted(config);
|
await configureHosted(config);
|
||||||
|
applyExplorerBindings(explorer);
|
||||||
} else if (config.platform === Platform.Emulator) {
|
} else if (config.platform === Platform.Emulator) {
|
||||||
configureEmulator();
|
configureEmulator();
|
||||||
|
applyExplorerBindings(explorer);
|
||||||
} else if (config.platform === Platform.Portal) {
|
} else if (config.platform === Platform.Portal) {
|
||||||
configurePortal();
|
configurePortal();
|
||||||
}
|
}
|
||||||
applyExplorerBindings(explorer);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
effect();
|
effect();
|
||||||
|
@ -237,13 +238,14 @@ function configurePortal() {
|
||||||
);
|
);
|
||||||
console.dir(message);
|
console.dir(message);
|
||||||
explorer.configure(message);
|
explorer.configure(message);
|
||||||
|
applyExplorerBindings(explorer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// In the Portal, configuration of Explorer happens via iframe message
|
// In the Portal, configuration of Explorer happens via iframe message
|
||||||
window.addEventListener(
|
window.addEventListener(
|
||||||
"message",
|
"message",
|
||||||
(event) => {
|
(event) => {
|
||||||
console.dir(event);
|
|
||||||
if (isInvalidParentFrameOrigin(event)) {
|
if (isInvalidParentFrameOrigin(event)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -265,6 +267,7 @@ function configurePortal() {
|
||||||
}
|
}
|
||||||
|
|
||||||
explorer.configure(inputs);
|
explorer.configure(inputs);
|
||||||
|
applyExplorerBindings(explorer);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
false
|
false
|
||||||
|
|
|
@ -37,6 +37,7 @@ export const uploadNotebookIfNotExist = async (frame: Frame, notebookName: strin
|
||||||
|
|
||||||
export const getNotebookNode = async (frame: Frame, uploadNotebookName: string): Promise<ElementHandle<Element>> => {
|
export const getNotebookNode = async (frame: Frame, uploadNotebookName: string): Promise<ElementHandle<Element>> => {
|
||||||
const notebookResourceTree = await frame.waitForSelector(".notebookResourceTree");
|
const notebookResourceTree = await frame.waitForSelector(".notebookResourceTree");
|
||||||
|
await frame.waitFor(RENDER_DELAY);
|
||||||
let currentNotebookNode: ElementHandle<Element>;
|
let currentNotebookNode: ElementHandle<Element>;
|
||||||
|
|
||||||
const treeNodeHeaders = await notebookResourceTree.$$(".treeNodeHeader");
|
const treeNodeHeaders = await notebookResourceTree.$$(".treeNodeHeader");
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
const { CosmosClient } = require("@azure/cosmos");
|
||||||
|
|
||||||
|
// TODO: Add support for other API connection strings
|
||||||
|
const mongoRegex = RegExp("mongodb://.*:(.*)@(.*).mongo.cosmos.azure.com");
|
||||||
|
|
||||||
|
const connectionString = process.env.PORTAL_RUNNER_CONNECTION_STRING;
|
||||||
|
|
||||||
|
async function cleanup() {
|
||||||
|
if (!connectionString) {
|
||||||
|
throw new Error("Connection string not provided");
|
||||||
|
}
|
||||||
|
|
||||||
|
let client;
|
||||||
|
switch (true) {
|
||||||
|
case connectionString.includes("mongodb://"): {
|
||||||
|
const [, key, accountName] = connectionString.match(mongoRegex);
|
||||||
|
client = new CosmosClient({
|
||||||
|
key,
|
||||||
|
endpoint: `https://${accountName}.documents.azure.com:443/`,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// TODO: Add support for other API connection strings
|
||||||
|
default:
|
||||||
|
client = new CosmosClient(connectionString);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await client.databases.readAll().fetchAll();
|
||||||
|
return Promise.all(
|
||||||
|
response.resources.map(async (db) => {
|
||||||
|
const dbTimestamp = new Date(db._ts * 1000);
|
||||||
|
const twentyMinutesAgo = new Date(Date.now() - 1000 * 60 * 20);
|
||||||
|
if (dbTimestamp < twentyMinutesAgo) {
|
||||||
|
await client.database(db.id).delete();
|
||||||
|
console.log(`DELETED: ${db.id} | Timestamp: ${dbTimestamp}`);
|
||||||
|
} else {
|
||||||
|
console.log(`SKIPPED: ${db.id} | Timestamp: ${dbTimestamp}`);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanup()
|
||||||
|
.then(() => {
|
||||||
|
process.exit(0);
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error(error);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
Loading…
Reference in New Issue