Skip to content

Commit

Permalink
feature: add typed Condition Manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
jcdcdev committed Dec 30, 2024
1 parent 1d021af commit 5c74aca
Show file tree
Hide file tree
Showing 6 changed files with 338 additions and 102 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,25 @@ public async Task<IEnumerable<PackageManifest>> ReadPackageManifestsAsync()
},
Conditions =
[
new ConditionManifest
{
Alias = "Umb.Condition.WorkspaceAlias",
Match = "Umb.Workspace.Document"
}
ConditionManifest.WorkspaceAlias(Constants.Workspaces.Document)
]
};

var newEntityWorkspaceViewManifest = new WorkspaceViewManifest
{
Alias = "trashed-entity-workspace-view",
Name = "Trashed Entity Workspace View",
ElementName = "uui-icon",
Weight = 10,
Meta = new WorkspaceViewManifest.MetaManifest
{
Label = "Trashed Entity Workspace View",
Pathname = "trashed-entity-workspace-view",
Icon = "favorite"
},
Conditions =
[
ConditionManifest.EntityIsTrashed()
]
};

Expand All @@ -54,16 +68,13 @@ public async Task<IEnumerable<PackageManifest>> ReadPackageManifestsAsync()
},
Conditions =
[
new ConditionManifest
{
Alias = "Umb.Condition.SectionAlias",
Match = "Umb.Section.Content"
}
ConditionManifest.SectionAlias(Constants.Sections.Content)
]
};

extensions.Add(dashboardManifest);
extensions.Add(workspaceViewManifest);
extensions.Add(newEntityWorkspaceViewManifest);
packageManifest.Extensions = extensions.OfType<object>().ToArray();
return [packageManifest];
}
Expand Down
24 changes: 24 additions & 0 deletions src/jcdcdev.Umbraco.Core.TestSite/uSync/v15/Content/test.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<Content Key="d10d23ab-d956-406c-b041-08c6298374e7" Alias="Test" Level="101">
<Info>
<Parent Key="00000000-0000-0000-0000-000000000000"></Parent>
<Path>/[-20]/Test</Path>
<Trashed Parent="916724a5-173d-4619-b97e-b9de133dd6f5">true</Trashed>
<ContentType>home</ContentType>
<CreateDate>2024-12-30T23:16:58</CreateDate>
<NodeName Default="Test">
<Name Culture="en-GB">Test</Name>
</NodeName>
<SortOrder>0</SortOrder>
<Published Default="true">
<Published Culture="en-GB">true</Published>
</Published>
<Schedule />
<Template Key="77e83006-4abe-4bff-b405-307a4f22f55d">home</Template>
</Info>
<Properties>
<gridContent>
<Value><![CDATA[]]></Value>
</gridContent>
</Properties>
</Content>
85 changes: 85 additions & 0 deletions src/jcdcdev.Umbraco.Core/Constants.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
namespace jcdcdev.Umbraco.Core;

