Compare commits

...

18 Commits

Author SHA1 Message Date
JustinKol
1858c04629 Update .npmrc 2025-05-20 08:17:54 -04:00
Justin Kolasa (from Dev Box)
2db9978d72 Changed the VSCode detection to a test url that will not open if successful 2025-05-20 08:02:13 -04:00
Justin Kolasa (from Dev Box)
ec195c466a Merge branch 'users/justinkolasa/VSCode-improvements' of https://github.com/Azure/cosmos-explorer into users/justinkolasa/VSCode-improvements 2025-05-19 18:20:59 -04:00
Justin Kolasa (from Dev Box)
3f3c3f1b83 Fixed ESLint error 2025-05-19 16:32:47 -04:00
JustinKol
2318061ceb Update settings.json 2025-05-19 16:27:21 -04:00
JustinKol
fd5b9a92ca Update .npmrc 2025-05-19 16:27:03 -04:00
Justin Kolasa (from Dev Box)
b24b3d6b8e Prettier run 2025-05-19 16:24:33 -04:00
Justin Kolasa (from Dev Box)
0ccedfb9bd Better VSCode detection 2025-05-19 16:22:24 -04:00
Justin Kolasa (from Dev Box)
97eb4fe3ef Merge branch 'master' of https://github.com/Azure/cosmos-explorer 2025-05-19 16:14:35 -04:00
Justin Kolasa (from Dev Box)
f1484a72c8 Merge branch 'master' of https://github.com/Azure/cosmos-explorer 2025-05-15 16:56:07 -04:00
Justin Kolasa (from Dev Box)
4444f66e91 Merge branch 'master' of https://github.com/Azure/cosmos-explorer 2025-05-14 10:02:56 -04:00
Justin Kolasa (from Dev Box)
2180eba0a0 Merge branch 'master' of https://github.com/Azure/cosmos-explorer 2025-05-14 09:47:45 -04:00
Justin Kolasa (from Dev Box)
ea1f0e9b0c Merge branch 'master' of https://github.com/Azure/cosmos-explorer 2025-05-13 11:37:09 -04:00
Justin Kolasa (from Dev Box)
f66b78aaf8 Merge branch 'master' of https://github.com/Azure/cosmos-explorer 2025-05-13 09:28:03 -04:00
Justin Kolasa (from Dev Box)
30182ed503 Merge branch 'master' of https://github.com/Azure/cosmos-explorer 2025-05-08 08:55:42 -04:00
Justin Kolasa (from Dev Box)
9bf8cffd29 Merge branch 'master' of https://github.com/Azure/cosmos-explorer 2025-05-05 11:29:18 -04:00
Justin Kolasa (from Dev Box)
cb92bdb003 Merge branch 'master' of https://github.com/Azure/cosmos-explorer 2025-05-02 11:22:49 -04:00
Justin Kolasa (from Dev Box)
5f4ea0e614 master pull 2025-04-22 08:50:29 -04:00
2 changed files with 75 additions and 20 deletions

2
.npmrc
View File

@@ -1,4 +1,4 @@
save-exact=true
# Ignore peer dependency conflicts
force=true # TODO: Remove this when we update to React 17 or higher!
force=true # TODO: Remove this when we update to React 17 or higher!

View File

@@ -31,6 +31,7 @@ import { readDatabases } from "../Common/dataAccess/readDatabases";
import * as DataModels from "../Contracts/DataModels";
import { ContainerConnectionInfo, IPhoenixServiceInfo, IProvisionData, IResponse } from "../Contracts/DataModels";
import * as ViewModels from "../Contracts/ViewModels";
import { UploadDetailsRecord } from "../Contracts/ViewModels";
import { GitHubOAuthService } from "../GitHub/GitHubOAuthService";
import { PhoenixClient } from "../Phoenix/PhoenixClient";
import * as ExplorerSettings from "../Shared/ExplorerSettings";
@@ -71,7 +72,6 @@ import { ResourceTreeAdapter } from "./Tree/ResourceTreeAdapter";
import StoredProcedure from "./Tree/StoredProcedure";
import { useDatabases } from "./useDatabases";
import { useSelectedNode } from "./useSelectedNode";
import { UploadDetailsRecord } from "../Contracts/ViewModels";
BindingHandlersRegisterer.registerBindingHandlers();
@@ -292,32 +292,87 @@ export default class Explorer {
const baseUrl = `vscode://ms-azuretools.vscode-cosmosdb?resourceId=${resourceId}`;
const vscodeUrl = activeTab ? `${baseUrl}&database=${database}&container=${container}` : baseUrl;
const openVSCodeDialogProps: DialogProps = {
linkProps: {
linkText: "Download Visual Studio Code",
linkUrl: "https://code.visualstudio.com/download",
},
isModal: true,
title: `Open your Azure Cosmos DB account in Visual Studio Code`,
subText: `Please ensure Visual Studio Code is installed on your device.
If you don't have it installed, please download it from the link below.`,
primaryButtonText: "Open in VS Code",
secondaryButtonText: "Cancel",
// 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);
onPrimaryButtonClick: () => {
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();
}
},
onSecondaryButtonClick: () => {
useDialog.getState().closeDialog();
TelemetryProcessor.traceCancel(Action.OpenVSCode);
},
} else {
showVSCodeDialog();
}
});
const showVSCodeDialog = () => {
const openVSCodeDialogProps: DialogProps = {
linkProps: {
linkText: "Download Visual Studio Code",
linkUrl: "https://code.visualstudio.com/download",
},
isModal: true,
title: `Open your Azure Cosmos DB account in Visual Studio Code`,
subText: `Please ensure Visual Studio Code is installed on your device.
If you don't have it installed, please download it from the link below.`,
primaryButtonText: "Open in VS Code",
secondaryButtonText: "Cancel",
onPrimaryButtonClick: () => {
try {
window.location.href = vscodeUrl;
TelemetryProcessor.traceStart(Action.OpenVSCode);
} catch (error) {
logConsoleError(`Failed to open VS Code: ${getErrorMessage(error)}`);
}
},
onSecondaryButtonClick: () => {
useDialog.getState().closeDialog();
TelemetryProcessor.traceCancel(Action.OpenVSCode);
},
};
useDialog.getState().openDialog(openVSCodeDialogProps);
};
useDialog.getState().openDialog(openVSCodeDialogProps);
}
public async openCESCVAFeedbackBlade(): Promise<void> {