Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert to tab not working when Group is called 'Content' #11202

Closed
prjseal opened this issue Sep 27, 2021 · 7 comments
Closed

Convert to tab not working when Group is called 'Content' #11202

prjseal opened this issue Sep 27, 2021 · 7 comments
Labels

Comments

@prjseal
Copy link
Contributor

prjseal commented Sep 27, 2021

Which exact Umbraco version are you using? For example: 8.13.1 - don't just write v8

v9 RC 4

Bug summary

In the Content Base composition, when I try to convert the group called 'Content' to a tab and press save I get a 400 error in the console. It does work for other groups not called 'Content'

Specifics

Request Url: https://localhost:44358/umbraco/backoffice/umbracoapi/contenttype/PostSave
Request Method: POST
Status Code: 400

{
  "allowedTemplates": [],
  "defaultTemplate": null,
  "allowCultureVariant": false,
  "allowSegmentVariant": false,
  "apps": [
    {
      "name": "Design",
      "alias": "design",
      "weight": -200,
      "icon": "icon-document-dashed-line",
      "view": "views/documentTypes/views/design/design.html",
      "viewModel": null,
      "active": false,
      "badge": null
    },
    {
      "name": "List view",
      "alias": "listView",
      "weight": -180,
      "icon": "icon-list",
      "view": "views/documentTypes/views/listview/listview.html",
      "viewModel": null,
      "active": false,
      "badge": null
    },
    {
      "name": "Permissions",
      "alias": "permissions",
      "weight": -160,
      "icon": "icon-keychain",
      "view": "views/documentTypes/views/permissions/permissions.html",
      "viewModel": null,
      "active": false,
      "badge": null
    },
    {
      "name": "Templates",
      "alias": "templates",
      "weight": -140,
      "icon": "icon-layout",
      "view": "views/documentTypes/views/templates/templates.html",
      "viewModel": null,
      "active": false,
      "badge": null
    }
  ],
  "groups": [
    {
      "contentTypeId": 0,
      "parentTabContentTypes": [],
      "parentTabContentTypeNames": [],
      "properties": [
        {
          "editor": null,
          "view": null,
          "config": null,
          "locked": false,
          "contentTypeId": 0,
          "contentTypeName": null,
          "inherited": false,
          "id": 100,
          "alias": "pageTitle",
          "description": "The title of the page, this is also the first text in a google search result. The ideal length is between 40 and 60 characters",
          "validation": {
            "mandatory": true,
            "mandatoryMessage": "",
            "pattern": null,
            "patternMessage": ""
          },
          "label": "Page Title",
          "sortOrder": 0,
          "dataTypeId": -88,
          "dataTypeKey": "00000000-0000-0000-0000-000000000000",
          "dataTypeName": null,
          "dataTypeIcon": null,
          "groupId": 56,
          "allowCultureVariant": false,
          "allowSegmentVariant": false,
          "labelOnTop": false
        },
        {
          "editor": null,
          "view": null,
          "config": null,
          "locked": false,
          "contentTypeId": 0,
          "contentTypeName": null,
          "inherited": false,
          "id": 101,
          "alias": "bodyText",
          "description": "",
          "validation": {
            "mandatory": false,
            "mandatoryMessage": "",
            "pattern": null,
            "patternMessage": ""
          },
          "label": "Content",
          "sortOrder": 1,
          "dataTypeId": 1064,
          "dataTypeKey": "00000000-0000-0000-0000-000000000000",
          "dataTypeName": null,
          "dataTypeIcon": null,
          "groupId": 56,
          "allowCultureVariant": false,
          "allowSegmentVariant": false,
          "labelOnTop": false
        }
      ],
      "inherited": false,
      "id": 56,
      "key": "0a6e9f1c-501a-4556-bfff-8faaf8375fee",
      "type": "Tab",
      "name": "Content",
      "alias": "content",
      "sortOrder": 0
    }
  ],
  "listViewEditorName": "List View - Content",
  "allowedContentTypes": [],
  "compositeContentTypes": [],
  "lockedCompositeContentTypes": [],
  "allowAsRoot": false,
  "notifications": [],
  "ModelState": {},
  "alias": "contentBase",
  "updateDate": "2021-09-27T09:34:13.997Z",
  "createDate": "2021-09-27T09:34:13.997Z",
  "description": null,
  "thumbnail": "folder.png",
  "iconIsClass": true,
  "iconFilePath": "",
  "thumbnailIsClass": false,
  "thumbnailFilePath": "/umbraco/images/thumbnails/folder.png",
  "blueprints": {},
  "isContainer": false,
  "isElement": false,
  "name": "Content Base",
  "id": 1090,
  "udi": null,
  "icon": "icon-document",
  "trashed": false,
  "key": "4ff4a1fc-24db-489a-bdd2-532081dbc62f",
  "parentId": 1089,
  "path": "-1,1089,1090",
  "metaData": {}
}

