Skip to content

Commit 6185db7

Browse files
Changed the update notification to use the default notification system (#386)
1 parent 670b065 commit 6185db7

File tree

5 files changed

+21
-56
lines changed

5 files changed

+21
-56
lines changed

app/MindWork AI Studio/Components/InnerScrolling.razor.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using AIStudio.Layout;
2-
31
using Microsoft.AspNetCore.Components;
42

53
namespace AIStudio.Components;
@@ -30,9 +28,6 @@ public partial class InnerScrolling : MSGComponentBase
3028
[Parameter]
3129
public string Style { get; set; } = string.Empty;
3230

33-
[CascadingParameter]
34-
private MainLayout MainLayout { get; set; } = null!;
35-
3631
[Inject]
3732
private IJSRuntime JsRuntime { get; init; } = null!;
3833

app/MindWork AI Studio/Layout/MainLayout.razor

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,26 +45,11 @@
4545

4646
<MudMainContent Class="mud-height-full pt-1" Style="@this.PaddingLeft">
4747
<MudContainer MaxWidth="MaxWidth.ExtraExtraLarge" Class="mud-height-full" Style="margin-left: 5em; width: calc(100% - 5em);">
48-
@if (!this.performingUpdate && this.IsUpdateAlertVisible)
49-
{
50-
<MudAlert NoIcon="@true" Severity="Severity.Info" Variant="Variant.Filled" ShowCloseIcon="@true" Dense="@true" CloseIconClicked="() => this.DismissUpdate()" Class="mt-2 mb-2">
51-
<div class="d-inline-flex align-center">
52-
<MudIcon Icon="@Icons.Material.Filled.Update" Size="Size.Medium" Class="mr-3"/>
53-
An update to version @this.updateToVersion is available.
54-
<MudButton Variant="Variant.Filled" Color="Color.Dark" Size="Size.Small" Class="ml-3" OnClick="() => this.ShowUpdateDialog()">
55-
Show details
56-
</MudButton>
57-
</div>
58-
</MudAlert>
59-
}
60-
6148
@if (!this.performingUpdate)
6249
{
63-
<CascadingValue Value="@this" IsFixed="true">
64-
@this.Body
65-
</CascadingValue>
50+
@this.Body
6651
}
67-
52+
6853
<MudOverlay Visible="@this.performingUpdate" DarkBackground="@true" LockScroll="@true">
6954
<MudText Typo="Typo.h3">Please wait for the update to complete...</MudText>
7055
<MudProgressLinear Color="Color.Primary" Indeterminate="@true" Size="Size.Large" Rounded="@true"/>

app/MindWork AI Studio/Layout/MainLayout.razor.cs

Lines changed: 15 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ public partial class MainLayout : LayoutComponentBase, IMessageBusReceiver, IDis
3737

3838
[Inject]
3939
private MudTheme ColorTheme { get; init; } = null!;
40-
41-
public string AdditionalHeight { get; private set; } = "0em";
4240

4341
private string PaddingLeft => this.navBarOpen ? $"padding-left: {NAVBAR_EXPANDED_WIDTH_INT - NAVBAR_COLLAPSED_WIDTH_INT}em;" : "padding-left: 0em;";
4442

@@ -48,10 +46,7 @@ public partial class MainLayout : LayoutComponentBase, IMessageBusReceiver, IDis
4846
private static readonly string NAVBAR_EXPANDED_WIDTH = $"{NAVBAR_EXPANDED_WIDTH_INT}em";
4947

5048
private bool navBarOpen;
51-
private bool isUpdateAvailable;
5249
private bool performingUpdate;
53-
private bool userDismissedUpdate;
54-
private string updateToVersion = string.Empty;
5550
private UpdateResponse? currentUpdateResponse;
5651
private MudThemeProvider themeProvider = null!;
5752
private bool useDarkMode;
@@ -107,7 +102,7 @@ protected override async Task OnInitializedAsync()
107102

108103
// Register this component with the message bus:
109104
this.MessageBus.RegisterComponent(this);
110-
this.MessageBus.ApplyFilters(this, [], [ Event.UPDATE_AVAILABLE, Event.USER_SEARCH_FOR_UPDATE, Event.CONFIGURATION_CHANGED, Event.COLOR_THEME_CHANGED, Event.SHOW_ERROR ]);
105+
this.MessageBus.ApplyFilters(this, [], [ Event.UPDATE_AVAILABLE, Event.CONFIGURATION_CHANGED, Event.COLOR_THEME_CHANGED, Event.SHOW_ERROR ]);
111106

112107
// Set the snackbar for the update service:
113108
UpdateService.SetBlazorDependencies(this.Snackbar);
@@ -142,19 +137,24 @@ public async Task ProcessMessage<T>(ComponentBase? sendingComponent, Event trigg
142137
{
143138
switch (triggeredEvent)
144139
{
145-
case Event.USER_SEARCH_FOR_UPDATE:
146-
this.userDismissedUpdate = false;
147-
break;
148-
149140
case Event.UPDATE_AVAILABLE:
150141
if (data is UpdateResponse updateResponse)
151142
{
152143
this.currentUpdateResponse = updateResponse;
153-
this.isUpdateAvailable = updateResponse.UpdateIsAvailable;
154-
this.updateToVersion = updateResponse.NewVersion;
155-
156-
await this.InvokeAsync(this.StateHasChanged);
157-
await this.SendMessage<bool>(Event.STATE_HAS_CHANGED);
144+
this.Snackbar.Add($"An update to version {updateResponse.NewVersion} is available.", Severity.Info, config =>
145+
{
146+
config.Icon = Icons.Material.Filled.Update;
147+
config.IconSize = Size.Large;
148+
config.HideTransitionDuration = 600;
149+
config.VisibleStateDuration = 32_000;
150+
config.OnClick = async _ =>
151+
{
152+
await this.ShowUpdateDialog();
153+
};
154+
config.Action = "Show details";
155+
config.ActionVariant = Variant.Filled;
156+
config.ActionColor = Color.Dark;
157+
});
158158
}
159159

160160
break;
@@ -207,25 +207,6 @@ private IEnumerable<NavBarItem> GetNavItems()
207207
yield return new("About", Icons.Material.Filled.Info, palette.DarkLighten, palette.GrayLight, Routes.ABOUT, false);
208208
yield return new("Settings", Icons.Material.Filled.Settings, palette.DarkLighten, palette.GrayLight, Routes.SETTINGS, false);
209209
}
210-
211-
private async Task DismissUpdate()
212-
{
213-
this.userDismissedUpdate = true;
214-
this.AdditionalHeight = "0em";
215-
216-
await this.SendMessage<bool>(Event.STATE_HAS_CHANGED);
217-
}
218-
219-
private bool IsUpdateAlertVisible
220-
{
221-
get
222-
{
223-
var state = this.isUpdateAvailable && !this.userDismissedUpdate;
224-
this.AdditionalHeight = state ? "3em" : "0em";
225-
226-
return state;
227-
}
228-
}
229210

230211
private async Task ShowUpdateDialog()
231212
{

app/MindWork AI Studio/wwwroot/app.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
font-weight: 300;
77
src: url('fonts/roboto-v30-latin-300.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
88
}
9+
910
/* roboto-regular - latin */
1011
@font-face {
1112
font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
@@ -14,6 +15,7 @@
1415
font-weight: 400;
1516
src: url('fonts/roboto-v30-latin-regular.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
1617
}
18+
1719
/* roboto-500 - latin */
1820
@font-face {
1921
font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
@@ -22,6 +24,7 @@
2224
font-weight: 500;
2325
src: url('fonts/roboto-v30-latin-500.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
2426
}
27+
2528
/* roboto-700 - latin */
2629
@font-face {
2730
font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */

app/MindWork AI Studio/wwwroot/changelog/v0.9.39.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- Added the plugin overview page. This page shows all installed plugins and allows you to enable or disable them. It is only available when the plugin preview feature is enabled.
66
- Added hot reloading for plugins. When any plugin is changed, the app will automatically reload the plugin without needing to restart the app.
77
- Added an API for streaming arbitrary local files to the embedding process. Thanks Nils `nilskruthoff` for this great contribution.
8+
- Changed the update notification to use the default notification system at the bottom instead of the custom alert bar at the top.
89
- Fixed the preview tooltip component not showing the correct position when used inside a scrollable container.
910
- Upgraded to Rust v1.86.0
1011
- Upgraded to MudBlazor v8.5.1

0 commit comments

Comments
 (0)