Skip to content

Commit 3d9f170

Browse files
committed
Renamed Parameter to reflect actual behavior
1 parent 5a54662 commit 3d9f170

File tree

9 files changed

+29
-28
lines changed

9 files changed

+29
-28
lines changed

src/LinkDotNet.Blog.Web/Features/AboutMe/AboutMePage.razor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
<div class="container">
1616
<div class="row">
1717
<div class="col-lg-3 col-md-4">
18-
<Profile IsAuthenticated="@isAuthenticated"/>
18+
<Profile ShowAdminActions="@isAuthenticated"/>
1919
</div>
2020
<div class="col-lg-9 col-md-8 tab-container">
2121
<div class="row">
2222
<div class="col-md12 tab-content">
2323
<Card Header="Skills">
24-
<SkillTable IsAuthenticated="@isAuthenticated"></SkillTable>
24+
<SkillTable ShowAdminActions="@isAuthenticated"></SkillTable>
2525
</Card>
2626
</div>
2727
</div>

src/LinkDotNet.Blog.Web/Features/AboutMe/Components/Card.razor

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
@code {
1010
[Parameter]
1111
public string Header { get; set; }
12+
1213
[Parameter]
1314
public RenderFragment ChildContent { get; set; }
1415
}

src/LinkDotNet.Blog.Web/Features/AboutMe/Components/Profile.razor

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
ondragover="event.preventDefault();">
2121
@foreach (var entry in profileInformationEntries)
2222
{
23-
@if (IsAuthenticated)
23+
@if (ShowAdminActions)
2424
{
2525
<li
2626
class="item-draggable"
@@ -39,7 +39,7 @@
3939
<li>@RenderMarkupString(entry.Content)</li>
4040
}
4141
}
42-
@if (IsAuthenticated)
42+
@if (ShowAdminActions)
4343
{
4444
<AddProfileShortItem ValueAdded="@AddValue"></AddProfileShortItem>
4545
}
@@ -51,7 +51,7 @@ OnYesPressed="DeleteItem"></ConfirmDialog>
5151

