Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Bug 528112 - Cannot create file in root in electron
  • Loading branch information
squarti committed Dec 5, 2017
1 parent d7e10ac commit fbd17ad
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 20 deletions.
5 changes: 0 additions & 5 deletions bundles/org.eclipse.orion.client.ui/web/orion/fileCommands.js
Expand Up @@ -940,11 +940,6 @@ 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") {
if ((util.isElectron && !isDirectory ) || isFileCreationAtRootEnabled()){
location = "/file";
}
}
var functionName = isDirectory ? "createFolder" : "createFile";
var deferred = fileClient[functionName](location, name, {select: true});
progressService.showWhile(deferred, i18nUtil.formatMessage(messages["Creating ${0}"], name)).then(
Expand Down
Expand Up @@ -364,7 +364,8 @@ define(["orion/Deferred", "orion/xhr", "orion/URL-shim", "orion/operation", "ori
return;
}
var data = {
Name: projectName
Name: projectName,
Directory: true
};
if (serverPath) {
data.ContentLocation = serverPath;
Expand Down
14 changes: 1 addition & 13 deletions modules/orionode/lib/fileUtil.js
Expand Up @@ -320,18 +320,6 @@ function getFileLocation(fileRoot, wwwpath, isDir) {
return filepath;
}

/**
* Gets a boolean associated with a key. Copes with Orion server REST API's use of "true" and "false" strings.
* @param {Object} obj
* @param {String} key
* @returns {Boolean} Returns <code>false</code> if there is no such key, or if the value is not the boolean <code>true</code>
* or the string <code>"true"</code>.
*/
function getBoolean(obj, key) {
var val = obj[key];
return Object.prototype.hasOwnProperty.call(obj, key) && (val === true || val === 'true');
}

/**
* File decorator interface.
*/
Expand Down Expand Up @@ -492,7 +480,7 @@ function isWorkspaceFile(file) {
* @param {?} metadataMixins Additional metadata to be mixed in to the File response.
*/
exports.handleFilePOST = function(workspaceRoot, fileRoot, req, res, destFile, metadataMixins) {
var isDirectory = req.body && getBoolean(req.body, 'Directory'),
var isDirectory = req.body && req.body.Directory,
xCreateOptions = (req.headers['x-create-options'] || "").split(","),
isCopy = xCreateOptions.indexOf('copy') !== -1,
isMove = xCreateOptions.indexOf('move') !== -1,
Expand Down
1 change: 0 additions & 1 deletion modules/orionode/lib/workspace.js
Expand Up @@ -148,7 +148,6 @@ module.exports = function(options) {
// Create/Move/Rename a project
var projectLocation = api.join(fileRoot, workspace.id, projectName);
var file = fileUtil.getFile(req, api.join(workspace.id, projectName));
req.body.Directory = true;
return fileUtil.handleFilePOST(workspaceRoot, fileRoot, req, res, file, {
Id: projectName,
ContentLocation: projectLocation,
Expand Down

0 comments on commit fbd17ad

Please sign in to comment.