-
Notifications
You must be signed in to change notification settings - Fork 17
Add PasteFox Share & server folders plugin #63
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
base: main
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughAdds a new PasteFox Share Filament plugin (manifest, docs, config, translations, Filament action, service provider, plugin class, admin settings page) to upload server logs to pastefox.com; also adds Server Folders plugin docs, translations, and a Filament view for folder/server listings. Changes
Sequence Diagram(s)sequenceDiagram
actor User as Filament User
participant UI as Filament Console UI
participant Action as UploadLogsAction
participant Daemon as Local Daemon API
participant PasteFox as PasteFox API
User->>UI: Click "Share Logs"
UI->>Action: invoke UploadLogsAction
rect rgba(235,247,255,0.9)
Action->>Daemon: GET /servers/{id}/logs
Daemon-->>Action: logs (text)
Action->>Action: read config/env (PASTEFOX_API_KEY, visibility, etc.)
end
alt API key present
rect rgba(235,255,240,0.9)
Action->>PasteFox: POST /api/paste {title, content, language: "log", visibility, password?}
PasteFox-->>Action: 200 OK {url} / error
end
alt success
Action-->>UI: show success notification with paste URL
else failure
Action-->>UI: show error notification
end
else API key missing
Action-->>UI: show danger notification "API key missing" (or proceed with limited behavior)
end
rect rgba(255,240,240,0.6)
Note right of Action: Exceptions are caught, reported, and shown as danger notifications
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
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: 4
🧹 Nitpick comments (1)
pastefox-share/src/Filament/Components/Actions/UploadLogsAction.php (1)
94-102: Catch specific HTTP exceptions for better error handling.Catching the generic
Exceptionclass captures all exceptions, including programming errors. Consider catchingIlluminate\Http\Client\RequestExceptionorIlluminate\Http\Client\ConnectionExceptionspecifically for HTTP-related errors.🔎 Proposed improvement
+use Illuminate\Http\Client\RequestException; +use Illuminate\Http\Client\ConnectionException; -} catch (Exception $exception) { +} catch (RequestException | ConnectionException $exception) { report($exception); Notification::make() ->title(trans('pastefox-share::messages.upload_failed')) ->body($exception->getMessage()) ->danger() ->send(); +} catch (Exception $exception) { + report($exception); + + Notification::make() + ->title('An unexpected error occurred') + ->body($exception->getMessage()) + ->danger() + ->send(); }
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
pastefox-share/README.mdpastefox-share/lang/en/messages.phppastefox-share/plugin.jsonpastefox-share/src/Filament/Components/Actions/UploadLogsAction.phppastefox-share/src/PasteFoxSharePlugin.phppastefox-share/src/Providers/PasteFoxSharePluginProvider.php
🧰 Additional context used
🧬 Code graph analysis (2)
pastefox-share/src/PasteFoxSharePlugin.php (1)
pastefox-share/src/Providers/PasteFoxSharePluginProvider.php (2)
register(12-15)boot(17-17)
pastefox-share/src/Providers/PasteFoxSharePluginProvider.php (2)
pastefox-share/src/Filament/Components/Actions/UploadLogsAction.php (1)
UploadLogsAction(13-105)pastefox-share/src/PasteFoxSharePlugin.php (2)
register(15-15)boot(17-17)
🪛 GitHub Actions: Pint
pastefox-share/src/Filament/Components/Actions/UploadLogsAction.php
[error] 1-1: pint linting failed. 1 style issue detected during Laravel linting. Command '~/.composer/vendor/bin/pint --test' exited with code 1.
🪛 markdownlint-cli2 (0.18.1)
pastefox-share/README.md
16-16: Bare URL used
(MD034, no-bare-urls)
🪛 PHPMD (2.15.0)
pastefox-share/src/PasteFoxSharePlugin.php
15-15: Avoid unused parameters such as '$panel'. (undefined)
(UnusedFormalParameter)
17-17: Avoid unused parameters such as '$panel'. (undefined)
(UnusedFormalParameter)
🔇 Additional comments (5)
pastefox-share/README.md (1)
1-33: Documentation looks comprehensive and well-structured.The README provides clear installation steps, usage instructions, and configuration details. The bare URL flagged by markdownlint (line 16) is acceptable in documentation prose.
pastefox-share/lang/en/messages.php (1)
1-10: Translation strings are clear and appropriate.The localization file provides user-friendly messages for all sharing-related UI interactions.
pastefox-share/plugin.json (1)
1-15: Plugin manifest is well-structured.The metadata correctly references the plugin class and namespace, and appropriately declares the server panel dependency.
pastefox-share/src/Providers/PasteFoxSharePluginProvider.php (1)
10-18: Service provider registration is clean and appropriate.The provider correctly registers the UploadLogsAction as a Filament Console header action.
pastefox-share/src/PasteFoxSharePlugin.php (1)
8-18: Plugin scaffold is correctly structured.The minimal implementation with empty
register()andboot()methods is a standard pattern for plugin scaffolding. The PHPMD warnings about unused parameters are expected and can be safely ignored in this context.
pastefox-share/src/Filament/Components/Actions/UploadLogsAction.php
Outdated
Show resolved
Hide resolved
pastefox-share/src/Filament/Components/Actions/UploadLogsAction.php
Outdated
Show resolved
Hide resolved
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
♻️ Duplicate comments (4)
pastefox-share/src/Filament/Components/Actions/UploadLogsAction.php (4)
1-106: Address the Pint linting failure.The pipeline failed due to Laravel Pint style violations. Please run
./vendor/bin/pintlocally to automatically fix code style issues.This issue was previously flagged in an earlier review and remains unresolved.
53-53: Useconfig()instead ofenv()for runtime access.Calling
env()directly in application code (lines 53 and 75) is an anti-pattern in Laravel. Environment variables should be read in config files, and accessed viaconfig()at runtime.This issue was previously flagged in an earlier review. The recommended approach is to create a config file at
pastefox-share/config/pastefox.phpand register it in your service provider.Also applies to: 75-75
64-77: Inconsistent error handling:throw()followed by success check.Using
->throw()on line 70 means HTTP errors will throw exceptions, but checking$response['success']on line 79 suggests the API can return a 200 status withsuccess: false. This creates inconsistent error handling.This issue was previously flagged. Consider either removing
->throw()and handling all errors via response checking, or keeping->throw()only for HTTP errors and documenting that the API always returns 200 with a success flag.
79-94: Add validation before accessing nested array keys.Lines 79-80 and 91 access array keys without validating the structure, which could cause undefined array key warnings or errors.
This issue was previously flagged. Add defensive checks using
isset()orarray_key_exists()before accessing$response['success'],$response['data']['slug'], and$response['error'].
🧹 Nitpick comments (2)
pastefox-share/README.md (2)
7-7: Consider using a relative path instead of an absolute one.The hardcoded absolute path
/var/www/pelican/plugins/pastefox-shareassumes a specific installation directory that may vary across environments. Consider documenting this as a relative path from the Pelican root or clarifying it as an example path.🔎 Suggested improvement
-1. Download and extract to `/var/www/pelican/plugins/pastefox-share` +1. Download and extract to `plugins/pastefox-share` (relative to your Pelican installation)
16-16: Use markdown link format for the URL.The bare URL should be wrapped in markdown link syntax for better formatting and accessibility.
🔎 Proposed fix
-Get your API key from https://pastefox.com/dashboard +Get your API key from [https://pastefox.com/dashboard](https://pastefox.com/dashboard)
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
pastefox-share/README.mdpastefox-share/lang/en/messages.phppastefox-share/plugin.jsonpastefox-share/src/Filament/Components/Actions/UploadLogsAction.phppastefox-share/src/PasteFoxSharePlugin.phppastefox-share/src/Providers/PasteFoxSharePluginProvider.php
🚧 Files skipped from review as they are similar to previous changes (2)
- pastefox-share/lang/en/messages.php
- pastefox-share/src/Providers/PasteFoxSharePluginProvider.php
🧰 Additional context used
🧬 Code graph analysis (1)
pastefox-share/src/PasteFoxSharePlugin.php (1)
pastefox-share/src/Providers/PasteFoxSharePluginProvider.php (2)
register(12-15)boot(17-17)
🪛 markdownlint-cli2 (0.18.1)
pastefox-share/README.md
16-16: Bare URL used
(MD034, no-bare-urls)
🪛 PHPMD (2.15.0)
pastefox-share/src/PasteFoxSharePlugin.php
15-15: Avoid unused parameters such as '$panel'. (undefined)
(UnusedFormalParameter)
17-17: Avoid unused parameters such as '$panel'. (undefined)
(UnusedFormalParameter)
🔇 Additional comments (2)
pastefox-share/plugin.json (1)
1-15: LGTM!The plugin manifest is well-structured with all required fields properly defined. The null values for
update_url,panel_version, andcomposer_packagesare acceptable for the initial release.pastefox-share/src/PasteFoxSharePlugin.php (1)
1-18: LGTM!The plugin class correctly implements the
Filament\Contracts\Plugininterface. The emptyregister()andboot()methods are intentional, as the actual registration logic is handled byPasteFoxSharePluginProvider. The PHPMD warnings about unused parameters are false positives—these parameters are required by the interface contract.
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
♻️ Duplicate comments (2)
pastefox-share/src/Filament/Components/Actions/UploadLogsAction.php (2)
79-94: Previous review feedback still applies: Add defensive checks for array access.This was flagged in a previous review. The code accesses
$response['success']and$response['data']['slug']without validating the array structure, which could cause undefined array key errors if the API response format changes or returns unexpected data.
64-77: Previous review feedback still applies: Consider error handling consistency.This was flagged in a previous review. Using
->throw()on line 70 means HTTP errors throw exceptions, but then checking$response['success']suggests the API can return 200 withsuccess: false. Consider handling this more explicitly or documenting the expected behavior.
🧹 Nitpick comments (3)
pastefox-share/README.md (1)
18-18: Consider formatting the bare URL as a markdown link.Static analysis flagged the bare URL. For consistency with line 3, wrap it in markdown link syntax.
🔎 Proposed fix
-Get your API key from https://pastefox.com/dashboard +Get your API key from [pastefox.com/dashboard](https://pastefox.com/dashboard)pastefox-share/src/Filament/Admin/Pages/PasteFoxSettings.php (1)
101-104: Consider using a translation key for the notification title.The "Settings saved" string is hardcoded while other text in this plugin uses
trans(). For consistency, consider adding this to the translation file.🔎 Proposed fix
Notification::make() - ->title('Settings saved') + ->title(trans('pastefox-share::messages.settings_saved')) ->success() ->send();Then add to
lang/en/messages.php:'settings_saved' => 'Settings saved',pastefox-share/src/PasteFoxSharePlugin.php (1)
61-64: Consider using a translation key for consistency.Same as in
PasteFoxSettings.php, the "Settings saved" string is hardcoded. For consistency with the rest of the plugin, consider using translations.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
pastefox-share/README.mdpastefox-share/config/pastefox-share.phppastefox-share/plugin.jsonpastefox-share/src/Filament/Admin/Pages/PasteFoxSettings.phppastefox-share/src/Filament/Components/Actions/UploadLogsAction.phppastefox-share/src/PasteFoxSharePlugin.php
✅ Files skipped from review due to trivial changes (1)
- pastefox-share/plugin.json
🧰 Additional context used
🪛 markdownlint-cli2 (0.18.1)
pastefox-share/README.md
18-18: Bare URL used
(MD034, no-bare-urls)
🪛 PHPMD (2.15.0)
pastefox-share/src/PasteFoxSharePlugin.php
32-32: Avoid unused parameters such as '$panel'. (undefined)
(UnusedFormalParameter)
🔇 Additional comments (5)
pastefox-share/config/pastefox-share.php (1)
1-6: LGTM!This config file correctly follows the Laravel pattern of reading environment variables in config files. The
visibilitydefault of'PUBLIC'is sensible.pastefox-share/src/Filament/Components/Actions/UploadLogsAction.php (1)
53-53: Good fix: Now usingconfig()instead ofenv().The code now correctly uses
config('pastefox-share.api_key')instead ofenv()at runtime, addressing the previous review feedback.pastefox-share/src/PasteFoxSharePlugin.php (2)
32-32: Unused parameter is acceptable here.The static analysis flags
$panelas unused, but this is required by thePlugininterface contract. No action needed.
43-50: Bug: Incorrect config key paths.The config paths reference
pastefox-share.config.api_keyandpastefox-share.config.visibility, but the config file atconfig/pastefox-share.phpdefines keys directly asapi_keyandvisibility. This will cause the defaults to always benull.🔎 Proposed fix
->helperText('Get your API key from https://pastefox.com/dashboard') - ->default(fn () => config('pastefox-share.config.api_key')), + ->default(fn () => config('pastefox-share.api_key')), Select::make('visibility') ->label('Default Visibility') ->options([ 'PUBLIC' => 'Public', 'PRIVATE' => 'Private', ]) - ->default(fn () => config('pastefox-share.config.visibility', 'PUBLIC')), + ->default(fn () => config('pastefox-share.visibility', 'PUBLIC')),Likely an incorrect or invalid review comment.
pastefox-share/src/Filament/Admin/Pages/PasteFoxSettings.php (1)
27-27: Verify the view path with the main application codebase or document its purpose.The view
filament.server.pages.server-form-pagedoesn't exist in the plugin and appears to belong to the main application. While its reuse across multiple admin pages suggests intentional design, the naming convention is semantically inconsistent (Admin page using a "server" context view). Either verify this view exists in the main app and confirm the naming is appropriate, or add a comment explaining why this shared template is used.
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: 3
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
pastefox-share/config/pastefox-share.phppastefox-share/lang/en/messages.phppastefox-share/src/Filament/Admin/Pages/PasteFoxSettings.phppastefox-share/src/Filament/Components/Actions/UploadLogsAction.php
🚧 Files skipped from review as they are similar to previous changes (2)
- pastefox-share/src/Filament/Components/Actions/UploadLogsAction.php
- pastefox-share/config/pastefox-share.php
🧰 Additional context used
🪛 GitHub Actions: Pint
pastefox-share/src/Filament/Admin/Pages/PasteFoxSettings.php
[error] 1-1: Pint lint error: no_unused_imports rule triggered in PasteFoxSettings.php.
🔇 Additional comments (1)
pastefox-share/lang/en/messages.php (1)
1-11: LGTM! Translation strings are clear and appropriate.The translation file is well-structured with descriptive keys and user-friendly messages that align with the plugin's sharing functionality.
FlexKleks
left a comment
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.
Fix lint: remove unused imports and whitespace
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: 3
🧹 Nitpick comments (1)
pastefox-share/src/PasteFoxSharePlugin.php (1)
33-33: Consider suppressing the unused parameter warning.The
$panelparameter is required by thePlugininterface but unused in this empty implementation. While this is intentional, you can suppress the static analysis warning by adding a docblock annotation or prefixing with an underscore if the linter supports it.🔎 Proposed fix to suppress the warning
+/** @phpstan-ignore-next-line */ public function boot(Panel $panel): void {}Or alternatively:
-public function boot(Panel $panel): void {} +public function boot(Panel $_panel): void {}
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
pastefox-share/src/Filament/Admin/Pages/PasteFoxSettings.phppastefox-share/src/Filament/Components/Actions/UploadLogsAction.phppastefox-share/src/PasteFoxSharePlugin.php
🚧 Files skipped from review as they are similar to previous changes (1)
- pastefox-share/src/Filament/Components/Actions/UploadLogsAction.php
🧰 Additional context used
🪛 PHPMD (2.15.0)
pastefox-share/src/PasteFoxSharePlugin.php
33-33: Avoid unused parameters such as '$panel'. (undefined)
(UnusedFormalParameter)
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: 1
🧹 Nitpick comments (4)
server-folders/README.md (2)
119-148: Add language identifier to the fenced code block.The file structure code block should have a language identifier for consistency and better rendering. Use
textorplaintextfor non-code content.Suggested fix
-``` +```text server-folders/ ├── config/
167-169: Minor style refinement.Consider a more concise phrasing for the contribution invitation.
Suggested fix
## Contributing -Contributions are welcome! Please feel free to submit a Pull Request. +Contributions are welcome! Submit a Pull Request to get started.server-folders/resources/views/view-folder.blade.php (2)
121-129: Accessibility: Hover-only visibility for remove button.The remove button uses
opacity-0 group-hover:opacity-100, making it invisible until hover. This may cause accessibility issues for keyboard navigation and screen reader users who cannot trigger hover states.Consider keeping the button visible (perhaps with reduced emphasis) or using
focus-withinto reveal it on keyboard focus.Suggested fix
<button type="button" wire:click="removeServer({{ $server->id }})" wire:confirm="{{ trans('server-folders::messages.confirm_remove') }}" - class="opacity-0 group-hover:opacity-100 inline-flex items-center justify-center rounded-lg p-2 text-gray-400 hover:text-danger-500 hover:bg-danger-50 dark:hover:bg-danger-500/10 transition"> + class="opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 focus:opacity-100 inline-flex items-center justify-center rounded-lg p-2 text-gray-400 hover:text-danger-500 hover:bg-danger-50 dark:hover:bg-danger-500/10 transition"> <x-filament::icon icon="tabler-folder-minus" class="w-5 h-5" /> </button>
52-53: Consider using Livewire navigation for SPA-like experience.Using
window.locationfor navigation causes a full page reload. If the application uses Livewire/Filament's SPA mode, consider usingwire:navigatefor smoother transitions.Alternative approach
-<tr class="fi-ta-row transition hover:bg-gray-50 dark:hover:bg-white/5 cursor-pointer group" - onclick="window.location='{{ route('filament.server.pages.console', ['tenant' => $server]) }}'"> +<tr class="fi-ta-row transition hover:bg-gray-50 dark:hover:bg-white/5 cursor-pointer group"> + <a href="{{ route('filament.server.pages.console', ['tenant' => $server]) }}" + wire:navigate + class="contents">This requires restructuring the row content, so alternatively wrap the clickable area differently or accept the current approach if full navigation is acceptable.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
pastefox-share/src/Filament/Components/Actions/UploadLogsAction.phpserver-folders/README.mdserver-folders/lang/de/messages.phpserver-folders/lang/en/messages.phpserver-folders/resources/views/view-folder.blade.php
🚧 Files skipped from review as they are similar to previous changes (1)
- pastefox-share/src/Filament/Components/Actions/UploadLogsAction.php
🧰 Additional context used
🪛 LanguageTool
server-folders/README.md
[style] ~169-~169: Consider using a less common alternative to make your writing sound more unique and professional.
Context: ...ontributing Contributions are welcome! Please feel free to submit a Pull Request. ## License Thi...
(FEEL_FREE_TO_STYLE_ME)
🪛 markdownlint-cli2 (0.18.1)
server-folders/README.md
119-119: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
🔇 Additional comments (3)
server-folders/lang/de/messages.php (1)
1-53: LGTM!The German translations are well-structured and correctly localized. The use of singular "Server" for
server_counton line 52 is appropriate since German uses the same word for both singular and plural forms of "Server."server-folders/lang/en/messages.php (1)
1-53: LGTM!The English translations are well-structured with proper Laravel pluralization syntax on line 52 (
:count server|:count servers). The keys are comprehensive and well-organized by category.server-folders/resources/views/view-folder.blade.php (1)
56-58: Icon fallback chain is safe; N+1 query verification requiresgetServers()inspection.The fallback logic using
$server->icon ?? $server->egg?->imagein the condition ensures the img tag only renders when at least one value is truthy, so accessing$server->egg->imagein the src attribute won't error. However, the N+1 query concern regarding theeggrelationship cannot be verified without inspecting thegetServers()method implementation (not present in this repository). Verify thatgetServers()loads the egg relationship viawith('egg')or similar eager-loading strategy.
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: 1
🧹 Nitpick comments (2)
server-folders/README.md (2)
119-119: Add language identifier to fenced code block.The file structure code block is missing a language identifier. Add
textorplaintextas the language identifier to comply with Markdown linting standards.-``` +```text server-folders/
169-169: Consider rephrasing for stronger tone.The phrase "Please feel free to submit a Pull Request" is somewhat passive. Consider a more direct alternative such as "Contributions through pull requests are welcome" or "Submit pull requests to contribute."
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
pastefox-share/README.mdpastefox-share/plugin.jsonserver-folders/README.mdserver-folders/plugin.json
✅ Files skipped from review due to trivial changes (2)
- server-folders/plugin.json
- pastefox-share/plugin.json
🧰 Additional context used
🪛 LanguageTool
server-folders/README.md
[style] ~169-~169: Consider using a less common alternative to make your writing sound more unique and professional.
Context: ...ontributing Contributions are welcome! Please feel free to submit a Pull Request. ## License Thi...
(FEEL_FREE_TO_STYLE_ME)
🪛 markdownlint-cli2 (0.18.1)
pastefox-share/README.md
38-38: Bare URL used
(MD034, no-bare-urls)
server-folders/README.md
119-119: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
🔇 Additional comments (1)
server-folders/README.md (1)
1-181: Comprehensive and well-structured documentation.The README provides excellent coverage of features, installation, usage, permissions, and troubleshooting. The step-by-step instructions are clear, and the file structure accurately reflects the plugin organization. The multi-language support and color-coding features are well-documented.
Adds PasteFox Share plugin - allows users to share console logs via pastefox.com with one click.
Features
Soon also with different effects, folders, custom domains, etc.
Configuration
Requires
PASTEFOX_API_KEYin.env(get from https://pastefox.com/dashboard)Summary by CodeRabbit
New Features
Localization
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.