Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add preferences to disable editor UI elements. (#267)
Add preferences that will disable specific elements of the editor ui:
RunBar
Editor Settings
User Menu
Progress Indicator

Driven by the following preferences (respectively):
"/runbar": {disabled: true}
"/editorSettingsActions": {disabled: true}
"/userMenu": {disabled: true}
"/progressIndicator": {disabled: true}

Signed-off-by: Casey Flynn <caseyflynn@google.com>
  • Loading branch information
caseyflynn-google committed Nov 8, 2017
1 parent 10b5dd7 commit 48b93eb
Show file tree
Hide file tree
Showing 4 changed files with 373 additions and 334 deletions.
46 changes: 26 additions & 20 deletions bundles/org.eclipse.orion.client.ui/web/edit/setup.js
Expand Up @@ -1658,7 +1658,7 @@ objects.mixin(EditorSetup.prototype, {
this.statusService = new mStatus.StatusReportingService(serviceRegistry, this.operationsClient, "statusPane", "notifications", "notificationArea"); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$ //$NON-NLS-3$
this.commandRegistry = new mCommandRegistry.CommandRegistry({selection: this.selection});
this.dialogService = new mDialogs.DialogService(serviceRegistry, this.commandRegistry);
this.progressService = new mProgress.ProgressService(serviceRegistry, this.operationsClient, this.commandRegistry);
this.progressService = new mProgress.ProgressService(serviceRegistry, this.operationsClient, this.commandRegistry, null, this.preferences);
this.getGeneralPreferences().then(function() {
if (this.generalPreferences.enableDebugger) {
this.nativeDeployService = new mNativeDeployService.NativeDeployService(serviceRegistry, this.commandRegistry);
Expand Down Expand Up @@ -1745,27 +1745,33 @@ objects.mixin(EditorSetup.prototype, {
createRunBar: function () {
var menuBar = this.menuBar;
var runBarParent = menuBar.runBarNode;
return mCustomGlobalCommands.createRunBar({
parentNode: runBarParent,
serviceRegistry: this.serviceRegistry,
commandRegistry: this.commandRegistry,
fileClient: this.fileClient,
projectCommands: ProjectCommands,
projectClient: this.serviceRegistry.getService("orion.project.client"),
progressService: this.progressService,
preferences: this.preferences,
editorInputManager: this.editorInputManager,
generalPreferences: this.generalPreferences
}).then(function(runBar){
if (runBar) {
this.preferences.get('/runBar').then(function(prefs){ //$NON-NLS-1$
return this.preferences.get('/runbar').then(function(prefs) {
if (Boolean(prefs) && prefs.disabled === true) {
console.log('returning resolved promise.')
var d = new Deferred();
d.resolve();
return d;
}
return mCustomGlobalCommands.createRunBar({
parentNode: runBarParent,
serviceRegistry: this.serviceRegistry,
commandRegistry: this.commandRegistry,
fileClient: this.fileClient,
projectCommands: ProjectCommands,
projectClient: this.serviceRegistry.getService("orion.project.client"),
progressService: this.progressService,
preferences: this.preferences,
editorInputManager: this.editorInputManager,
generalPreferences: this.generalPreferences
}).then(function(runBar){
if (runBar) {
this.runBar = runBar;
var displayRunBar = prefs.display === undefined || prefs.display;
if (!displayRunBar) {
lib.node("runBarWrapper").style.display = "none";
}
}.bind(this));
}
if (!displayRunBar) {
lib.node("runBarWrapper").style.display = "none";
}
}
}.bind(this));
}.bind(this));
},

Expand Down
Expand Up @@ -239,8 +239,13 @@ define([
},
registerCommands: function() {
var commandRegistry = this.commandService;

commandRegistry.registerCommandContribution("settingsActions", "orion.edit.settings", 1, null, false, new mKeyBinding.KeyBinding("s", true, true), null, this); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
if (this.preferences) {
this.preferences.get('/editorSettingsActions').then(function(prefs) {
if (!Boolean(prefs) || !Boolean(prefs.disabled)) {
commandRegistry.registerCommandContribution("settingsActions", "orion.edit.settings", 1, null, false, new mKeyBinding.KeyBinding("s", true, true), null, this); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
}
}.bind(this));
}
commandRegistry.registerCommandContribution(this.editToolbarId || this.toolbarId, "orion.edit.undo", 400, this.editToolbarId ? "orion.menuBarEditGroup/orion.edit.undoGroup" : null, !this.editToolbarId, new mKeyBinding.KeyBinding('z', true), null, this); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-3$
commandRegistry.registerCommandContribution(this.editToolbarId || this.toolbarId, "orion.edit.redo", 401, this.editToolbarId ? "orion.menuBarEditGroup/orion.edit.undoGroup" : null, !this.editToolbarId, util.isMac ? new mKeyBinding.KeyBinding('z', true, true) : new mKeyBinding.KeyBinding('y', true), null, this); //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-4$
commandRegistry.registerCommandContribution(this.saveToolbarId || this.toolbarId, "orion.edit.openFolder", 1, this.saveToolbarId ? "orion.menuBarFileGroup/orion.edit.saveGroup" : null, false, new mKeyBinding.KeyBinding('o', true)); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
Expand Down
69 changes: 39 additions & 30 deletions bundles/org.eclipse.orion.client.ui/web/orion/globalCommands.js
Expand Up @@ -131,41 +131,50 @@ define([
* @function
*/

function generateUserInfo(serviceRegistry, keyAssistFunction) {
var authServices = serviceRegistry.getServiceReferences("orion.core.auth"); //$NON-NLS-0$
authenticationIds = [];

var menuGenerator = customGlobalCommands.createMenuGenerator.apply(this, arguments);

if (!menuGenerator) { return; }

for (var i = 0; i < authServices.length; i++) {
var servicePtr = authServices[i];
var authService = serviceRegistry.getService(servicePtr);
getLabel(authService, servicePtr).then(function (label) {
authService.getKey().then(function (key) {
authenticationIds.push(key);
authService.getUser().then(function (jsonData) {
menuGenerator.addUserItem(key, authService, label, jsonData);
}, function (errorData, jsonData) {
menuGenerator.addUserItem(key, authService, label, jsonData);
});
window.addEventListener("storage", function (e) {
if (authRendered[key] === localStorage.getItem(key)) {
return;
}
function generateUserInfo(serviceRegistry, keyAssistFunction, prefsService) {
prefsService.get("/userMenu").then(function(prefs) {
if (Boolean(prefs) && prefs.disabled === true) {
var menu = lib.node("userMenu");
if (Boolean(menu)) {
menu.parentElement.removeChild(menu);
}
return;
}
var authServices = serviceRegistry.getServiceReferences("orion.core.auth"); //$NON-NLS-0$
authenticationIds = [];

var menuGenerator = customGlobalCommands.createMenuGenerator.apply(this, arguments);

authRendered[key] = localStorage.getItem(key);
if (!menuGenerator) { return; }

for (var i = 0; i < authServices.length; i++) {
var servicePtr = authServices[i];
var authService = serviceRegistry.getService(servicePtr);
getLabel(authService, servicePtr).then(function (label) {
authService.getKey().then(function (key) {
authenticationIds.push(key);
authService.getUser().then(function (jsonData) {
menuGenerator.addUserItem(key, authService, label, jsonData);
}, function (errorData) {
menuGenerator.addUserItem(key, authService, label);
}, function (errorData, jsonData) {
menuGenerator.addUserItem(key, authService, label, jsonData);
});
}, false);
window.addEventListener("storage", function (e) {
if (authRendered[key] === localStorage.getItem(key)) {
return;
}

authRendered[key] = localStorage.getItem(key);

authService.getUser().then(function (jsonData) {
menuGenerator.addUserItem(key, authService, label, jsonData);
}, function (errorData) {
menuGenerator.addUserItem(key, authService, label);
});
}, false);
});
});
});
}
}
});
}

// Related links menu management. The related menu is reused as content changes. If the menu becomes empty, we hide the dropdown.
Expand Down Expand Up @@ -856,7 +865,7 @@ define([

renderGlobalCommands(commandRegistry);

generateUserInfo(serviceRegistry, keyAssistCommand.callback);
generateUserInfo(serviceRegistry, keyAssistCommand.callback, prefsService);
}


Expand Down

0 comments on commit 48b93eb

Please sign in to comment.