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

Add migrators to support DocTypeGridEditor to Block Grid migration #66

Merged
merged 3 commits into from
Jul 16, 2024

Conversation

ronaldbarendse
Copy link
Contributor

This PR extends the built-in migrators (coming in Deploy 13.2.0) to migrate the legacy Grid layout using DocTypeGridEditor (exports need to be created using a version that contains PR #65):

  • ReplaceDocTypeGridEditorDataTypeArtifactMigrator extends ReplaceGridDataTypeArtifactMigrator and ensures any DocTypeGridEditor is migrated to blocks using the allowed element types (otherwise they will be migrated to new element types by the default implementation);
  • DocTypeGridEditorPropertyTypeMigrator extends GridPropertyTypeMigrator and ensures the DocTypeGridEditor values are mapped 1:1 to the block item data.

I've created a Deploy 13.2.0-rc1 preview version on the MyGet pre-releases feed to test (and ensure this PR builds). Testing by HQ is easier done by copying these files into the latest v13 Deploy codebase.

The migrations can to be added using the following composer:

using Umbraco.Cms.Core.Composing;
using Umbraco.Deploy.Infrastructure.Migrators;

internal sealed class DeployMigratorsComposer : IComposer
{
    public void Compose(IUmbracoBuilder builder)
    {
        builder.DeployArtifactMigrators()
            .Append<ReplaceNestedContentDataTypeArtifactMigrator>()
            .Append<ReplaceDocTypeGridEditorDataTypeArtifactMigrator>()
            .Append<ReplaceUnknownEditorDataTypeArtifactMigrator>();

        builder.DeployPropertyTypeMigrators()
            .Append<NestedContentPropertyTypeMigrator>()
            .Append<DocTypeGridEditorPropertyTypeMigrator>();
    }
}

And to test, I've exported a v8 site using The Starter Kit and DocTypeGridEditor (used on the Biker Jacket product page): export-TheStarterKit-DocTypeGridEditor.zip.

@AndyButland
Copy link
Contributor

On testing this one I get this element type created:

image

But I can't see where it's being referenced and used?

@ronaldbarendse
Copy link
Contributor Author

ronaldbarendse commented Jul 9, 2024

But I can't see where it's being referenced and used?

This element type should be configured as settings model on one of the blocks (but this isn't really specific to the DocTypeGridEditor support this PR adds)...

@AndyButland
Copy link
Contributor

I'm not seeing it being used though. For example "Content Base - Content - Grid layout" looks like this after importing the provided zip into a clean database:

image

@ronaldbarendse
Copy link
Contributor Author

Hmm, I've just setup a clean Umbraco project with the following package references (using the same Deploy version from the MyGet feed as in this PR and configured a license):

<PackageReference Include="Umbraco.Cms" Version="13.4.0" />
<PackageReference Include="Umbraco.Forms" Version="13.1.2" />
<PackageReference Include="Umbraco.Forms.Deploy" Version="13.0.1" />
<PackageReference Include="Umbraco.Deploy.Cloud" Version="13.2.0--rc1.preview.1.g294fdcd" />
<PackageReference Include="Umbraco.Deploy.Contrib" Version="13.1.0" />

I then copied over the 2 migrators from this PR, added the composer and imported the provided ZIP archive:

Data type configuration

I do see that the ZIP archive still contains the 'Umbraco Block Grid Demo' element types, which causes them to also be added as DocTypeGridEditor allowed element types, but that doesn't cause any issues (even though some have the same name).

The only time I've seen the configured blocks come up empty, was when duplicate items were added, but you should see an error in your console if that's the case... If the import completed with a PanicException, maybe restarting the site is enough to fix it (as that properly clears the memory caches)?

@AndyButland
Copy link
Contributor

Here's what I'm doing... so let me know if I missed something:

  • Using the "Dev On-Prem" example project, with v13/feature/grid-migrator checked out.
  • Registered only the migrators you indicated in the PR description.
  • Created a new, empty local SQL Server database and added the connection string details
  • Started Umbraco and manually installed using this database.
  • Imported the provided zip
    • All imports OK, no "panic exception" but I see the "Content Base - Content - Grid layout" I shared above.

@ronaldbarendse
Copy link
Contributor Author

All imports OK, no "panic exception" but I see the "Content Base - Content - Grid layout" I shared above.

I followed the exact same steps and get the expected data type configuration 🙃 Can you check whether the UDA file of this data type contains any configured blocks and if it does, whether some have identical contentElementTypeKey values?

@AndyButland
Copy link
Contributor

data-type__ea0ed4c1c48943b89058a70babf430ff.txt

Here's the .uda file for this data type from my local environment after the import. I can see there is at least one duplicate - 924312d2-92d9-4f41-86ac-a7a9f17060a8.

@ronaldbarendse
Copy link
Contributor Author

ronaldbarendse commented Jul 10, 2024

Thanks! I've been able to reproduce this by configuring multiple DocTypeGridEditor grid editors, so I guess you already had one added in a grid.editors.config.js file... Both editors could then return the same migrated content element types (depending on the allowedDocTypes setting), potentially resulting in the duplicate block configurations.

This is now fixed by checking whether the content element type is already returned/added to a hash set, which also means the DocTypeGridEditor configuration of the first grid editor will be used.

Copy link
Contributor

@AndyButland AndyButland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good now with the latest updates... glad you got to the bottom of it.

@ronaldbarendse ronaldbarendse merged commit 6131add into v13/dev Jul 16, 2024
6 checks passed
@ronaldbarendse ronaldbarendse deleted the v13/feature/doctypegrideditor-migrators branch July 16, 2024 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants