Skip to content

Commit

Permalink
refactor: datatype container methods obsolete
Browse files Browse the repository at this point in the history
  • Loading branch information
jcdcdev committed Oct 15, 2024
1 parent 3b44a20 commit 5eb9ffc
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/TestSite/SimpleWorkspaceViewPackageManifestReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,6 @@ public async Task<IEnumerable<PackageManifest>> ReadPackageManifestsAsync()
extensions.Add(dashboardManifest);
extensions.Add(workspaceViewManifest);
packageManifest.Extensions = extensions.OfType<object>().ToArray();
return new[] { packageManifest };
return [packageManifest];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace jcdcdev.Umbraco.Core.Extensions;
public static class ContentTypeBaseServiceExtensions
{
public static IEnumerable<EntityContainer> GetAllContainers<T>(this IContentTypeBaseService<T> service) where T : IContentTypeComposition =>
service.GetContainers(Array.Empty<int>());
service.GetContainers([]);

public static void DeleteAllEmptyContainers<T>(this IContentTypeBaseService<T> service) where T : IContentTypeComposition
{
Expand Down Expand Up @@ -41,4 +41,4 @@ public static EntityContainer GetOrCreateFolder<T>(this IContentTypeBaseService<

return container ?? throw new Exception();
}
}
}
14 changes: 10 additions & 4 deletions src/jcdcdev.Umbraco.Core/Extensions/DataTypeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace jcdcdev.Umbraco.Core.Extensions;
public static class DataTypeExtensions
{
private static readonly Guid[] Guids =
{
[
// Legacy editors
Constants.DataTypes.Guids.ContentPickerGuid,
Constants.DataTypes.Guids.MemberPickerGuid,
Expand Down Expand Up @@ -44,10 +44,10 @@ public static class DataTypeExtensions
Constants.DataTypes.Guids.LabelDateTimeGuid,
Constants.DataTypes.Guids.LabelTimeGuid,
Constants.DataTypes.Guids.LabelDecimalGuid
};
];

private static readonly string[] Aliases =
{
[
Constants.PropertyEditors.Aliases.BlockList,
Constants.PropertyEditors.Aliases.CheckBoxList,
Constants.PropertyEditors.Aliases.ColorPicker,
Expand Down Expand Up @@ -83,7 +83,13 @@ public static class DataTypeExtensions
Constants.PropertyEditors.Aliases.MultiUrlPicker,
Constants.PropertyEditors.Aliases.TinyMce,

Check warning on line 84 in src/jcdcdev.Umbraco.Core/Extensions/DataTypeExtensions.cs

View workflow job for this annotation

GitHub Actions / build

'Constants.PropertyEditors.Aliases.TinyMce' is obsolete: 'Please use RichText constant instead, scheduled for removal in v16'

Check warning on line 84 in src/jcdcdev.Umbraco.Core/Extensions/DataTypeExtensions.cs

View workflow job for this annotation

GitHub Actions / build

'Constants.PropertyEditors.Aliases.TinyMce' is obsolete: 'Please use RichText constant instead, scheduled for removal in v16'

Check warning on line 84 in src/jcdcdev.Umbraco.Core/Extensions/DataTypeExtensions.cs

View workflow job for this annotation

GitHub Actions / release

'Constants.PropertyEditors.Aliases.TinyMce' is obsolete: 'Please use RichText constant instead, scheduled for removal in v16'

Check warning on line 84 in src/jcdcdev.Umbraco.Core/Extensions/DataTypeExtensions.cs

View workflow job for this annotation

GitHub Actions / release

'Constants.PropertyEditors.Aliases.TinyMce' is obsolete: 'Please use RichText constant instead, scheduled for removal in v16'
Constants.PropertyEditors.Aliases.RichText,
};
Constants.PropertyEditors.Aliases.PlainString,
Constants.PropertyEditors.Aliases.PlainJson,
Constants.PropertyEditors.Aliases.PlainDecimal,
Constants.PropertyEditors.Aliases.PlainInteger,
Constants.PropertyEditors.Aliases.PlainDateTime,
Constants.PropertyEditors.Aliases.PlainTime
];

public static bool IsUmbracoEditor(this IDataType dataType) => Aliases.InvariantContains(dataType.EditorAlias);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ namespace jcdcdev.Umbraco.Core.Extensions;

public static class DataTypeServiceExtensions
{
public static IEnumerable<EntityContainer> GetAllContainers(this IDataTypeService dataTypeService) => dataTypeService.GetContainers(Array.Empty<int>());
[Obsolete("Please use IDataTypeContainerService for all data type container operations. Will be removed in V15.")]
public static IEnumerable<EntityContainer> GetAllContainers(this IDataTypeService dataTypeService) => dataTypeService.GetContainers([]);

[Obsolete("Please use IDataTypeContainerService for all data type container operations. Will be removed in V15.")]
public static void DeleteAllEmptyContainers(this IDataTypeService dataTypeService)
{
var dataTypes = dataTypeService.GetAll();
Expand All @@ -27,6 +29,7 @@ public static void DeleteAllEmptyContainers(this IDataTypeService dataTypeServic
}
}

[Obsolete("Please use IDataTypeContainerService for all data type container operations. Will be removed in V15.")]
public static EntityContainer GetOrCreateFolder(
this IDataTypeService dataTypeService,
string folder,
Expand All @@ -43,4 +46,4 @@ public static EntityContainer GetOrCreateFolder(

return dts ?? throw new Exception();
}
}
}
6 changes: 3 additions & 3 deletions src/jcdcdev.Umbraco.Core/Extensions/FileSystemExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static IEnumerable<string> GetFiles(this IFileSystem fs, string? path, bo
return files;
}

public static void CreateDirectoryIfNotExists(this IFileSystem fileSystem, string? path)
public static void CreateDirectoryIfNotExists(this IFileSystem fileSystem, string path)
{
if (!fileSystem.CanAddPhysical)
{
Expand All @@ -39,7 +39,7 @@ public static void CreateDirectoryIfNotExists(this IFileSystem fileSystem, strin
}
}

public static void CreateOrEmptyIfExists(this IFileSystem fileSystem, string? backupDir)
public static void CreateOrEmptyIfExists(this IFileSystem fileSystem, string backupDir)
{
if (!fileSystem.CanAddPhysical)
{
Expand All @@ -50,7 +50,7 @@ public static void CreateOrEmptyIfExists(this IFileSystem fileSystem, string? ba
fileSystem.CreateFolder(backupDir);
}

public static void DeleteDirectoryIfExists(this IFileSystem fileSystem, string? path, bool recursive = false)
public static void DeleteDirectoryIfExists(this IFileSystem fileSystem, string path, bool recursive = false)
{
if (!fileSystem.DirectoryExists(path))
{
Expand Down
6 changes: 3 additions & 3 deletions src/jcdcdev.Umbraco.Core/Extensions/MediaTypeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace jcdcdev.Umbraco.Core.Extensions;
public static class MediaTypeExtensions
{
private static readonly string[] MediaTypes =
{
[
Constants.Conventions.MediaTypes.File,
Constants.Conventions.MediaTypes.Folder,
Constants.Conventions.MediaTypes.Image,
Expand All @@ -18,8 +18,8 @@ public static class MediaTypeExtensions
Constants.Conventions.MediaTypes.VideoAlias,
Constants.Conventions.MediaTypes.AudioAlias,
Constants.Conventions.MediaTypes.ArticleAlias,
Constants.Conventions.MediaTypes.VectorGraphicsAlias,
};
Constants.Conventions.MediaTypes.VectorGraphicsAlias
];

public static bool IsInternal(this IMediaType mediaType) => MediaTypes.InvariantContains(mediaType.Alias);
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ namespace jcdcdev.Umbraco.Core.HealthChecks;
/// </summary>
public abstract class ConfigurationNotNullHealthcheck<T> : AbstractSettingsCheck where T : class
{
private readonly string _prefix = typeof(T).Name.ToFirstLowerInvariant();
private readonly IOptions<T> _options;
private readonly string _prefix = typeof(T).Name.ToFirstLowerInvariant();

/// <summary>
/// Ensure a lang file exists with the area "healthcheck" and keys:<br />
Expand All @@ -38,12 +38,12 @@ protected ConfigurationNotNullHealthcheck(ILocalizedTextService textService, IOp

protected T Options => _options.Value;
public override ValueComparisonType ValueComparisonType => ValueComparisonType.ShouldNotEqual;
public override string CheckSuccessMessage => LocalizedTextService.Localize("healthcheck", $"{_prefix}CheckSuccessMessage", new[] { CurrentValueDisplay, ItemPaths });
public override string CheckSuccessMessage => LocalizedTextService.Localize("healthcheck", $"{_prefix}CheckSuccessMessage", [CurrentValueDisplay, ItemPaths]);

public override string CheckErrorMessage =>
Recommended.IsNullOrWhiteSpace()
? LocalizedTextService.Localize("healthcheck", $"{_prefix}CheckErrorMessage", new[] { CurrentValueDisplay, ItemPaths })
: LocalizedTextService.Localize("healthcheck", $"{_prefix}CheckErrorMessageWithRecommendedValue", new[] { CurrentValueDisplay, ItemPaths, Recommended });
? LocalizedTextService.Localize("healthcheck", $"{_prefix}CheckErrorMessage", [CurrentValueDisplay, ItemPaths])
: LocalizedTextService.Localize("healthcheck", $"{_prefix}CheckErrorMessageWithRecommendedValue", [CurrentValueDisplay, ItemPaths, Recommended]);

private string CurrentValueDisplay => CurrentValue.IsNullOrWhiteSpace() ? "<em>undefined</em>" : $"<code>{CurrentValue}</code>";
private string ItemPaths => $"<code>{ItemPath}</code> | <code>{ItemPath.Replace(":", "__")}</code>";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

public class DashboardManifest : IManifest
{
public string Type => "dashboard";
public required string Alias { get; set; }
public required string Name { get; set; }
public string? ElementName { get; set; }
public string? Element { get; set; }
public int Weight { get; set; }
public MetaManifest? Meta { get; set; }
public ConditionManifest[]? Conditions { get; set; }
public string Type => "dashboard";

public class MetaManifest
{
Expand Down

0 comments on commit 5eb9ffc

Please sign in to comment.