5252
@code {
5353
[Parameter]
54-
public bool IsAuthenticated { get; set; }
54+
public bool ShowAdminActions { get; set; }
5555

5656
private List<ProfileInformationEntry> profileInformationEntries = new();
5757
private ConfirmDialog Dialog { get; set; }

src/LinkDotNet.Blog.Web/Features/AboutMe/Components/SkillTable.razor

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
@using LinkDotNet.Blog.Infrastructure.Persistence
33
@inject IRepository<Skill> repository
44
<div>
5-
@if (IsAuthenticated)
5+
@if (ShowAdminActions)
66
{
77
<button type="button" class="btn btn-primary" @onclick="() => AddSkillDialog.Open()"><i class="fas
88
fa-plus-square"></i>
@@ -28,12 +28,12 @@
2828
<td @ondrop="@(() => HandleDrop(skillLevel))" class="proficiency-level">
2929
@foreach (var skill in skillCapabilityGroup.Where(s => s.ProficiencyLevel == skillLevel))
3030
{
31-
@if (IsAuthenticated)
31+
@if (ShowAdminActions)
3232
{
3333
<div draggable="true" @ondrag="@(() => currentDragItem = skill)" style="cursor: grab"
3434
class="skill-tag">
3535
<SkillTag Skill="@skill"
36-
IsAuthenticated="@true"
36+
ShowAdminActions="@true"
3737
DeleteSkill="@(() => DeleteSkill(skill))"/>
3838
</div>
3939
}
@@ -50,14 +50,14 @@
5050
}
5151
</tbody>
5252
</table>
53-
@if (IsAuthenticated)
53+
@if (ShowAdminActions)
5454
{
5555
<small for="skill-table">You can drag and drop your skills from one proficency to another</small>
5656
}
5757
</div>
5858
@code {
5959
[Parameter]
60-
public bool IsAuthenticated { get; set; }
60+
public bool ShowAdminActions { get; set; }
6161

6262
private AddSkillDialog AddSkillDialog { get; set; }
6363

src/LinkDotNet.Blog.Web/Features/AboutMe/Components/SkillTag.razor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
}
77
@Skill.Name
88

9-
@if (IsAuthenticated)
9+
@if (ShowAdminActions)
1010
{
1111
<button type="button" class="btn btn-default" aria-label="Delete Skill" @onclick="() => DeleteSkill.InvokeAsync()">
1212
<i class="fas fa-trash-alt" aria-hidden="true"></i>
@@ -19,7 +19,7 @@
1919
public Skill Skill { get; set; }
2020

2121
[Parameter]
22-
public bool IsAuthenticated { get; set; }
22+
public bool ShowAdminActions { get; set; }
2323

2424
[Parameter]
2525
public EventCallback DeleteSkill { get; set; }

tests/LinkDotNet.Blog.IntegrationTests/Web/Shared/ProfileTests.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public void ShouldNotShowAdminActions()
4343
public void ShouldShowAdminActionsWhenLoggedIn()
4444
{
4545
RegisterServices();
46-
RenderComponent<Profile>(p => p.Add(s => s.IsAuthenticated, true))
46+
RenderComponent<Profile>(p => p.Add(s => s.ShowAdminActions, true))
4747
.FindComponents<AddProfileShortItem>().Should().HaveCount(1);
4848
}
4949

@@ -54,7 +54,7 @@ public void ShouldAddEntry()
5454
ProfileInformationEntry entryToDb = null;
5555
repo.Setup(p => p.StoreAsync(It.IsAny<ProfileInformationEntry>()))
5656
.Callback<ProfileInformationEntry>(p => entryToDb = p);
57-
var cut = RenderComponent<Profile>(p => p.Add(s => s.IsAuthenticated, true));
57+
var cut = RenderComponent<Profile>(p => p.Add(s => s.ShowAdminActions, true));
5858
var addShortItemComponent = cut.FindComponent<AddProfileShortItem>();
5959
addShortItemComponent.Find("input").Change("key");
6060

@@ -72,7 +72,7 @@ public void ShouldDeleteEntryWhenConfirmed()
7272
entryToDelete.Id = "SomeId";
7373
var (repoMock, _) = RegisterServices();
7474
SetupGetAll(repoMock, entryToDelete);
75-
var cut = RenderComponent<Profile>(p => p.Add(s => s.IsAuthenticated, true));
75+
var cut = RenderComponent<Profile>(p => p.Add(s => s.ShowAdminActions, true));
7676
cut.Find(".profile-keypoints li button").Click();
7777

7878
cut.FindComponent<ConfirmDialog>().Find("#ok").Click();
@@ -87,7 +87,7 @@ public void ShouldNotDeleteEntryWhenNotConfirmed()
8787
entryToDelete.Id = "SomeId";
8888
var (repoMock, _) = RegisterServices();
8989
SetupGetAll(repoMock, entryToDelete);
90-
var cut = RenderComponent<Profile>(p => p.Add(s => s.IsAuthenticated, true));
90+
var cut = RenderComponent<Profile>(p => p.Add(s => s.ShowAdminActions, true));
9191
cut.Find(".profile-keypoints li button").Click();
9292

9393
cut.FindComponent<ConfirmDialog>().Find("#cancel").Click();
@@ -104,7 +104,7 @@ public void ShouldAddEntryWithCorrectSortOrder()
104104
ProfileInformationEntry entryToDb = null;
105105
repo.Setup(p => p.StoreAsync(It.IsAny<ProfileInformationEntry>()))
106106
.Callback<ProfileInformationEntry>(p => entryToDb = p);
107-
var cut = RenderComponent<Profile>(p => p.Add(s => s.IsAuthenticated, true));
107+
var cut = RenderComponent<Profile>(p => p.Add(s => s.ShowAdminActions, true));
108108
var addShortItemComponent = cut.FindComponent<AddProfileShortItem>();
109109
addShortItemComponent.Find("input").Change("key");
110110

@@ -126,7 +126,7 @@ public void ShouldSetNewOrderWhenItemDragAndDropped()
126126
ProfileInformationEntry entryToDb = null;
127127
repo.Setup(p => p.StoreAsync(It.IsAny<ProfileInformationEntry>()))
128128
.Callback<ProfileInformationEntry>(p => entryToDb = p);
129-
var cut = RenderComponent<Profile>(p => p.Add(s => s.IsAuthenticated, true));
129+
var cut = RenderComponent<Profile>(p => p.Add(s => s.ShowAdminActions, true));
130130
calculator.Setup(s => s.GetSortOrder(target, profileInformationEntries)).Returns(150);
131131

132132
cut.FindAll("li")[1].Drag();
@@ -142,7 +142,7 @@ public void ShouldNotChangeSortOrderWhenDroppedOnItself()
142142
var source = new ProfileInformationEntryBuilder().WithSortOrder(200).Build();
143143
var (repo, _) = RegisterServices();
144144
SetupGetAll(repo, source);
145-
var cut = RenderComponent<Profile>(p => p.Add(s => s.IsAuthenticated, true));
145+
var cut = RenderComponent<Profile>(p => p.Add(s => s.ShowAdminActions, true));
146146

147147
cut.FindAll("li")[0].Drag();
148148
cut.FindAll("li")[0].Drop();

tests/LinkDotNet.Blog.IntegrationTests/Web/Shared/Skills/SkillTableTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public async Task ShouldDeleteItem()
2222
ctx.Services.AddScoped(_ => Repository);
2323
ctx.Services.AddScoped(_ => Mock.Of<IToastService>());
2424
var cut = ctx.RenderComponent<SkillTable>(p =>
25-
p.Add(s => s.IsAuthenticated, true));
25+
p.Add(s => s.ShowAdminActions, true));
2626
cut.WaitForState(() => cut.HasComponent<SkillTag>());
2727

2828
cut.FindComponent<SkillTag>().Find("button").Click();
@@ -39,7 +39,7 @@ public async Task ShouldAddSkill()
3939
ctx.Services.AddScoped(_ => Repository);
4040
ctx.Services.AddScoped(_ => Mock.Of<IToastService>());
4141
var cut = ctx.RenderComponent<SkillTable>(p =>
42-
p.Add(s => s.IsAuthenticated, true));
42+
p.Add(s => s.ShowAdminActions, true));
4343
cut.Find("button").Click();
4444
var dialog = cut.FindComponent<AddSkillDialog>();
4545
dialog.Find("#title").Change("C#");
@@ -69,10 +69,10 @@ public async Task ShouldNotAllowToEditSkillTagsWhenNotAdmin()
6969
ctx.Services.AddScoped(_ => Mock.Of<IToastService>());
7070

7171
var cut = ctx.RenderComponent<SkillTable>(p =>
72-
p.Add(s => s.IsAuthenticated, false));
72+
p.Add(s => s.ShowAdminActions, false));
7373

