Skip to content

Commit

Permalink
Merge pull request umbraco#5109 from leekelleher/chore/constants-root
Browse files Browse the repository at this point in the history
V8: Updated Constant.System.Root references (to use correct constant, and others)
  • Loading branch information
Warren Buckley authored Apr 1, 2019
2 parents 61cfba5 + 0a687ab commit 3af8d0e
Show file tree
Hide file tree
Showing 34 changed files with 110 additions and 130 deletions.
4 changes: 2 additions & 2 deletions src/Umbraco.Core/Compose/RelateOnTrashComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public void Terminate()

private static void ContentService_Moved(IContentService sender, MoveEventArgs<IContent> e)
{
foreach (var item in e.MoveInfoCollection.Where(x => x.OriginalPath.Contains(Constants.System.RecycleBinContent.ToInvariantString())))
foreach (var item in e.MoveInfoCollection.Where(x => x.OriginalPath.Contains(Constants.System.RecycleBinContentString)))
{
var relationService = Current.Services.RelationService;
const string relationTypeAlias = Constants.Conventions.RelationTypes.RelateParentDocumentOnDeleteAlias;
Expand All @@ -37,7 +37,7 @@ private static void ContentService_Moved(IContentService sender, MoveEventArgs<I

private static void MediaService_Moved(IMediaService sender, MoveEventArgs<IMedia> e)
{
foreach (var item in e.MoveInfoCollection.Where(x => x.OriginalPath.Contains(Constants.System.RecycleBinMedia.ToInvariantString())))
foreach (var item in e.MoveInfoCollection.Where(x => x.OriginalPath.Contains(Constants.System.RecycleBinMediaString)))
{
var relationService = Current.Services.RelationService;
const string relationTypeAlias = Constants.Conventions.RelationTypes.RelateParentMediaFolderOnDeleteAlias;
Expand Down
1 change: 0 additions & 1 deletion src/Umbraco.Core/Constants-AppSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ public static class AppSettings
/// </summary>
public const string DisableElectionForSingleServer = "Umbraco.Core.DisableElectionForSingleServer";


/// <summary>
/// Debug specific web.config AppSetting keys for Umbraco
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions src/Umbraco.Core/Constants-Applications.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,11 @@ public static class Trees

public const string PartialViewMacros = "partialViewMacros";

public const string LogViewer = "logViewer";
public const string LogViewer = "logViewer";

public static class Groups
{
public const string Settings = "settingsGroup";
public const string Settings = "settingsGroup";

public const string Templating = "templatingGroup";

Expand Down
116 changes: 58 additions & 58 deletions src/Umbraco.Core/Constants-Conventions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ public static class Media
/// </summary>
public const string Extension = "umbracoExtension";

/// <summary>
/// The default height/width of an image file if the size can't be determined from the metadata
/// </summary>
public const int DefaultSize = 200;
/// <summary>
/// The default height/width of an image file if the size can't be determined from the metadata
/// </summary>
public const int DefaultSize = 200;
}

/// <summary>
Expand Down Expand Up @@ -209,71 +209,71 @@ public static class Member
public static Dictionary<string, PropertyType> GetStandardPropertyTypeStubs()
{
return new Dictionary<string, PropertyType>
{
{
Comments,
new PropertyType(PropertyEditors.Aliases.TextArea, ValueStorageType.Ntext, true, Comments)
{
Comments,
new PropertyType(PropertyEditors.Aliases.TextArea, ValueStorageType.Ntext, true, Comments)
{
Name = CommentsLabel
}
},
Name = CommentsLabel
}
},
{
FailedPasswordAttempts,
new PropertyType(PropertyEditors.Aliases.Label, ValueStorageType.Integer, true, FailedPasswordAttempts)
{
FailedPasswordAttempts,
new PropertyType(PropertyEditors.Aliases.Label, ValueStorageType.Integer, true, FailedPasswordAttempts)
{
Name = FailedPasswordAttemptsLabel
}
},
Name = FailedPasswordAttemptsLabel
}
},
{
IsApproved,
new PropertyType(PropertyEditors.Aliases.Boolean, ValueStorageType.Integer, true, IsApproved)
{
IsApproved,
new PropertyType(PropertyEditors.Aliases.Boolean, ValueStorageType.Integer, true, IsApproved)
{
Name = IsApprovedLabel
}
},
Name = IsApprovedLabel
}
},
{
IsLockedOut,
new PropertyType(PropertyEditors.Aliases.Boolean, ValueStorageType.Integer, true, IsLockedOut)
{
IsLockedOut,
new PropertyType(PropertyEditors.Aliases.Boolean, ValueStorageType.Integer, true, IsLockedOut)
{
Name = IsLockedOutLabel
}
},
Name = IsLockedOutLabel
}
},
{
LastLockoutDate,
new PropertyType(PropertyEditors.Aliases.Label, ValueStorageType.Date, true, LastLockoutDate)
{
LastLockoutDate,
new PropertyType(PropertyEditors.Aliases.Label, ValueStorageType.Date, true, LastLockoutDate)
{
Name = LastLockoutDateLabel
}
},
Name = LastLockoutDateLabel
}
},
{
LastLoginDate,
new PropertyType(PropertyEditors.Aliases.Label, ValueStorageType.Date, true, LastLoginDate)
{
LastLoginDate,
new PropertyType(PropertyEditors.Aliases.Label, ValueStorageType.Date, true, LastLoginDate)
{
Name = LastLoginDateLabel
}
},
Name = LastLoginDateLabel
}
},
{
LastPasswordChangeDate,
new PropertyType(PropertyEditors.Aliases.Label, ValueStorageType.Date, true, LastPasswordChangeDate)
{
LastPasswordChangeDate,
new PropertyType(PropertyEditors.Aliases.Label, ValueStorageType.Date, true, LastPasswordChangeDate)
{
Name = LastPasswordChangeDateLabel
}
},
Name = LastPasswordChangeDateLabel
}
},
{
PasswordAnswer,
new PropertyType(PropertyEditors.Aliases.Label, ValueStorageType.Nvarchar, true, PasswordAnswer)
{
PasswordAnswer,
new PropertyType(PropertyEditors.Aliases.Label, ValueStorageType.Nvarchar, true, PasswordAnswer)
{
Name = PasswordAnswerLabel
}
},
Name = PasswordAnswerLabel
}
},
{
PasswordQuestion,
new PropertyType(PropertyEditors.Aliases.Label, ValueStorageType.Nvarchar, true, PasswordQuestion)
{
PasswordQuestion,
new PropertyType(PropertyEditors.Aliases.Label, ValueStorageType.Nvarchar, true, PasswordQuestion)
{
Name = PasswordQuestionLabel
}
Name = PasswordQuestionLabel
}
};
}
};
}
}

Expand Down
12 changes: 1 addition & 11 deletions src/Umbraco.Core/Constants-Icons.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Umbraco.Core
namespace Umbraco.Core
{
public static partial class Constants
{
public static class Icons
{


/// <summary>
/// System contenttype icon
/// </summary>
Expand Down Expand Up @@ -42,12 +34,10 @@ public static class Icons
/// </summary>
public const string MemberType = "icon-users";


/// <summary>
/// System member icon
/// </summary>
public const string Template = "icon-layout";

}
}
}
5 changes: 1 addition & 4 deletions src/Umbraco.Core/Constants-Indexes.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.ComponentModel;

namespace Umbraco.Core
namespace Umbraco.Core
{
public static partial class Constants
{
Expand Down
1 change: 0 additions & 1 deletion src/Umbraco.Core/Constants-ObjectTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ public static class Strings
public static readonly Guid Template = new Guid(Strings.Template);

public static readonly Guid ContentItem = new Guid(Strings.ContentItem);

}
}
}
2 changes: 1 addition & 1 deletion src/Umbraco.Core/Constants-PackageRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
public static partial class Constants
{
/// <summary>
/// Defines the constants used for the Umbraco package repository
/// Defines the constants used for the Umbraco package repository
/// </summary>
public static class PackageRepository
{
Expand Down
1 change: 0 additions & 1 deletion src/Umbraco.Core/Constants-PropertyEditors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public static class Aliases
/// </summary>
public const string ContentPicker = "Umbraco.ContentPicker";


/// <summary>
/// DateTime.
/// </summary>
Expand Down
6 changes: 1 addition & 5 deletions src/Umbraco.Core/Constants-Web.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.ComponentModel;

namespace Umbraco.Core
namespace Umbraco.Core
{
public static partial class Constants
{
Expand All @@ -22,7 +19,6 @@ public static class Web
public const string PreviewCookieName = "UMB_PREVIEW";

public const string InstallerCookieName = "umb_installId";

}
}
}
10 changes: 5 additions & 5 deletions src/Umbraco.Core/Models/UserExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,22 +151,22 @@ internal static CultureInfo GetUserCulture(string userLanguage, ILocalizedTextSe

internal static bool HasContentRootAccess(this IUser user, IEntityService entityService)
{
return ContentPermissionsHelper.HasPathAccess(Constants.System.Root.ToInvariantString(), user.CalculateContentStartNodeIds(entityService), Constants.System.RecycleBinContent);
return ContentPermissionsHelper.HasPathAccess(Constants.System.RootString, user.CalculateContentStartNodeIds(entityService), Constants.System.RecycleBinContent);
}

internal static bool HasContentBinAccess(this IUser user, IEntityService entityService)
{
return ContentPermissionsHelper.HasPathAccess(Constants.System.RecycleBinContent.ToInvariantString(), user.CalculateContentStartNodeIds(entityService), Constants.System.RecycleBinContent);
return ContentPermissionsHelper.HasPathAccess(Constants.System.RecycleBinContentString, user.CalculateContentStartNodeIds(entityService), Constants.System.RecycleBinContent);
}

internal static bool HasMediaRootAccess(this IUser user, IEntityService entityService)
{
return ContentPermissionsHelper.HasPathAccess(Constants.System.Root.ToInvariantString(), user.CalculateMediaStartNodeIds(entityService), Constants.System.RecycleBinMedia);
return ContentPermissionsHelper.HasPathAccess(Constants.System.RootString, user.CalculateMediaStartNodeIds(entityService), Constants.System.RecycleBinMedia);
}

internal static bool HasMediaBinAccess(this IUser user, IEntityService entityService)
{
return ContentPermissionsHelper.HasPathAccess(Constants.System.RecycleBinMedia.ToInvariantString(), user.CalculateMediaStartNodeIds(entityService), Constants.System.RecycleBinMedia);
return ContentPermissionsHelper.HasPathAccess(Constants.System.RecycleBinMediaString, user.CalculateMediaStartNodeIds(entityService), Constants.System.RecycleBinMedia);
}

internal static bool HasPathAccess(this IUser user, IContent content, IEntityService entityService)
Expand Down Expand Up @@ -327,7 +327,7 @@ internal static int[] CombineStartNodes(UmbracoObjectTypes objectType, int[] gro
? entityService.GetAllPaths(objectType, asn).ToDictionary(x => x.Id, x => x.Path)
: new Dictionary<int, string>();

paths[Constants.System.Root] = Constants.System.Root.ToString(); // entityService does not get that one
paths[Constants.System.Root] = Constants.System.RootString; // entityService does not get that one

var binPath = GetBinPath(objectType);

Expand Down
2 changes: 1 addition & 1 deletion src/Umbraco.Core/Persistence/Constants-DatabaseSchema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static class Tables

public const string Tag = /*TableNamePrefix*/ "cms" + "Tags";
public const string TagRelationship = /*TableNamePrefix*/ "cms" + "TagRelationship";

public const string KeyValue = TableNamePrefix + "KeyValue";

public const string AuditEntry = TableNamePrefix + "Audit";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public IEnumerable<MoveEventInfo<TEntity>> Move(TEntity moving, EntityContainer
// move to parent (or -1), update path, save
moving.ParentId = parentId;
var movingPath = moving.Path + ","; // save before changing
moving.Path = (container == null ? Constants.System.Root.ToString() : container.Path) + "," + moving.Id;
moving.Path = (container == null ? Constants.System.RootString : container.Path) + "," + moving.Id;
moving.Level = container == null ? 1 : container.Level + 1;
Save(moving);

Expand Down
4 changes: 2 additions & 2 deletions src/Umbraco.Core/Services/Implement/ContentService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ public IEnumerable<IContent> GetAncestors(IContent content)
//null check otherwise we get exceptions
if (content.Path.IsNullOrWhiteSpace()) return Enumerable.Empty<IContent>();

var rootId = Constants.System.Root.ToInvariantString();
var rootId = Constants.System.RootString;
var ids = content.Path.Split(',')
.Where(x => x != rootId && x != content.Id.ToString(CultureInfo.InvariantCulture)).Select(int.Parse).ToArray();
if (ids.Any() == false)
Expand Down Expand Up @@ -1922,7 +1922,7 @@ private void PerformMoveLocked(IContent content, int parentId, IContent parent,
// if uow is not immediate, content.Path will be updated only when the UOW commits,
// and because we want it now, we have to calculate it by ourselves
//paths[content.Id] = content.Path;
paths[content.Id] = (parent == null ? (parentId == Constants.System.RecycleBinContent ? "-1,-20" : "-1") : parent.Path) + "," + content.Id;
paths[content.Id] = (parent == null ? (parentId == Constants.System.RecycleBinContent ? "-1,-20" : Constants.System.RootString) : parent.Path) + "," + content.Id;

const int pageSize = 500;
var page = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/Umbraco.Core/Services/Implement/MediaService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,7 @@ private void PerformMoveLocked(IMedia media, int parentId, IMedia parent, int us
// if uow is not immediate, content.Path will be updated only when the UOW commits,
// and because we want it now, we have to calculate it by ourselves
//paths[media.Id] = media.Path;
paths[media.Id] = (parent == null ? (parentId == Constants.System.RecycleBinMedia ? "-1,-21" : "-1") : parent.Path) + "," + media.Id;
paths[media.Id] = (parent == null ? (parentId == Constants.System.RecycleBinMedia ? "-1,-21" : Constants.System.RootString) : parent.Path) + "," + media.Id;

const int pageSize = 500;
var page = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/Umbraco.Core/UdiEntityType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static class UdiEntityType

internal static Dictionary<string, UdiType> GetTypes()
{
return new Dictionary<string,UdiType>
return new Dictionary<string, UdiType>
{
{ Unknown, UdiType.Unknown },

Expand Down
4 changes: 2 additions & 2 deletions src/Umbraco.Web/Editors/CodeFileController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public HttpResponseMessage PostCreateContainer(string type, string parentId, str

// if the parentId is root (-1) then we just need an empty string as we are
// creating the path below and we don't want -1 in the path
if (parentId == Core.Constants.System.Root.ToInvariantString())
if (parentId == Core.Constants.System.RootString)
{
parentId = string.Empty;
}
Expand Down Expand Up @@ -276,7 +276,7 @@ public CodeFileDisplay GetScaffold(string type, string id, string snippetName =
// Make sure that the root virtual path ends with '/'
codeFileDisplay.VirtualPath = codeFileDisplay.VirtualPath.EnsureEndsWith("/");

if (id != Core.Constants.System.Root.ToInvariantString())
if (id != Core.Constants.System.RootString)
{
codeFileDisplay.VirtualPath += id.TrimStart("/").EnsureEndsWith("/");
//if it's not new then it will have a path, otherwise it won't
Expand Down
2 changes: 1 addition & 1 deletion src/Umbraco.Web/Models/Trees/TreeRootNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace Umbraco.Web.Models.Trees
[DataContract(Name = "node", Namespace = "")]
public sealed class TreeRootNode : TreeNode
{
private static readonly string RootId = Core.Constants.System.Root.ToString(CultureInfo.InvariantCulture);
private static readonly string RootId = Core.Constants.System.RootString;
private bool _isGroup;
private bool _isSingleNodeTree;

Expand Down
Loading

0 comments on commit 3af8d0e

Please sign in to comment.