Steps to reproduce

Install the default starter kit using these unattended install commands

# Ensure we have the latest Umbraco templates
dotnet new -i Umbraco.Templates::9.0.0-rc004

# Create solution/project
dotnet new sln --name MySolution
dotnet new umbraco -n MyProject --friendly-name "Admin User" --email "[email protected]" --password "1234567890" --connection-string "Data Source=|DataDirectory|\Umbraco.sdf;Flush Interval=1" -ce
dotnet sln add MyProject
dotnet add MyProject package Umbraco.TheStarterKit --prerelease

# Run
dotnet run --project MyProject

ConvertToTab

Expected result / actual result

I expected to be able to convert my group called Content to a tab called Content.


This item has been added to our backlog AB#14159

@nul800sebastiaan
Copy link
Member

Ah thanks @prjseal for the repro! I had the same problem last week but could not figure out how to reproduce it. I believe this is also a problem for v8, so we'll need to fix both. 👍

@nul800sebastiaan nul800sebastiaan added the state/sprint-candidate We're trying to get this in a sprint at HQ in the next few weeks label Sep 27, 2021
@ronaldbarendse
Copy link
Contributor

The composition can't be saved with a Content tab, because document types using it already have a Content generic group with 'local' properties (which would result in different types for the same group alias, which can't be merged).

You currently have to rename all the generic groups in the document types to something else first (or move the local properties added to the composition group somewhere else), convert the composition group into a tab and then move the local properties back to the composition tab. I hope this makes sense 😇

We already do all the validation and return the invalid property group aliases in the InvalidCompositionException, but this isn't bubbled up to the front-end (because that would require breaking the Attempt<string[]> IContentTypeBaseService<TItem>.ValidateComposition(TItem compo) which currently only returns invalid property type aliases):

public Attempt<string[]> ValidateComposition(TItem compo)
{
try
{
using (var scope = ScopeProvider.CreateScope(autoComplete: true))
{
scope.ReadLock(ReadLockIds);
ValidateLocked(compo);
}
return Attempt<string[]>.Succeed();
}
catch (InvalidCompositionException ex)
{
return Attempt.Fail(ex.PropertyTypeAliases, ex);
}
}

Because the validation fails, you do get the save error/cross, but no further feedback why that's the case. This is definitely something we can improve!

Not directly related, but something we should also fix is the TODO comment in the InvalidCompositionException:

private static string FormatMessage(string contentTypeAlias, string addedCompositionAlias, string[] propertyTypeAliases, string[] propertyGroupAliases)
{
// TODO Add property group aliases to message
return addedCompositionAlias.IsNullOrWhiteSpace()
? string.Format(
"ContentType with alias '{0}' has an invalid composition " +
"and there was a conflict on the following PropertyTypes: '{1}'. " +
"PropertyTypes must have a unique alias across all Compositions in order to compose a valid ContentType Composition.",
contentTypeAlias, string.Join(", ", propertyTypeAliases))
: string.Format(
"ContentType with alias '{0}' was added as a Composition to ContentType with alias '{1}', " +
"but there was a conflict on the following PropertyTypes: '{2}'. " +
"PropertyTypes must have a unique alias across all Compositions in order to compose a valid ContentType Composition.",
addedCompositionAlias, contentTypeAlias, string.Join(", ", propertyTypeAliases));
}

@prjseal
Copy link
Contributor Author

prjseal commented Sep 29, 2021

@ronaldbarendse Thanks for describing the workaround. It would be good if this actually gets fixed though. You should be able to detect the difference between a tab and a group and they should be able to have the same name in my opinion.

@ronaldbarendse
Copy link
Contributor

@prjseal We should make sure a helpful validation message is shown when the save fails because of an invalid property group in the compositions (similar to the property type aliases). Fixing it will still require manual steps, because you need to update/save multiple document types (and possibly other compositions as well).

Please also note that this is only an issue when multiple compositions bring the same group/tab into a document type or if you have added properties to a group that's inherited from a composition: in that case a 'local' group is added to the document type to contain this property. This is done to ensure the property (and group) isn't deleted if you remove the composition. This is also the reason why you can't reorder/convert to tab on inherited tabs/groups.

@nul800sebastiaan
Copy link
Member

Fixed for 8.18.0 / 9.1.0 in #11373

@wvankesteren-ax
Copy link

I've got the same issue in 8.18.4 when the section is named 'Generic properties'.

  • that section can't be renamed: it will delete that section completely
  • The Convert to tab action is completed successfully, the newly created tab can be renamed (if you want to) and the document type can be saved, but after reopening the document type the action seems not saved.

@ewuski
Copy link

ewuski commented Jan 1, 2024

Are there any another restricted names? I am not able to convert to tab Settings or Images groups to tab...

Getting same error like when trying to convert Content to tab:

Different group types aren't allowed between compositions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants