From d170193a95a6da9f9e01e7d9831e4e8688f445be Mon Sep 17 00:00:00 2001 From: Sven Geusens Date: Fri, 28 Jun 2024 09:28:55 +0200 Subject: [PATCH] Fixed toolbar not showing for seeded,untouched and then migrated RTE datatypes (#16665) Moved 14.1 migrations into their own namespace Co-authored-by: Sven Geusens --- .../Migrations/Upgrade/UmbracoPlan.cs | 5 ++- .../MigrateOldRichTextSeedConfiguration.cs | 38 +++++++++++++++++++ .../MigrateRichTextConfiguration.cs | 2 +- 3 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 src/Umbraco.Infrastructure/Migrations/Upgrade/V_14_1_0/MigrateOldRichTextSeedConfiguration.cs rename src/Umbraco.Infrastructure/Migrations/Upgrade/{V_14_0_0 => V_14_1_0}/MigrateRichTextConfiguration.cs (93%) diff --git a/src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPlan.cs b/src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPlan.cs index 91ca3b4d58..8502e4c529 100644 --- a/src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPlan.cs +++ b/src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPlan.cs @@ -84,6 +84,9 @@ public class UmbracoPlan : MigrationPlan // we need to re-run this migration, as it was flawed for V14 RC3 (the migration can run twice without any issues) To("{6FB5CA9E-C823-473B-A14C-FE760D75943C}"); To("{827360CA-0855-42A5-8F86-A51F168CB559}"); - To("{FEF2DAF4-5408-4636-BB0E-B8798DF8F095}"); + + // To 14.1.0 + To("{FEF2DAF4-5408-4636-BB0E-B8798DF8F095}"); + To("{A385C5DF-48DC-46B4-A742-D5BB846483BC}"); } } diff --git a/src/Umbraco.Infrastructure/Migrations/Upgrade/V_14_1_0/MigrateOldRichTextSeedConfiguration.cs b/src/Umbraco.Infrastructure/Migrations/Upgrade/V_14_1_0/MigrateOldRichTextSeedConfiguration.cs new file mode 100644 index 0000000000..765fba03d1 --- /dev/null +++ b/src/Umbraco.Infrastructure/Migrations/Upgrade/V_14_1_0/MigrateOldRichTextSeedConfiguration.cs @@ -0,0 +1,38 @@ +using NPoco; +using Umbraco.Cms.Core; +using Umbraco.Cms.Infrastructure.Persistence; +using Umbraco.Cms.Infrastructure.Persistence.Dtos; +using Umbraco.Extensions; + +namespace Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_14_1_0; + +public class MigrateOldRichTextSeedConfiguration : MigrationBase +{ + private const string OldSeedValue = + "{\"value\":\",code,undo,redo,cut,copy,mcepasteword,stylepicker,bold,italic,bullist,numlist,outdent,indent,mcelink,unlink,mceinsertanchor,mceimage,umbracomacro,mceinserttable,umbracoembed,mcecharmap,|1|1,2,3,|0|500,400|1049,|true|\"}"; + + private const string NewDefaultValue = + "{\"toolbar\":[\"styles\",\"bold\",\"italic\",\"alignleft\",\"aligncenter\",\"alignright\",\"bullist\",\"numlist\",\"outdent\",\"indent\",\"sourcecode\",\"link\",\"umbmediapicker\",\"umbembeddialog\"],\"mode\":\"Classic\",\"maxImageSize\":500}"; + public MigrateOldRichTextSeedConfiguration(IMigrationContext context) : base(context) + { + } + + protected override void Migrate() + { + Sql sql = Sql() + .Select() + .From() + .Where(x => + x.EditorAlias.Equals(Constants.PropertyEditors.Aliases.RichText) + && x.Configuration == OldSeedValue); + + List dataTypeDtos = Database.Fetch(sql); + + foreach (DataTypeDto dataTypeDto in dataTypeDtos) + { + // Update the configuration + dataTypeDto.Configuration = NewDefaultValue; + Database.Update(dataTypeDto); + } + } +} diff --git a/src/Umbraco.Infrastructure/Migrations/Upgrade/V_14_0_0/MigrateRichTextConfiguration.cs b/src/Umbraco.Infrastructure/Migrations/Upgrade/V_14_1_0/MigrateRichTextConfiguration.cs similarity index 93% rename from src/Umbraco.Infrastructure/Migrations/Upgrade/V_14_0_0/MigrateRichTextConfiguration.cs rename to src/Umbraco.Infrastructure/Migrations/Upgrade/V_14_1_0/MigrateRichTextConfiguration.cs index 950259f575..bca328eb3f 100644 --- a/src/Umbraco.Infrastructure/Migrations/Upgrade/V_14_0_0/MigrateRichTextConfiguration.cs +++ b/src/Umbraco.Infrastructure/Migrations/Upgrade/V_14_1_0/MigrateRichTextConfiguration.cs @@ -4,7 +4,7 @@ using Umbraco.Cms.Infrastructure.Persistence; using Umbraco.Cms.Infrastructure.Persistence.Dtos; using Umbraco.Extensions; -namespace Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_14_0_0; +namespace Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_14_1_0; public class MigrateRichTextConfiguration : MigrationBase {