Browse Source

Fixes

pull/568/head
Sebastian 5 years ago
parent
commit
900512a479
  1. 1
      backend/src/Squidex.Domain.Apps.Entities/Apps/AppDomainObject.cs
  2. 1
      backend/src/Squidex.Domain.Apps.Entities/Apps/Templates/Builders/ReferencesFieldBuilder.cs
  3. 1
      backend/src/Squidex.Domain.Apps.Entities/Assets/AssetDomainObject.cs
  4. 19
      backend/src/Squidex.Domain.Apps.Entities/Assets/AssetFolderDomainObject.cs
  5. 1
      backend/src/Squidex.Domain.Apps.Entities/Rules/RuleDomainObject.cs
  6. 1
      backend/src/Squidex.Domain.Apps.Entities/Schemas/SchemaDomainObject.cs
  7. 44
      backend/src/Squidex.Infrastructure/Translations/MissingKeys.cs
  8. 29
      backend/src/Squidex.Infrastructure/Translations/ResourcesLocalizer.cs
  9. 4
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetCommandMiddlewareTests.cs

1
backend/src/Squidex.Domain.Apps.Entities/Apps/AppDomainObject.cs

@ -21,7 +21,6 @@ using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Log;
using Squidex.Infrastructure.Reflection;
using Squidex.Infrastructure.States;
using Squidex.Infrastructure.Translations;
using Squidex.Shared.Users;
namespace Squidex.Domain.Apps.Entities.Apps

1
backend/src/Squidex.Domain.Apps.Entities/Apps/Templates/Builders/ReferencesFieldBuilder.cs

@ -5,7 +5,6 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System;
using Squidex.Domain.Apps.Core.Schemas;
using Squidex.Domain.Apps.Entities.Schemas.Commands;
using Squidex.Infrastructure;

1
backend/src/Squidex.Domain.Apps.Entities/Assets/AssetDomainObject.cs

@ -20,7 +20,6 @@ using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Log;
using Squidex.Infrastructure.Reflection;
using Squidex.Infrastructure.States;
using Squidex.Infrastructure.Translations;
namespace Squidex.Domain.Apps.Entities.Assets
{

19
backend/src/Squidex.Domain.Apps.Entities/Assets/AssetFolderDomainObject.cs

@ -54,7 +54,6 @@ namespace Squidex.Domain.Apps.Entities.Assets
public override Task<object?> ExecuteAsync(IAggregateCommand command)
{
VerifyNotDeleted();
VerifyCommand(command);
switch (command)
{
@ -97,24 +96,6 @@ namespace Squidex.Domain.Apps.Entities.Assets
}
}
private void VerifyCommand(IAggregateCommand command)
{
switch (command)
{
case AssetFolderCommand assetFolderCommand:
if (Version >= 0 && (
!assetFolderCommand.AssetFolderId.Equals(Snapshot.Id) ||
!assetFolderCommand.AppId.Equals(Snapshot.AppId)))
{
throw new InvalidOperationException();
}
break;
default:
throw new NotSupportedException();
}
}
public void Create(CreateAssetFolder command)
{
RaiseEvent(SimpleMapper.Map(command, new AssetFolderCreated()));

1
backend/src/Squidex.Domain.Apps.Entities/Rules/RuleDomainObject.cs

@ -18,7 +18,6 @@ using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Log;
using Squidex.Infrastructure.Reflection;
using Squidex.Infrastructure.States;
using Squidex.Infrastructure.Translations;
namespace Squidex.Domain.Apps.Entities.Rules
{

1
backend/src/Squidex.Domain.Apps.Entities/Schemas/SchemaDomainObject.cs

@ -21,7 +21,6 @@ using Squidex.Infrastructure.Log;
using Squidex.Infrastructure.Orleans;
using Squidex.Infrastructure.Reflection;
using Squidex.Infrastructure.States;
using Squidex.Infrastructure.Translations;
namespace Squidex.Domain.Apps.Entities.Schemas
{

44
backend/src/Squidex.Infrastructure/Translations/MissingKeys.cs

@ -0,0 +1,44 @@
// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschraenkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System.Collections.Generic;
using System.IO;
namespace Squidex.Infrastructure.Translations
{
public sealed class MissingKeys
{
private const string MissingFileName = "__missing.txt";
private readonly object lockObject = new object();
private readonly HashSet<string> missingTranslations;
public MissingKeys()
{
if (File.Exists(MissingFileName))
{
var missing = File.ReadAllLines(MissingFileName);
missingTranslations = new HashSet<string>(missing);
}
else
{
missingTranslations = new HashSet<string>();
}
}
public void Log(string key)
{
lock (lockObject)
{
if (!missingTranslations.Add(key))
{
File.AppendAllLines(MissingFileName, new string[] { key });
}
}
}
}
}

29
backend/src/Squidex.Infrastructure/Translations/ResourcesLocalizer.cs

@ -6,9 +6,7 @@
// ==========================================================================
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Resources;
using System.Text;
@ -16,29 +14,16 @@ namespace Squidex.Infrastructure.Translations
{
public sealed class ResourcesLocalizer : ILocalizer
{
private const string MissingFileName = "__missing.txt";
private static readonly object LockObject = new object();
#if DEBUG
private static readonly MissingKeys MissingKeys = new MissingKeys();
#endif
private readonly ResourceManager resourceManager;
private readonly HashSet<string> missingTranslations;
public ResourcesLocalizer(ResourceManager resourceManager)
{
Guard.NotNull(resourceManager, nameof(resourceManager));
this.resourceManager = resourceManager;
#if DEBUG
if (File.Exists(MissingFileName))
{
var missing = File.ReadAllLines(MissingFileName);
missingTranslations = new HashSet<string>(missing);
}
else
{
missingTranslations = new HashSet<string>();
}
#endif
}
public (string Result, bool Found) Get(CultureInfo culture, string key, string fallback, object? args = null)
@ -166,13 +151,7 @@ namespace Squidex.Infrastructure.Translations
if (translation == null)
{
#if DEBUG
lock (LockObject)
{
if (!missingTranslations.Add(key))
{
File.AppendAllLines(MissingFileName, new string[] { key });
}
}
MissingKeys.Log(key);
#endif
}

4
backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetCommandMiddlewareTests.cs

@ -7,7 +7,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using FakeItEasy;
@ -37,7 +36,6 @@ namespace Squidex.Domain.Apps.Entities.Assets
private readonly IServiceProvider serviceProvider = A.Fake<IServiceProvider>();
private readonly ITagService tagService = A.Fake<ITagService>();
private readonly DomainId assetId = DomainId.NewGuid();
private readonly Stream stream = new MemoryStream();
private readonly AssetDomainObjectGrain asset;
private readonly AssetFile file;
private readonly Context requestContext = Context.Anonymous();
@ -281,7 +279,7 @@ namespace Squidex.Domain.Apps.Entities.Assets
private Task ExecuteCreateAsync()
{
var command = CreateCommand(new CreateAsset { AssetId = Id, File = file });
var command = CreateCommand(new CreateAsset { AssetId = assetId, File = file });
return asset.ExecuteAsync(CommandRequest.Create(command));
}

Loading…
Cancel
Save