From 781c5a9a9e0c24acd1d8b15fe20ca46a122e49d5 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Fri, 4 Nov 2022 18:59:39 +0100 Subject: [PATCH] UI fix. --- .../Contents/ContentsController.cs | 40 ++----------------- .../Contents/Generator/OperationBuilder.cs | 26 ++++++++++-- .../Generator/SchemasOpenApiGenerator.cs | 10 +---- .../editor/content-field.component.scss | 3 +- .../editor/field-copy-button.component.html | 20 +++++----- 5 files changed, 41 insertions(+), 58 deletions(-) diff --git a/backend/src/Squidex/Areas/Api/Controllers/Contents/ContentsController.cs b/backend/src/Squidex/Areas/Api/Controllers/Contents/ContentsController.cs index 366a24738..e0cf66d9b 100644 --- a/backend/src/Squidex/Areas/Api/Controllers/Contents/ContentsController.cs +++ b/backend/src/Squidex/Areas/Api/Controllers/Contents/ContentsController.cs @@ -100,6 +100,7 @@ namespace Squidex.Areas.Api.Controllers.Contents /// The name of the app. /// The name of the schema. /// The ID of the content to fetch. + /// The optional version. /// /// 200 => Content returned. /// 404 => Content, schema or app not found. @@ -112,9 +113,9 @@ namespace Squidex.Areas.Api.Controllers.Contents [ProducesResponseType(typeof(ContentDto), StatusCodes.Status200OK)] [ApiPermissionOrAnonymous] [ApiCosts(1)] - public async Task GetContent(string app, string schema, DomainId id) + public async Task GetContent(string app, string schema, DomainId id, long version = EtagVersion.Any) { - var content = await contentQuery.FindAsync(Context, schema, id, ct: HttpContext.RequestAborted); + var content = await contentQuery.FindAsync(Context, schema, id, version, HttpContext.RequestAborted); if (content == null) { @@ -218,41 +219,6 @@ namespace Squidex.Areas.Api.Controllers.Contents return Ok(response); } - /// - /// Get a content by version V2. - /// - /// The name of the app. - /// The name of the schema. - /// The ID of the content to fetch. - /// The version fo the content to fetch. - /// - /// 200 => Content version returned. - /// 404 => Content, schema or app not found. - /// - /// - /// You can read the generated documentation for your app at /api/content/{appName}/docs. - /// - [HttpGet] - [Route("content/{app}/{schema}/{id}/v/{version}/")] - [ApiPermissionOrAnonymous(PermissionIds.AppContentsReadOwn)] - [ApiCosts(1)] - public async Task GetContentVersionV2(string app, string schema, DomainId id, int version) - { - var content = await contentQuery.FindAsync(Context, schema, id, version, HttpContext.RequestAborted); - - if (content == null) - { - return NotFound(); - } - - var response = Deferred.Response(() => - { - return ContentDto.FromDomain(content, Resources); - }); - - return Ok(response); - } - /// /// Get a content by version. /// diff --git a/backend/src/Squidex/Areas/Api/Controllers/Contents/Generator/OperationBuilder.cs b/backend/src/Squidex/Areas/Api/Controllers/Contents/Generator/OperationBuilder.cs index 1d0eb1ada..8aee6fce7 100644 --- a/backend/src/Squidex/Areas/Api/Controllers/Contents/Generator/OperationBuilder.cs +++ b/backend/src/Squidex/Areas/Api/Controllers/Contents/Generator/OperationBuilder.cs @@ -10,6 +10,7 @@ using NJsonSchema; using NSwag; using Squidex.Areas.Api.Config.OpenApi; using Squidex.Domain.Apps.Core; +using Squidex.Infrastructure; using Squidex.Shared; using Squidex.Web; @@ -94,7 +95,14 @@ namespace Squidex.Areas.Api.Controllers.Contents.Generator return this; } - public OperationBuilder HasQuery(string name, JsonObjectType type, string? description = null) + public OperationBuilder Deprecated() + { + operation.IsDeprecated = true; + + return this; + } + + public OperationBuilder HasQuery(string name, JsonObjectType type, string description) { var jsonSchema = new JsonSchema { Type = type }; @@ -108,14 +116,26 @@ namespace Squidex.Areas.Api.Controllers.Contents.Generator return AddParameter(name, jsonSchema, OpenApiParameterKind.Path, description); } - public OperationBuilder HasBody(string name, JsonSchema jsonSchema, string? description = null) + public OperationBuilder HasBody(string name, JsonSchema schema, string? description = null) { + var jsonSchema = schema; + return AddParameter(name, jsonSchema, OpenApiParameterKind.Body, description); } public OperationBuilder Responds(int statusCode, string description, JsonSchema? schema = null) { - var response = new OpenApiResponse { Description = description, Schema = schema }; + var response = new OpenApiResponse + { + Description = description + }; + + if (schema != null && statusCode == 204) + { + ThrowHelper.ArgumentException("Invalid status code.", nameof(statusCode)); + } + + response.Schema = schema; operation.Responses.Add(statusCode.ToString(CultureInfo.InvariantCulture), response); diff --git a/backend/src/Squidex/Areas/Api/Controllers/Contents/Generator/SchemasOpenApiGenerator.cs b/backend/src/Squidex/Areas/Api/Controllers/Contents/Generator/SchemasOpenApiGenerator.cs index 5202dbfd7..5a2e5a70e 100644 --- a/backend/src/Squidex/Areas/Api/Controllers/Contents/Generator/SchemasOpenApiGenerator.cs +++ b/backend/src/Squidex/Areas/Api/Controllers/Contents/Generator/SchemasOpenApiGenerator.cs @@ -133,25 +133,19 @@ namespace Squidex.Areas.Api.Controllers.Contents.Generator .RequirePermission(PermissionIds.AppContentsReadOwn) .Operation("Get") .OperationSummary("Get a [schema] content item.") + .HasQuery("version", JsonObjectType.Number, FieldDescriptions.EntityVersion) .HasId() .Responds(200, "Content item returned.", builder.ContentSchema); builder.AddOperation(OpenApiOperationMethod.Get, "/{id}/{version}") .RequirePermission(PermissionIds.AppContentsReadOwn) + .Deprecated() .Operation("GetVersioned") .OperationSummary("Get a [schema] content item by id and version.") .HasPath("version", JsonObjectType.Number, FieldDescriptions.EntityVersion) .HasId() .Responds(200, "Content item returned.", builder.DataSchema); - builder.AddOperation(OpenApiOperationMethod.Get, "/{id}/v/{version}") - .RequirePermission(PermissionIds.AppContentsReadOwn) - .Operation("GetVersionedV2") - .OperationSummary("Get a [schema] content item by id and version.") - .HasPath("version", JsonObjectType.Number, FieldDescriptions.EntityVersion) - .HasId() - .Responds(200, "Content item returned.", builder.ContentSchema); - builder.AddOperation(OpenApiOperationMethod.Get, "/{id}/validity") .RequirePermission(PermissionIds.AppContentsReadOwn) .Operation("Validate") diff --git a/frontend/src/app/features/content/pages/content/editor/content-field.component.scss b/frontend/src/app/features/content/pages/content/editor/content-field.component.scss index 5640588e2..d193046b5 100644 --- a/frontend/src/app/features/content/pages/content/editor/content-field.component.scss +++ b/frontend/src/app/features/content/pages/content/editor/content-field.component.scss @@ -27,7 +27,8 @@ } &-buttons { - @include absolute(-.75rem, 4.25rem); + @include absolute(-.75rem, 4.25rem, null, 0); + overflow: hidden; } &-buttons-compare { diff --git a/frontend/src/app/features/content/pages/content/editor/field-copy-button.component.html b/frontend/src/app/features/content/pages/content/editor/field-copy-button.component.html index 8d7054241..f8c584346 100644 --- a/frontend/src/app/features/content/pages/content/editor/field-copy-button.component.html +++ b/frontend/src/app/features/content/pages/content/editor/field-copy-button.component.html @@ -13,15 +13,17 @@ -
- - -
- +
+
+ + +
+ +