Added Drafts and Review Pages (WIP)
This commit is contained in:
parent
021e5c5b71
commit
cc0c75e5d0
|
@ -12,6 +12,12 @@
|
|||
<AuthorizeView Policy="ArticleEditPermissions">
|
||||
<Authorized>
|
||||
<li><NavLink href="article/new">New Article</NavLink></li>
|
||||
<li><NavLink href="drafts">Drafts</NavLink></li>
|
||||
</Authorized>
|
||||
</AuthorizeView>
|
||||
<AuthorizeView Policy="ArticleReviewPermissions">
|
||||
<Authorized>
|
||||
<li><NavLink href="review">In Review</NavLink></li>
|
||||
</Authorized>
|
||||
</AuthorizeView>
|
||||
<AuthorizeView Policy="RoleAssignPermissions">
|
||||
|
|
|
@ -124,8 +124,7 @@
|
|||
article = new Article {
|
||||
Title = Model.Title!,
|
||||
Body = Model.Body!,
|
||||
Author = User,
|
||||
Status = ArticleStatus.Published // TODO remove
|
||||
Author = User
|
||||
};
|
||||
await context.AddAsync(article);
|
||||
}
|
||||
|
|
37
Wave/Components/Pages/Drafts.razor
Normal file
37
Wave/Components/Pages/Drafts.razor
Normal file
|
@ -0,0 +1,37 @@
|
|||
@page "/drafts"
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@using Wave.Data
|
||||
@using Microsoft.AspNetCore.Identity
|
||||
|
||||
@attribute [Authorize(Policy = "ArticleEditPermissions")]
|
||||
@inject IDbContextFactory<ApplicationDbContext> ContextFactory
|
||||
@inject UserManager<ApplicationUser> UserManager
|
||||
@inject IStringLocalizer<Drafts> Localizer
|
||||
|
||||
<div class="flex gap-x-8 gap-y-4">
|
||||
@foreach (var article in Articles) {
|
||||
<ArticleTile Article="article" />
|
||||
}
|
||||
@if (Articles.Count < 1) {
|
||||
<p>@Localizer["NoArticles"]</p>
|
||||
}
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[CascadingParameter]
|
||||
private HttpContext HttpContext { get; set; } = default!;
|
||||
|
||||
private List<Article> Articles { get; } = [];
|
||||
|
||||
protected override async Task OnInitializedAsync() {
|
||||
await using var context = await ContextFactory.CreateDbContextAsync();
|
||||
string userId = UserManager.GetUserId(HttpContext.User)!;
|
||||
|
||||
Articles.AddRange(await
|
||||
context.Set<Article>()
|
||||
.Include(a => a.Author)
|
||||
.Where(a => a.Status == ArticleStatus.Draft && a.Author.Id == userId)
|
||||
.OrderByDescending(a => a.PublishDate)
|
||||
.ToListAsync());
|
||||
}
|
||||
}
|
31
Wave/Components/Pages/Review.razor
Normal file
31
Wave/Components/Pages/Review.razor
Normal file
|
@ -0,0 +1,31 @@
|
|||
@page "/review"
|
||||
@using Wave.Data
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
|
||||
@attribute [Authorize(Policy = "ArticleReviewPermissions")]
|
||||
@inject IDbContextFactory<ApplicationDbContext> ContextFactory
|
||||
@inject IStringLocalizer<Review> Localizer
|
||||
|
||||
<div class="flex gap-x-8 gap-y-4">
|
||||
@foreach (var article in Articles) {
|
||||
<ArticleTile Article="article" />
|
||||
}
|
||||
@if(Articles.Count < 1) {
|
||||
<p>@Localizer["NoArticles"]</p>
|
||||
}
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private List<Article> Articles { get; } = [];
|
||||
|
||||
protected override async Task OnInitializedAsync() {
|
||||
await using var context = await ContextFactory.CreateDbContextAsync();
|
||||
|
||||
Articles.AddRange(await
|
||||
context.Set<Article>()
|
||||
.Include(a => a.Author)
|
||||
.Where(a => a.Status == ArticleStatus.InReview)
|
||||
.OrderByDescending(a => a.PublishDate)
|
||||
.ToListAsync());
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
@using System.Net.Http
|
||||
@using System.Net.Http.Json
|
||||
@using Microsoft.AspNetCore.Components.Authorization
|
||||
@using Microsoft.AspNetCore.Authorization
|
||||
@using Microsoft.AspNetCore.Components.Forms
|
||||
@using Microsoft.AspNetCore.Components.Routing
|
||||
@using Microsoft.AspNetCore.Components.Web
|
||||
|
|
Loading…
Reference in a new issue