Skip to content

Commit

Permalink
Add AutorouteSettings.AllowSetAsHomePage to control whether user can…
Browse files Browse the repository at this point in the history
… set a content to display on a home page (#8424)

* Add AutorouteSettings.AllowSetAsHomePage to control whether user can set a content to display on a home page

* Extending the description of the AllowSetAsHomePage setting

* Updating setting label

---------

Co-authored-by: Benedek Farkas <[email protected]>
  • Loading branch information
aaronamm and BenedekFarkas authored Nov 14, 2024
1 parent 6e4fefd commit 32e7d86
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class AutorouteSettings {
public AutorouteSettings() {
PerItemConfiguration = false;
AllowCustomPattern = true;
AllowSetAsHomePage = true;
UseCulturePattern = false;
AutomaticAdjustmentOnEdit = false;
PatternDefinitions = "[]";
Expand All @@ -27,6 +28,7 @@ public AutorouteSettings() {

public bool PerItemConfiguration { get; set; }
public bool AllowCustomPattern { get; set; }
public bool AllowSetAsHomePage { get; set; }
public bool UseCulturePattern { get; set; }
public bool AutomaticAdjustmentOnEdit { get; set; }
public bool? IsDefault { get; set; }
Expand Down Expand Up @@ -100,6 +102,7 @@ public List<DefaultPattern> DefaultPatterns {
public void Build(ContentTypePartDefinitionBuilder builder) {
builder.WithSetting("AutorouteSettings.PerItemConfiguration", PerItemConfiguration.ToString(CultureInfo.InvariantCulture));
builder.WithSetting("AutorouteSettings.AllowCustomPattern", AllowCustomPattern.ToString(CultureInfo.InvariantCulture));
builder.WithSetting("AutorouteSettings.AllowSetAsHomePage", AllowSetAsHomePage.ToString(CultureInfo.InvariantCulture));
builder.WithSetting("AutorouteSettings.UseCulturePattern", UseCulturePattern.ToString(CultureInfo.InvariantCulture));
builder.WithSetting("AutorouteSettings.AutomaticAdjustmentOnEdit", AutomaticAdjustmentOnEdit.ToString(CultureInfo.InvariantCulture));
builder.WithSetting("AutorouteSettings.PatternDefinitions", PatternDefinitions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,15 @@
<div>
@Html.CheckBoxFor(m => m.AllowCustomPattern)
<label class="forcheckbox" for="@Html.FieldIdFor(m => m.AllowCustomPattern)">@T("Allow custom patterns")</label>
<span class="hint">@T("Allow the user to change the pattern on each item")</span>
<span class="hint">@T("Allow the user to change the pattern on each item.")</span>
</div>
</fieldset>
<fieldset>
<div>
@Html.CheckBoxFor(m => m.AllowSetAsHomePage)
<label class="forcheckbox" for="@Html.FieldIdFor(m => m.AllowSetAsHomePage)">@T("Allow \"Set as home page\"")</label>
<span class="hint">@T("Allow the user to set a content item of this type as the home page.")</span>
<span class="hint">@T("NOTE: Certain combinations of content type definitions and permission settings can create circumstances for non-Admin users with Dashboard access to remove the home page without the ability to set another one. Use this option with caution.")</span>
</div>
</fieldset>
<fieldset>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

</fieldset>
@if (!Model.IsHomePage) {
if (AuthorizedFor(Permissions.SetHomePage)) {
if (AuthorizedFor(Permissions.SetHomePage) && Model.Settings.AllowSetAsHomePage) {
<fieldset>
<span class="checkbox-and-label">
@Html.CheckBoxFor(m => m.PromoteToHomePage)
Expand Down

0 comments on commit 32e7d86

Please sign in to comment.