public static class Constants
{
public class Conditions
{
public const string BlockEntryShowContentEdit = "Umb.Condition.BlockEntryShowContentEdit";
public const string BlockHasSettings = "Umb.Condition.BlockWorkspaceHasSettings";
public const string CollectionAlias = "Umb.Condition.CollectionAlias";
public const string CollectionBulkActionPermission = "Umb.Condition.CollectionBulkActionPermission";
public const string CurrentUserAllowDocumentRecycleBin = "Umb.Condition.CurrentUser.AllowDocumentRecycleBin";
public const string CurrentUserAllowMediaRecycleBin = "Umb.Condition.CurrentUser.AllowMediaRecycleBin";
public const string EntityIsNotTrashed = "Umb.Condition.EntityIsNotTrashed";
public const string EntityIsTrashed = "Umb.Condition.EntityIsTrashed";
public const string MenuAlias = "Umb.Condition.MenuAlias";
public const string MultipleAppLanguages = "Umb.Condition.MultipleAppLanguages";
public const string PropertyWritable = "Umb.Condition.Property.Writable";
public const string SectionAlias = "Umb.Condition.SectionAlias";
public const string SectionUserPermission = "Umb.Condition.SectionUserPermission";
public const string Switch = "Umb.Condition.Switch";
public const string UserAllowDeleteAction = "Umb.Condition.User.AllowDeleteAction";
public const string UserAllowDisableAction = "Umb.Condition.User.AllowDisableAction";
public const string UserAllowEnableAction = "Umb.Condition.User.AllowEnableAction";
public const string UserAllowExternalLoginAction = "Umb.Condition.User.AllowExternalLoginAction";
public const string UserAllowMfaAction = "Umb.Condition.User.AllowMfaAction";
public const string UserAllowResendInviteAction = "Umb.Condition.User.AllowResendInviteAction";
public const string UserAllowUnlockAction = "Umb.Condition.User.AllowUnlockAction";
public const string UserPermissionDocument = "Umb.Condition.UserPermission.Document";
public const string WorkspaceContentHasProperties = "Umb.Condition.Workspace.ContentHasProperties";
public const string WorkspaceAlias = "Umb.Condition.WorkspaceAlias";
public const string WorkspaceContentTypeAlias = "Umb.Condition.WorkspaceContentTypeAlias";
public const string WorkspaceEntityType = "Umb.Condition.WorkspaceEntityType";
public const string WorkspaceHasCollection = "Umb.Condition.WorkspaceHasCollection";
public const string WorkspaceEntityIsNew = "Umb.Condition.WorkspaceEntityIsNew";
}

public class Sections
{
public const string Content = "Umb.Section.Content";
public const string Media = "Umb.Section.Media";
public const string Settings = "Umb.Section.Settings";
public const string Members = "Umb.Section.Members";
public const string Packages = "Umb.Section.Packages";
public const string Dictionary = "Umb.Section.Translation";
public const string Users = "Umb.Section.Users";
}

public class Workspaces
{
public const string Block = "Umb.Workspace.Block";
public const string BlockGridAreaType = "Umb.Workspace.BlockGridAreaType";
public const string BlockGridType = "Umb.Workspace.BlockGridType";
public const string BlockListType = "Umb.Workspace.BlockListType";
public const string BlockRteType = "Umb.Workspace.BlockRteType";
public const string DataType = "Umb.Workspace.DataType";
public const string Dictionary = "Umb.Workspace.Dictionary";
public const string Document = "Umb.Workspace.Document";
public const string DocumentBlueprint = "Umb.Workspace.DocumentBlueprint";
public const string DocumentBlueprintFolder = "Umb.Workspace.DocumentBlueprint.Folder";
public const string DocumentBlueprintRoot = "Umb.Workspace.DocumentBlueprint.Root";
public const string DocumentType = "Umb.Workspace.DocumentType";
public const string ExtensionRoot = "Umb.Workspace.ExtensionRoot";
public const string Language = "Umb.Workspace.Language";
public const string LanguageRoot = "Umb.Workspace.LanguageRoot";
public const string LogViewer = "Umb.Workspace.LogViewer";
public const string Media = "Umb.Workspace.Media";
public const string MediaType = "Umb.Workspace.MediaType";
public const string Member = "Umb.Workspace.Member";
public const string MemberGroup = "Umb.Workspace.MemberGroup";
public const string MemberType = "Umb.Workspace.MemberType";
public const string Package = "Umb.Workspace.Package";
public const string PackageBuilder = "Umb.Workspace.PackageBuilder";
public const string PartialView = "Umb.Workspace.PartialView";
public const string PropertyType = "Umb.Workspace.PropertyType";
public const string RelationType = "Umb.Workspace.RelationType";
public const string RelationTypeRoot = "Umb.Workspace.RelationTypeRoot";
public const string Script = "Umb.Workspace.Script";
public const string Stylesheet = "Umb.Workspace.Stylesheet";
public const string Template = "Umb.Workspace.Template";
public const string User = "Umb.Workspace.User";
public const string UserGroup = "Umb.Workspace.UserGroup";
public const string Webhook = "Umb.Workspace.Webhook";
public const string WebhookRoot = "Umb.Workspace.WebhookRoot";
}
}
155 changes: 78 additions & 77 deletions src/jcdcdev.Umbraco.Core/Extensions/DataTypeExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Umbraco.Cms.Core;


