mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-08-20 22:32:56 +00:00
Enhance preview feature management by filtering unreleased features and adding release check
This commit is contained in:
parent
038ddec46b
commit
154b3522c1
@ -26,7 +26,7 @@
|
||||
var availablePreviewFeatures = ConfigurationSelectDataFactory.GetPreviewFeaturesData(this.SettingsManager).ToList();
|
||||
if (availablePreviewFeatures.Count > 0)
|
||||
{
|
||||
<ConfigurationMultiSelect OptionDescription="@T("Select preview features")" SelectedValues="@(() => this.SettingsManager.ConfigurationData.App.EnabledPreviewFeatures)" Data="@availablePreviewFeatures" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.App.EnabledPreviewFeatures = selectedValue)" OptionHelp="@T("Which preview features would you like to enable?")"/>
|
||||
<ConfigurationMultiSelect OptionDescription="@T("Select preview features")" SelectedValues="@(() => this.SettingsManager.ConfigurationData.App.EnabledPreviewFeatures.Where(x => !x.IsReleased()).ToHashSet())" Data="@availablePreviewFeatures" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.App.EnabledPreviewFeatures = selectedValue)" OptionHelp="@T("Which preview features would you like to enable?")"/>
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,7 @@ public static class ConfigurationSelectDataFactory
|
||||
|
||||
public static IEnumerable<ConfigurationSelectData<PreviewFeatures>> GetPreviewFeaturesData(SettingsManager settingsManager)
|
||||
{
|
||||
foreach (var source in settingsManager.ConfigurationData.App.PreviewVisibility.GetPreviewFeatures())
|
||||
foreach (var source in settingsManager.ConfigurationData.App.PreviewVisibility.GetPreviewFeatures().Where(x => !x.IsReleased()))
|
||||
yield return new(source.GetPreviewDescription(), source);
|
||||
}
|
||||
|
||||
|
@ -17,5 +17,26 @@ public static class PreviewFeaturesExtensions
|
||||
_ => TB("Unknown preview feature")
|
||||
};
|
||||
|
||||
public static bool IsEnabled(this PreviewFeatures feature, SettingsManager settingsManager) => settingsManager.ConfigurationData.App.EnabledPreviewFeatures.Contains(feature);
|
||||
/// <summary>
|
||||
/// Check if the preview feature is released or not.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This metadata is necessary because we cannot remove the enum values from the list.
|
||||
/// Otherwise, we could not deserialize old settings files that may contain these values.
|
||||
/// </remarks>
|
||||
/// <param name="feature">The preview feature to check.</param>
|
||||
/// <returns>True when the preview feature is released, false otherwise.</returns>
|
||||
public static bool IsReleased(this PreviewFeatures feature) => feature switch
|
||||
{
|
||||
PreviewFeatures.PRE_READ_PDF_2025 => true,
|
||||
_ => false
|
||||
};
|
||||
|
||||
public static bool IsEnabled(this PreviewFeatures feature, SettingsManager settingsManager)
|
||||
{
|
||||
if(feature.IsReleased())
|
||||
return true;
|
||||
|
||||
return settingsManager.ConfigurationData.App.EnabledPreviewFeatures.Contains(feature);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user