Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSOE-867: Addressing analyzer warnings #69

Merged
merged 2 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Lombiq.ContentEditors.Samples/Constants/EditorGroups.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ public static class Employee
public const string PersonalDetails = nameof(PersonalDetails);
public const string EmploymentDetails = nameof(EmploymentDetails);

public static readonly IEnumerable<string> EditorGroups = new[]
{
public static readonly IEnumerable<string> EditorGroups =
[
PersonalDetails,
EmploymentDetails,
};
];
}

public static class SupportTicket
Expand All @@ -22,11 +22,11 @@ public static class SupportTicket
public const string Details = nameof(Details);
public const string Summary = nameof(Summary);

public static readonly IEnumerable<string> EditorGroups = new[]
{
public static readonly IEnumerable<string> EditorGroups =
[
Reporter,
Details,
Summary,
};
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public FrontEndDemoContentItemAsyncEditorController(IAuthorizationService author
[HttpGet("{contentItemId?}")]
public async Task<IActionResult> Index(string contentItemId)
{
if (!ModelState.IsValid) return BadRequest(ModelState);

if (!await _authorizationService.AuthorizeAsync(User, Permissions.EditContent)) return this.ChallengeOrForbid();

// You can use the existing ContentItemAsyncEditorViewModel to pass the required data.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public ContentItemAsyncEditorApiController(
[HttpGet]
public async Task<ActionResult<RenderedAsyncEditorGroupRequest>> Get([FromQuery] RenderAsyncEditorRequest request)
{
if (!ModelState.IsValid) return BadRequest(ModelState);

var provider = GetProvider(request.ProviderName);
if (provider == null) return NotFound();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ namespace Lombiq.ContentEditors.Controllers;
public class ContentItemAsyncEditorController : Controller
{
[HttpGet("{providerName}/{contentType}/{contentItemId?}")]
public ActionResult Index(string providerName, string contentType, string contentItemId) =>
View(new ContentItemAsyncEditorViewModel
public ActionResult Index(string providerName, string contentType, string contentItemId)
{
if (!ModelState.IsValid) return BadRequest(ModelState);

return View(new ContentItemAsyncEditorViewModel
{
ProviderName = providerName,
ContentType = contentType,
ContentItemId = contentItemId,
});
}
}
2 changes: 1 addition & 1 deletion Lombiq.ContentEditors/Extensions/ContentExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static IEnumerable<string> GetFilledEditorGroups(this IContent content, s
content
.GetOrWeldAsyncEditorPart()
.FilledEditorGroups
.GetMaybe(asyncEditorId) ?? Enumerable.Empty<string>();
.GetMaybe(asyncEditorId) ?? [];

public static bool IsEditorGroupFilled(this IContent content, string asyncEditorId, string editorGroup) =>
content.GetFilledEditorGroups(asyncEditorId).Contains(editorGroup);
Expand Down