Skip to content

Commit

Permalink
Release 3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
callumbwhyte committed Mar 1, 2022
1 parent b7fdb7d commit 587e970
Show file tree
Hide file tree
Showing 24 changed files with 183 additions and 143 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/) and this project adheres to [Semantic Versioning](https://semver.org/).

## [3.0.0] - 2022-03-01
### Added
* Initial release of Meganav for Umbraco 9+
* Ability to create item types with Element Type settings, custom views, and permissions
* Ability to toggle the visibility of nav items
* Actions to expand / collapse Meganav, and populate with all nodes from the tree
* UI overhaul with improved accessibility

## [2.0.0] - 2022-03-01
### Added
* Initial release of Meganav for Umbraco 8.7+
Expand Down Expand Up @@ -46,7 +54,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/) and this
### Added
* Initial release of Meganav for Umbraco 7.5

[Unreleased]: https://github.com/callumbwhyte/meganav/compare/release-2.0.0...HEAD
[Unreleased]: https://github.com/callumbwhyte/meganav/compare/release-3.0.0...HEAD
[3.0.0]: https://github.com/callumbwhyte/meganav/compare/release-2.0.0...release-3.0.0
[2.0.0]: https://github.com/callumbwhyte/meganav/tree/release-2.0.0
[1.1.2]: https://github.com/callumbwhyte/meganav/compare/release-1.1.1...release-1.1.2
[1.1.1]: https://github.com/callumbwhyte/meganav/compare/release-1.1.0...release-1.1.1
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Click and drag an item to change it's position within the navigation; drop it wh

## Getting started

This package is supported on Umbraco 8.7+.
This package is supported on Umbraco 9+.

### Installation

Expand Down
18 changes: 18 additions & 0 deletions src/Our.Umbraco.Meganav/Composing/MeganavComposer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Microsoft.Extensions.DependencyInjection;
using Our.Umbraco.Meganav.PublishedContent;
using Our.Umbraco.Meganav.ValueReferences;
using Umbraco.Cms.Core.Composing;
using Umbraco.Cms.Core.DependencyInjection;

namespace Our.Umbraco.Meganav.Composing
{
public class MeganavComposer : IComposer
{
public void Compose(IUmbracoBuilder builder)
{
builder.Services.AddTransient<PublishedElementFactory>();

builder.DataValueReferenceFactories().Append<MeganavValueReferenceFactory>();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System.Linq;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Notifications;
using Umbraco.Cms.Core.Services;
using Umbraco.Extensions;

namespace Our.Umbraco.Meganav.Migrations
{
internal class LegacyDataTypeChangingHandler : INotificationHandler<DataTypeSavingNotification>
{
private readonly IDataTypeService _dataTypeService;
private readonly LegacyValueMigrator _legacyValueMigrator;

public LegacyDataTypeChangingHandler(IDataTypeService dataTypeService, LegacyValueMigrator legacyValueMigrator)
{
_dataTypeService = dataTypeService;
_legacyValueMigrator = legacyValueMigrator;
}

public void Handle(DataTypeSavingNotification notification)
{
var dataTypes = notification.SavedEntities
.Where(x => x.EditorAlias == Constants.PropertyEditorAlias)
.Where(x =>
{
var existingEntity = _dataTypeService.GetDataType(x.Id);

return existingEntity != null && LegacyEditors.Aliases.Any(existingEntity.EditorAlias.InvariantContains);
});

foreach (var dataType in dataTypes)
{
_legacyValueMigrator.MigrateContentValues(dataType);
}
}
}
}
47 changes: 0 additions & 47 deletions src/Our.Umbraco.Meganav/Migrations/LegacyMigrationComponent.cs

This file was deleted.

14 changes: 8 additions & 6 deletions src/Our.Umbraco.Meganav/Migrations/LegacyMigrationComposer.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
using Umbraco.Core;
using Umbraco.Core.Composing;
using Microsoft.Extensions.DependencyInjection;
using Umbraco.Cms.Core.Composing;
using Umbraco.Cms.Core.DependencyInjection;
using Umbraco.Cms.Core.Notifications;

namespace Our.Umbraco.Meganav.Migrations
{
public class LegacyMigrationComposer : IUserComposer
public class LegacyMigrationComposer : IComposer
{
public void Compose(Composition composition)
public void Compose(IUmbracoBuilder builder)
{
composition.Register<LegacyValueMigrator>();
builder.Services.AddTransient<LegacyValueMigrator>();

composition.Components().Append<LegacyMigrationComponent>();
builder.AddNotificationHandler<DataTypeSavingNotification, LegacyDataTypeChangingHandler>();
}
}
}
23 changes: 12 additions & 11 deletions src/Our.Umbraco.Meganav/Migrations/LegacyValueMigrator.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Our.Umbraco.Meganav.Models;
using Umbraco.Core;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
using Umbraco.Core.Services;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Services;
using Umbraco.Extensions;

namespace Our.Umbraco.Meganav.Migrations
{
internal class LegacyValueMigrator
{
private readonly IContentTypeService _contentTypeService;
private readonly IContentService _contentService;
private readonly ILogger _logger;
private readonly ILogger<LegacyValueMigrator> _logger;

public LegacyValueMigrator(IContentTypeService contentTypeService, IContentService contentService, ILogger logger)
public LegacyValueMigrator(IContentTypeService contentTypeService, IContentService contentService, ILogger<LegacyValueMigrator> logger)
{
_contentTypeService = contentTypeService;
_contentService = contentService;
Expand Down Expand Up @@ -64,7 +65,7 @@ public void MigrateContentValues(IEnumerable<IContent> contentItems, string[] pr
}
catch (Exception ex)
{
_logger.Error<LegacyValueMigrator>(ex, "Failed to migrate Meganav values for {alias} on content {id}", property.Alias, content.Id);
_logger.LogError(ex, "Failed to migrate Meganav values for {alias} on content {id}", property.Alias, content.Id);
}
}
}
Expand Down Expand Up @@ -98,12 +99,12 @@ private IEnumerable<MeganavEntity> ConvertToEntity(object value)

var id = item.Value<int>("id");

GuidUdi.TryParse(item.Value<string>("udi"), out GuidUdi udi);
UdiParser.TryParse(item.Value<string>("udi"), out Udi udi);

if (id > 0 || udi?.Guid != Guid.Empty)
if (id > 0 || udi != null)
{
var contentItem = udi != null
? _contentService.GetById(udi.Guid)
var contentItem = udi is GuidUdi guidUdi
? _contentService.GetById(guidUdi.Guid)
: _contentService.GetById(id);

if (contentItem != null)
Expand Down
2 changes: 1 addition & 1 deletion src/Our.Umbraco.Meganav/Models/IMeganavEntity.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using System.Collections.Generic;
using Umbraco.Core;
using Umbraco.Cms.Core;

namespace Our.Umbraco.Meganav.Models
{
Expand Down
2 changes: 1 addition & 1 deletion src/Our.Umbraco.Meganav/Models/IMeganavItem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Collections.Generic;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Cms.Core.Models.PublishedContent;

namespace Our.Umbraco.Meganav.Models
{
Expand Down
2 changes: 1 addition & 1 deletion src/Our.Umbraco.Meganav/Models/MeganavEntity.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using Umbraco.Core;
using Umbraco.Cms.Core;

namespace Our.Umbraco.Meganav.Models
{
Expand Down
2 changes: 1 addition & 1 deletion src/Our.Umbraco.Meganav/Models/MeganavItem.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using System.Runtime.Serialization;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Cms.Core.Models.PublishedContent;

namespace Our.Umbraco.Meganav.Models
{
Expand Down
7 changes: 4 additions & 3 deletions src/Our.Umbraco.Meganav/Our.Umbraco.Meganav.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<Version Condition="'$(BUILD_BUILDNUMBER)' == ''">1.0.0.0</Version>
<Version Condition="'$(BUILD_BUILDNUMBER)' != ''">$(BUILD_BUILDNUMBER)</Version>
<Description>A flexible, draggable link picker for constructing site navigation menus in Umbraco</Description>
Expand All @@ -16,9 +16,10 @@
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>
<ItemGroup>
<Content Include="Web\UI\**\*.*" PackagePath="content" />
<Content Include="Web\UI\**\*.*" Pack="true" PackagePath="content" />
<None Include="..\build\**\*.*" Pack="true" PackagePath="buildTransitive" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="UmbracoCms.Web" Version="[8.7.0,9.0.0)" />
<PackageReference Include="Umbraco.Cms.Web.Common" Version="[9.0.0,10.0.0)" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using Our.Umbraco.Meganav.Models;
using Umbraco.Core.PropertyEditors;
using Umbraco.Cms.Core.PropertyEditors;

namespace Our.Umbraco.Meganav.PropertyEditors
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
using Umbraco.Core.PropertyEditors;
using Umbraco.Cms.Core.IO;
using Umbraco.Cms.Core.PropertyEditors;
using Umbraco.Cms.Core.Services;

namespace Our.Umbraco.Meganav.PropertyEditors
{
internal class MeganavConfigurationEditor : ConfigurationEditor<MeganavConfiguration>
{
public MeganavConfigurationEditor(IIOHelper ioHelper)
: base(ioHelper)
{

}
}
}
18 changes: 9 additions & 9 deletions src/Our.Umbraco.Meganav/PropertyEditors/MeganavPropertyEditor.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
using Umbraco.Core.Logging;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Services;
using Umbraco.Cms.Core.IO;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.PropertyEditors;

namespace Our.Umbraco.Meganav.PropertyEditors
{
[DataEditor(Constants.PropertyEditorAlias, Constants.PropertyEditorName, Group = "pickers")]
internal class MeganavPropertyEditor : DataEditor
{
private readonly IContentService _contentService;
private readonly IIOHelper _ioHelper;

public MeganavPropertyEditor(IContentService contentService, ILogger logger)
: base(logger, EditorType.PropertyValue)
public MeganavPropertyEditor(IDataValueEditorFactory dataValueEditorFactory, IIOHelper ioHelper)
: base(dataValueEditorFactory, EditorType.PropertyValue)
{
_contentService = contentService;
_ioHelper = ioHelper;
}

protected override IConfigurationEditor CreateConfigurationEditor() => new MeganavConfigurationEditor();
protected override IConfigurationEditor CreateConfigurationEditor() => new MeganavConfigurationEditor(_ioHelper);

protected override IDataValueEditor CreateValueEditor() => new MeganavValueEditor(_contentService);
protected override IDataValueEditor CreateValueEditor() => DataValueEditorFactory.Create<MeganavValueEditor>();
}
}
Loading

0 comments on commit 587e970

Please sign in to comment.