7474
cut.WaitForState(() => cut.FindComponents<SkillTag>().Any());
75-
cut.FindComponent<SkillTag>().Instance.IsAuthenticated.Should().BeFalse();
75+
cut.FindComponent<SkillTag>().Instance.ShowAdminActions.Should().BeFalse();
7676
}
7777

7878
[Fact]
@@ -85,7 +85,7 @@ public async Task ShouldUpdateProficiencyWhenSkillTagDragged()
8585
ctx.Services.AddScoped(_ => Repository);
8686
ctx.Services.AddScoped(_ => Mock.Of<IToastService>());
8787
var cut = ctx.RenderComponent<SkillTable>(p =>
88-
p.Add(s => s.IsAuthenticated, true));
88+
p.Add(s => s.ShowAdminActions, true));
8989
cut.WaitForState(() => cut.FindAll(".skill-tag").Any());
9090

9191
cut.FindAll(".skill-tag")[0].Drag();
@@ -105,7 +105,7 @@ public async Task ShouldStayOnSameProficiencyWhenDroppedOnSameProficiencyLevel()
105105
ctx.Services.AddScoped(_ => Repository);
106106
ctx.Services.AddScoped(_ => Mock.Of<IToastService>());
107107
var cut = ctx.RenderComponent<SkillTable>(p =>
108-
p.Add(s => s.IsAuthenticated, true));
108+
p.Add(s => s.ShowAdminActions, true));
109109
cut.WaitForState(() => cut.FindAll(".skill-tag").Any());
110110

111111
cut.FindAll(".skill-tag")[0].Drag();

tests/LinkDotNet.Blog.UnitTests/Web/Features/AboutMe/AboutMePageTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ public void ShouldPassIsAuthenticated()
2727

2828
var cut = RenderComponent<AboutMePage>();
2929

30-
cut.FindComponent<Profile>().Instance.IsAuthenticated.Should().BeTrue();
31-
cut.FindComponent<SkillTable>().Instance.IsAuthenticated.Should().BeTrue();
30+
cut.FindComponent<Profile>().Instance.ShowAdminActions.Should().BeTrue();
31+
cut.FindComponent<SkillTable>().Instance.ShowAdminActions.Should().BeTrue();
3232
}
3333

3434
[Fact]

tests/LinkDotNet.Blog.UnitTests/Web/Features/AboutMe/Components/SkillTagTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public void ShouldInvokeDeleteEvent()
3939
var cut = RenderComponent<SkillTag>(p => p
4040
.Add(
4141
s => s.Skill, skill)
42-
.Add(s => s.IsAuthenticated, true)
42+
.Add(s => s.ShowAdminActions, true)
4343
.Add(s => s.DeleteSkill, () => wasInvoked = true));
4444

4545
cut.Find("button").Click();

0 commit comments

Comments
 (0)