this.dispose()));
const recentlyOpened = this.workspacesService.getRecentlyOpened();
@@ -317,7 +319,7 @@ class WelcomePage extends Disposable {
while (ul.firstChild) {
ul.removeChild(ul.firstChild);
}
- await this.mapListEntries(workspacesToShow, fileService);
+ await this.mapListEntries(workspacesToShow, fileService, container);
};
await updateEntries();
this._register(this.labelService.onDidChangeFormatters(updateEntries));
@@ -334,11 +336,76 @@ class WelcomePage extends Disposable {
}
}
}));
+ this.createButtons();
this.createDropDown();
this.createWidePreviewToolTip();
this.createPreviewModal();
}
+ private createButtons(): void {
+ const container = document.querySelector('.ads-homepage .hero');
+ const dropdownButtonContainer = document.querySelector('#dropdown-btn-container') as HTMLElement;
+ const dropdownUl = document.createElement('ul');
+ const i = document.createElement('div');
+ const nav = document.createElement('nav');
+ const newText = localize('welcomePage.new', "New");
+ let dropdownBtn = this._register(new Button(dropdownButtonContainer));
+ dropdownBtn.label = newText;
+
+ const iconClassList = ['twisties', 'codicon', 'codicon-chevron-right'];
+
+ i.classList.add(...iconClassList);
+ const openFileCopy = localize('welcomePage.openFile', "Open file");
+ dropdownUl.classList.add('dropdown-content');
+ dropdownUl.setAttribute('aria-hidden', 'true');
+ dropdownUl.setAttribute('aria-label', 'submenu');
+ dropdownUl.setAttribute('role', 'menu');
+ dropdownUl.setAttribute('aria-labelledby', 'dropdown-btn');
+ dropdownUl.id = 'dropdown';
+ dropdownUl.innerHTML =
+ `
${(localize('welcomePage.newConnection', "New connection"))}
+
${(localize('welcomePage.newQuery', "New query"))}
+
${(localize('welcomePage.newNotebook', "New notebook"))}
+
${(localize('welcomePage.deployServer', "Deploy a Server"))}
+
${openFileCopy}
+
${openFileCopy} {
+ await this.commandService.executeCommand('workbench.action.files.openFile');
+ }
+ );
+ } else if (body.classList.contains('mac')) {
+ getNewFileBtn.classList.add(...fileBtnMacClasses);
+ openFileButton.onDidClick(async () => {
+ await this.commandService.executeCommand('workbench.action.files.openLocalFileFolder');
+ }
+ );
+ }
+ }
+
private enableGuidedTour(): void {
const guidedTour = this.instantiationService.createInstance(GuidedTour);
const adsHomepage = document.querySelector('.ads-homepage');
@@ -375,6 +442,7 @@ class WelcomePage extends Disposable {
guidedTour.create();
});
+
removeTourBtn.addEventListener('click', (e: MouseEvent) => {
this.configurationService.updateValue(configurationKey, 'welcomePage', ConfigurationTarget.USER);
guidedTourNotificationContainer.classList.add('hide');
@@ -390,10 +458,11 @@ class WelcomePage extends Disposable {
}
private createWidePreviewToolTip(): void {
- const previewLink = document.querySelector('#tool-tip-container-wide') as HTMLElement;
- const tooltip = document.querySelector('#tooltip-text-wide') as HTMLElement;
- const previewModalBody = document.querySelector('.preview-tooltip-body') as HTMLElement;
- const previewModalHeader = document.querySelector('.preview-tooltip-header') as HTMLElement;
+ const container = document.querySelector('.ads-homepage .tool-tip');
+ const previewLink = container.querySelector('#tool-tip-container-wide') as HTMLElement;
+ const tooltip = container.querySelector('#tooltip-text-wide') as HTMLElement;
+ const previewModalBody = container.querySelector('.preview-tooltip-body') as HTMLElement;
+ const previewModalHeader = container.querySelector('.preview-tooltip-header') as HTMLElement;
addStandardDisposableListener(previewLink, 'mouseover', () => {
tooltip.setAttribute('aria-hidden', 'true');
tooltip.classList.toggle('show');
@@ -431,6 +500,7 @@ class WelcomePage extends Disposable {
}
}
});
+
window.addEventListener('click', (event) => {
const target = event.target as HTMLTextAreaElement;
if (!target.matches('.tooltip')) {
@@ -442,8 +512,9 @@ class WelcomePage extends Disposable {
}
private createDropDown(): void {
- const dropdownBtn = document.querySelector('#dropdown-btn') as HTMLElement;
- const dropdown = document.querySelector('#dropdown') as HTMLInputElement;
+ const container = document.querySelector('.ads-homepage .hero');
+ const dropdownBtn = container.querySelector('#dropdown-btn') as HTMLElement;
+ const dropdown = container.querySelector('#dropdown') as HTMLInputElement;
addStandardDisposableListener(dropdownBtn, 'click', () => {
dropdown.classList.toggle('show');
});
@@ -466,24 +537,25 @@ class WelcomePage extends Disposable {
const body = document.querySelector('body');
if (body.classList.contains('windows') || body.classList.contains('linux')) {
- const macOnly = document.querySelector('#dropdown-mac-only');
+ const macOnly = container.querySelector('#dropdown-mac-only');
macOnly.remove();
} else if (body.classList.contains('mac')) {
- const windowsLinuxOnly = document.querySelector('#dropdown-windows-linux-only');
+ const windowsLinuxOnly = container.querySelector('#dropdown-windows-linux-only');
windowsLinuxOnly.remove();
}
window.addEventListener('click', (event) => {
const target = event.target as HTMLTextAreaElement;
- if (!target.matches('.dropdown')) {
+ if (!target.matches('#dropdown-btn')) {
if (dropdown.classList.contains('show')) {
- dropdown.classList.remove('show');
+ dropdown.classList.toggle('show');
}
}
});
addStandardDisposableListener(dropdown, 'keydown', event => {
- const dropdownLastElement = document.querySelector('#dropdown').lastElementChild.children[0] as HTMLInputElement;
- const dropdownFirstElement = document.querySelector('#dropdown').firstElementChild.children[0] as HTMLInputElement;
+ const container = document.querySelector('.ads-homepage .hero');
+ const dropdownLastElement = container.querySelector('#dropdown').lastElementChild.children[0] as HTMLInputElement;
+ const dropdownFirstElement = container.querySelector('#dropdown').firstElementChild.children[0] as HTMLInputElement;
if (event.equals(KeyCode.Tab)) {
EventHelper.stop(event);
return;
@@ -492,7 +564,7 @@ class WelcomePage extends Disposable {
if (event.target === dropdownFirstElement) {
dropdownLastElement.focus();
} else {
- const movePrev =
document.querySelector('.move:focus').parentElement.previousElementSibling.children[0] as HTMLElement;
+ const movePrev = container.querySelector('.move:focus').parentElement.previousElementSibling.children[0] as HTMLElement;
movePrev.focus();
}
}
@@ -500,7 +572,7 @@ class WelcomePage extends Disposable {
if (event.target === dropdownLastElement) {
dropdownFirstElement.focus();
} else {
- const moveNext = document.querySelector('.move:focus').parentElement.nextElementSibling.children[0] as HTMLElement;
+ const moveNext = container.querySelector('.move:focus').parentElement.nextElementSibling.children[0] as HTMLElement;
moveNext.focus();
}
}
@@ -508,13 +580,15 @@ class WelcomePage extends Disposable {
}
private createPreviewModal(): void {
- const modal = document.querySelector('#preview-modal') as HTMLElement;
- const btn = document.querySelector('#tool-tip-container-narrow') as HTMLElement;
- const span = document.querySelector('.close-icon') as HTMLElement;
- const previewModalHeader = document.querySelector('.preview-modal-header') as HTMLElement;
+ const container = document.querySelector('.ads-homepage');
+ const modal = container.querySelector('#preview-modal') as HTMLElement;
+ const btn = container.querySelector('#tool-tip-container-narrow') as HTMLElement;
+ const span = container.querySelector('.close-icon') as HTMLElement;
+ const previewModalHeader = container.querySelector('.preview-modal-header') as HTMLElement;
btn.addEventListener('click', function () {
modal.classList.toggle('show');
});
+
span.addEventListener('click', function () {
modal.classList.remove('show');
});
@@ -548,10 +622,9 @@ class WelcomePage extends Disposable {
}
}
});
-
modal.addEventListener('keydown', function (e: KeyboardEvent) {
- const previewModalBody = document.querySelector('.preview-modal-body') as HTMLElement;
- const previewModalHeader = document.querySelector('.preview-modal-header') as HTMLElement;
+ const previewModalBody = container.querySelector('.preview-modal-body') as HTMLElement;
+ const previewModalHeader = container.querySelector('.preview-modal-header') as HTMLElement;
let event = new StandardKeyboardEvent(e);
if (event.equals(KeyCode.Tab)) {
@@ -566,7 +639,7 @@ class WelcomePage extends Disposable {
});
}
- private async createListEntries(fileService: IFileService, fullPath: URI, windowOpenable: IWindowOpenable, relativePath: string): Promise {
+ private async createListEntries(container: HTMLElement, fileService: IFileService, fullPath: URI, windowOpenable: IWindowOpenable, relativePath: string): Promise {
let result: HTMLElement[] = [];
const value = await fileService.resolve(fullPath);
let date = new Date(value.mtime);
@@ -578,12 +651,13 @@ class WelcomePage extends Disposable {
const icon = document.createElement('i');
const a = document.createElement('a');
const span = document.createElement('span');
- const ul = document.querySelector('.recent ul');
+ const ul = container.querySelector('.list');
icon.title = relativePath;
a.innerText = name;
a.title = relativePath;
a.setAttribute('aria-label', localize('welcomePage.openFolderWithPath', "Open folder {0} with path {1}", name, parentPath));
a.href = 'javascript:void(0)';
+
a.addEventListener('click', e => {
this.telemetryService.publicLog2('workbenchActionExecuted', {
id: 'openRecentFolder',
@@ -606,7 +680,7 @@ class WelcomePage extends Disposable {
return result;
}
- private async mapListEntries(recents: (IRecentWorkspace | IRecentFolder)[], fileService: IFileService): Promise {
+ private async mapListEntries(recents: (IRecentWorkspace | IRecentFolder)[], fileService: IFileService, container: HTMLElement): Promise {
const result: HTMLElement[] = [];
for (let i = 0; i < recents.length; i++) {
const recent = recents[i];
@@ -621,7 +695,7 @@ class WelcomePage extends Disposable {
relativePath = recent.label || this.labelService.getWorkspaceLabel(recent.workspace, { verbose: true });
windowOpenable = { workspaceUri: recent.workspace.configPath };
}
- const elements = await this.createListEntries(fileService, fullPath, windowOpenable, relativePath);
+ const elements = await this.createListEntries(container, fileService, fullPath, windowOpenable, relativePath);
result.push(...elements);
}
return result;
@@ -662,33 +736,46 @@ class WelcomePage extends Disposable {
}
private addExtensionPack(container: HTMLElement, anchorSelector: string): void {
- const btnContainer = container.querySelector(anchorSelector);
+ const btnContainer = container.querySelector(anchorSelector) as HTMLElement;
+
if (btnContainer) {
- extensionPacks.forEach((extension, i) => {
- const a = document.createElement('a');
- const classes = ['btn', 'btn-secondary', 'a-self-end', 'flex', 'flex-a-center', 'flex-j-center'];
- const btn = document.createElement('button');
- const description = document.querySelector('.extension-pack-body');
- const header = document.querySelector('.extension-pack-header');
- a.classList.add(...classes);
- a.innerText = localize('welcomePage.install', "Install");
- a.title = extension.title || (extension.isKeymap ? localize('welcomePage.installKeymap', "Install {0} keymap", extension.name) : localize('welcomePage.installExtensionPack', "Install additional support for {0}", extension.name));
- a.classList.add('installExtension');
- a.setAttribute('data-extension', extension.id);
- a.href = 'javascript:void(0)';
- a.addEventListener('click', e => {
+ extensionPacks.forEach((extension) => {
+ const installText = localize('welcomePage.install', "Install");
+ let dropdownBtn = this._register(new Button(btnContainer));
+ dropdownBtn.label = installText;
+ const classes = ['btn', 'btn-secondary'];
+ const getDropdownBtn = container.querySelector('.extensionPack .monaco-button:first-of-type') as HTMLAnchorElement;
+ getDropdownBtn.id = 'dropdown-btn';
+ getDropdownBtn.classList.add(...classes);
+ getDropdownBtn.title = extension.title || (extension.isKeymap ? localize('welcomePage.installKeymap', "Install {0} keymap", extension.name) : localize('welcomePage.installExtensionPack', "Install additional support for {0}", extension.name));
+ getDropdownBtn.setAttribute('aria-haspopup', 'true');
+ getDropdownBtn.setAttribute('aria-controls', 'dropdown');
+ getDropdownBtn.id = 'dropdown-btn';
+ getDropdownBtn.classList.add('installExtension');
+ getDropdownBtn.setAttribute('data-extension', extension.id);
+ getDropdownBtn.href = 'javascript:void(0)';
+
+ getDropdownBtn.addEventListener('click', e => {
this.installExtension(extension);
e.preventDefault();
e.stopPropagation();
});
- btnContainer.appendChild(a);
- btn.innerText = localize('welcomePage.installed', "Installed");
- btn.title = extension.isKeymap ? localize('welcomePage.installedKeymap', "{0} keymap is already installed", extension.name) : localize('welcomePage.installedExtensionPack', "{0} support is already installed", extension.name);
- btn.classList.add('enabledExtension');
- btn.classList.add(...classes);
- btn.setAttribute('disabled', 'true');
- btn.setAttribute('data-extension', extension.id);
- btnContainer.appendChild(btn);
+
+
+ const description = container.querySelector('.extension-pack-body');
+ const header = container.querySelector('.extension-pack-header');
+
+ const installedText = localize('welcomePage.installed', "Installed");
+ let installedButton = new Button(btnContainer);
+ installedButton.label = installedText;
+ installedButton.enabled = false;
+ const getInstalledButton = container.querySelector('.extensionPack .monaco-button:nth-of-type(2)') as HTMLAnchorElement;
+
+ getInstalledButton.innerText = localize('welcomePage.installed', "Installed");
+ getInstalledButton.title = extension.isKeymap ? localize('welcomePage.installedKeymap', "{0} keymap is already installed", extension.name) : localize('welcomePage.installedExtensionPack', "{0} support is already installed", extension.name);
+ getInstalledButton.classList.add('enabledExtension');
+ getInstalledButton.classList.add(...classes);
+ getInstalledButton.setAttribute('data-extension', extension.id);
description.innerHTML = extension.description;
header.innerHTML = extension.name;
this.addExtensionPackList(container, '.extension-pack-extension-list');
@@ -923,6 +1010,7 @@ registerThemingParticipant((theme, collector) => {
const tileBackgroundColor = theme.getColor(inputBackground);
if (tileBackgroundColor) {
collector.addRule(`.monaco-workbench .part.editor > .content .welcomePageContainer .tile:not(.extension):not(.extension-pack) { background-color: ${tileBackgroundColor}; }`);
+ collector.addRule(`.monaco-workbench .part.editor > .content .welcomePageContainer .btn-secondary .monaco-button { background-color: ${tileBackgroundColor} !important; }`);
collector.addRule(`.monaco-workbench .part.editor > .content .welcomePageContainer .tool-tip .tool-tip-text { background-color: ${tileBackgroundColor}; }`);
collector.addRule(`.monaco-workbench .part.editor > .content .welcomePageContainer .modal-content { background-color: ${tileBackgroundColor}; }`);
}
@@ -955,7 +1043,7 @@ registerThemingParticipant((theme, collector) => {
}
const buttonSecondaryBackgroundColor = theme.getColor(buttonSecondaryBackground);
if (buttonSecondaryBackgroundColor) {
- collector.addRule(`.monaco-workbench .part.editor > .content .welcomePageContainer .btn-secondary { background-color: ${buttonSecondaryBackgroundColor};}`);
+ collector.addRule(`.monaco-workbench .part.editor > .content .welcomePageContainer .btn-secondary { background-color: ${buttonSecondaryBackgroundColor} !important;}`);
}
const buttonSecondaryBorderColor = theme.getColor(buttonSecondaryBorder);
if (buttonSecondaryBorderColor) {
@@ -963,7 +1051,7 @@ registerThemingParticipant((theme, collector) => {
}
const buttonSecondaryColor = theme.getColor(buttonSecondary);
if (buttonSecondaryColor) {
- collector.addRule(`.monaco-workbench .part.editor > .content .welcomePageContainer .btn-secondary { color: ${buttonSecondaryColor};}`);
+ collector.addRule(`.monaco-workbench .part.editor > .content .welcomePageContainer .btn-secondary { color: ${buttonSecondaryColor} !important;}`);
}
const buttonSecondaryHover = theme.getColor(buttonSecondaryHoverColor);
if (buttonSecondaryColor) {
@@ -1037,6 +1125,7 @@ registerThemingParticipant((theme, collector) => {
const link = theme.getColor(textLinkForeground);
if (link) {
collector.addRule(`.monaco-workbench .part.editor > .content .welcomePage a { color: ${link}; }`);
+ collector.addRule(`.monaco-workbench .part.editor > .content .welcomePage .btn-primary .monaco-button { border: 1px solid ${link}; }`);
}
const activeLink = theme.getColor(textLinkActiveForeground);
if (activeLink) {