Skip to content
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

Admin panel module uninstallation feature #1755

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jelmer-visser
Copy link
Contributor

Fixes: #530

This PR introduces a new feature that allows modules to be uninstalled directly from the admin panel. This enhances the user experience by providing a more straightforward and efficient method for module management.

Copy link
Member

@BelleNottelling BelleNottelling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a handful of comments on the changes where I'd like to see changes.

Additionally, I think the UI would be better if the deactivate and delete buttons weren't separated by the settings icon. I'd likely move the settings icon to either be first or last.
image

We should also consider preventing people from deleting modules that come with FOSSBilling. The deactivate function will prevent core modules from being disabled or uninstalled, but there's no checks against modules that are included, but not considered core. In theory deleting them shouldn't cause any issues, but it may cause confusion when updating as they will return.

/**
* Recursively remove a directory at a specific path.
*/
public function removeDirectory(string $dir): void
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We actually already have a function to empty a directory:
https://github.com/FOSSBilling/FOSSBilling/blob/main/src/library/FOSSBilling/Tools.php#L93
$this->di['tools']->emptyFolder($dir);

I don't recall if it will delete a directory and it's contents or just the contents of the directory. However, if it only deletes the contents then all you need to do this:

$this->di['tools']->emptyFolder($dir);
rmdir($dir);

(If you figure out if the function deletes the directory and the contents or just the contents, would you mind adding to a PHPDoc to the function explaining that?)

*/
public function deleteExtension($type, $id): bool
{
switch ($type) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing as how this duplicates the switch block in the install function and that both locations will need to be updated at the same time, I'd prefer it if we created a private helper function to return the path for a given type and ID. Then there's only one location to update.

@@ -203,5 +213,8 @@
bb.reload();
}
}
function onAfterModuleUninstalled() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be needed.
You should be able to add data-api-reload="1" to have the page reload

{
$this->deactivate($ext);

switch ($ext->type) {
$this->di['db']->trash($ext);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unneeded, deactivate already does this:

$this->di['db']->trash($ext);

@John-S4
Copy link
Member

John-S4 commented Oct 27, 2023

Additionally, I think the UI would be better if the deactivate and delete buttons weren't separated by the settings icon. I'd likely move the settings icon to either be first or last.

I agree, this ordering is odd. I think that settings first makes the most sense but either way is fine, just not in the middle.

@Anuril
Copy link
Contributor

Anuril commented Oct 29, 2023

I agree, this ordering is odd. I think that settings first makes the most sense but either way is fine, just not in the middle.

I disagree. The ordering "enable / disable" - "settings" - "uninstall" feels intuitive to me. Also, having the deactivate and uninstall buttons right next to each other makes for easy misclicks.

@jaapmarcus
Copy link
Member

Ideally it should only an remove button on deactivated plugins

@John-S4
Copy link
Member

John-S4 commented Nov 11, 2023

Ideally it should only an remove button on deactivated plugins

That is a good point, agreed.

@admdly admdly force-pushed the feature/530_uninstall_modules branch from 0fcac8d to 7f81551 Compare December 4, 2023 10:18
@admdly admdly added merge-hold PRs that are on hold from being merged (generally to allow a discussion to occur) and removed merge-hold PRs that are on hold from being merged (generally to allow a discussion to occur) labels Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] Add support for deleting extensions from the disk
6 participants