yangzhang75 commented on code in PR #8125:
URL: https://github.com/apache/texera/pull/8125#discussion_r3890624781
##########
amber/src/main/scala/org/apache/texera/web/resource/dashboard/user/workflow/WorkflowResource.scala:
##########
@@ -726,6 +741,39 @@ class WorkflowResource extends LazyLogging {
workflowDao.update(workflow)
}
+ /**
+ * Turn the Form View on for a workflow. Only this on/off flag lives in a
column; the
+ * form's definition travels in workflow.content under `formBinding`, so
turning it
+ * off does not erase it -- toggling back on restores the author's setup.
+ */
+ @PUT
+ @RolesAllowed(Array("REGULAR", "ADMIN"))
+ @Path("/enable-form-view/{wid}")
+ def enableFormView(@PathParam("wid") wid: Integer, @Auth user: SessionUser):
Unit = {
+ setFormView(wid, user, enabled = true)
+ }
+
+ @PUT
+ @RolesAllowed(Array("REGULAR", "ADMIN"))
+ @Path("/disable-form-view/{wid}")
+ def disableFormView(@PathParam("wid") wid: Integer, @Auth user:
SessionUser): Unit = {
+ setFormView(wid, user, enabled = false)
+ }
+
+ private def setFormView(wid: Integer, user: SessionUser, enabled: Boolean):
Unit = {
+ if (!WorkflowAccessResource.hasWriteAccess(wid, user.getUid)) {
+ throw new ForbiddenException(s"You do not have permission to modify
workflow $wid")
+ }
+ // Update only this column. The flag is deliberately independent of
content, so a toggle
+ // must not rewrite the whole row -- doing so would touch content (and
could clobber a
+ // concurrent save) and bump the last-modified time for a mere flag flip.
+ context
+ .update(WORKFLOW)
+ .set(WORKFLOW.IS_FORM_VIEW, java.lang.Boolean.valueOf(enabled))
+ .where(WORKFLOW.WID.eq(wid))
+ .execute()
Review Comment:
Added a test that captures last_modified_time before enable/disable and
asserts it is unchanged after both, so a later switch back to a whole-row
update can't silently bump it.
##########
amber/src/main/scala/org/apache/texera/web/resource/dashboard/user/workflow/WorkflowVersionResource.scala:
##########
@@ -435,7 +435,9 @@ class WorkflowVersionResource {
assignNewOperatorIds(workflowVersion.getContent),
null,
null,
- false
+ false,
+ // the version's content carries the Form View definition, so keep
it usable
+ workflowVersion.getIsFormView
Review Comment:
Added tests in WorkflowVersionResourceSpec: cloneVersion now asserts the
clone inherits the source's Form View flag, with both the true and false cases.
(retrieveWorkflowVersion reconstructs from the current workflow row, so it
carries the flag.)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]