-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Add archive action to StatusesPage (admin-only) #139
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,4 +32,14 @@ public record ListIssuesQuery | |
| /// Gets or sets the author name for filtering by author. | ||
| /// </summary> | ||
| public string? AuthorName { get; init; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the status name for filtering by status. | ||
| /// </summary> | ||
| public string? StatusName { get; init; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the category name for filtering by category. | ||
| /// </summary> | ||
| public string? CategoryName { get; init; } | ||
|
Comment on lines
+35
to
+44
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,8 +17,10 @@ public interface IIssueApiClient | |
| /// <param name="pageSize">The number of items per page.</param> | ||
| /// <param name="searchTerm">Optional search term to filter by title or description.</param> | ||
| /// <param name="authorName">Optional author name to filter by.</param> | ||
| /// <param name="statusName">Optional status name to filter by.</param> | ||
| /// <param name="categoryName">Optional category name to filter by.</param> | ||
| /// <param name="cancellationToken">Cancellation token.</param> | ||
| Task<PaginatedResponse<IssueDto>> GetAllAsync(int page = 1, int pageSize = 20, string? searchTerm = null, string? authorName = null, CancellationToken cancellationToken = default); | ||
| Task<PaginatedResponse<IssueDto>> GetAllAsync(int page = 1, int pageSize = 20, string? searchTerm = null, string? authorName = null, string? statusName = null, string? categoryName = null, CancellationToken cancellationToken = default); | ||
|
Comment on lines
19
to
+23
|
||
|
|
||
| /// <summary>Gets an issue by its identifier.</summary> | ||
| Task<IssueDto?> GetByIdAsync(string id, CancellationToken cancellationToken = default); | ||
|
|
@@ -45,7 +47,7 @@ public class IssueApiClient : IIssueApiClient | |
| public IssueApiClient(HttpClient httpClient) => _httpClient = httpClient; | ||
|
|
||
| /// <inheritdoc/> | ||
| public async Task<PaginatedResponse<IssueDto>> GetAllAsync(int page = 1, int pageSize = 20, string? searchTerm = null, string? authorName = null, CancellationToken cancellationToken = default) | ||
| public async Task<PaginatedResponse<IssueDto>> GetAllAsync(int page = 1, int pageSize = 20, string? searchTerm = null, string? authorName = null, string? statusName = null, string? categoryName = null, CancellationToken cancellationToken = default) | ||
| { | ||
| try | ||
| { | ||
|
|
@@ -58,6 +60,14 @@ public async Task<PaginatedResponse<IssueDto>> GetAllAsync(int page = 1, int pag | |
| { | ||
| url += $"&authorName={Uri.EscapeDataString(authorName)}"; | ||
| } | ||
| if (!string.IsNullOrWhiteSpace(statusName)) | ||
| { | ||
| url += $"&statusName={Uri.EscapeDataString(statusName)}"; | ||
| } | ||
| if (!string.IsNullOrWhiteSpace(categoryName)) | ||
| { | ||
| url += $"&categoryName={Uri.EscapeDataString(categoryName)}"; | ||
| } | ||
|
|
||
| var result = await _httpClient.GetFromJsonAsync<PaginatedResponse<IssueDto>>(url, cancellationToken).ConfigureAwait(false); | ||
| return result ?? PaginatedResponse<IssueDto>.Empty; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -153,7 +153,7 @@ | |
| _currentPage = page; | ||
| try | ||
| { | ||
| var response = await IssueClient.GetAllAsync(page, 20); | ||
| var response = await IssueClient.GetAllAsync(page, 20, _searchTerm, null, _statusFilter, _categoryFilter); | ||
|
||
| _issues = response.Items; | ||
| _totalPages = response.TotalPages; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
StatusName/CategoryName filters are applied as MongoDB regular expressions using the raw user input. This can cause query failures if the input is not a valid regex pattern (e.g., unmatched brackets) and can also make queries more expensive than intended. Consider escaping user input (treating it as a literal) or using an equality match/collation-based case-insensitive comparison instead of passing user-provided regex patterns directly.