mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-13 17:22:15 -05:00
* Merge from vscode bead496a613e475819f89f08e9e882b841bc1fe8 * Bump distro * Upgrade GCC to 4.9 due to yarn install errors * Update build image * Fix bootstrap base url * Bump distro * Fix build errors * Update source map file * Disable checkbox for blocking migration issues (#15131) * disable checkbox for blocking issues * wip * disable checkbox fixes * fix strings * Remove duplicate tsec command * Default to off for tab color if settings not present * re-skip failing tests * Fix mocha error * Bump sqlite version & fix notebooks search view * Turn off esbuild warnings * Update esbuild log level * Fix overflowactionbar tests * Fix ts-ignore in dropdown tests * cleanup/fixes * Fix hygiene * Bundle in entire zone.js module * Remove extra constructor param * bump distro for web compile break * bump distro for web compile break v2 * Undo log level change * New distro * Fix integration test scripts * remove the "no yarn.lock changes" workflow * fix scripts v2 * Update unit test scripts * Ensure ads-kerberos2 updates in .vscodeignore * Try fix unit tests * Upload crash reports * remove nogpu * always upload crashes * Use bash script * Consolidate data/ext dir names * Create in tmp directory Co-authored-by: chlafreniere <hichise@gmail.com> Co-authored-by: Christopher Suh <chsuh@microsoft.com> Co-authored-by: chgagnon <chgagnon@microsoft.com>
121 lines
3.2 KiB
JavaScript
121 lines
3.2 KiB
JavaScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const os = require('os');
|
|
const { ipcRenderer } = require('electron');
|
|
|
|
const builtInExtensionsPath = path.join(__dirname, '..', '..', 'product.json');
|
|
const controlFilePath = path.join(os.homedir(), '.vscode-oss-dev', 'extensions', 'control.json');
|
|
|
|
function readJson(filePath) {
|
|
return JSON.parse(fs.readFileSync(filePath, { encoding: 'utf8' }));
|
|
}
|
|
|
|
function writeJson(filePath, obj) {
|
|
fs.writeFileSync(filePath, JSON.stringify(obj, null, 2));
|
|
}
|
|
|
|
function renderOption(form, id, title, value, checked) {
|
|
const input = document.createElement('input');
|
|
input.type = 'radio';
|
|
input.id = id;
|
|
input.name = 'choice';
|
|
input.value = value;
|
|
input.checked = !!checked;
|
|
form.appendChild(input);
|
|
|
|
const label = document.createElement('label');
|
|
label.setAttribute('for', id);
|
|
label.textContent = title;
|
|
form.appendChild(label);
|
|
|
|
return input;
|
|
}
|
|
|
|
function render(el, state) {
|
|
function setState(state) {
|
|
try {
|
|
writeJson(controlFilePath, state.control);
|
|
} catch (err) {
|
|
console.error(err);
|
|
}
|
|
|
|
el.innerHTML = '';
|
|
render(el, state);
|
|
}
|
|
|
|
const ul = document.createElement('ul');
|
|
const { builtin, control } = state;
|
|
|
|
for (const ext of builtin) {
|
|
const controlState = control[ext.name] || 'marketplace';
|
|
|
|
const li = document.createElement('li');
|
|
ul.appendChild(li);
|
|
|
|
const name = document.createElement('code');
|
|
name.textContent = ext.name;
|
|
li.appendChild(name);
|
|
|
|
const form = document.createElement('form');
|
|
li.appendChild(form);
|
|
|
|
const marketplaceInput = renderOption(form, `marketplace-${ext.name}`, 'Marketplace', 'marketplace', controlState === 'marketplace');
|
|
marketplaceInput.onchange = function () {
|
|
control[ext.name] = 'marketplace';
|
|
setState({ builtin, control });
|
|
};
|
|
|
|
const disabledInput = renderOption(form, `disabled-${ext.name}`, 'Disabled', 'disabled', controlState === 'disabled');
|
|
disabledInput.onchange = function () {
|
|
control[ext.name] = 'disabled';
|
|
setState({ builtin, control });
|
|
};
|
|
|
|
let local = undefined;
|
|
|
|
if (controlState !== 'marketplace' && controlState !== 'disabled') {
|
|
local = controlState;
|
|
}
|
|
|
|
const localInput = renderOption(form, `local-${ext.name}`, 'Local', 'local', !!local);
|
|
localInput.onchange = async function () {
|
|
const result = await ipcRenderer.invoke('pickdir');
|
|
|
|
if (result) {
|
|
control[ext.name] = result;
|
|
setState({ builtin, control });
|
|
}
|
|
};
|
|
|
|
if (local) {
|
|
const localSpan = document.createElement('code');
|
|
localSpan.className = 'local';
|
|
localSpan.textContent = local;
|
|
form.appendChild(localSpan);
|
|
}
|
|
}
|
|
|
|
el.appendChild(ul);
|
|
}
|
|
|
|
function main() {
|
|
const el = document.getElementById('extensions');
|
|
const builtin = readJson(builtInExtensionsPath).builtInExtensions;
|
|
let control;
|
|
|
|
try {
|
|
control = readJson(controlFilePath);
|
|
} catch (err) {
|
|
control = {};
|
|
}
|
|
|
|
render(el, { builtin, control });
|
|
}
|
|
|
|
window.onload = main;
|