mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-23 10:51:30 +00:00
Compare commits
18 Commits
index-arch
...
users/just
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1858c04629 | ||
|
|
2db9978d72 | ||
|
|
ec195c466a | ||
|
|
3f3c3f1b83 | ||
|
|
2318061ceb | ||
|
|
fd5b9a92ca | ||
|
|
b24b3d6b8e | ||
|
|
0ccedfb9bd | ||
|
|
97eb4fe3ef | ||
|
|
f1484a72c8 | ||
|
|
4444f66e91 | ||
|
|
2180eba0a0 | ||
|
|
ea1f0e9b0c | ||
|
|
f66b78aaf8 | ||
|
|
30182ed503 | ||
|
|
9bf8cffd29 | ||
|
|
cb92bdb003 | ||
|
|
5f4ea0e614 |
@@ -31,6 +31,7 @@ import { readDatabases } from "../Common/dataAccess/readDatabases";
|
|||||||
import * as DataModels from "../Contracts/DataModels";
|
import * as DataModels from "../Contracts/DataModels";
|
||||||
import { ContainerConnectionInfo, IPhoenixServiceInfo, IProvisionData, IResponse } from "../Contracts/DataModels";
|
import { ContainerConnectionInfo, IPhoenixServiceInfo, IProvisionData, IResponse } from "../Contracts/DataModels";
|
||||||
import * as ViewModels from "../Contracts/ViewModels";
|
import * as ViewModels from "../Contracts/ViewModels";
|
||||||
|
import { UploadDetailsRecord } from "../Contracts/ViewModels";
|
||||||
import { GitHubOAuthService } from "../GitHub/GitHubOAuthService";
|
import { GitHubOAuthService } from "../GitHub/GitHubOAuthService";
|
||||||
import { PhoenixClient } from "../Phoenix/PhoenixClient";
|
import { PhoenixClient } from "../Phoenix/PhoenixClient";
|
||||||
import * as ExplorerSettings from "../Shared/ExplorerSettings";
|
import * as ExplorerSettings from "../Shared/ExplorerSettings";
|
||||||
@@ -71,7 +72,6 @@ import { ResourceTreeAdapter } from "./Tree/ResourceTreeAdapter";
|
|||||||
import StoredProcedure from "./Tree/StoredProcedure";
|
import StoredProcedure from "./Tree/StoredProcedure";
|
||||||
import { useDatabases } from "./useDatabases";
|
import { useDatabases } from "./useDatabases";
|
||||||
import { useSelectedNode } from "./useSelectedNode";
|
import { useSelectedNode } from "./useSelectedNode";
|
||||||
import { UploadDetailsRecord } from "../Contracts/ViewModels";
|
|
||||||
|
|
||||||
BindingHandlersRegisterer.registerBindingHandlers();
|
BindingHandlersRegisterer.registerBindingHandlers();
|
||||||
|
|
||||||
@@ -292,6 +292,60 @@ export default class Explorer {
|
|||||||
const baseUrl = `vscode://ms-azuretools.vscode-cosmosdb?resourceId=${resourceId}`;
|
const baseUrl = `vscode://ms-azuretools.vscode-cosmosdb?resourceId=${resourceId}`;
|
||||||
const vscodeUrl = activeTab ? `${baseUrl}&database=${database}&container=${container}` : baseUrl;
|
const vscodeUrl = activeTab ? `${baseUrl}&database=${database}&container=${container}` : baseUrl;
|
||||||
|
|
||||||
|
// Detect if VS Code is installed
|
||||||
|
const detectVSCode = () => {
|
||||||
|
return new Promise<boolean>((resolve) => {
|
||||||
|
// Create hidden iframe to detect protocol handler
|
||||||
|
const iframe = document.createElement("iframe");
|
||||||
|
iframe.style.display = "none";
|
||||||
|
document.body.appendChild(iframe);
|
||||||
|
|
||||||
|
const timeoutId = setTimeout(() => {
|
||||||
|
if (document.body.contains(iframe)) {
|
||||||
|
document.body.removeChild(iframe);
|
||||||
|
}
|
||||||
|
resolve(false);
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Listen for blur event which might indicate app was launched
|
||||||
|
const onBlur = () => {
|
||||||
|
clearTimeout(timeoutId);
|
||||||
|
window.removeEventListener("blur", onBlur);
|
||||||
|
if (document.body.contains(iframe)) {
|
||||||
|
document.body.removeChild(iframe);
|
||||||
|
}
|
||||||
|
// Window lost focus, likely because VS Code opened
|
||||||
|
resolve(true);
|
||||||
|
};
|
||||||
|
window.addEventListener("blur", onBlur, { once: true });
|
||||||
|
// Use a test URL that won't open a specific resource but will check if the extension is installed
|
||||||
|
iframe.src = "vscode://ms-azuretools.vscode-cosmosdb?test=1";
|
||||||
|
} catch (error) {
|
||||||
|
clearTimeout(timeoutId);
|
||||||
|
if (document.body.contains(iframe)) {
|
||||||
|
document.body.removeChild(iframe);
|
||||||
|
}
|
||||||
|
resolve(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
detectVSCode().then((isVSCodeInstalled) => {
|
||||||
|
if (isVSCodeInstalled) {
|
||||||
|
try {
|
||||||
|
window.location.href = vscodeUrl;
|
||||||
|
TelemetryProcessor.traceStart(Action.OpenVSCode);
|
||||||
|
} catch (error) {
|
||||||
|
logConsoleError(`Failed to open VS Code: ${getErrorMessage(error)}`);
|
||||||
|
showVSCodeDialog();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
showVSCodeDialog();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const showVSCodeDialog = () => {
|
||||||
const openVSCodeDialogProps: DialogProps = {
|
const openVSCodeDialogProps: DialogProps = {
|
||||||
linkProps: {
|
linkProps: {
|
||||||
linkText: "Download Visual Studio Code",
|
linkText: "Download Visual Studio Code",
|
||||||
@@ -318,6 +372,7 @@ export default class Explorer {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
useDialog.getState().openDialog(openVSCodeDialogProps);
|
useDialog.getState().openDialog(openVSCodeDialogProps);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public async openCESCVAFeedbackBlade(): Promise<void> {
|
public async openCESCVAFeedbackBlade(): Promise<void> {
|
||||||
|
|||||||
Reference in New Issue
Block a user