Skip to content

Commit

Permalink
Removing warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
Psichorex committed Jun 8, 2024
1 parent 1f7ceb1 commit 1576436
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions Lombiq.JsonEditor/Controllers/AdminController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public AdminController(
[AdminRoute("Contents/ContentItems/{contentItemId}/Edit/Json")]
public async Task<IActionResult> Edit(string contentItemId)
{
if (!ModelState.IsValid) return BadRequest(ModelState);

if (string.IsNullOrWhiteSpace(contentItemId) ||
await _contentManager.GetAsync(contentItemId, VersionOptions.Latest) is not { } contentItem ||
!await CanEditAsync(contentItem))
Expand Down Expand Up @@ -90,6 +92,8 @@ public async Task<IActionResult> EditPost(
[Bind(Prefix = "submit.Publish")] string submitPublish,
[Bind(Prefix = "submit.Save")] string submitSave)
{
if (!ModelState.IsValid) return BadRequest(ModelState);

if (string.IsNullOrWhiteSpace(contentItemId) ||
string.IsNullOrWhiteSpace(json) ||
JsonConvert.DeserializeObject<ContentItem>(json) is not { } contentItem)
Expand Down
8 changes: 4 additions & 4 deletions Lombiq.JsonEditor/Models/JsonEditorOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public JsonEditorMode Mode
set => ModeString = GetModeString(value);
}

public IEnumerable<string> Modes { get; set; } = new[] { "tree", "view", "form", "code", "text", "preview" };
public IEnumerable<string> Modes { get; set; } = ["tree", "view", "form", "code", "text", "preview"];

/// <summary>
/// Gets or sets the JSON Schema to validate against. A JSON schema describes the structure that a JSON object must
Expand Down Expand Up @@ -116,8 +116,8 @@ private static string GetModeString(JsonEditorMode mode) =>
public static JsonEditorOptions GetSample(IHtmlLocalizer localizer) =>
new()
{
Templates = new[]
{
Templates =
[
new JsonEditorTemplate
{
Field = "aTechnicalNameThatHasToBeUnique",
Expand All @@ -127,6 +127,6 @@ public static JsonEditorOptions GetSample(IHtmlLocalizer localizer) =>
.Value,
Value = new { YourObject = "goes here" },
},
},
],
};
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Lombiq.HelpfulLibraries.AspNetCore.Security;
using Lombiq.HelpfulLibraries.AspNetCore.Security;
using Lombiq.JsonEditor.Constants;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
Expand All @@ -18,7 +18,7 @@ public class JsonEditorContentSecurityPolicyProvider : ResourceManagerContentSec
{
protected override string ResourceType => "script";
protected override string ResourceName => ResourceNames.Library;
protected override IReadOnlyCollection<string> DirectiveNameChain { get; } = new[] { WorkerSrc, ScriptSrc };
protected override IReadOnlyCollection<string> DirectiveNameChain { get; } = [WorkerSrc, ScriptSrc];
protected override string DirectiveValue => $"{Blob} {Data}";

protected override ValueTask ThenUpdateAsync(
Expand Down

0 comments on commit 1576436

Please sign in to comment.