Skip to content

Commit

Permalink
Issue 30571 has comment subaction (#30574)
Browse files Browse the repository at this point in the history
Adding a flag to know if the comment on workflow subaction is being part
of the wf action

---------

Co-authored-by: Will Ezell <[email protected]>
  • Loading branch information
jdotcms and wezell authored Nov 8, 2024
1 parent 7a5f044 commit e44f9cc
Show file tree
Hide file tree
Showing 6 changed files with 216 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,7 @@ public static WorkflowActionView convertToWorkflowActionView(final WorkflowActio
workflowActionView.setShowOn(workflowAction.getShowOn());
workflowActionView.setActionInputs(createActionInputViews(workflowAction));
workflowActionView.setMetadata(workflowAction.getMetadata());
workflowActionView.setCommentActionlet(workflowAction.hasCommentActionlet());
workflowActionView.setResetable(workflowAction.hasResetActionlet());
return workflowActionView;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@
*/
boolean onlyBatch() default false;

/**
* Set this to true if the actionlet is commentable
*/
boolean comment() default false;

/**
* Set this to true if the sub actionlet is a reset content
* @return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.List;
import java.util.Map;

@Actionlet(comment = true)
public class CommentOnWorkflowActionlet extends WorkFlowActionlet {


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1657,6 +1657,7 @@ protected void fillActionInfo(final WorkflowAction action,
boolean isPushPublish = false;
boolean isMove = false;
boolean isMoveHasPath = false;
boolean isComment = false;
boolean isReset = false;

for (final WorkflowActionClass actionClass : actionClasses) {
Expand All @@ -1672,6 +1673,7 @@ protected void fillActionInfo(final WorkflowAction action,
isDelete |= (null != actionlet) && actionlet.delete();
isDestroy |= (null != actionlet) && actionlet.destroy();
isPushPublish |= (null != actionlet) && actionlet.pushPublish();
isComment |= (null != actionlet) && actionlet.comment();
isReset |= (null != actionlet) && actionlet.reset();

/*
Expand Down Expand Up @@ -1699,6 +1701,7 @@ protected void fillActionInfo(final WorkflowAction action,
action.setPushPublishActionlet(isPushPublish);
action.setMoveActionlet(isMove);
action.setMoveActionletHashPath(isMoveHasPath);
action.setCommentActionlet(isComment);
action.setResetable(isReset);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,13 @@ public class WorkflowAction implements Permissionable, Serializable{
private boolean destroyActionlet;
private boolean moveActionlet;
private boolean moveActionletHasPath;
private boolean commentActionlet;

private Set<WorkflowState> showOn = Collections.emptySet();
private Map<String, Object> metadata = new HashMap<>();
private boolean resetable;


public WorkflowAction() {
}

Expand Down Expand Up @@ -259,6 +262,16 @@ public boolean hasMoveActionletHasPathActionlet() {
return this.moveActionletHasPath;
}


/**
* Returns true if the action has comment sub action
* @return Boolean true if has a comment action
*/
@JsonProperty("hasCommentActionlet")
public boolean hasCommentActionlet() {
return this.commentActionlet;
}

/**
* Returns true if the action has at least one action let that unpublish
* @return Boolean true if has unpublish action
Expand Down Expand Up @@ -339,6 +352,10 @@ public void setArchiveActionlet(final boolean archiveActionlet) {
this.archiveActionlet = archiveActionlet;
}

public void setCommentActionlet(final boolean isComment) {
this.commentActionlet = isComment;
}

public void setUnarchiveActionlet(final boolean unarchiveActionlet) {
this.unarchiveActionlet = unarchiveActionlet;
}
Expand Down Expand Up @@ -580,5 +597,4 @@ public int hashCode() {
return Objects.hash(id);
}


}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"info": {
"_postman_id": "f71e0eaf-03a0-48a4-b053-9724ee897240",
"_postman_id": "551fc73a-c338-498a-9aeb-b4f19b1708f9",
"name": "Workflow Resource Tests [/api/v1/workflows]",
"description": "Test the necesary validations to every end point of the worlflow resource ",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
Expand Down Expand Up @@ -17962,6 +17962,194 @@
"response": []
}
]
},
{
"name": "Commentable",
"item": [
{
"name": "CreateContentPreconditions",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200 \", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"",
"var jsonData = pm.response.json();",
"pm.collectionVariables.set(\"contentletIdentifier\", jsonData.entity.identifier);",
"pm.collectionVariables.set(\"contentletInode\", jsonData.entity.inode);",
"",
""
],
"type": "text/javascript",
"packages": {}
}
},
{
"listen": "prerequest",
"script": {
"packages": {},
"type": "text/javascript"
}
}
],
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{jwt}}",
"type": "string"
}
]
},
"method": "PUT",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"contentlet\": {\n \"contentType\": \"webPageContent\",\n \"title\": \"Test Title\",\n \"body\": \"Test Body\",\n \"contentHost\": \"default\"\n }\n}"
},
"url": {
"raw": "{{serverURL}}/api/v1/workflow/actions/default/fire/PUBLISH",
"host": [
"{{serverURL}}"
],
"path": [
"api",
"v1",
"workflow",
"actions",
"default",
"fire",
"PUBLISH"
]
},
"description": "Fire any action using the actionId\n\nOptional: If you pass ?inode={inode}, you don't need body here.\n\n@Path(\"/actions/{actionId}/fire\")"
},
"response": []
},
{
"name": "CheckCommentable",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Response has expected properties\", function () {",
" const jsonData = pm.response.json();",
" pm.expect(jsonData).to.have.property(\"entity\");",
" pm.expect(jsonData).to.have.property(\"errors\");",
" pm.expect(jsonData).to.have.property(\"i18nMessagesMap\");",
" pm.expect(jsonData).to.have.property(\"messages\");",
" pm.expect(jsonData).to.have.property(\"pagination\");",
" pm.expect(jsonData).to.have.property(\"permissions\");",
"});",
"",
"pm.test(\"Entity is an array and contains items\", function () {",
" const entity = pm.response.json().entity;",
" pm.expect(entity).to.be.an(\"array\").that.is.not.empty;",
"});",
"",
"pm.test(\"Each entity item has expected properties\", function () {",
" const entity = pm.response.json().entity;",
" entity.forEach(item => {",
" pm.expect(item).to.have.property(\"actionInputs\").that.is.an(\"array\");",
" pm.expect(item).to.have.property(\"assignable\").that.is.a(\"boolean\");",
" pm.expect(item).to.have.property(\"commentable\").that.is.a(\"boolean\");",
" pm.expect(item).to.have.property(\"condition\").that.is.a(\"string\");",
" pm.expect(item).to.have.property(\"hasArchiveActionlet\").that.is.a(\"boolean\");",
" pm.expect(item).to.have.property(\"hasDeleteActionlet\").that.is.a(\"boolean\");",
" pm.expect(item).to.have.property(\"hasDestroyActionlet\").that.is.a(\"boolean\");",
" pm.expect(item).to.have.property(\"hasMoveActionletActionlet\").that.is.a(\"boolean\");",
" pm.expect(item).to.have.property(\"hasMoveActionletHasPathActionlet\").that.is.a(\"boolean\");",
" pm.expect(item).to.have.property(\"hasOnlyBatchActionlet\").that.is.a(\"boolean\");",
" pm.expect(item).to.have.property(\"hasPublishActionlet\").that.is.a(\"boolean\");",
" pm.expect(item).to.have.property(\"hasPushPublishActionlet\").that.is.a(\"boolean\");",
" pm.expect(item).to.have.property(\"hasSaveActionlet\").that.is.a(\"boolean\");",
" pm.expect(item).to.have.property(\"hasUnarchiveActionlet\").that.is.a(\"boolean\");",
" pm.expect(item).to.have.property(\"hasUnpublishActionlet\").that.is.a(\"boolean\");",
" pm.expect(item).to.have.property(\"hasCommentActionlet\").that.is.a(\"boolean\");",
" pm.expect(item).to.have.property(\"icon\").that.is.a(\"string\");",
" pm.expect(item).to.have.property(\"id\").that.is.a(\"string\");",
" pm.expect(item).to.have.property(\"name\").that.is.a(\"string\");",
" pm.expect(item).to.have.property(\"nextAssign\").that.is.a(\"string\");",
" pm.expect(item).to.have.property(\"nextStep\").that.is.a(\"string\");",
" pm.expect(item).to.have.property(\"nextStepCurrentStep\").that.is.a(\"boolean\");",
" pm.expect(item).to.have.property(\"order\").that.is.a(\"number\");",
" pm.expect(item).to.have.property(\"owner\").that.is.null;",
" pm.expect(item).to.have.property(\"hasResetActionlet\").that.is.a(\"boolean\");",
" pm.expect(item).to.have.property(\"roleHierarchyForAssign\").that.is.a(\"boolean\");",
" pm.expect(item).to.have.property(\"schemeId\").that.is.a(\"string\");",
" pm.expect(item).to.have.property(\"showOn\").that.is.an(\"array\");",
" ",
" const allowedShowOnValues = [\"NEW\", \"LISTING\", \"PUBLISHED\", \"UNLOCKED\", \"ARCHIVED\", \"UNPUBLISHED\", \"EDITING\", \"LOCKED\"];",
" item.showOn.forEach(status => {",
" pm.expect(allowedShowOnValues).to.include(status);",
" });",
" });",
"});",
"",
"pm.test(\"Errors array is empty\", function () {",
" const errors = pm.response.json().errors;",
" pm.expect(errors).to.be.an(\"array\").that.is.empty;",
"});",
""
],
"type": "text/javascript",
"packages": {}
}
}
],
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{jwt}}",
"type": "string"
}
]
},
"method": "GET",
"header": [],
"url": {
"raw": "{{serverURL}}/api/v1/workflow/contentlet/{{contentletInode}}/actions?renderMode=EDITING",
"host": [
"{{serverURL}}"
],
"path": [
"api",
"v1",
"workflow",
"contentlet",
"{{contentletInode}}",
"actions"
],
"query": [
{
"key": "renderMode",
"value": "EDITING"
}
]
}
},
"response": []
}
]
}
],
"event": [
Expand Down

0 comments on commit e44f9cc

Please sign in to comment.