From 58676e438e4973c4c3dcf956cd6a5b5b7822dc95 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Fri, 15 Nov 2019 18:27:24 +0100 Subject: [PATCH] Several bugfixes. --- .../Apps/Indexes/AppsIndex.cs | 8 ++++---- .../Api/Controllers/Assets/Models/AnnotateAssetDto.cs | 2 +- .../Areas/Api/Controllers/Assets/Models/AssetQuery.cs | 2 +- .../Areas/Api/Controllers/Contents/Models/ContentDto.cs | 6 +++--- .../Controllers/EventConsumers/Models/EventConsumerDto.cs | 4 ++-- .../Apps/Indexes/AppsIndexTests.cs | 8 +++++--- .../Schemas/Indexes/SchemasIndexTests.cs | 8 +++++--- .../pages/clients/client-connect-form.component.html | 8 ++------ 8 files changed, 23 insertions(+), 23 deletions(-) diff --git a/backend/src/Squidex.Domain.Apps.Entities/Apps/Indexes/AppsIndex.cs b/backend/src/Squidex.Domain.Apps.Entities/Apps/Indexes/AppsIndex.cs index ce416a3c1..39e093d9f 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Apps/Indexes/AppsIndex.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Apps/Indexes/AppsIndex.cs @@ -123,7 +123,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.Indexes { var app = await grainFactory.GetGrain(appId).GetStateAsync(); - if (IsFound(app.Value)) + if (IsFound(app.Value, false)) { return app.Value; } @@ -257,7 +257,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.Indexes var app = await grainFactory.GetGrain(appId).GetStateAsync(); - if (IsFound(app.Value)) + if (IsFound(app.Value, true)) { await Index().RemoveAsync(appId); } @@ -268,9 +268,9 @@ namespace Squidex.Domain.Apps.Entities.Apps.Indexes } } - private static bool IsFound(IAppEntity app) + private static bool IsFound(IAppEntity entity, bool allowArchived) { - return app.Version > EtagVersion.Empty && !app.IsArchived; + return entity.Version > EtagVersion.Empty && (!entity.IsArchived || allowArchived); } private IAppsByNameIndexGrain Index() diff --git a/backend/src/Squidex/Areas/Api/Controllers/Assets/Models/AnnotateAssetDto.cs b/backend/src/Squidex/Areas/Api/Controllers/Assets/Models/AnnotateAssetDto.cs index 2f2cd6b93..ab3b56805 100644 --- a/backend/src/Squidex/Areas/Api/Controllers/Assets/Models/AnnotateAssetDto.cs +++ b/backend/src/Squidex/Areas/Api/Controllers/Assets/Models/AnnotateAssetDto.cs @@ -27,7 +27,7 @@ namespace Squidex.Areas.Api.Controllers.Assets.Models /// /// The new asset tags. /// - public HashSet Tags { get; set; } + public HashSet? Tags { get; set; } public AnnotateAsset ToCommand(Guid id) { diff --git a/backend/src/Squidex/Areas/Api/Controllers/Assets/Models/AssetQuery.cs b/backend/src/Squidex/Areas/Api/Controllers/Assets/Models/AssetQuery.cs index 744ee3312..751d0d8bd 100644 --- a/backend/src/Squidex/Areas/Api/Controllers/Assets/Models/AssetQuery.cs +++ b/backend/src/Squidex/Areas/Api/Controllers/Assets/Models/AssetQuery.cs @@ -52,7 +52,7 @@ namespace Squidex.Areas.Api.Controllers.Assets.Models /// The resize mode when the width and height is defined. /// [FromQuery(Name = "mode")] - public string Mode { get; set; } + public string? Mode { get; set; } public bool ShouldResize() { diff --git a/backend/src/Squidex/Areas/Api/Controllers/Contents/Models/ContentDto.cs b/backend/src/Squidex/Areas/Api/Controllers/Contents/Models/ContentDto.cs index 0e415924e..8c78bd109 100644 --- a/backend/src/Squidex/Areas/Api/Controllers/Contents/Models/ContentDto.cs +++ b/backend/src/Squidex/Areas/Api/Controllers/Contents/Models/ContentDto.cs @@ -89,17 +89,17 @@ namespace Squidex.Areas.Api.Controllers.Contents.Models /// /// The name of the schema. /// - public string SchemaName { get; set; } + public string? SchemaName { get; set; } /// /// The display name of the schema. /// - public string SchemaDisplayName { get; set; } + public string? SchemaDisplayName { get; set; } /// /// The reference fields. /// - public FieldDto[] ReferenceFields { get; set; } + public FieldDto[]? ReferenceFields { get; set; } /// /// The version of the content. diff --git a/backend/src/Squidex/Areas/Api/Controllers/EventConsumers/Models/EventConsumerDto.cs b/backend/src/Squidex/Areas/Api/Controllers/EventConsumers/Models/EventConsumerDto.cs index e40d6d196..a3a443410 100644 --- a/backend/src/Squidex/Areas/Api/Controllers/EventConsumers/Models/EventConsumerDto.cs +++ b/backend/src/Squidex/Areas/Api/Controllers/EventConsumers/Models/EventConsumerDto.cs @@ -20,9 +20,9 @@ namespace Squidex.Areas.Api.Controllers.EventConsumers.Models public string Name { get; set; } - public string Error { get; set; } + public string? Error { get; set; } - public string Position { get; set; } + public string? Position { get; set; } public static EventConsumerDto FromEventConsumerInfo(EventConsumerInfo eventConsumerInfo, ApiController controller) { diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/Indexes/AppsIndexTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/Indexes/AppsIndexTests.cs index 7b6468ead..91a8f68e8 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/Indexes/AppsIndexTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/Indexes/AppsIndexTests.cs @@ -19,6 +19,8 @@ using Squidex.Infrastructure.Security; using Squidex.Infrastructure.Validation; using Xunit; +#pragma warning disable SA1133 // Do not combine attributes + namespace Squidex.Domain.Apps.Entities.Apps.Indexes { public sealed class AppsIndexTests @@ -262,10 +264,10 @@ namespace Squidex.Domain.Apps.Entities.Apps.Indexes .MustHaveHappened(); } - [Fact] - public async Task Should_remove_app_from_indexes_on_archive() + [Theory, InlineData(true), InlineData(false)] + public async Task Should_remove_app_from_indexes_on_archive(bool isArchived) { - var app = SetupApp(0, false); + var app = SetupApp(0, isArchived); var context = new CommandContext(new ArchiveApp { AppId = appId.Id }, commandBus) diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/Indexes/SchemasIndexTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/Indexes/SchemasIndexTests.cs index 5befc397b..ca0989f5e 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/Indexes/SchemasIndexTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/Indexes/SchemasIndexTests.cs @@ -18,6 +18,8 @@ using Squidex.Infrastructure.Orleans; using Squidex.Infrastructure.Validation; using Xunit; +#pragma warning disable SA1133 // Do not combine attributes + namespace Squidex.Domain.Apps.Entities.Schemas.Indexes { public class SchemasIndexTests @@ -188,10 +190,10 @@ namespace Squidex.Domain.Apps.Entities.Schemas.Indexes .MustNotHaveHappened(); } - [Fact] - public async Task Should_remove_schema_from_index_on_delete() + [Theory, InlineData(true), InlineData(false)] + public async Task Should_remove_schema_from_index_on_delete_when_existed_before(bool isDeleted) { - var schema = SetupSchema(0, false); + var schema = SetupSchema(0, isDeleted); var context = new CommandContext(new DeleteSchema { SchemaId = schema.Id }, commandBus) diff --git a/frontend/app/features/settings/pages/clients/client-connect-form.component.html b/frontend/app/features/settings/pages/clients/client-connect-form.component.html index 574bc7bd1..e48f8e9ec 100644 --- a/frontend/app/features/settings/pages/clients/client-connect-form.component.html +++ b/frontend/app/features/settings/pages/clients/client-connect-form.component.html @@ -116,9 +116,7 @@
3 Add your app name the CLI config

- - sq config add {{appName}} {{appName}}:{{client.id}} ${{client.secret}} -u ${{apiUrl.value}} - + sq config add {{appName}} {{appName}}:{{client.id}} {{client.secret}} -u {{apiUrl.value}} You can manage configuration to multiple apps in the CLI and switch to an app. @@ -130,9 +128,7 @@

4 Switch to your app in the CLI

- - sq config use {{appName}} - + sq config use {{appName}}