Skip to content

Conversation

@tvatavuk
Copy link
Contributor

@tvatavuk tvatavuk commented Dec 9, 2025

Fixes #6810

Summary

New pages behave correctly for all combinations of Versioning and Workflow settings:

TODO

  • Add an upgrade SQL script to repair pages left in an invalid workflow state by earlier versions.
    Specifically, auto-publish pages that were incorrectly created as Draft when:
    • Versioning = On and Workflow = Off
    • Versioning = On and Workflow = Direct Publish

Copilot AI review requested due to automatic review settings December 9, 2025 19:49
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes an issue where new pages remained in Draft status when Versioning was enabled but Workflow was disabled. The fix ensures pages are created with the correct published state for all combinations of Versioning and Workflow settings, particularly addressing the broken case where Versioning=On and Workflow=Off.

Key changes:

  • Adds logic to hide workflow menu items (Complete/Discard) when Direct Publish workflow is active, reducing UI confusion
  • Refactors workflow information display in PersonaBar to show more accurate state information even when no explicit state is assigned
  • Fixes portal ID retrieval in WorkflowHelper to use the tab's portal ID instead of current portal settings

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
Dnn.AdminExperience/EditBar/Dnn.EditBar.UI/Items/WorkflowBaseMenuItem.cs Adds IsDirectPublishWorkflow property to identify when Direct Publish workflow is active
Dnn.AdminExperience/EditBar/Dnn.EditBar.UI/Items/DiscardWorkflowMenu.cs Updates visibility logic to hide discard menu when Direct Publish workflow is active
Dnn.AdminExperience/EditBar/Dnn.EditBar.UI/Items/CompleteWorkflowMenu.cs Updates visibility logic to hide complete menu when Direct Publish workflow is active
Dnn.AdminExperience/Dnn.PersonaBar.Extensions/Components/Pages/WorkflowHelper.cs Fixes potential null reference by using tab's PortalID instead of PortalSettings.Current
Dnn.AdminExperience/Dnn.PersonaBar.Extensions/Components/Pages/PagesControllerImpl.cs Refactors workflow handling to determine StateName and WorkflowName with proper null handling when StateID is not set

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +825 to +826
? workflow.LastState.StateName
: workflow.FirstState.StateName;
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

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

Potential NullReferenceException: workflow.LastState and workflow.FirstState can return null if the workflow has no states. Use the null-conditional operator to safely access StateName:

: isWorkflowCompleted
    ? workflow.LastState?.StateName
    : workflow.FirstState?.StateName;
Suggested change
? workflow.LastState.StateName
: workflow.FirstState.StateName;
? workflow.LastState?.StateName
: workflow.FirstState?.StateName;

Copilot uses AI. Check for mistakes.
public override bool Visible() => base.Visible()
&& !this.IsDirectPublishWorkflow
&& ((this.IsLastState == false && (this.IsDraftWithPermissions == true || this.IsReviewOrOtherIntermediateStateWithPermissions == true))
|| (this.IsLastState == true && this.HasUnpublishVersion && this.HasDraftPermission)); // for Direct Publish workflow
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

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

The comment "for Direct Publish workflow" is now misleading since line 37 explicitly excludes the Direct Publish workflow from being visible. This comment should either be removed or updated to clarify that this condition handles other workflow scenarios.

Suggested change
|| (this.IsLastState == true && this.HasUnpublishVersion && this.HasDraftPermission)); // for Direct Publish workflow
|| (this.IsLastState == true && this.HasUnpublishVersion && this.HasDraftPermission)); // handles other workflow scenarios (not Direct Publish)

Copilot uses AI. Check for mistakes.
&& !this.IsDirectPublishWorkflow
&& (this.IsReviewOrOtherIntermediateStateWithPermissions == true
|| (this.IsPriorState == true && this.IsDraftWithPermissions == true) // for Save Draft workflow
|| (this.IsLastState == true && this.HasUnpublishVersion && this.HasDraftPermission == true)); // for Direct Publish workflow
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

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

The comment "for Direct Publish workflow" is now misleading since line 37 explicitly excludes the Direct Publish workflow from being visible. This comment should either be removed or updated to clarify that this condition handles other workflow scenarios.

Suggested change
|| (this.IsLastState == true && this.HasUnpublishVersion && this.HasDraftPermission == true)); // for Direct Publish workflow
|| (this.IsLastState == true && this.HasUnpublishVersion && this.HasDraftPermission == true)); // handles other workflow scenarios (not Direct Publish)

Copilot uses AI. Check for mistakes.
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.

[Bug]: New pages remain in Draft when Versioning is enabled and Workflow is disabled

1 participant