diff options
author | Casey Flynn <caseyflynn@google.com> | 2016-11-22 18:12:24 -0500 |
---|---|---|
committer | Michael Rennie <Michael_Rennie@ca.ibm.com> | 2016-11-24 11:32:16 -0400 |
commit | cc36e31993b42f25c6bbd7630e142affe3f78a09 (patch) | |
tree | 49667c7764657d64625931e37d604e9c08d7e502 | |
parent | e55f970624d10b2216a589f5e94258a20b58813b (diff) | |
download | org.eclipse.orion.client-cc36e31993b42f25c6bbd7630e142affe3f78a09.zip org.eclipse.orion.client-cc36e31993b42f25c6bbd7630e142affe3f78a09.tar.gz org.eclipse.orion.client-cc36e31993b42f25c6bbd7630e142affe3f78a09.tar.bz2 |
Bug 493957 - Cannot create file in root directory -- Proof Of Concept
**This code is not meant to be merged to master**
This is a proof of concept outlining changes required to save files at the root of the file system mocked out with "darklaunch" features. The hope is to generate discussion on whether the Orion community would be interested integrating this functionality driven by preferences or some other mechanism.
Change-Id: I7495c6f69c25dd0da22af30ecfcf78a701a3680e
Signed-off-by: Casey Flynn <caseyflynn@google.com>
-rw-r--r-- | bundles/org.eclipse.orion.client.ui/web/orion/explorers/explorer-table.js | 6 | ||||
-rw-r--r-- | bundles/org.eclipse.orion.client.ui/web/orion/fileCommands.js | 26 |
2 files changed, 25 insertions, 7 deletions
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/explorers/explorer-table.js b/bundles/org.eclipse.orion.client.ui/web/orion/explorers/explorer-table.js index 5e79a15..e2a5c68 100644 --- a/bundles/org.eclipse.orion.client.ui/web/orion/explorers/explorer-table.js +++ b/bundles/org.eclipse.orion.client.ui/web/orion/explorers/explorer-table.js @@ -21,7 +21,9 @@ define([ 'orion/objects', 'orion/util' ], function(messages, Deferred, lib, i18nUtil, mFileUtils, mExplorer, EventTarget, objects, util){ - +/* + * + */ /** * Tree model used by the FileExplorer */ @@ -249,7 +251,7 @@ define([ return null; } var elementNode; - if(loc === "/file" && util.isElectron){ + if(loc === "/file" && (util.isElectron || localStorage.getItem("darklaunch.createAtRoot"))){ // Special case in electron, need to find the workspace element to create file at workspace level. elementNode = this.model.root; }else{ diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/fileCommands.js b/bundles/org.eclipse.orion.client.ui/web/orion/fileCommands.js index 2b79972..04f0875 100644 --- a/bundles/org.eclipse.orion.client.ui/web/orion/fileCommands.js +++ b/bundles/org.eclipse.orion.client.ui/web/orion/fileCommands.js @@ -18,6 +18,13 @@ define(['i18n!orion/navigate/nls/messages', 'orion/webui/littlelib', 'orion/i18n 'orion/EventTarget', 'orion/form', 'orion/xsrfUtils', 'orion/bidiUtils', 'orion/util'], function(messages, lib, i18nUtil, mUIUtils, mFileUtils, mCommands, mFileDownloader, mCommandRegistry, mContentTypes, mCompareUtils, Deferred, DirPrompter, SFTPDialog, EventTarget, form, xsrfUtils, bidiUtils, util){ + function initialize_darklaunch() { + localStorage.setItem("darklaunch.createFileAtRoot", "true"); + localStorage.setItem("darklaunch.createFolderAtRoot", "true"); + localStorage.setItem("darklaunch.enableNewProject", "false"); + localStorage.setItem("darklaunch.enableLinkProject", "false"); + } + /** * Utility methods * @class This class contains static utility methods for creating and managing commands @@ -377,6 +384,9 @@ define(['i18n!orion/navigate/nls/messages', 'orion/webui/littlelib', 'orion/i18n progressService = serviceRegistry.getService("orion.page.progress"); //$NON-NLS-0$ var dispatchModelEvent = dispatchModelEventOn.bind(null); + //Enable experimental features. + initialize_darklaunch(); + function contains(arr, item) { return arr.indexOf(item) !== -1; } @@ -916,7 +926,8 @@ define(['i18n!orion/navigate/nls/messages', 'orion/webui/littlelib', 'orion/i18n var createFunction = function(name) { if (name) { var location = parentItem.Location; - if(location === "/workspace/orionode" && util.isElectron && !isDirectory ){ + if(location === "/workspace/orionode" && (util.isElectron && !isDirectory) || + localStorage.getItem("darklaunch.createFileAtRoot") || localStorage.getItem("darklaunch.createFolderAtRoot")){ // Special case for electron only to create files at workspace level. location = "/file"; } @@ -970,7 +981,7 @@ define(['i18n!orion/navigate/nls/messages', 'orion/webui/littlelib', 'orion/i18n createNewArtifact(messages["New File"], item, false); }, visibleWhen: function(item) { - return checkFolderSelection(item) || util.isElectron; + return checkFolderSelection(item) || util.isElectron || localStorage.getItem("darklaunch.createFileAtRoot") === 'true'; } }); commandService.addCommand(newFileCommand); @@ -985,7 +996,7 @@ define(['i18n!orion/navigate/nls/messages', 'orion/webui/littlelib', 'orion/i18n createNewArtifact(messages["New Folder"], item, true); }, visibleWhen: function(item) { - return checkFolderSelection(item) && !mFileUtils.isAtRoot(item.Location); + return localStorage.getItem("darklaunch.createFolderAtRoot") === 'true' || checkFolderSelection(item) && !mFileUtils.isAtRoot(item.Location); } }); commandService.addCommand(newFolderCommand); @@ -1035,7 +1046,9 @@ define(['i18n!orion/navigate/nls/messages', 'orion/webui/littlelib', 'orion/i18n }); } }, - visibleWhen: canCreateProject + visibleWhen: function(item) { + return canCreateProject && localStorage.getItem("darklaunch.enableNewProject") !== "false"; + } }); commandService.addCommand(newProjectCommand); @@ -1060,7 +1073,10 @@ define(['i18n!orion/navigate/nls/messages', 'orion/webui/littlelib', 'orion/i18n errorHandler(messages["NameLocationNotClear"]); } }, - visibleWhen: canCreateProject + visibleWhen: function (item) { + canCreateProject && localStorage.getItem("darklaunch.enableLinkProject") !== 'false'; + } + }); commandService.addCommand(linkProjectCommand); |