Skip to content

Commit ee76c40

Browse files
committed
Fixed navigation on empty blog posts
1 parent f38e068 commit ee76c40

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

LinkDotNet.Blog.UnitTests/Web/Shared/BlogPostNavigationTests.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,17 @@ public void ShouldNotFireNextWhenOnFirstPage()
5656
cut.Find("li:first-child").ClassList.Should().Contain("disabled");
5757
}
5858

59+
[Fact]
60+
public void ShouldNotFireNextWhenNoPage()
61+
{
62+
var page = CreatePagedList(0, 0);
63+
var cut = RenderComponent<BlogPostNavigation>(p =>
64+
p.Add(param => param.CurrentPage, page.Object));
65+
66+
cut.Find("li:first-child").ClassList.Should().Contain("disabled");
67+
cut.Find("li:last-child").ClassList.Should().Contain("disabled");
68+
}
69+
5970
private static Mock<IPagedList<BlogPost>> CreatePagedList(int currentPage, int pageCount)
6071
{
6172
var page = new Mock<IPagedList<BlogPost>>();

LinkDotNet.Blog.Web/Shared/BlogPostNavigation.razor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
@using X.PagedList
33
<nav aria-label="Page navigation example">
44
<ul class="pagination justify-content-center">
5-
<li class="page-item @(!CurrentPage.IsFirstPage ? string.Empty : "disabled")">
5+
<li class="page-item @(!CurrentPage.IsFirstPage && CurrentPage.Count > 0 ? string.Empty : "disabled")">
66
<a class="page-link" href="#" tabindex="-1" @onclick="PreviousPage">Previous</a>
77
</li>
8-
<li class="page-item @(!CurrentPage.IsLastPage ? string.Empty : "disabled")">
8+
<li class="page-item @(!CurrentPage.IsLastPage && CurrentPage.Count > 0 ? string.Empty : "disabled")">
99
<a class="page-link"
1010
@onclick="NextPage"
1111
href="#">Next</a>

LinkDotNet.Blog.Web/Shared/Profile.razor

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ OnYesPressed="DeleteItem"></ConfirmDialog>
4747

4848
protected override async Task OnInitializedAsync()
4949
{
50-
profileInformationEntries = await repository.GetAllAsync();
50+
profileInformationEntries = (await repository.GetAllAsync()).OrderBy(d => d.CreatedDate).ToList();
5151
}
5252

5353
private void ShowDeleteDialog(string key)
@@ -65,12 +65,8 @@ OnYesPressed="DeleteItem"></ConfirmDialog>
6565

6666
private async Task AddValue(KeyValuePair<string, string> toAdd)
6767
{
68-
var newEntry = new ProfileInformationEntry
69-
{
70-
Key = toAdd.Key,
71-
Value = toAdd.Value,
72-
};
73-
68+
var newEntry = ProfileInformationEntry.Create(toAdd.Key, toAdd.Value);
69+
7470
profileInformationEntries.Add(newEntry);
7571
await repository.AddAsync(newEntry);
7672
}

0 commit comments

Comments
 (0)