mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-10-13 23:38:45 +01:00
Merge branch 'master' of https://github.com/Azure/cosmos-explorer
This commit is contained in:
commit
4444f66e91
@ -284,43 +284,12 @@ export default class Explorer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public openInVsCode(): void {
|
public openInVsCode(): void {
|
||||||
TelemetryProcessor.traceStart(Action.OpenVSCode);
|
|
||||||
this.openVsCodeButtonClick();
|
|
||||||
}
|
|
||||||
|
|
||||||
private openVsCodeButtonClick(): void {
|
|
||||||
const activeTab = useTabs.getState().activeTab;
|
const activeTab = useTabs.getState().activeTab;
|
||||||
const resourceId = encodeURIComponent(userContext.databaseAccount.id);
|
const resourceId = encodeURIComponent(userContext.databaseAccount.id);
|
||||||
const database = encodeURIComponent(activeTab?.collection?.databaseId);
|
const database = encodeURIComponent(activeTab?.collection?.databaseId);
|
||||||
const container = encodeURIComponent(activeTab?.collection?.id());
|
const container = encodeURIComponent(activeTab?.collection?.id());
|
||||||
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;
|
||||||
const startTime = Date.now();
|
|
||||||
let vsCodeNotOpened = false;
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
const timeOutTime = Date.now() - startTime;
|
|
||||||
if (!vsCodeNotOpened && timeOutTime < 1050) {
|
|
||||||
vsCodeNotOpened = true;
|
|
||||||
useDialog.getState().openDialog(openVSCodeDialogProps);
|
|
||||||
}
|
|
||||||
}, 1000);
|
|
||||||
|
|
||||||
const link = document.createElement("a");
|
|
||||||
link.href = vscodeUrl;
|
|
||||||
link.rel = "noopener noreferrer";
|
|
||||||
document.body.appendChild(link);
|
|
||||||
|
|
||||||
try {
|
|
||||||
link.click();
|
|
||||||
document.body.removeChild(link);
|
|
||||||
TelemetryProcessor.traceStart(Action.OpenVSCode);
|
|
||||||
} catch (error) {
|
|
||||||
if (!vsCodeNotOpened) {
|
|
||||||
vsCodeNotOpened = true;
|
|
||||||
logConsoleError(`Failed to open VS Code: ${getErrorMessage(error)}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const openVSCodeDialogProps: DialogProps = {
|
const openVSCodeDialogProps: DialogProps = {
|
||||||
linkProps: {
|
linkProps: {
|
||||||
@ -335,15 +304,19 @@ export default class Explorer {
|
|||||||
secondaryButtonText: "Cancel",
|
secondaryButtonText: "Cancel",
|
||||||
|
|
||||||
onPrimaryButtonClick: () => {
|
onPrimaryButtonClick: () => {
|
||||||
vsCodeNotOpened = false;
|
try {
|
||||||
this.openVsCodeButtonClick();
|
window.location.href = vscodeUrl;
|
||||||
useDialog.getState().closeDialog();
|
TelemetryProcessor.traceStart(Action.OpenVSCode);
|
||||||
|
} catch (error) {
|
||||||
|
logConsoleError(`Failed to open VS Code: ${getErrorMessage(error)}`);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onSecondaryButtonClick: () => {
|
onSecondaryButtonClick: () => {
|
||||||
useDialog.getState().closeDialog();
|
useDialog.getState().closeDialog();
|
||||||
TelemetryProcessor.traceCancel(Action.OpenVSCode);
|
TelemetryProcessor.traceCancel(Action.OpenVSCode);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
useDialog.getState().openDialog(openVSCodeDialogProps);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async openCESCVAFeedbackBlade(): Promise<void> {
|
public async openCESCVAFeedbackBlade(): Promise<void> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user