umbraco / Umbraco.UIBuilder.Issues

Back office UI builder for Umbraco
3 stars 2 forks source link

Contentment Data picker not rendering in UI builder actions #83

Closed brannmark closed 9 months ago

brannmark commented 10 months ago

Describe the bug Datatype with a data picker in a custom UI builder action doesn't work. It does not render as supposed to.

Throw following error: image

Using this code for custom action:

using Umbraco.UIBuilder.Configuration;
using Umbraco.UIBuilder.Configuration.Actions;
using Umbraco.UIBuilder.Configuration.Builders;
using Umbraco.UIBuilder.Services;
using IHostingEnvironment = Umbraco.Cms.Core.Hosting.IHostingEnvironment;

namespace MyProj.Actions.BulkActions
{
    public class TestAction : Umbraco.UIBuilder.Configuration.Actions.Action<TestActionSetting, ActionResult>
    {
        public override string Icon => "icon-edit";
        public override string Alias => "test";
        public override string Name => "Test";
        public override bool ConfirmAction => false;
        private readonly Lazy<UIBuilderConfig> _config;
        private readonly Lazy<EntityService> _entityService;
        private readonly Lazy<IHostingEnvironment> _hostingEnv;

        public TestAction(Lazy<UIBuilderConfig> config, Lazy<EntityService> entityService, Lazy<IHostingEnvironment> hostingEnv)
        {
            _config = config;
            _entityService = entityService;
            _hostingEnv = hostingEnv;
        }

        public override void Configure(SettingsConfigBuilder<TestActionSetting> settingsConfig)
        {
            settingsConfig.AddFieldset("Content", fieldsetConfig =>
            {
                fieldsetConfig.AddField(m => m.TestProperty).SetDataType("Test");
            });
        }

        public override ActionResult Execute(string collectionAlias, object[] entityIds, TestActionSetting settings)
        {
            return new ActionResult(true, new ActionNotification("Test action executed"));
        }

        public override bool IsVisible(ActionVisibilityContext ctx)
        {
            if (ctx.ActionType == ActionType.Row || ctx.ActionType == ActionType.Bulk)
            {
                return true;
            }

            return false;
        }
    }

    public class TestActionSetting
    {
        public string TestProperty { get; set; } = string.Empty;
    }
}

Datatype: image

Collection: image

Rendering: image

Steps To Reproduce Steps to reproduce the behavior: 1, Create a datatype using Data Picker

  1. Create a custom action for UI Builder
  2. Create a customer Settings Model
  3. Add datatype with data picker to the settings model in configure
  4. Add action to an UI Builder collection
  5. Click on action
  6. See property but no editor rendered.

Expected behavior Expected editor to be rendered.

Environment (please complete the following information):

Additional context Also submitted here: https://github.com/leekelleher/umbraco-contentment/issues/374


This item has been added to our backlog AB#36292

acoumb commented 9 months ago

Hi @brannmark ,

Thank you for reporting this. Based on your feedback and Lee's comments, I have set an empty object to editorState. Normally a specific content item would go into the editorState, but hopefully version 13.0.1 addresses your situation.

Regards, Adrian