umbraco / Umbraco.UIBuilder.Issues

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

Built-in import action not working #55

Closed jemayn closed 6 months ago

jemayn commented 1 year ago

Describe the bug When I add the KonstruktImportEntityAction, it gets added to the context menu just fine. However when I click it I get an error.

Steps To Reproduce Steps to reproduce the behavior:

  1. Add a collection with the import action
  2. Go to the action dropdown on the page, and click the import button

Expected behavior I'd expect a file upload field to show.

Screenshots I click the action here: image It gives me this error in a popup: image

Environment (please complete the following information):

Additional context All I did was add this to my collection:

.AddCollection<LocalizationView>(x => x.Id, "Localization", "Localizations",
                        "Translated dictionary items", collectionConfig => collectionConfig
    .SetRepositoryType<LocalizationRepository>()
    .AddAction<KonstruktExportEntityAction>()
    .AddAction<KonstruktImportEntityAction>()

The full error message:

An error occurred
No data type found with the Name: Upload File

Exception Details
System.ApplicationException, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e: No data type found with the Name: Upload File
Stacktrace
at Konstrukt.Web.Helpers.UmbracoDataTypeHelper.<>c__DisplayClass5_0.<ResolveDataType>b__0()
   at Umbraco.Extensions.AppCacheExtensions.<>c__DisplayClass5_0`1.<GetCacheItem>b__0()
   at Umbraco.Cms.Core.Cache.SafeLazy.<>c__DisplayClass1_0.<GetSafeLazy>b__0()
--- End of stack trace from previous location ---
   at Umbraco.Cms.Core.Cache.ObjectCacheAppCache.Get(String key, Func`1 factory, Nullable`1 timeout, Boolean isSliding, String[] dependentFiles)
   at Umbraco.Cms.Core.Cache.ObjectCacheAppCache.Get(String key, Func`1 factory)
   at Umbraco.Cms.Core.Cache.DeepCloneAppCache.Get(String key, Func`1 factory)
   at Umbraco.Extensions.AppCacheExtensions.GetCacheItem[T](IAppCache provider, String cacheKey, Func`1 getCacheItem)
   at Konstrukt.Web.Helpers.UmbracoDataTypeHelper.ResolveDataType(String dataTypeName, Boolean isReadOnly)
   at Konstrukt.Web.Helpers.UmbracoDataTypeHelper.ResolveDataType(DataTypeReference dataTypeRef, Boolean isReadOnly)
   at Konstrukt.Web.Models.Mappers.UmbracoPropertyMapper.ToContentPropertyDisplayModel(DataTypeReference dataTypeRef, Int32 id, String alias, String label, String description, Object value, Boolean isRequired, String regexPattern, Boolean hideLabel, Boolean isReadOnly)
   at Konstrukt.Web.Models.Mappers.KonstruktEditorMapper.ToEditModel(EditModelMappingContext ctx)
   at Konstrukt.Web.Models.Mappers.KonstruktSettingsMapper.ToEditModel(EditModelMappingContext ctx)
   at Konstrukt.Web.Controllers.Api.KonstruktApiController.GetSettingsScaffold(String collectionAlias, String settingsSourceType, String settingsSourceAlias)
   at lambda_method1637(Closure, Object, Object[])
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncObjectResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Logged|12_1(ControllerActionInvoker invoker)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)

This item has been added to our backlog AB#34770

mattbrailsford commented 1 year ago

Is there a data type named "Upload File" in the settings section? Maybe Umbraco changed the default names 🤔

jemayn commented 1 year ago

I guess this is the one? image

This is also a migrated v7 -> 11 project, so could be part of the reason.

After renaming the datatype to "Upload File" it works - although maybe there is a better way than checking on the string name? 🙂

Either way my immediate problem is solved, so if you want to close this feel free. Thanks for the quick help!

mattbrailsford commented 1 year ago

Yea, I may need to check to see if it has the same ID as the old "File Upload". If so, it might be better for us to code that to the upload field instead.

mattbrailsford commented 1 year ago

Ok, I've pushed an update to our unstable feed where we are now referncing the upload control via Umbraco's NodeID constant at Umbraco.Cms.Core.Constants.DataTypes.Upload which hopefully should mean this will just work for both instances.

You can find a test build at https://nuget.outfield.digital/unstable/v3/index.json v1.6.5-beta002