Skip to content

Add jobs for plugin install, update and uninstall#2267

Merged
Boy132 merged 2 commits intomainfrom
boy132/plugin-install-job
Mar 17, 2026
Merged

Add jobs for plugin install, update and uninstall#2267
Boy132 merged 2 commits intomainfrom
boy132/plugin-install-job

Conversation

@Boy132
Copy link
Copy Markdown
Member

@Boy132 Boy132 commented Feb 25, 2026

Closes #2183

@Boy132 Boy132 self-assigned this Feb 25, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 25, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e8391b6 and 71758bf.

📒 Files selected for processing (4)
  • app/Jobs/Plugin/InstallPlugin.php
  • app/Jobs/Plugin/UninstallPlugin.php
  • app/Jobs/Plugin/UpdatePlugin.php
  • lang/en/admin/plugin.php
🚧 Files skipped from review as they are similar to previous changes (3)
  • app/Jobs/Plugin/UpdatePlugin.php
  • app/Jobs/Plugin/UninstallPlugin.php
  • app/Jobs/Plugin/InstallPlugin.php

📝 Walkthrough

Walkthrough

Plugin install, update, and uninstall actions were moved from synchronous PluginService calls to queued background jobs. Three new unique queued jobs (InstallPlugin, UpdatePlugin, UninstallPlugin) perform the operations and send success/failure notifications; resource actions now dispatch these jobs and use notification keys for background-started states.

Changes

Cohort / File(s) Summary
Plugin Job Classes
app/Jobs/Plugin/InstallPlugin.php, app/Jobs/Plugin/UpdatePlugin.php, app/Jobs/Plugin/UninstallPlugin.php
Added three queued, unique job classes. Each accepts User and Plugin, calls the corresponding PluginService method in handle(), sends Filament DB notifications on success/failure, reports exceptions, and implements uniqueId() scoped by plugin id.
Plugin Resource Actions
app/Filament/Admin/Resources/Plugins/PluginResource.php
Replaced direct PluginService calls with dispatching the new jobs for install/update/uninstall. Reduced action closure signatures to (Plugin), removed immediate redirects, and updated notification titles to install_started, update_started, uninstall_started.
Localization
lang/en/admin/plugin.php
Added notification keys: goto_plugins, background_info, install_started, uninstall_started, update_started, and update_error. Minor reordering of an existing key.

Sequence Diagram

sequenceDiagram
    participant User as User/UI
    participant Action as PluginResource Action
    participant Queue as Job Queue
    participant Job as Plugin Job
    participant Service as PluginService
    participant Notif as Notification System

    User->>Action: Trigger install/update/uninstall
    Action->>Queue: Dispatch Job(User, Plugin)
    Action-->>User: Return (no immediate redirect)
    activate Queue
    Queue->>Job: Process Job
    Job->>Service: Execute operation (install/update/uninstall)
    alt Success
        Service-->>Job: Operation complete
        Job->>Notif: Send success notification (goto_plugins link)
        Notif-->>User: Display success & action link
    else Failure
        Service-->>Job: Exception
        Job->>Job: Report exception
        Job->>Notif: Send danger notification with error message
        Notif-->>User: Display error
    end
    deactivate Queue
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately summarizes the main change: adding jobs for plugin install, update, and uninstall operations.
Description check ✅ Passed The description references the linked issue #2183 and describes the changes made, indicating it relates to the changeset.
Linked Issues check ✅ Passed The PR successfully implements job classes for plugin install, update, and uninstall operations with proper error handling and notifications, addressing the objective to move plugin operations to background jobs.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing background jobs for plugin operations and updating the resource to dispatch these jobs, with no extraneous modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
app/Filament/Admin/Resources/Plugins/PluginResource.php (1)

125-141: ⚠️ Potential issue | 🟡 Minor

user() is nullable — TypeError from a null dispatch would be uncaught.

user() returns ?User. If it returns null, PHP throws a TypeError (which extends \Error, not \Exception) when constructing the job. The catch (Exception $exception) block will not intercept it, resulting in an unhandled server error surfacing to the user.

While the ->authorize() guard makes this scenario unlikely in practice, the type is still unsafe. The same pattern applies to the exclude_update (Line 148) and exclude_uninstall (Line 224) actions.

🛡️ Proposed fix
-                        ->action(function (Plugin $plugin) {
+                        ->action(function (Plugin $plugin) {
+                            $user = user();
+                            if ($user === null) {
+                                return;
+                            }
                             try {
-                                InstallPlugin::dispatch(user(), $plugin);
+                                InstallPlugin::dispatch($user, $plugin);

Apply the same guard in the exclude_update and exclude_uninstall action closures.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/Filament/Admin/Resources/Plugins/PluginResource.php` around lines 125 -
141, The action closures call InstallPlugin::dispatch(user(), $plugin) while
user() is nullable, so add an explicit guard at the start of each closure (the
install action and the closures for exclude_update and exclude_uninstall) that
checks if user() is null and, if so, sends a Notification::make()->danger() with
an appropriate title/body and returns early; otherwise proceed to dispatch.
Alternatively, you can replace catch (Exception $exception) with catch
(\Throwable $t) to also intercept TypeError, but the primary fix is to verify
user() !== null before calling InstallPlugin::dispatch (and the corresponding
dispatch calls in the exclude_update and exclude_uninstall closures).
lang/en/admin/plugin.php (1)

47-70: ⚠️ Potential issue | 🔴 Critical

Missing *_failed translation keys referenced by the new job classes.

InstallPlugin.php, UpdatePlugin.php, and UninstallPlugin.php each reference install_failed, update_failed, and uninstall_failed respectively in their catch blocks, but these keys do not exist in this file. The existing install_error, update_error, and uninstall_error keys are already present and used correctly by PluginResource.php. The fix belongs in the job files (changing _failed_error), but this file is the source of truth for what is valid.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lang/en/admin/plugin.php` around lines 47 - 70, The catch blocks in the job
classes InstallPlugin.php, UpdatePlugin.php, and UninstallPlugin.php reference
non-existent translation keys install_failed, update_failed, and
uninstall_failed; update those references to use the existing keys
install_error, update_error, and uninstall_error respectively so the jobs
log/notify using the translation keys defined in the notifications array
(replace any occurrences of 'install_failed' → 'install_error', 'update_failed'
→ 'update_error', and 'uninstall_failed' → 'uninstall_error' inside the job
catch blocks).
♻️ Duplicate comments (4)
app/Jobs/Plugin/UninstallPlugin.php (2)

45-45: ⚠️ Potential issue | 🔴 Critical

Wrong translation key — uninstall_failed does not exist; the correct key is uninstall_error.

Same issue as in UpdatePlugin.php. The lang file defines uninstall_error, not uninstall_failed.

🐛 Proposed fix
-                ->title(trans('admin/plugin.notifications.uninstall_failed'))
+                ->title(trans('admin/plugin.notifications.uninstall_error'))
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/Jobs/Plugin/UninstallPlugin.php` at line 45, The notification title in
UninstallPlugin.php uses the wrong translation key; locate the chain that calls
->title(trans('admin/plugin.notifications.uninstall_failed')) inside the
UninstallPlugin job and change the key to
trans('admin/plugin.notifications.uninstall_error') (mirror the same fix applied
in UpdatePlugin.php) so it matches the lang file; ensure any other occurrences
in this class use the correct 'uninstall_error' key.

10-10: Same Filament\Actions\Action import issue as UpdatePlugin.php — use Filament\Notifications\Actions\Action instead.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/Jobs/Plugin/UninstallPlugin.php` at line 10, The file imports the wrong
Action class; replace the import "use Filament\Actions\Action" with "use
Filament\Notifications\Actions\Action" in the UninstallPlugin job so it uses the
notifications Action type; locate the top-of-file import and any type hints or
usages of Action inside the UninstallPlugin class (e.g., in methods that build
or return actions) to ensure they reference the notifications Action and adjust
any docblocks or use-sites if necessary.
app/Jobs/Plugin/InstallPlugin.php (2)

45-45: ⚠️ Potential issue | 🔴 Critical

Wrong translation key — install_failed does not exist; the correct key is install_error.

Same issue as in UpdatePlugin.php and UninstallPlugin.php.

🐛 Proposed fix
-                ->title(trans('admin/plugin.notifications.install_failed'))
+                ->title(trans('admin/plugin.notifications.install_error'))
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/Jobs/Plugin/InstallPlugin.php` at line 45, The notification title in
InstallPlugin (where ->title(trans('admin/plugin.notifications.install_failed'))
is used) references a non-existent translation key; update the call to use the
correct key trans('admin/plugin.notifications.install_error') and make the same
replacement in the analogous usages inside UpdatePlugin and UninstallPlugin so
all notification titles use 'install_error' (or the appropriate
'update_error'/'uninstall_error' equivalents if those files expect different
names).

10-10: Same Filament\Actions\Action import issue — use Filament\Notifications\Actions\Action instead.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/Jobs/Plugin/InstallPlugin.php` at line 10, The imported symbol is wrong:
replace the incorrect import "Filament\Actions\Action" with the correct
"Filament\Notifications\Actions\Action" in InstallPlugin.php; locate the use
statement at the top of the file (referencing Action) and update it so the class
InstallPlugin and any references to Action resolve to
Filament\Notifications\Actions\Action, then run a quick static check or IDE
resolution to ensure no other references need updating.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@app/Jobs/Plugin/UpdatePlugin.php`:
- Line 45: Replace the incorrect translation key
"admin/plugin.notifications.update_failed" with
"admin/plugin.notifications.update_error" in the danger notification builder
inside UpdatePlugin.php (the code that calls ->title(...)); do the same pattern
fix in InstallPlugin.php (install_failed → install_error) and
UninstallPlugin.php (uninstall_failed → uninstall_error) so the notifications
use the existing keys defined in lang/en/admin/plugin.php.

In `@lang/en/admin/plugin.php`:
- Line 49: Update the string value for the 'background_info' array entry to
correct the grammar from "its finished" to "it's finished" by locating the
'background_info' => 'This process can take a few seconds. You will be notified
once its finished.' entry in plugin.php and replacing the contraction
accordingly so the message reads "This process can take a few seconds. You will
be notified once it's finished."

---

Outside diff comments:
In `@app/Filament/Admin/Resources/Plugins/PluginResource.php`:
- Around line 125-141: The action closures call InstallPlugin::dispatch(user(),
$plugin) while user() is nullable, so add an explicit guard at the start of each
closure (the install action and the closures for exclude_update and
exclude_uninstall) that checks if user() is null and, if so, sends a
Notification::make()->danger() with an appropriate title/body and returns early;
otherwise proceed to dispatch. Alternatively, you can replace catch (Exception
$exception) with catch (\Throwable $t) to also intercept TypeError, but the
primary fix is to verify user() !== null before calling InstallPlugin::dispatch
(and the corresponding dispatch calls in the exclude_update and
exclude_uninstall closures).

In `@lang/en/admin/plugin.php`:
- Around line 47-70: The catch blocks in the job classes InstallPlugin.php,
UpdatePlugin.php, and UninstallPlugin.php reference non-existent translation
keys install_failed, update_failed, and uninstall_failed; update those
references to use the existing keys install_error, update_error, and
uninstall_error respectively so the jobs log/notify using the translation keys
defined in the notifications array (replace any occurrences of 'install_failed'
→ 'install_error', 'update_failed' → 'update_error', and 'uninstall_failed' →
'uninstall_error' inside the job catch blocks).

---

Duplicate comments:
In `@app/Jobs/Plugin/InstallPlugin.php`:
- Line 45: The notification title in InstallPlugin (where
->title(trans('admin/plugin.notifications.install_failed')) is used) references
a non-existent translation key; update the call to use the correct key
trans('admin/plugin.notifications.install_error') and make the same replacement
in the analogous usages inside UpdatePlugin and UninstallPlugin so all
notification titles use 'install_error' (or the appropriate
'update_error'/'uninstall_error' equivalents if those files expect different
names).
- Line 10: The imported symbol is wrong: replace the incorrect import
"Filament\Actions\Action" with the correct
"Filament\Notifications\Actions\Action" in InstallPlugin.php; locate the use
statement at the top of the file (referencing Action) and update it so the class
InstallPlugin and any references to Action resolve to
Filament\Notifications\Actions\Action, then run a quick static check or IDE
resolution to ensure no other references need updating.

In `@app/Jobs/Plugin/UninstallPlugin.php`:
- Line 45: The notification title in UninstallPlugin.php uses the wrong
translation key; locate the chain that calls
->title(trans('admin/plugin.notifications.uninstall_failed')) inside the
UninstallPlugin job and change the key to
trans('admin/plugin.notifications.uninstall_error') (mirror the same fix applied
in UpdatePlugin.php) so it matches the lang file; ensure any other occurrences
in this class use the correct 'uninstall_error' key.
- Line 10: The file imports the wrong Action class; replace the import "use
Filament\Actions\Action" with "use Filament\Notifications\Actions\Action" in the
UninstallPlugin job so it uses the notifications Action type; locate the
top-of-file import and any type hints or usages of Action inside the
UninstallPlugin class (e.g., in methods that build or return actions) to ensure
they reference the notifications Action and adjust any docblocks or use-sites if
necessary.

ℹ️ Review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e35ce1e and e8391b6.

📒 Files selected for processing (5)
  • app/Filament/Admin/Resources/Plugins/PluginResource.php
  • app/Jobs/Plugin/InstallPlugin.php
  • app/Jobs/Plugin/UninstallPlugin.php
  • app/Jobs/Plugin/UpdatePlugin.php
  • lang/en/admin/plugin.php

Comment thread app/Jobs/Plugin/UpdatePlugin.php Outdated
Comment thread lang/en/admin/plugin.php Outdated
@Boy132 Boy132 merged commit 64bcdb5 into main Mar 17, 2026
17 checks passed
@Boy132 Boy132 deleted the boy132/plugin-install-job branch March 17, 2026 08:08
@github-actions github-actions bot locked and limited conversation to collaborators Mar 17, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move plugin install/update to job

2 participants