-
-
Notifications
You must be signed in to change notification settings - Fork 334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for deleting plugin settings when uninstalling plugins #3219
base: dev
Are you sure you want to change the base?
Conversation
🥷 Code experts: jjw24, VictoriousRaptor Jack251970, Yusyuriv have most 👩💻 activity in the files. See details
Activity based on git-commit:
Knowledge based on git-blame:
Activity based on git-commit:
Knowledge based on git-blame:
Activity based on git-commit:
Knowledge based on git-blame: To learn more about /:\ gitStream - Visit our Docs |
This comment has been minimized.
This comment has been minimized.
📝 WalkthroughWalkthroughThe pull request introduces enhancements to the plugin management system in Flow Launcher, focusing on providing more granular control over plugin settings during uninstallation. The Changes
Suggested labels
Suggested reviewers
Poem
Tip 🌐 Web search-backed reviews and chat
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
Flow.Launcher.Core/Plugin/PluginManager.cs (1)
546-556
: Consider adding error handling for directory operations.The directory deletion operation could fail due to various reasons (e.g., file locks, permissions). Consider adding try-catch blocks to handle potential exceptions gracefully.
if (removePluginSettings) { var assemblyLoader = new PluginAssemblyLoader(plugin.ExecuteFilePath); var assembly = assemblyLoader.LoadAssemblyAndDependencies(); var assemblyName = assembly.GetName().Name; var directoryPath = Path.Combine(DataLocation.DataDirectory(), JsonStorage<object>.DirectoryName, Constant.Plugins, assemblyName); if (Directory.Exists(directoryPath)) { + try + { Directory.Delete(directoryPath, true); + } + catch (Exception ex) + { + Log.Exception(nameof(PluginManager), $"Failed to delete plugin settings directory for {plugin.Name}", ex); + } } }Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs (1)
685-689
: LGTM! Consider adding documentation to clarify parameters.The implementation looks good and aligns with the PR objectives. The user prompt is clear and consistent with the codebase's style.
Consider adding a comment to explain the difference between
removeSettings
andremovePluginSettings
parameters:private void Uninstall(PluginMetadata plugin) { try { + // removeSettings: Remove plugin's system settings + // removePluginSettings: Remove plugin's user settings from %APPDATA%\FlowLauncher\Settings\Plugins\{Plugin_AssemblyName} var removePluginSettings = Context.API.ShowMsgBox( Context.API.GetTranslation("plugin_pluginsmanager_keep_plugin_settings_subtitle"), Context.API.GetTranslation("plugin_pluginsmanager_keep_plugin_settings_title"), button: MessageBoxButton.YesNo) == MessageBoxResult.No; PluginManager.UninstallPlugin(plugin, removeSettings: true, removePluginSettings: removePluginSettings);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
Flow.Launcher.Core/Plugin/PluginManager.cs
(5 hunks)Plugins/Flow.Launcher.Plugin.PluginsManager/Languages/en.xaml
(2 hunks)Plugins/Flow.Launcher.Plugin.PluginsManager/Languages/zh-cn.xaml
(2 hunks)Plugins/Flow.Launcher.Plugin.PluginsManager/Languages/zh-tw.xaml
(2 hunks)Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: gitStream.cm
🔇 Additional comments (5)
Flow.Launcher.Core/Plugin/PluginManager.cs (2)
458-460
: LGTM! Method signature updated to support plugin settings deletion.The new
removePluginSettings
parameter with a default value offalse
maintains backward compatibility while adding support for plugin settings deletion.
443-443
: LGTM! UpdatePlugin method updated to maintain settings.The
UpdatePlugin
method correctly passesfalse
for bothremoveSettings
andremovePluginSettings
to preserve settings during updates.Plugins/Flow.Launcher.Plugin.PluginsManager/Languages/en.xaml (1)
18-19
: LGTM! Clear and consistent English localization strings.The strings are well-written and clearly communicate the purpose to users.
Plugins/Flow.Launcher.Plugin.PluginsManager/Languages/zh-cn.xaml (1)
16-17
: LGTM! Clear and consistent Simplified Chinese localization strings.The translations maintain the same meaning as the English strings while being natural in Chinese.
Plugins/Flow.Launcher.Plugin.PluginsManager/Languages/zh-tw.xaml (1)
16-17
: LGTM! Clear and consistent Traditional Chinese localization strings.The translations are accurate and maintain consistency with other language versions.
Hey @Jack251970, are you in flow's Discord? |
Yes? |
Can you message me in Discord - jjw24 |
Already sent. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the behaviour like when I choose that option in PluginsManagee to not restart automatically and uninstall multiple plugins? Will I get many prompts?
@@ -13,6 +13,8 @@ | |||
<system:String x:Key="plugin_pluginsmanager_installing_plugin">Installing Plugin</system:String> | |||
<system:String x:Key="plugin_pluginsmanager_install_from_web">下載並安裝 {0}</system:String> | |||
<system:String x:Key="plugin_pluginsmanager_uninstall_title">解除安裝擴充功能</system:String> | |||
<system:String x:Key="plugin_pluginsmanager_keep_plugin_settings_title">保留插件設置</system:String> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, language files other than English need to be added by Crowdin. This may exist until next Crowdin PR update, which will revert this to English or new translation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean, I need to revert all changes in non-English languages files?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or I need to add the strings as the same string as English to other non-English files?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seem that the former is the right choice🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have used the former way as I check the previous commits.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@jjw24 And every time you uninstall one plugin, you will get one prompts for this. So uninstall multiple plugins will get many prompts. |
@@ -454,9 +455,9 @@ public static void InstallPlugin(UserPlugin plugin, string zipFilePath) | |||
/// <summary> | |||
/// Uninstall a plugin. | |||
/// </summary> | |||
public static void UninstallPlugin(PluginMetadata plugin, bool removeSettings = true) | |||
public static void UninstallPlugin(PluginMetadata plugin, bool removeSettings = true, bool removePluginSettings = false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kinda forget what is removeSettings
for. Is it possible to use this arg rather than adding a new one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps not. This arg is for remove plugin in FL settings file (settings.json
as I remember).
More details here:
if (removeSettings)
{
Settings.Plugins.Remove(plugin.ID);
AllPlugins.RemoveAll(p => p.Metadata.ID == plugin.ID);
}
if (removePluginSettings)
{
var assemblyLoader = new PluginAssemblyLoader(plugin.ExecuteFilePath);
var assembly = assemblyLoader.LoadAssemblyAndDependencies();
var assemblyName = assembly.GetName().Name;
var directoryPath = Path.Combine(DataLocation.DataDirectory(), JsonStorage<object>.DirectoryName, Constant.Plugins, assemblyName);
if (Directory.Exists(directoryPath))
{
Directory.Delete(directoryPath, true);
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK nvm. it just removes data in PluginManager rather than on disk. perhaps we can rename it to avoid confusion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, np
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs (2)
685-689
: LGTM! The implementation aligns well with the PR objectives.The changes effectively implement the feature to optionally delete plugin settings during uninstallation:
- Clear user prompt asking whether to keep plugin settings
- Proper handling of the user's choice when calling
UninstallPlugin
However, consider the following enhancement:
The message box text could be more explicit about the consequences of the choice. Here's a suggested improvement:
- Context.API.GetTranslation("plugin_pluginsmanager_keep_plugin_settings_subtitle"), + Context.API.GetTranslation("plugin_pluginsmanager_keep_plugin_settings_subtitle") + + Environment.NewLine + + Context.API.GetTranslation("These settings will be permanently deleted if you choose No."),
681-697
: Consider enhancing the bulk uninstallation experience.When uninstalling multiple plugins without auto-restart, users will see multiple prompts (one for settings and one for confirmation per plugin). Consider adding a bulk operation option that allows users to apply the same settings choice to all plugins being uninstalled.
Here's a suggested approach:
private void Uninstall(PluginMetadata plugin) { + // Use a static field to remember the user's choice during bulk operations + private static bool? _bulkUninstallKeepSettings = null; try { - var removePluginSettings = Context.API.ShowMsgBox( - Context.API.GetTranslation("plugin_pluginsmanager_keep_plugin_settings_subtitle"), - Context.API.GetTranslation("plugin_pluginsmanager_keep_plugin_settings_title"), - button: MessageBoxButton.YesNo) == MessageBoxResult.No; + var removePluginSettings = true; + if (_bulkUninstallKeepSettings == null) + { + var result = Context.API.ShowMsgBox( + Context.API.GetTranslation("plugin_pluginsmanager_keep_plugin_settings_subtitle") + + Environment.NewLine + + "Apply this choice to all plugins being uninstalled?", + Context.API.GetTranslation("plugin_pluginsmanager_keep_plugin_settings_title"), + button: MessageBoxButton.YesNoCancel); + + if (result == MessageBoxResult.Cancel) + return; + + removePluginSettings = result == MessageBoxResult.No; + _bulkUninstallKeepSettings = removePluginSettings; + } + else + { + removePluginSettings = _bulkUninstallKeepSettings.Value; + } PluginManager.UninstallPlugin(plugin, removePluginFromSettings: true, removePluginSettings: removePluginSettings); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
Flow.Launcher.Core/Plugin/PluginManager.cs
(4 hunks)Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- Flow.Launcher.Core/Plugin/PluginManager.cs
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: gitStream.cm
- GitHub Check: gitStream.cm
@check-spelling-bot Report🔴 Please reviewSee the 📂 files view, the 📜action log, or 📝 job summary for details.
See ❌ Event descriptions for more information. If the flagged items are 🤯 false positivesIf items relate to a ...
|
Allow user to delete plugin settings (under %APPDATA%\FlowLauncher\Settings\Plugins{Plugin_AssemblyName}) when uninstalling plugins.