mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-29 01:25:37 -05:00
Merge from vscode 7eaf220cafb9d9e901370ffce02229171cbf3ea6
This commit is contained in:
committed by
Anthony Dresser
parent
39d9eed585
commit
a63578e6f7
@@ -17,6 +17,9 @@
|
||||
<!-- Builtin Extensions (running out of sources) -->
|
||||
<meta id="vscode-workbench-builtin-extensions" data-settings="{{WORKBENCH_BUILTIN_EXTENSIONS}}">
|
||||
|
||||
<!-- Workbench Credentials (running out of sources) -->
|
||||
<meta id="vscode-workbench-credentials" data-settings="{{WORKBENCH_CREDENTIALS}}">
|
||||
|
||||
<!-- Workarounds/Hacks (remote user data uri) -->
|
||||
<meta id="vscode-remote-user-data-uri" data-settings="{{REMOTE_USER_DATA_URI}}">
|
||||
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IWorkbenchConstructionOptions, create, ICredentialsProvider, IURLCallbackProvider, IWorkspaceProvider, IWorkspace, IWindowIndicator, ICommand, IHomeIndicator, IProductQualityChangeHandler } from 'vs/workbench/workbench.web.api';
|
||||
import product from 'vs/platform/product/common/product';
|
||||
import { IWorkbenchConstructionOptions, create, ICredentialsProvider, IURLCallbackProvider, IWorkspaceProvider, IWorkspace, IWindowIndicator, IHomeIndicator, IProductQualityChangeHandler } from 'vs/workbench/workbench.web.api';
|
||||
import { URI, UriComponents } from 'vs/base/common/uri';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
@@ -16,6 +15,7 @@ import { isFolderToOpen, isWorkspaceToOpen } from 'vs/platform/windows/common/wi
|
||||
import { isEqual } from 'vs/base/common/resources';
|
||||
import { isStandalone } from 'vs/base/browser/browser';
|
||||
import { localize } from 'vs/nls';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
|
||||
interface ICredential {
|
||||
service: string;
|
||||
@@ -27,6 +27,13 @@ class LocalStorageCredentialsProvider implements ICredentialsProvider {
|
||||
|
||||
static readonly CREDENTIALS_OPENED_KEY = 'credentials.provider';
|
||||
|
||||
constructor(credentials: ICredential[]) {
|
||||
this._credentials = credentials;
|
||||
for (const { service, account, password } of this._credentials) {
|
||||
this.setPassword(service, account, password);
|
||||
}
|
||||
}
|
||||
|
||||
private _credentials: ICredential[] | undefined;
|
||||
private get credentials(): ICredential[] {
|
||||
if (!this._credentials) {
|
||||
@@ -277,6 +284,20 @@ class WorkspaceProvider implements IWorkspaceProvider {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
hasRemote(): boolean {
|
||||
if (this.workspace) {
|
||||
if (isFolderToOpen(this.workspace)) {
|
||||
return this.workspace.folderUri.scheme === Schemas.vscodeRemote;
|
||||
}
|
||||
|
||||
if (isWorkspaceToOpen(this.workspace)) {
|
||||
return this.workspace.workspaceUri.scheme === Schemas.vscodeRemote;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class WindowIndicator implements IWindowIndicator {
|
||||
@@ -287,8 +308,6 @@ class WindowIndicator implements IWindowIndicator {
|
||||
readonly tooltip: string;
|
||||
readonly command: string | undefined;
|
||||
|
||||
readonly commandImpl: ICommand | undefined = undefined;
|
||||
|
||||
constructor(workspace: IWorkspace) {
|
||||
let repositoryOwner: string | undefined = undefined;
|
||||
let repositoryName: string | undefined = undefined;
|
||||
@@ -306,20 +325,16 @@ class WindowIndicator implements IWindowIndicator {
|
||||
}
|
||||
}
|
||||
|
||||
// Repo
|
||||
if (repositoryName && repositoryOwner) {
|
||||
this.label = localize('openInDesktopLabel', "$(remote) Open in Desktop");
|
||||
this.tooltip = localize('openInDesktopTooltip', "Open in Desktop");
|
||||
this.command = '_web.openInDesktop';
|
||||
this.commandImpl = {
|
||||
id: this.command,
|
||||
handler: () => {
|
||||
const protocol = product.quality === 'stable' ? 'vscode' : 'vscode-insiders';
|
||||
window.open(`${protocol}://vscode.git/clone?url=${encodeURIComponent(`https://github.com/${repositoryOwner}/${repositoryName}.git`)}`);
|
||||
}
|
||||
};
|
||||
} else {
|
||||
this.label = localize('playgroundLabel', "Web Playground");
|
||||
this.tooltip = this.label;
|
||||
this.label = localize('playgroundLabelRepository', "$(remote) VS Code Web Playground: {0}/{1}", repositoryOwner, repositoryName);
|
||||
this.tooltip = localize('playgroundRepositoryTooltip', "VS Code Web Playground: {0}/{1}", repositoryOwner, repositoryName);
|
||||
}
|
||||
|
||||
// No Repo
|
||||
else {
|
||||
this.label = localize('playgroundLabel', "$(remote) VS Code Web Playground");
|
||||
this.tooltip = localize('playgroundTooltip', "VS Code Web Playground");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -391,6 +406,9 @@ class WindowIndicator implements IWindowIndicator {
|
||||
}
|
||||
}
|
||||
|
||||
// Workspace Provider
|
||||
const workspaceProvider = new WorkspaceProvider(workspace, payload);
|
||||
|
||||
// Home Indicator
|
||||
const homeIndicator: IHomeIndicator = {
|
||||
href: 'https://github.com/Microsoft/vscode',
|
||||
@@ -398,13 +416,10 @@ class WindowIndicator implements IWindowIndicator {
|
||||
title: localize('home', "Home")
|
||||
};
|
||||
|
||||
// Commands
|
||||
const commands: ICommand[] = [];
|
||||
|
||||
// Window indicator
|
||||
const windowIndicator = new WindowIndicator(workspace);
|
||||
if (windowIndicator.commandImpl) {
|
||||
commands.push(windowIndicator.commandImpl);
|
||||
// Window indicator (unless connected to a remote)
|
||||
let windowIndicator: WindowIndicator | undefined = undefined;
|
||||
if (!workspaceProvider.hasRemote()) {
|
||||
windowIndicator = new WindowIndicator(workspace);
|
||||
}
|
||||
|
||||
// Product Quality Change Handler
|
||||
@@ -422,15 +437,19 @@ class WindowIndicator implements IWindowIndicator {
|
||||
window.location.href = `${window.location.origin}?${queryString}`;
|
||||
};
|
||||
|
||||
// Find credentials from DOM
|
||||
const credentialsElement = document.getElementById('vscode-workbench-credentials');
|
||||
const credentialsElementAttribute = credentialsElement ? credentialsElement.getAttribute('data-settings') : undefined;
|
||||
const credentialsProvider = new LocalStorageCredentialsProvider(credentialsElementAttribute ? JSON.parse(credentialsElementAttribute) : []);
|
||||
|
||||
// Finally create workbench
|
||||
create(document.body, {
|
||||
...config,
|
||||
homeIndicator,
|
||||
commands,
|
||||
windowIndicator,
|
||||
productQualityChangeHandler,
|
||||
workspaceProvider: new WorkspaceProvider(workspace, payload),
|
||||
workspaceProvider,
|
||||
urlCallbackProvider: new PollingURLCallbackProvider(),
|
||||
credentialsProvider: new LocalStorageCredentialsProvider()
|
||||
credentialsProvider
|
||||
});
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user