using Umbraco.Cms.Core.Models;
using Umbraco.Extensions;

Expand All @@ -9,86 +10,86 @@ public static class DataTypeExtensions
private static readonly Guid[] Guids =
[
// Legacy editors
Constants.DataTypes.Guids.ContentPickerGuid,
Constants.DataTypes.Guids.MemberPickerGuid,
Constants.DataTypes.Guids.MediaPicker3Guid,
Constants.DataTypes.Guids.MediaPicker3MultipleGuid,
Constants.DataTypes.Guids.MediaPicker3SingleImageGuid,
Constants.DataTypes.Guids.MediaPicker3MultipleImagesGuid,
Constants.DataTypes.Guids.RelatedLinksGuid,
Constants.DataTypes.Guids.MemberGuid,
Constants.DataTypes.Guids.ImageCropperGuid,
Constants.DataTypes.Guids.TagsGuid,
Constants.DataTypes.Guids.ListViewContentGuid,
Constants.DataTypes.Guids.ListViewMediaGuid,
Constants.DataTypes.Guids.DatePickerWithTimeGuid,
Constants.DataTypes.Guids.ApprovedColorGuid,
Constants.DataTypes.Guids.DropdownMultipleGuid,
Constants.DataTypes.Guids.RadioboxGuid,
Constants.DataTypes.Guids.DatePickerGuid,
Constants.DataTypes.Guids.DropdownGuid,
Constants.DataTypes.Guids.CheckboxListGuid,
Constants.DataTypes.Guids.CheckboxGuid,
Constants.DataTypes.Guids.NumericGuid,
Constants.DataTypes.Guids.RichtextEditorGuid,
Constants.DataTypes.Guids.TextstringGuid,
Constants.DataTypes.Guids.TextareaGuid,
Constants.DataTypes.Guids.UploadGuid,
Constants.DataTypes.Guids.UploadVideoGuid,
Constants.DataTypes.Guids.UploadAudioGuid,
Constants.DataTypes.Guids.UploadArticleGuid,
Constants.DataTypes.Guids.UploadVectorGraphicsGuid,
Constants.DataTypes.Guids.LabelStringGuid,
Constants.DataTypes.Guids.LabelIntGuid,
Constants.DataTypes.Guids.LabelBigIntGuid,
Constants.DataTypes.Guids.LabelDateTimeGuid,
Constants.DataTypes.Guids.LabelTimeGuid,
Constants.DataTypes.Guids.LabelDecimalGuid
global::Umbraco.Cms.Core.Constants.DataTypes.Guids.ContentPickerGuid,
global::Umbraco.Cms.Core.Constants.DataTypes.Guids.MemberPickerGuid,
global::Umbraco.Cms.Core.Constants.DataTypes.Guids.MediaPicker3Guid,
global::Umbraco.Cms.Core.Constants.DataTypes.Guids.MediaPicker3MultipleGuid,
global::Umbraco.Cms.Core.Constants.DataTypes.Guids.MediaPicker3SingleImageGuid,
global::Umbraco.Cms.Core.Constants.DataTypes.Guids.MediaPicker3MultipleImagesGuid,
global::Umbraco.Cms.Core.Constants.DataTypes.Guids.RelatedLinksGuid,
global::Umbraco.Cms.Core.Constants.DataTypes.Guids.MemberGuid,
global::Umbraco.Cms.Core.Constants.DataTypes.Guids.ImageCropperGuid,
global::Umbraco.Cms.Core.Constants.DataTypes.Guids.TagsGuid,
global::Umbraco.Cms.Core.Constants.DataTypes.Guids.ListViewContentGuid,
global::Umbraco.Cms.Core.Constants.DataTypes.Guids.ListViewMediaGuid,
global::Umbraco.Cms.Core.Constants.DataTypes.Guids.DatePickerWithTimeGuid,
global::Umbraco.Cms.Core.Constants.DataTypes.Guids.ApprovedColorGuid,
global::Umbraco.Cms.Core.Constants.DataTypes.Guids.DropdownMultipleGuid,
global::Umbraco.Cms.Core.Constants.DataTypes.Guids.RadioboxGuid,
global::Umbraco.Cms.Core.Constants.DataTypes.Guids.DatePickerGuid,
global::Umbraco.Cms.Core.Constants.DataTypes.Guids.DropdownGuid,
global::Umbraco.Cms.Core.Constants.DataTypes.Guids.CheckboxListGuid,
global::Umbraco.Cms.Core.Constants.DataTypes.Guids.CheckboxGuid,
global::Umbraco.Cms.Core.Constants.DataTypes.Guids.NumericGuid,
global::Umbraco.Cms.Core.Constants.DataTypes.Guids.RichtextEditorGuid,
global::Umbraco.Cms.Core.Constants.DataTypes.Guids.TextstringGuid,
global::Umbraco.Cms.Core.Constants.DataTypes.Guids.TextareaGuid,
global::Umbraco.Cms.Core.Constants.DataTypes.Guids.UploadGuid,
global::Umbraco.Cms.Core.Constants.DataTypes.Guids.UploadVideoGuid,
global::Umbraco.Cms.Core.Constants.DataTypes.Guids.UploadAudioGuid,
global::Umbraco.Cms.Core.Constants.DataTypes.Guids.UploadArticleGuid,
global::Umbraco.Cms.Core.Constants.DataTypes.Guids.UploadVectorGraphicsGuid,
global::Umbraco.Cms.Core.Constants.DataTypes.Guids.LabelStringGuid,
global::Umbraco.Cms.Core.Constants.DataTypes.Guids.LabelIntGuid,
global::Umbraco.Cms.Core.Constants.DataTypes.Guids.LabelBigIntGuid,
global::Umbraco.Cms.Core.Constants.DataTypes.Guids.LabelDateTimeGuid,
global::Umbraco.Cms.Core.Constants.DataTypes.Guids.LabelTimeGuid,
global::Umbraco.Cms.Core.Constants.DataTypes.Guids.LabelDecimalGuid
];

