Skip to content
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

Merged

Conversation

simonholzapfel
Copy link
Contributor

@simonholzapfel simonholzapfel commented Nov 2, 2023

CHECKLIST

We will not consider a PR until the following items are checked off--thank you!

  • There aren't existing pull requests attempting to address the issue mentioned here
  • Submission developed in a feature branch--not master

CONVINCING DESCRIPTION

(JSConsole) Saving/Updating/Loading of Scripts in Subfolders.

  • Support for saving new Scripts in Subfolders like this:
    image

  • Fix for updating Scripts in Subfolders

@simonholzapfel simonholzapfel changed the title Saving/Updating Scripts in Subfolder JSConsole: Saving/Updating Scripts in Subfolder Nov 7, 2023
@AFaust AFaust self-requested a review November 29, 2023 08:24
@AFaust AFaust added this to the 1.2.2.0 milestone Nov 29, 2023
@p4535992
Copy link

p4535992 commented Feb 19, 2024

Is this been integrated ? Or is still in progress ? nevermind i just see the milestone 1.2.2.0

Copy link
Contributor

@AFaust AFaust left a 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);
Copy link
Contributor

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.

Copy link
Contributor

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));
Copy link
Contributor

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.

Copy link
Contributor

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));
Copy link
Contributor

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.

Copy link
Contributor

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',
Copy link
Contributor

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 of name 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 likenamePath) 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.

Copy link
Contributor

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);
Copy link
Contributor

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.

Copy link
Contributor

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) {
Copy link
Contributor

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@oboldyreva-faw oboldyreva-faw force-pushed the saving-updating-script-in-subfolder branch from b22be15 to 5dfa9ca Compare February 20, 2024 16:17
@AFaust AFaust merged commit 0c9abcb into OrderOfTheBee:master Feb 21, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants