Skip to content

Commit

Permalink
Add content workflow settings and info per tab. dnnsoftware#6115
Browse files Browse the repository at this point in the history
  • Loading branch information
tvatavuk committed Oct 1, 2024
1 parent 471a211 commit 597b84d
Show file tree
Hide file tree
Showing 12 changed files with 253 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { GridSystem, GridCell, Label, Switch, Dropdown, Button, RadioButtons, Si
import Localization from "../../localization";
import { pageActions as PageActions } from "../../actions";
import styles from "./style.less";
import utils from "../../utils";

class More extends Component {
componentDidMount() {
Expand Down Expand Up @@ -56,73 +57,73 @@ class More extends Component {
return (
<div className={styles.moreContainer}>
<div className="title">
{Localization.get("Security") }
{Localization.get("Security")}
</div>
<GridSystem>
<GridCell className="left-column">
<Label
labelType="inline"
tooltipMessage={Localization.get("SecureConnection_tooltip") }
label={Localization.get("SecureConnection") }
tooltipMessage={Localization.get("SecureConnection_tooltip")}
label={Localization.get("SecureConnection")}
/>
<Switch
labelHidden={false}
onText={Localization.get("On") }
offText={Localization.get("Off") }
onText={Localization.get("On")}
offText={Localization.get("Off")}
value={page.isSecure}
onChange={onChangeField.bind(this, "isSecure") } />
onChange={onChangeField.bind(this, "isSecure")} />
</GridCell>
<GridCell className="right-column">
<Label
labelType="inline"
tooltipMessage={Localization.get("DisableLink_tooltip") }
label={Localization.get("DisableLink") }
tooltipMessage={Localization.get("DisableLink_tooltip")}
label={Localization.get("DisableLink")}
/>
<Switch
labelHidden={false}
onText={Localization.get("On") }
offText={Localization.get("Off") }
onText={Localization.get("On")}
offText={Localization.get("Off")}
value={page.disableLink}
onChange={onChangeField.bind(this, "disableLink") } />
onChange={onChangeField.bind(this, "disableLink")} />
</GridCell>
</GridSystem>

<div className="title sectionTitle">
{Localization.get("CacheSettings") }
{Localization.get("CacheSettings")}
</div>

<GridSystem>
<GridCell className="left-column">
<Label
labelType="block"
tooltipMessage={Localization.get("OutputCacheProvider_tooltip") }
label={Localization.get("OutputCacheProvider") }
tooltipMessage={Localization.get("OutputCacheProvider_tooltip")}
label={Localization.get("OutputCacheProvider")}
/>
{cacheProviderOptions &&
<Dropdown options={cacheProviderOptions}
value={page.cacheProvider}
onSelect={this.onCacheProviderSelected.bind(this) }
onSelect={this.onCacheProviderSelected.bind(this)}
withBorder={true} />}

{page.cacheProvider &&
<SingleLineInputWithError
error={!!errors.cacheDuration}
errorMessage={errors.cacheDuration}
label={Localization.get("CacheDuration") }
tooltipMessage={Localization.get("CacheDuration_tooltip") }
label={Localization.get("CacheDuration")}
tooltipMessage={Localization.get("CacheDuration_tooltip")}
value={page.cacheDuration}
onChange={this.onChangeField.bind(this, "cacheDuration") } />}
onChange={this.onChangeField.bind(this, "cacheDuration")} />}
{page.cacheProvider &&
<div className="clear-cache">
<Label
labelType="block"
label={Localization.get("lblCachedItemCount").replace("{0}", this.props.cachedPageCount) }
label={Localization.get("lblCachedItemCount").replace("{0}", this.props.cachedPageCount)}
/>
<Button
disabled={this.props.cachedPageCount === 0}
type="secondary"
onClick={this.onClearCache.bind(this) }>
{Localization.get("ClearPageCache") }
onClick={this.onClearCache.bind(this)}>
{Localization.get("ClearPageCache")}
</Button>
</div>}
</GridCell>
Expand All @@ -131,38 +132,68 @@ class More extends Component {
<GridCell className="right-column">
<Label
labelType="inline"
tooltipMessage={Localization.get("IncludeExcludeParams_tooltip") }
label={Localization.get("IncludeExcludeParams") } />
tooltipMessage={Localization.get("IncludeExcludeParams_tooltip")}
label={Localization.get("IncludeExcludeParams")} />
<RadioButtons
options={includeExcludeOptions}
value={page.cacheIncludeExclude}
onChange={this.onChangeIncludeExclude.bind(this) } />
onChange={this.onChangeIncludeExclude.bind(this)} />

{!page.cacheIncludeExclude &&
<SingleLineInputWithError
label={Localization.get("IncludeParamsInCacheValidation") }
tooltipMessage={Localization.get("IncludeParamsInCacheValidation_tooltip") }
label={Localization.get("IncludeParamsInCacheValidation")}
tooltipMessage={Localization.get("IncludeParamsInCacheValidation_tooltip")}
value={page.cacheIncludeVaryBy}
onChange={this.onChangeField.bind(this, "cacheIncludeVaryBy") } />}
onChange={this.onChangeField.bind(this, "cacheIncludeVaryBy")} />}

{page.cacheIncludeExclude &&
<SingleLineInputWithError
label={Localization.get("ExcludeParamsInCacheValidation") }
tooltipMessage={Localization.get("ExcludeParamsInCacheValidation_tooltip") }
label={Localization.get("ExcludeParamsInCacheValidation")}
tooltipMessage={Localization.get("ExcludeParamsInCacheValidation_tooltip")}
value={page.cacheExcludeVaryBy}
onChange={this.onChangeField.bind(this, "cacheExcludeVaryBy") } />}
onChange={this.onChangeField.bind(this, "cacheExcludeVaryBy")} />}

<SingleLineInputWithError
error={!!errors.cacheMaxVaryByCount}
errorMessage={errors.cacheMaxVaryByCount}
label={Localization.get("VaryByLimit") }
tooltipMessage={Localization.get("VaryByLimit_tooltip") }
label={Localization.get("VaryByLimit")}
tooltipMessage={Localization.get("VaryByLimit_tooltip")}
value={page.cacheMaxVaryByCount}
onChange={this.onChangeField.bind(this, "cacheMaxVaryByCount") } />
onChange={this.onChangeField.bind(this, "cacheMaxVaryByCount")} />

</GridCell>
}
</GridSystem>

{utils.isPlatform() && <>
<div className="sectionTitle">Workflow</div>
<GridSystem>
<GridCell className="left-column">
<Label
labelType="inline"
tooltipMessage="TabVersionSettings"
label="EnabledVersioning" />
<Switch
onText={Localization.get("On")}
offText={Localization.get("Off")}
value={page.enabledVersioning}
onChange={onChangeField.bind(this, "enabledVersioning")} />

</GridCell>
<GridCell className="right-column">

<Label
labelType="inline"
tooltipMessage="TabWorkflowSettings"
label="WorkflowEnabled" />
<Switch
onText={Localization.get("On")}
offText={Localization.get("Off")}
value={page.workflowEnabled}
onChange={onChangeField.bind(this, "workflowEnabled")} />
</GridCell>
</GridSystem></>
}
</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,30 @@ class PageTypeSelector extends Component {
{page.tabId}
</span>
</div>
<div className="page-info-item">
<span className="page-info-item-label">
{Localization.get("PublishStatus") + ": "}
</span>
<span className="page-info-item-value">
{page.publishStatus}
</span>
</div>
<div className="page-info-item">
<span className="page-info-item-label">
{Localization.get("Versioning") + ": "}
</span>
<span className="page-info-item-value">
{page.enabledVersioning ? Localization.get("On") : Localization.get("Off")}
</span>
</div>
<div className="page-info-item">
<span className="page-info-item-label">
{Localization.get("Workflow") + ": "}
</span>
<span className="page-info-item-value">
{page.enabledVersioning && page.workflowEnabled ? page.workflowName + " (" + page.stateName + ")" : Localization.get("Off")}
</span>
</div>
</div>
<div className="page-info-row">
<div className="page-info-item page-type">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ namespace Dnn.PersonaBar.Pages.Components
using DotNetNuke.Entities.Content;
using DotNetNuke.Entities.Content.Common;
using DotNetNuke.Entities.Content.Taxonomy;
using DotNetNuke.Entities.Content.Workflow;
using DotNetNuke.Entities.Content.Workflow.Repositories;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Entities.Portals;
using DotNetNuke.Entities.Tabs;
using DotNetNuke.Entities.Tabs.TabVersions;
using DotNetNuke.Entities.Urls;
using DotNetNuke.Entities.Users;
using DotNetNuke.Framework;
Expand Down Expand Up @@ -760,6 +763,18 @@ public PageSettings GetPageSettings(int pageId, PortalSettings requestPortalSett
};
}

page.EnabledVersioning = TabVersionSettings.Instance.IsVersioningEnabled(portalSettings.PortalId, pageId);
page.WorkflowEnabled = TabWorkflowSettings.Instance.IsWorkflowEnabled(portalSettings.PortalId, pageId);
page.HasAVisibleVersion = tab.HasAVisibleVersion;
page.HasBeenPublished = tab.HasBeenPublished;
page.IsWorkflowCompleted = WorkflowHelper.IsWorkflowCompleted(tab);
page.IsWorkflowOnDraft = WorkflowEngine.Instance.IsWorkflowCompleted(tab);
page.WorkflowId = WorkflowHelper.GetTabWorkflowId(tab);
page.WorkflowName = WorkflowRepository.Instance.GetWorkflow(page.WorkflowId).WorkflowName;
page.StateId = tab.StateID;
page.StateName = WorkflowStateManager.Instance.GetWorkflowState(tab.StateID).StateName;
page.PublishStatus = tab.HasBeenPublished && page.IsWorkflowCompleted ? "Published" : "Draft";

return page;
}

Expand Down Expand Up @@ -1233,6 +1248,19 @@ protected virtual void UpdateTabInfoFromPageSettings(TabInfo tab, PageSettings p
{
tab.IconFileLarge = null;
}

var tabVersionSettings = TabVersionSettings.Instance;
var tabWorkflowSettings = TabWorkflowSettings.Instance;

if (pageSettings.EnabledVersioning.HasValue && tabVersionSettings.IsVersioningEnabled(tab.PortalID))
{
tabVersionSettings.SetEnabledVersioningForTab(tab.TabID, pageSettings.EnabledVersioning.Value);
}

if (pageSettings.WorkflowEnabled.HasValue && tabWorkflowSettings.IsWorkflowEnabled(tab.PortalID))
{
tabWorkflowSettings.SetWorkflowEnabled(tab.PortalID, tab.TabID, pageSettings.WorkflowEnabled.Value);
}
}

protected IOrderedEnumerable<KeyValuePair<int, string>> GetLocales(int portalId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,39 @@ public class PageSettings
public FileDto IconFile { get; set; }

[DataMember(Name = "iconFileLarge")]
public FileDto IconFileLarge { get; set; }
public FileDto IconFileLarge { get; set; }

[DataMember(Name = "enabledVersioning")]
public bool? EnabledVersioning { get; set; }

[DataMember(Name = "workflowEnabled")]
public bool? WorkflowEnabled { get; set; }

[DataMember(Name = "hasAVisibleVersion")]
public bool HasAVisibleVersion { get; set; }

[DataMember(Name = "hasBeenPublished")]
public bool HasBeenPublished { get; set; }

[DataMember(Name = "isWorkflowCompleted")]
public bool IsWorkflowCompleted { get; set; }

[DataMember(Name = "isWorkflowOnDraft")]
public bool IsWorkflowOnDraft { get; set; }

[DataMember(Name = "workflowId")]
public int WorkflowId { get; set; }

[DataMember(Name = "workflowName")]
public string WorkflowName { get; set; }

[DataMember(Name = "stateId")]
public int StateId { get; set; }

[DataMember(Name = "stateName")]
public string StateName { get; set; }

[DataMember(Name = "publishStatus")]
public string PublishStatus { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
<Compile Include="HttpModules\EditBarModule.cs" />
<Compile Include="Items\AddExistingModuleMenu.cs" />
<Compile Include="Items\AddModuleMenu.cs" />
<Compile Include="Items\WorkflowStateMenu.cs" />
<Compile Include="Items\CompleteWorkflowMenu.cs" />
<Compile Include="Items\DiscardWorkflowMenu.cs" />
<Compile Include="Items\DiscardStateMenu.cs" />
Expand Down Expand Up @@ -127,13 +128,15 @@
<None Include="editBar\css\SourceCodePro-Regular.ttf.woff" />
<None Include="editBar\css\SourceCodePro-Semibold.ttf" />
<None Include="editBar\css\SourceCodePro-Semibold.ttf.woff" />
<Content Include="editBar\css\WorkflowState.css" />
<Content Include="editBar\css\CompleteWorkflow.css" />
<Content Include="editBar\css\DiscardWorkflow.css" />
<Content Include="editBar\css\DiscardState.css" />
<Content Include="editBar\css\CompleteState.css" />
<Content Include="editBar\css\QuickAddModule.css" />
<Content Include="editBar\css\theme.css" />
<Content Include="editBar\QuickAddModule.html" />
<Content Include="editBar\scripts\WorkflowState.js" />
<Content Include="editBar\scripts\CompleteWorkflow.js" />
<Content Include="editBar\scripts\DiscardWorkflow.js" />
<Content Include="editBar\scripts\DiscardState.js" />
Expand Down Expand Up @@ -248,6 +251,10 @@
<Project>{6b29aded-7b56-4484-bea5-c0e09079535b}</Project>
<Name>DotNetNuke.Library</Name>
</ProjectReference>
<ProjectReference Include="..\..\Dnn.PersonaBar.Extensions\Dnn.PersonaBar.Extensions.csproj">
<Project>{9CCA271F-CFAA-42A3-B577-7D5CBB38C646}</Project>
<Name>Dnn.PersonaBar.Extensions</Name>
</ProjectReference>
<ProjectReference Include="..\..\Library\Dnn.PersonaBar.Library\Dnn.PersonaBar.Library.csproj">
<Project>{8b50ba8b-0a08-41b8-81b8-ea70707c7379}</Project>
<Name>Dnn.PersonaBar.Library</Name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace Dnn.EditBar.UI.Items
using DotNetNuke.Entities.Content.Workflow;
using DotNetNuke.Entities.Portals;
using DotNetNuke.Entities.Tabs;
using DotNetNuke.Entities.Tabs.TabVersions;
using DotNetNuke.Security.Permissions;
using DotNetNuke.Services.Personalization;

Expand All @@ -38,15 +39,16 @@ public class CompleteStateMenu : BaseMenuItem
public override string Loader { get; } = "CompleteState";

/// <inheritdoc/>
public override int Order { get; } = 77;
public override int Order { get; } = 78;

/// <inheritdoc/>
public override bool Visible()
{
var contentItem = Util.GetContentController().GetContentItem(TabController.CurrentPage.ContentItemId);
return Personalization.GetUserMode() == PortalSettings.Mode.Edit
&& DotNetNukeContext.Current.Application.SKU == "DNN" // IsPlatform
&& TabWorkflowSettings.Instance.IsWorkflowEnabled(PortalSettings.Current.PortalId) // workflow is enabled
&& TabVersionSettings.Instance.IsVersioningEnabled(PortalSettings.Current.PortalId, TabController.CurrentPage.TabID) // versioning is enabled
&& TabWorkflowSettings.Instance.IsWorkflowEnabled(PortalSettings.Current.PortalId, TabController.CurrentPage.TabID) // workflow is enabled
&& ((WorkflowEngine.Instance.IsWorkflowOnDraft(contentItem) && PermissionProvider.Instance().CanAddContentToPage(TabController.CurrentPage))
|| (!WorkflowEngine.Instance.IsWorkflowCompleted(contentItem) && WorkflowSecurity.Instance.HasStateReviewerPermission(contentItem.StateID)));
}
Expand Down
Loading

0 comments on commit 597b84d

Please sign in to comment.