Refactor error modal into its own partial (#785)

* Refactor error modal into its own partial

* Fix unresolved error string in TwoFactorPartial

* Use tuple model instead of ViewData for error title and message

* Apply suggestions from code review
This commit is contained in:
koko 2023-06-08 00:01:59 -04:00 committed by GitHub
parent af6fdb457b
commit 77e46a0721
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 68 additions and 94 deletions

View file

@ -12,12 +12,7 @@
@if (!string.IsNullOrWhiteSpace(Model.Error)) @if (!string.IsNullOrWhiteSpace(Model.Error))
{ {
<div class="ui negative message"> @await Html.PartialAsync("Partials/ErrorModalPartial", (Model.Translate(GeneralStrings.Error), Model.Error), ViewData)
<div class="header">
@Model.Translate(GeneralStrings.Error)
</div>
<p style="white-space: pre-line">@Model.Error</p>
</div>
} }
<form class="ui form" onsubmit="return onSubmit(this)" method="post"> <form class="ui form" onsubmit="return onSubmit(this)" method="post">

View file

@ -31,12 +31,7 @@
<form class="ui form" onsubmit="return onSubmit(this)" method="post"> <form class="ui form" onsubmit="return onSubmit(this)" method="post">
@if (!string.IsNullOrWhiteSpace(Model.Error)) @if (!string.IsNullOrWhiteSpace(Model.Error))
{ {
<div class="ui negative message"> @await Html.PartialAsync("Partials/ErrorModalPartial", (Model.Translate(GeneralStrings.Error), Model.Error), ViewData)
<div class="header">
@Model.Translate(GeneralStrings.Error)
</div>
<p style="white-space: pre-line">@Model.Error</p>
</div>
} }
@Html.AntiForgeryToken() @Html.AntiForgeryToken()
<input type="hidden" id="redirect" name="redirect"> <input type="hidden" id="redirect" name="redirect">

View file

@ -1,5 +1,4 @@
@page "/passwordReset" @page "/passwordReset"
@using LBPUnion.ProjectLighthouse.Configuration
@using LBPUnion.ProjectLighthouse.Localization.StringLists @using LBPUnion.ProjectLighthouse.Localization.StringLists
@model LBPUnion.ProjectLighthouse.Servers.Website.Pages.Login.PasswordResetPage @model LBPUnion.ProjectLighthouse.Servers.Website.Pages.Login.PasswordResetPage
@ -27,12 +26,7 @@
@if (!string.IsNullOrWhiteSpace(Model.Error)) @if (!string.IsNullOrWhiteSpace(Model.Error))
{ {
<div class="ui negative message"> @await Html.PartialAsync("Partials/ErrorModalPartial", (Model.Translate(GeneralStrings.Error), Model.Error), ViewData)
<div class="header">
@Model.Translate(GeneralStrings.Error)
</div>
<p>@Model.Error</p>
</div>
} }
<div class="ui middle aligned center aligned grid"> <div class="ui middle aligned center aligned grid">

View file

@ -9,12 +9,7 @@
@if (!string.IsNullOrWhiteSpace(Model.Error)) @if (!string.IsNullOrWhiteSpace(Model.Error))
{ {
<div class="ui negative message"> @await Html.PartialAsync("Partials/ErrorModalPartial", (Model.Translate(GeneralStrings.Error), Model.Error), ViewData)
<div class="header">
@Model.Translate(GeneralStrings.Error)
</div>
<p style="white-space: pre-line">@Model.Error</p>
</div>
} }
@if (!string.IsNullOrWhiteSpace(Model.Status)) @if (!string.IsNullOrWhiteSpace(Model.Status))

View file

@ -25,17 +25,14 @@
@if (!string.IsNullOrWhiteSpace(Model.Error)) @if (!string.IsNullOrWhiteSpace(Model.Error))
{ {
<div class="ui negative message"> @await Html.PartialAsync("Partials/ErrorModalPartial", (Model.Translate(GeneralStrings.Error), Model.Error), ViewData)
<div class="header">
@Model.Translate(GeneralStrings.Error)
</div>
<p>@Model.Error</p>
</div>
} }
@if (Model.Username == null) @if (Model.Username == null)
{ {
<p><b>@Model.Translate(RegisterStrings.UsernameNotice)</b></p> <p>
<b>@Model.Translate(RegisterStrings.UsernameNotice)</b>
</p>
} }
<form class="ui form" onsubmit="return onSubmit(this)" method="post"> <form class="ui form" onsubmit="return onSubmit(this)" method="post">

View file

@ -12,12 +12,7 @@
@if (!string.IsNullOrWhiteSpace(Model.Error)) @if (!string.IsNullOrWhiteSpace(Model.Error))
{ {
<div class="ui negative message"> @await Html.PartialAsync("Partials/ErrorModalPartial", (Model.Translate(GeneralStrings.Error), Model.Error), ViewData)
<div class="header">
@Model.Translate(GeneralStrings.Error)
</div>
<p style="white-space: pre-line">@Model.Error</p>
</div>
} }
<input type="hidden" name="type" value="@((int)Model.Type)"/> <input type="hidden" name="type" value="@((int)Model.Type)"/>

View file

@ -0,0 +1,8 @@
@model (string Title, string Message)
<div class="ui negative message">
<div class="header">
@Model.Title
</div>
<p style="white-space: pre-line">@Model.Message</p>
</div>

View file

@ -11,12 +11,7 @@
<div class="digits" id="2fa"> <div class="digits" id="2fa">
@if (!string.IsNullOrWhiteSpace(error)) @if (!string.IsNullOrWhiteSpace(error))
{ {
<div class="ui negative message"> @await Html.PartialAsync("Partials/ErrorModalPartial", ((string)Model.Translate(GeneralStrings.Error), error), ViewData)
<div class="header">
@Model.Translate(GeneralStrings.Error)
</div>
<p style="white-space: pre-line">@Model.Error</p>
</div>
} }
<input type="text" pattern="\d*" maxlength="1" id="digit1"/> <input type="text" pattern="\d*" maxlength="1" id="digit1"/>
<input type="text" pattern="\d*" maxlength="1" id="digit2"/> <input type="text" pattern="\d*" maxlength="1" id="digit2"/>