private static readonly string[] Aliases =
[
Constants.PropertyEditors.Aliases.BlockList,
Constants.PropertyEditors.Aliases.CheckBoxList,
Constants.PropertyEditors.Aliases.ColorPicker,
Constants.PropertyEditors.Aliases.ColorPickerEyeDropper,
Constants.PropertyEditors.Aliases.ContentPicker,
Constants.PropertyEditors.Aliases.DateTime,
Constants.PropertyEditors.Aliases.DropDownListFlexible,
Constants.PropertyEditors.Aliases.Grid,
Constants.PropertyEditors.Aliases.BlockGrid,
Constants.PropertyEditors.Aliases.ImageCropper,
Constants.PropertyEditors.Aliases.Integer,
Constants.PropertyEditors.Aliases.Decimal,
Constants.PropertyEditors.Aliases.ListView,
Constants.PropertyEditors.Aliases.MediaPicker3,
Constants.PropertyEditors.Aliases.MultipleMediaPicker,
Constants.PropertyEditors.Aliases.MemberPicker,
Constants.PropertyEditors.Aliases.MemberGroupPicker,
Constants.PropertyEditors.Aliases.MultiNodeTreePicker,
Constants.PropertyEditors.Aliases.MultipleTextstring,
Constants.PropertyEditors.Aliases.Label,
Constants.PropertyEditors.Aliases.PickerRelations,
Constants.PropertyEditors.Aliases.RadioButtonList,
Constants.PropertyEditors.Aliases.Slider,
Constants.PropertyEditors.Aliases.Tags,
Constants.PropertyEditors.Aliases.TextBox,
Constants.PropertyEditors.Aliases.TextArea,
Constants.PropertyEditors.Aliases.Boolean,
Constants.PropertyEditors.Aliases.MarkdownEditor,
Constants.PropertyEditors.Aliases.UserPicker,
Constants.PropertyEditors.Aliases.UploadField,
Constants.PropertyEditors.Aliases.EmailAddress,
Constants.PropertyEditors.Aliases.NestedContent,
Constants.PropertyEditors.Aliases.MultiUrlPicker,
Constants.PropertyEditors.Aliases.TinyMce,
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
global::Umbraco.Cms.Core.Constants.PropertyEditors.Aliases.BlockList,
global::Umbraco.Cms.Core.Constants.PropertyEditors.Aliases.CheckBoxList,
global::Umbraco.Cms.Core.Constants.PropertyEditors.Aliases.ColorPicker,
global::Umbraco.Cms.Core.Constants.PropertyEditors.Aliases.ColorPickerEyeDropper,
global::Umbraco.Cms.Core.Constants.PropertyEditors.Aliases.ContentPicker,
global::Umbraco.Cms.Core.Constants.PropertyEditors.Aliases.DateTime,
global::Umbraco.Cms.Core.Constants.PropertyEditors.Aliases.DropDownListFlexible,
global::Umbraco.Cms.Core.Constants.PropertyEditors.Aliases.Grid,
global::Umbraco.Cms.Core.Constants.PropertyEditors.Aliases.BlockGrid,
global::Umbraco.Cms.Core.Constants.PropertyEditors.Aliases.ImageCropper,
global::Umbraco.Cms.Core.Constants.PropertyEditors.Aliases.Integer,
global::Umbraco.Cms.Core.Constants.PropertyEditors.Aliases.Decimal,
global::Umbraco.Cms.Core.Constants.PropertyEditors.Aliases.ListView,
global::Umbraco.Cms.Core.Constants.PropertyEditors.Aliases.MediaPicker3,
global::Umbraco.Cms.Core.Constants.PropertyEditors.Aliases.MultipleMediaPicker,
global::Umbraco.Cms.Core.Constants.PropertyEditors.Aliases.MemberPicker,
global::Umbraco.Cms.Core.Constants.PropertyEditors.Aliases.MemberGroupPicker,
global::Umbraco.Cms.Core.Constants.PropertyEditors.Aliases.MultiNodeTreePicker,
global::Umbraco.Cms.Core.Constants.PropertyEditors.Aliases.MultipleTextstring,
global::Umbraco.Cms.Core.Constants.PropertyEditors.Aliases.Label,
global::Umbraco.Cms.Core.Constants.PropertyEditors.Aliases.PickerRelations,
global::Umbraco.Cms.Core.Constants.PropertyEditors.Aliases.RadioButtonList,
global::Umbraco.Cms.Core.Constants.PropertyEditors.Aliases.Slider,
global::Umbraco.Cms.Core.Constants.PropertyEditors.Aliases.Tags,
global::Umbraco.Cms.Core.Constants.PropertyEditors.Aliases.TextBox,
global::Umbraco.Cms.Core.Constants.PropertyEditors.Aliases.TextArea,
global::Umbraco.Cms.Core.Constants.PropertyEditors.Aliases.Boolean,
global::Umbraco.Cms.Core.Constants.PropertyEditors.Aliases.MarkdownEditor,
global::Umbraco.Cms.Core.Constants.PropertyEditors.Aliases.UserPicker,
global::Umbraco.Cms.Core.Constants.PropertyEditors.Aliases.UploadField,
global::Umbraco.Cms.Core.Constants.PropertyEditors.Aliases.EmailAddress,
global::Umbraco.Cms.Core.Constants.PropertyEditors.Aliases.NestedContent,
global::Umbraco.Cms.Core.Constants.PropertyEditors.Aliases.MultiUrlPicker,
global::Umbraco.Cms.Core.Constants.PropertyEditors.Aliases.TinyMce,

Check warning on line 85 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 85 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'
global::Umbraco.Cms.Core.Constants.PropertyEditors.Aliases.RichText,
global::Umbraco.Cms.Core.Constants.PropertyEditors.Aliases.PlainString,
global::Umbraco.Cms.Core.Constants.PropertyEditors.Aliases.PlainJson,
global::Umbraco.Cms.Core.Constants.PropertyEditors.Aliases.PlainDecimal,
global::Umbraco.Cms.Core.Constants.PropertyEditors.Aliases.PlainInteger,
global::Umbraco.Cms.Core.Constants.PropertyEditors.Aliases.PlainDateTime,
global::Umbraco.Cms.Core.Constants.PropertyEditors.Aliases.PlainTime
];

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

0 comments on commit 5c74aca

Please sign in to comment.