-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JSConsole: Saving/Updating Scripts in Subfolder #211
JSConsole: Saving/Updating Scripts in Subfolder #211
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you have a chance, please look through the review comments, and rebase against the latest state of the master branch (at that time).
var createFile = function createFile(parent, path) { | ||
var name = path.shift(); | ||
if (path.length > 0) { | ||
return createFile(parent.childByNamePath(name) || parent.createFolder(name), path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to validate that the return of childByNamePath
is a folder/container node. E.g. currently when the user specifies backup.js.sample/test.js
as a path, the save operation will fail but the error message will not be short and specific to the fact that the backup.js.sample
is not a folder. Instead, an integrity violation is thrown and displayed, denoting that the cm:contains
child association requires a cm:folder
and is not supported for cm:content
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added check and Error throw.
@@ -411,7 +420,12 @@ if (typeof OOTBee === 'undefined' || !OOTBee) | |||
|
|||
if (listOfScripts) | |||
{ | |||
saveMenuItems.push(listOfScripts); | |||
var scripts = JSON.parse(JSON.stringify(listOfScripts)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please initialise the variable at the start of the function to align with the existing code style.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -444,7 +458,12 @@ if (typeof OOTBee === 'undefined' || !OOTBee) | |||
|
|||
if (listOfScripts) | |||
{ | |||
loadMenuItems.push(listOfScripts); | |||
var scripts = JSON.parse(JSON.stringify(listOfScripts)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please initialise the variable at the start of the function to align with the existing code style.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -2237,7 +2256,7 @@ if (typeof OOTBee === 'undefined' || !OOTBee) | |||
saveAsExistingScript: function JavaScriptConsole_saveAsExistingScript(filename, nodeRef) | |||
{ | |||
Alfresco.util.Ajax.jsonPut({ | |||
url: Alfresco.constants.PROXY_URI + 'ootbee/jsconsole/savescript.json?name=' + encodeURIComponent(filename) + '&isUpdate=true', | |||
url: Alfresco.constants.PROXY_URI + 'ootbee/jsconsole/savescript.json?name=' + encodeURIComponent(nodeRef) + '&isUpdate=true', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Always using the nodeRef
now would allow for the following general refactoring:
- removal of
isUpdate
argument - using
nodeRef
argument instead ofname
argument in update use case - adapt the
saveScript.put.json.js
to differentiate the udpate/create use cases based on presence of either ´name(more like
namePath) and
nodeRef`
Would you be willing to include this small refactoring when processing the review comments? It's not a must and I would have done it, but the PR/branch does not allow reviewers to add commits to it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored both jsconsole.js
and saveScript.put.json.js
to use nodeRef
and namePath
arguments instead of isUpdate
if (args.name.indexOf("workspace://") === 0) { | ||
scriptFile = search.findNode(args.name); | ||
}else{ | ||
scriptFile = scriptFolder.childByNamePath(args.name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See last comment on jsconsole.js
- I think that case (update by name) is now obsolete and can be removed to always update by the NodeRef.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -74,6 +74,14 @@ function findAvailableScripts() | |||
} | |||
} | |||
|
|||
var createFile = function createFile(parent, path) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There does not need to be an assignment to a variable here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
b22be15
to
5dfa9ca
Compare
CHECKLIST
We will not consider a PR until the following items are checked off--thank you!
CONVINCING DESCRIPTION
(JSConsole) Saving/Updating/Loading of Scripts in Subfolders.
Support for saving new Scripts in Subfolders like this:
Fix for updating Scripts in Subfolders