Skip to content

17.0.0-rc1 Custom Action added via config is not available #207

@paulsterling

Description

@paulsterling

A Custom action added via config is not availble for repository entities in ths UI Builder backoffice. In v13 this is available.

Steps To Reproduce
Here's the complete config from Program.cs

    .AddUIBuilder( cfg =>
    {
        cfg.AddSectionAfter("media", "Repositories", sectionConfig => sectionConfig
        .Tree(treeConfig => treeConfig
            .AddCollection<JobSurvey>(x => x.jobSurveyCd, "JobSurvey", "JobSurveys", "A job survey entity", "icon-notepad", "icon-notepad", collectionConfig => collectionConfig
                .SetNameProperty(p => p.recipientName)
                .SetSortProperty(p => p.createDate, Umbraco.UIBuilder.SortDirection.Descending)
                .SetDateCreatedProperty(p => p.createDate)
                .ListView(listViewConfig => listViewConfig
                    .AddField(p => p.createDate).SetFormat((v, p) => $"{v.ToShortDateString()}").SetHeading("Sent Date")
                    .AddField(p => p.recipientName).SetHeading("Recipient")
                    .AddField(p => p.recipientEmail).SetHeading("Email")
                    .AddField(p => p.recipientPhone).SetHeading("Phone")
                    .AddField(p => p.market).SetHeading("Market")
                    .AddField(p => p.surveyScore).SetHeading("Score")
                    .AddField(p => p.surveyComment).SetFormat((v, p) => $"{(v.Length > 0 ? "Yes" : "No")}").SetHeading("Has Comment")
                )
                .Editor(editorConfig => editorConfig
                    .AddTab("General", tabConfig => tabConfig
                        .AddFieldset("Response", fieldsetConfig => fieldsetConfig
                            .AddField(p => p.surveyScore).SetDataType("Textstring").SetLabel("Score")
                            .AddField(p => p.surveyComment).SetDataType("Textarea").SetLabel("Comment")
                        )
                        .AddFieldset("Details", fieldsetConfig => fieldsetConfig
                            .AddField(p => p.jobSurveyLocator).SetLabel("Job Survey Locator").SetDescription("Unique identifier for the job survey, used in Url").MakeReadOnly()
                            .AddField(p => p.market).MakeRequired().SetLabel("Market Id")
                            .AddField(p => p.inspectorName).SetLabel("Inspector Name")
                            .AddField(p => p.recipientName).SetLabel("Recipient Name")
                            .AddField(p => p.recipientEmail).SetValidationRegex("[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+").SetLabel("Recipient Email")
                            .AddField(p => p.recipientPhone).SetDescription("Include area code, omit +1, only digits").SetLabel("Recipient Phone")
                            .AddField(p => p.submitterIP).SetLabel("Submitter IP Address")
                        )
                        .AddFieldset("Urls", fieldsetConfig => fieldsetConfig
                            .AddField(p => p.promoterRedirectUrl).SetLabel("Promoter Redirect Url")
                            .AddField(p => p.detractorRedirectUrl).SetLabel("Detractor Redirect Url")
                            .AddField(p => p.passiveRedirectUrl).SetLabel("Passive Redirect Url")
                        )
                    )
                )
                .AddAction(typeof(CreateTestimonialAction),actionConfig => actionConfig
                .SetVisibility(x => x.ActionType == ActionType.EntityMenu))
            )
        ));
    })

And the Action itself:

using MisWeb.Core.Services;
using Umbraco.UIBuilder.Configuration.Actions;

namespace MisWeb.Core.Actions
{
    public class CreateTestimonialAction : Umbraco.UIBuilder.Configuration.Actions.Action<ActionResult>
    {
        private readonly ISurveyService _surveyService;
        public override string Icon => "icon-chat";
        public override string Alias => "createtestimonialaction";
        public override string Name => "Create Testimonial";
        public override bool ConfirmAction => true;

        public CreateTestimonialAction(ISurveyService surveyService)
        {
            _surveyService = surveyService;
        }

        public override ActionResult Execute(string collectionAlias, object[] entityIds)
        {
            // create a new testimonial
            if(_surveyService.CreateTestimonialFromSurvey(entityIds))
                return new ActionResult(true);

            return new ActionResult(false);
        }
    }
}

Environment (please complete the following information):

  • Server OS: Windows/.NET 10/IIS Express
  • Browser chrome
  • Umbraco Version 17.0.0-rc3
  • Product Version 17.0.0-rc1

This item has been added to our backlog AB#62393

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions