From 90683a5b4d74b34e4813ebb9e7f68245435bbf7b Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Thu, 23 Jan 2025 13:20:41 +0100 Subject: [PATCH] Refactored & added the text info line component --- .../Components/TextInfoLine.razor | 18 +++++ .../Components/TextInfoLine.razor.cs | 31 +++++++++ .../DataSourceLocalFileInfoDialog.razor | 66 ++----------------- .../DataSourceLocalFileInfoDialog.razor.cs | 8 --- 4 files changed, 53 insertions(+), 70 deletions(-) create mode 100644 app/MindWork AI Studio/Components/TextInfoLine.razor create mode 100644 app/MindWork AI Studio/Components/TextInfoLine.razor.cs diff --git a/app/MindWork AI Studio/Components/TextInfoLine.razor b/app/MindWork AI Studio/Components/TextInfoLine.razor new file mode 100644 index 0000000..b3bf2ba --- /dev/null +++ b/app/MindWork AI Studio/Components/TextInfoLine.razor @@ -0,0 +1,18 @@ + + + + @if (this.ShowingCopyButton) + { + + + + } + \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/TextInfoLine.razor.cs b/app/MindWork AI Studio/Components/TextInfoLine.razor.cs new file mode 100644 index 0000000..a68f25f --- /dev/null +++ b/app/MindWork AI Studio/Components/TextInfoLine.razor.cs @@ -0,0 +1,31 @@ +using Microsoft.AspNetCore.Components; + +namespace AIStudio.Components; + +public partial class TextInfoLine : ComponentBase +{ + [Parameter] + public string Label { get; set; } = string.Empty; + + [Parameter] + public string Icon { get; set; } = Icons.Material.Filled.Info; + + [Parameter] + public string Value { get; set; } = string.Empty; + + [Parameter] + public string ClipboardTooltipSubject { get; set; } = "the text"; + + [Parameter] + public bool ShowingCopyButton { get; set; } = true; + + [Inject] + private RustService RustService { get; init; } = null!; + + [Inject] + private ISnackbar Snackbar { get; init; } = null!; + + private string ClipboardTooltip => $"Copy {this.ClipboardTooltipSubject} to the clipboard"; + + private async Task CopyToClipboard(string content) => await this.RustService.CopyText2Clipboard(this.Snackbar, content); +} \ No newline at end of file diff --git a/app/MindWork AI Studio/Dialogs/DataSourceLocalFileInfoDialog.razor b/app/MindWork AI Studio/Dialogs/DataSourceLocalFileInfoDialog.razor index 828abf5..6fb4b12 100644 --- a/app/MindWork AI Studio/Dialogs/DataSourceLocalFileInfoDialog.razor +++ b/app/MindWork AI Studio/Dialogs/DataSourceLocalFileInfoDialog.razor @@ -1,37 +1,8 @@ - - - - - - - + - - - - - - - - + @if (!this.IsFileAvailable) { @@ -45,22 +16,7 @@ } - - - - - - - - + @if (this.IsCloudEmbedding) { @@ -75,21 +31,7 @@ } - - - - - - - + Close diff --git a/app/MindWork AI Studio/Dialogs/DataSourceLocalFileInfoDialog.razor.cs b/app/MindWork AI Studio/Dialogs/DataSourceLocalFileInfoDialog.razor.cs index 23fa068..a4a5c4a 100644 --- a/app/MindWork AI Studio/Dialogs/DataSourceLocalFileInfoDialog.razor.cs +++ b/app/MindWork AI Studio/Dialogs/DataSourceLocalFileInfoDialog.razor.cs @@ -13,12 +13,6 @@ public partial class DataSourceLocalFileInfoDialog : ComponentBase [Parameter] public DataSourceLocalFile DataSource { get; set; } - [Inject] - private RustService RustService { get; init; } = null!; - - [Inject] - private ISnackbar Snackbar { get; init; } = null!; - [Inject] private SettingsManager SettingsManager { get; init; } = null!; @@ -42,7 +36,5 @@ public partial class DataSourceLocalFileInfoDialog : ComponentBase private string FileSize => this.fileInfo.FileSize(); - private async Task CopyToClipboard(string content) => await this.RustService.CopyText2Clipboard(this.Snackbar, content); - private void Close() => this.MudDialog.Close(); } \ No newline at end of file