Skip to content

Commit b445600

Browse files
Enhanced enterprise config support (#666)
1 parent 6e33c36 commit b445600

31 files changed

Lines changed: 716 additions & 409 deletions
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<div style="display: flex; align-items: center; gap: 8px; @this.Item.Style">
2+
<MudIcon Icon="@this.Item.Icon"/>
3+
<span>
4+
@this.Item.Text
5+
</span>
6+
@if (!string.IsNullOrWhiteSpace(this.Item.CopyValue))
7+
{
8+
<MudCopyClipboardButton TooltipMessage="@this.Item.CopyTooltip" StringContent="@this.Item.CopyValue"/>
9+
}
10+
</div>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using Microsoft.AspNetCore.Components;
2+
3+
namespace AIStudio.Components;
4+
5+
public partial class ConfigInfoRow : ComponentBase
6+
{
7+
[Parameter]
8+
public ConfigInfoRowItem Item { get; set; } = new(Icons.Material.Filled.ArrowRightAlt, string.Empty, string.Empty, string.Empty, string.Empty);
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace AIStudio.Components;
2+
3+
public sealed record ConfigInfoRowItem(
4+
string Icon,
5+
string Text,
6+
string CopyValue,
7+
string CopyTooltip,
8+
string Style = ""
9+
);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<MudPaper Outlined="true" Class="@this.Class">
2+
<div style="display: flex; align-items: center; gap: 8px; margin-bottom: 8px;">
3+
<MudIcon Icon="@this.HeaderIcon" Size="Size.Small"/>
4+
<MudText Typo="Typo.subtitle2">
5+
@this.HeaderText
6+
</MudText>
7+
</div>
8+
9+
@foreach (var item in this.Items)
10+
{
11+
<ConfigInfoRow Item="@item"/>
12+
}
13+
14+
@if (this.ShowWarning)
15+
{
16+
<div style="display: flex; align-items: center; gap: 8px; margin-top: 4px;">
17+
<MudIcon Icon="@Icons.Material.Filled.Warning" Size="Size.Small" Color="Color.Warning"/>
18+
<MudText Typo="Typo.subtitle2">@this.WarningText</MudText>
19+
</div>
20+
}
21+
</MudPaper>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using Microsoft.AspNetCore.Components;
2+
3+
namespace AIStudio.Components;
4+
5+
public partial class ConfigPluginInfoCard : ComponentBase
6+
{
7+
[Parameter]
8+
public string HeaderIcon { get; set; } = Icons.Material.Filled.Extension;
9+
10+
[Parameter]
11+
public string HeaderText { get; set; } = string.Empty;
12+
13+
[Parameter]
14+
public IEnumerable<ConfigInfoRowItem> Items { get; set; } = [];
15+
16+
[Parameter]
17+
public bool ShowWarning { get; set; }
18+
19+
[Parameter]
20+
public string WarningText { get; set; } = string.Empty;
21+
22+
[Parameter]
23+
public string Class { get; set; } = "pa-3 mt-2 mb-2";
24+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<MudText Typo="Typo.body1" Class="@this.Class">
2+
<div style="display: flex; align-items: center; gap: 8px;">
3+
<MudIcon Icon="@Icons.Material.Filled.ArrowRightAlt"/>
4+
@if (this.IsConfigured)
5+
{
6+
<MudIcon Icon="@Icons.Material.Filled.CheckCircle" Color="Color.Success" Size="Size.Small"/>
7+
<span>@this.ConfiguredText</span>
8+
}
9+
else
10+
{
11+
<MudIcon Icon="@Icons.Material.Filled.Cancel" Color="Color.Error" Size="Size.Small"/>
12+
<span>@this.NotConfiguredText</span>
13+
}
14+
</div>
15+
</MudText>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using Microsoft.AspNetCore.Components;
2+
3+
namespace AIStudio.Components;
4+
5+
public partial class EncryptionSecretInfo : ComponentBase
6+
{
7+
[Parameter]
8+
public bool IsConfigured { get; set; }
9+
10+
[Parameter]
11+
public string ConfiguredText { get; set; } = string.Empty;
12+
13+
[Parameter]
14+
public string NotConfiguredText { get; set; } = string.Empty;
15+
16+
[Parameter]
17+
public string Class { get; set; } = "mt-2 mb-2";
18+
}

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

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,28 @@ await this.InvokeAsync(async () =>
215215
.CheckDeferredMessages<EnterpriseEnvironment>(Event.STARTUP_ENTERPRISE_ENVIRONMENT)
216216
.Where(env => env != default)
217217
.ToList();
218+
219+
var failedDeferredConfigIds = new HashSet<Guid>();
218220
foreach (var env in enterpriseEnvironments)
219-
await PluginFactory.TryDownloadingConfigPluginAsync(env.ConfigurationId, env.ConfigurationServerUrl);
221+
{
222+
var wasDownloadSuccessful = await PluginFactory.TryDownloadingConfigPluginAsync(env.ConfigurationId, env.ConfigurationServerUrl);
223+
if (!wasDownloadSuccessful)
224+
{
225+
failedDeferredConfigIds.Add(env.ConfigurationId);
226+
this.Logger.LogWarning("Failed to download deferred enterprise configuration '{ConfigId}' during startup. Keeping managed plugins unchanged.", env.ConfigurationId);
227+
}
228+
}
229+
230+
if (EnterpriseEnvironmentService.HasValidEnterpriseSnapshot)
231+
{
232+
var activeConfigIds = EnterpriseEnvironmentService.CURRENT_ENVIRONMENTS
233+
.Select(env => env.ConfigurationId)
234+
.ToHashSet();
235+
236+
PluginFactory.RemoveUnreferencedManagedConfigurationPlugins(activeConfigIds);
237+
if (failedDeferredConfigIds.Count > 0)
238+
this.Logger.LogWarning("Deferred startup updates failed for {FailedCount} enterprise configuration(s). Those configurations were kept unchanged.", failedDeferredConfigIds.Count);
239+
}
220240

221241
// Initialize the enterprise encryption service for decrypting API keys:
222242
await PluginFactory.InitializeEnterpriseEncryption(this.RustService);

0 commit comments

Comments
 (0)