Skip to content

Commit

Permalink
fix(Dashboard): added icon to close editor errors
Browse files Browse the repository at this point in the history
Closes #447

Signed-off-by: Jean-Baptiste Bianchi <[email protected]>
  • Loading branch information
JBBianchi committed Oct 30, 2024
1 parent 6ba3e73 commit 251c2af
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@
}
@if (problemDetails != null)
{
<div class="problems p-3">
<Callout Color="CalloutColor.Danger" Heading="@problemDetails.Title">
<div class="problems px-3">
<Callout Color="CalloutColor.Danger" Heading="@problemDetails.Title" Class="position-relative">
<Icon Name="IconName.X" Class="position-absolute" @onclick="() => Store.SetProblemDetails(null)" />
<p>@problemDetails.Detail</p>

@if (problemDetails.Errors != null && problemDetails.Errors.Any())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,5 @@ public record DocumentDetailsState
/// <summary>
/// Gets/sets the list of <see cref="ProblemDetails"/> errors that occurred when trying to save the resource, if any
/// </summary>
public EquatableDictionary<string, string[]> ProblemErrors { get; set; } = new EquatableDictionary<string, string[]>();
public IDictionary<string, string[]> ProblemErrors { get; set; } = new EquatableDictionary<string, string[]>();
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

using Synapse.Api.Client.Services;
using Synapse.Dashboard.Components.WorkflowInstanceLogsStateManagement;
using Synapse.Dashboard.Pages.Functions.Create;

namespace Synapse.Dashboard.Components.DocumentDetailsStateManagement;

Expand Down Expand Up @@ -380,6 +381,22 @@ public async Task OnCopyToClipboard()
this.Logger.LogError("Unable to copy to clipboard: {exception}", ex.ToString());
}
}

/// <summary>
/// Sets the state's <see cref="CreateFunctionViewState" /> <see cref="ProblemDetails"/>'s related data
/// </summary>
/// <param name="problem">The <see cref="ProblemDetails"/> to populate the data with</param>
public void SetProblemDetails(ProblemDetails? problem)
{
this.Reduce(state => state with
{
ProblemType = problem?.Type,
ProblemTitle = problem?.Title ?? string.Empty,
ProblemStatus = problem?.Status ?? 0,
ProblemDetail = problem?.Detail ?? string.Empty,
ProblemErrors = problem?.Errors?.ToDictionary(kvp => kvp.Key, kvp => kvp.Value) ?? []
});
}
#endregion

/// <inheritdoc/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@
OnDidChangeModelContent="OnTextBasedValueChanged" />
@if (problemDetails != null)
{
<div class="problems p-3">
<Callout Color="CalloutColor.Danger" Heading="@problemDetails.Title">
<div class="problems px-3">
<Callout Color="CalloutColor.Danger" Heading="@problemDetails.Title" Class="position-relative">
<Icon Name="IconName.X" Class="position-absolute" @onclick="() => Store.SetProblemDetails(null)" />
<p>@problemDetails.Detail</p>

@if (problemDetails.Errors != null && problemDetails.Errors.Any())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ else
CssClass="h-100" />
@if (problemDetails != null)
{
<div class="problems p-3">
<Callout Color="CalloutColor.Danger" Heading="@problemDetails.Title">
<div class="problems px-3">
<Callout Color="CalloutColor.Danger" Heading="@problemDetails.Title" Class="position-relative">
<Icon Name="IconName.X" Class="position-absolute" @onclick="() => Store.SetProblemDetails(null)" />
<p>@problemDetails.Detail</p>

@if (problemDetails.Errors != null && problemDetails.Errors.Any())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ else
CssClass="h-100" />
@if (problemDetails != null)
{
<div class="problems p-3">
<Callout Color="CalloutColor.Danger" Heading="@problemDetails.Title">
<div class="problems px-3">
<Callout Color="CalloutColor.Danger" Heading="@problemDetails.Title" Class="position-relative">
<Icon Name="IconName.X" Class="position-absolute" @onclick="() => Store.SetProblemDetails(null)" />
<p>@problemDetails.Detail</p>

@if (problemDetails.Errors != null && problemDetails.Errors.Any())
Expand Down
11 changes: 10 additions & 1 deletion src/dashboard/Synapse.Dashboard/wwwroot/css/app.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/dashboard/Synapse.Dashboard/wwwroot/css/app.min.css

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions src/dashboard/Synapse.Dashboard/wwwroot/css/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,15 @@ input[type="search"]::-webkit-search-cancel-button {
max-height: 300px;
overflow: scroll;
width: 100%;

.bb-callout {
margin-top: 0;
margin-bottom: 0;

.bi.bi-x.position-absolute {
cursor: pointer;
top: $spacer;
right: $spacer;
}
}
}

0 comments on commit 251c2af

Please sign in to comment.