forked from dnnsoftware/Dnn.Platform
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integration of Content Workflow API dnnsoftware#6115
- Loading branch information
Showing
53 changed files
with
3,101 additions
and
1,723 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
DNN Platform/Library/Entities/Content/Workflow/Actions/TabActions/CompleteState.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information | ||
|
||
namespace DotNetNuke.Entities.Content.Workflow.Actions.TabActions | ||
{ | ||
using DotNetNuke.Entities.Content.Workflow.Actions; | ||
using DotNetNuke.Entities.Content.Workflow.Dto; | ||
using DotNetNuke.Entities.Content.Workflow.Entities; | ||
|
||
/// <summary> | ||
/// Completes a state, moving the workflow forward to the next state. If the next state is not the last one, | ||
/// it sends notifications to the reviewers of the next state; otherwise, it sends a notification to the user | ||
/// who submitted the draft once the workflow is complete. | ||
/// </summary> | ||
internal class CompleteState : TabActionBase, IWorkflowAction | ||
{ | ||
/// <inheritdoc /> | ||
public void DoActionOnStateChanging(StateTransaction stateTransaction) | ||
{ | ||
// nothing | ||
} | ||
|
||
/// <inheritdoc /> | ||
public void DoActionOnStateChanged(StateTransaction stateTransaction) | ||
=> RemoveCache(stateTransaction); | ||
|
||
/// <inheritdoc /> | ||
public ActionMessage GetActionMessage(StateTransaction stateTransaction, WorkflowState currentState) | ||
=> new () | ||
{ | ||
Subject = GetString($"{nameof(CompleteState)}{nameof(ActionMessage.Subject)}", "Page Approval"), | ||
Body = GetString($"{nameof(CompleteState)}{nameof(ActionMessage.Body)}", "Page '{0}' is in the '{1}' state and awaits review and approval.", GetTab(stateTransaction.ContentItemId).LocalizedTabName, currentState.StateName), | ||
}; | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
DNN Platform/Library/Entities/Content/Workflow/Actions/TabActions/CompleteWorkflow.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information | ||
|
||
namespace DotNetNuke.Entities.Content.Workflow.Actions.TabActions | ||
{ | ||
using DotNetNuke.Entities.Content.Workflow.Actions; | ||
using DotNetNuke.Entities.Content.Workflow.Dto; | ||
using DotNetNuke.Entities.Content.Workflow.Entities; | ||
using DotNetNuke.Entities.Tabs.TabVersions; | ||
|
||
/// <summary> | ||
/// Completes the workflow, no matter what the current state is. | ||
/// It also sends a system notification to the user who submitted the workflow to | ||
/// inform them about the complete workflow action. | ||
/// </summary> | ||
internal class CompleteWorkflow : TabActionBase, IWorkflowAction | ||
{ | ||
/// <summary> | ||
/// Publishes the tab version. | ||
/// </summary> | ||
/// <param name="stateTransaction">The state transaction.</param> | ||
public void DoActionOnStateChanging(StateTransaction stateTransaction) | ||
{ | ||
var tab = GetTab(stateTransaction.ContentItemId); | ||
if (tab == null) | ||
{ | ||
return; | ||
} | ||
|
||
TabVersionBuilder.Instance.Publish(tab.PortalID, tab.TabID, stateTransaction.UserId); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public void DoActionOnStateChanged(StateTransaction stateTransaction) | ||
=> RemoveCache(stateTransaction); | ||
|
||
/// <inheritdoc /> | ||
public ActionMessage GetActionMessage(StateTransaction stateTransaction, WorkflowState currentState) | ||
=> new () | ||
{ | ||
Subject = GetString($"{nameof(CompleteWorkflow)}{nameof(ActionMessage.Subject)}", "Page Published"), | ||
Body = GetString($"{nameof(CompleteWorkflow)}{nameof(ActionMessage.Body)}", "Page '{0}' has been published and is now live.", GetTab(stateTransaction.ContentItemId).LocalizedTabName), | ||
}; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
DNN Platform/Library/Entities/Content/Workflow/Actions/TabActions/DiscardState.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information | ||
|
||
namespace DotNetNuke.Entities.Content.Workflow.Actions.TabActions | ||
{ | ||
using DotNetNuke.Entities.Content.Workflow.Actions; | ||
using DotNetNuke.Entities.Content.Workflow.Dto; | ||
using DotNetNuke.Entities.Content.Workflow.Entities; | ||
|
||
/// <summary> | ||
/// Discards a state, moving the workflow backward to the previous state. If the previous state is not the first one, | ||
/// it sends notifications to the reviewers of the previous state; otherwise, it sends a notification to the user | ||
/// who submitted the draft when the workflow is in the draft state. | ||
/// </summary> | ||
internal class DiscardState : TabActionBase, IWorkflowAction | ||
{ | ||
/// <inheritdoc /> | ||
public void DoActionOnStateChanging(StateTransaction stateTransaction) | ||
{ | ||
// nothing | ||
} | ||
|
||
/// <inheritdoc /> | ||
public void DoActionOnStateChanged(StateTransaction stateTransaction) | ||
=> RemoveCache(stateTransaction); | ||
|
||
/// <inheritdoc /> | ||
public ActionMessage GetActionMessage(StateTransaction stateTransaction, WorkflowState currentState) | ||
=> new () | ||
{ | ||
Subject = GetString($"{nameof(DiscardState)}{nameof(ActionMessage.Subject)}", "Page Rejected"), | ||
Body = GetString($"{nameof(DiscardState)}{nameof(ActionMessage.Body)}", "The edits for page '{0}' were rejected, and it is now in '{1}' state.", GetTab(stateTransaction.ContentItemId).LocalizedTabName, currentState.StateName), | ||
}; | ||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
DNN Platform/Library/Entities/Content/Workflow/Actions/TabActions/DiscardWorkflow.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information | ||
|
||
namespace DotNetNuke.Entities.Content.Workflow.Actions.TabActions | ||
{ | ||
using System.Linq; | ||
|
||
using DotNetNuke.Common.Utilities; | ||
using DotNetNuke.Entities.Content.Workflow.Actions; | ||
using DotNetNuke.Entities.Content.Workflow.Dto; | ||
using DotNetNuke.Entities.Content.Workflow.Entities; | ||
using DotNetNuke.Entities.Portals; | ||
using DotNetNuke.Entities.Tabs; | ||
using DotNetNuke.Entities.Tabs.TabVersions; | ||
|
||
/// <summary> | ||
/// Discards the tab workflow, no matter what the current state is. It also sends a system notification to the user | ||
/// who submitted the workflow to inform them about the discard workflow action. | ||
/// </summary> | ||
internal class DiscardWorkflow : TabActionBase, IWorkflowAction | ||
{ | ||
/// <summary> | ||
/// Discards the tab version. | ||
/// </summary> | ||
/// <param name="stateTransaction">The state transaction.</param> | ||
public void DoActionOnStateChanging(StateTransaction stateTransaction) | ||
{ | ||
var tab = GetTab(stateTransaction.ContentItemId); | ||
if (tab == null) | ||
{ | ||
return; | ||
} | ||
|
||
TabVersionBuilder.Instance.Discard(tab.TabID, stateTransaction.UserId); | ||
} | ||
|
||
/// <summary> | ||
/// Deletes the tab when necessary. | ||
/// </summary> | ||
/// <param name="stateTransaction">The state transaction.</param> | ||
public void DoActionOnStateChanged(StateTransaction stateTransaction) | ||
{ | ||
var tab = GetTab(stateTransaction.ContentItemId); | ||
if (tab == null) | ||
{ | ||
return; | ||
} | ||
|
||
if (HasOnlyOneTabVersion(tab)) | ||
{ | ||
TabController.Instance.SoftDeleteTab(tab.TabID, new PortalSettings(tab.PortalID)); | ||
TabController.Instance.DeleteTab(tab.TabID, tab.PortalID); | ||
} | ||
|
||
DataCache.RemoveCache($"Tab_Tabs{tab.PortalID}"); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public ActionMessage GetActionMessage(StateTransaction stateTransaction, WorkflowState currentState) | ||
=> new () | ||
{ | ||
Subject = GetString($"{nameof(DiscardWorkflow)}{nameof(ActionMessage.Subject)}", "Page Discarded"), | ||
Body = GetString($"{nameof(DiscardWorkflow)}{nameof(ActionMessage.Body)}", "Edits for page '{0}' have been discarded.", GetTab(stateTransaction.ContentItemId).LocalizedTabName), | ||
}; | ||
|
||
/// <summary> | ||
/// Checks if the tab has only one version. | ||
/// </summary> | ||
/// <param name="tabInfo">The tab information.</param> | ||
/// <returns>True if the tab has only one version; otherwise, false.</returns> | ||
private static bool HasOnlyOneTabVersion(TabInfo tabInfo) | ||
{ | ||
var tabVersions = TabVersionController.Instance.GetTabVersions(tabInfo.TabID, true); | ||
return tabVersions == null || !tabVersions.Any(); | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
DNN Platform/Library/Entities/Content/Workflow/Actions/TabActions/StartWorkflow.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information | ||
|
||
namespace DotNetNuke.Entities.Content.Workflow.Actions.TabActions | ||
{ | ||
using DotNetNuke.Entities.Content.Workflow.Actions; | ||
using DotNetNuke.Entities.Content.Workflow.Dto; | ||
using DotNetNuke.Entities.Content.Workflow.Entities; | ||
|
||
/// <summary> | ||
/// Starts a tab workflow. | ||
/// </summary> | ||
internal class StartWorkflow : TabActionBase, IWorkflowAction | ||
{ | ||
/// <inheritdoc /> | ||
public void DoActionOnStateChanging(StateTransaction stateTransaction) | ||
{ | ||
// nothing | ||
} | ||
|
||
/// <inheritdoc /> | ||
public void DoActionOnStateChanged(StateTransaction stateTransaction) | ||
=> RemoveCache(stateTransaction); | ||
|
||
/// <inheritdoc /> | ||
public ActionMessage GetActionMessage(StateTransaction stateTransaction, WorkflowState currentState) | ||
=> new () | ||
{ | ||
Subject = GetString($"{nameof(StartWorkflow)}{nameof(ActionMessage.Subject)}", "Page Submitted"), | ||
Body = GetString($"{nameof(StartWorkflow)}{nameof(ActionMessage.Body)}", "Page '{0}' is in the '{1}' state and waiting to be submitted.", GetTab(stateTransaction.ContentItemId).LocalizedTabName, currentState.StateName), | ||
}; | ||
} | ||
} |
Oops, something went wrong.