Skip to content

Conversation

@killerbite95
Copy link
Contributor

The upload logs action was building the wrong file path, causing 'log not found' errors.

The code used just the date (e.g. 2025-01-15) but the actual files have prefix and extension (e.g. laravel-2025-01-15.log).

Now uses config('filament-log-viewer.pattern.prefix') and config('filament-log-viewer.pattern.extension') to match the package behavior.

Previously, activity log icons only displayed the actor type (user, system, API). This change adds event-specific icons that match the panel's icon conventions used in SubuserPermission and other resources.

Changes:

- Add EVENT_ICON_MAP constant with 18 event group mappings

- Icons include: backup, file, database, schedule, allocation, startup, settings, subuser, console, control, power, sftp, server, auth, user, api-key, reset-password, ssh

- Extract getActorIcon() as fallback for unmapped events

- Parse event string to determine group (e.g., 'server:backup.create' -> 'backup')

This provides visual consistency and better UX when browsing activity logs.
@killerbite95
Copy link
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@coderabbitai
Copy link

coderabbitai bot commented Dec 18, 2025

📝 Walkthrough

Walkthrough

Log file paths in the admin panel are now configurable via prefix and extension settings (defaults: 'laravel-' and '.log'). Additionally, a new icon resolution method is added to the ActivityLog model to map event types to specific icons.

Changes

Cohort / File(s) Summary
Configurable log file paths
app/Filament/Admin/Pages/ListLogs.php, app/Filament/Admin/Pages/ViewLogs.php
Modified log file path calculation to use configurable prefix and extension parameters instead of fixed paths. Now builds paths as logs/{prefix}{date}{extension} with configuration-based defaults ('laravel-' and '.log').
ActivityLog icon mapping
app/Models/ActivityLog.php
Added getIcon(): string public method to determine icons based on event type using an internal EVENT_ICON_MAP. Includes private helper getActorIcon() for fallback icon selection. Minor formatting adjustments to trans_choice calls in getLabel() and hasAdditionalMetadata().

Possibly related PRs

Pre-merge checks

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: use correct log path for upload action' clearly describes the main change—fixing the log file path calculation for the upload action by making it configurable.
Description check ✅ Passed The description directly addresses the changeset, explaining the problem (incorrect file path causing errors), the root cause (missing prefix and extension), and the solution (using configuration values).

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

@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: 0

🧹 Nitpick comments (2)
app/Filament/Admin/Pages/ListLogs.php (1)

59-61: LGTM! Consistent fix applied across both list and view pages.

The same configurable path construction is now used in both ListLogs and ViewLogs, ensuring consistent behavior.

Optional: Extract duplicated logic to reduce repetition

The 3-line path construction pattern is duplicated between this file and ViewLogs.php. Consider extracting to a shared trait or helper method:

trait BuildsLogPath
{
    protected function buildLogPath(string $date): string
    {
        $prefix = config('filament-log-viewer.pattern.prefix', 'laravel-');
        $extension = config('filament-log-viewer.pattern.extension', '.log');
        return storage_path('logs/' . $prefix . $date . $extension);
    }
}

Then use: $logPath = $this->buildLogPath($record['date']);

app/Models/ActivityLog.php (1)

146-216: Consider separating unrelated changes into focused PRs.

The icon resolution changes in ActivityLog.php appear unrelated to the log path fix described in the PR title and description. While both changes are individually sound, bundling unrelated features in a single PR can make reviews more complex and rollbacks harder.

📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5a47948 and d06227d.

📒 Files selected for processing (3)
  • app/Filament/Admin/Pages/ListLogs.php (1 hunks)
  • app/Filament/Admin/Pages/ViewLogs.php (1 hunks)
  • app/Models/ActivityLog.php (3 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-11-05T22:21:31.863Z
Learnt from: notAreYouScared
Repo: pelican-dev/panel PR: 1865
File: app/Filament/Admin/Resources/Nodes/Pages/EditNode.php:682-682
Timestamp: 2025-11-05T22:21:31.863Z
Learning: In app/Filament/Admin/Resources/Nodes/Pages/EditNode.php, the diagnostics tab's upload action intentionally does not use the iconButton() modifier, while the pull action does. This UI difference is intentional.

Applied to files:

  • app/Filament/Admin/Pages/ViewLogs.php
🧬 Code graph analysis (2)
app/Filament/Admin/Pages/ViewLogs.php (1)
app/Traits/ResolvesRecordDate.php (1)
  • resolveRecordDate (12-44)
app/Models/ActivityLog.php (2)
app/Models/File.php (1)
  • getIcon (103-118)
app/Services/Activity/ActivityLogService.php (1)
  • event (48-53)
🔇 Additional comments (5)
app/Models/ActivityLog.php (4)

146-169: Icon mapping looks comprehensive and consistent.

The EVENT_ICON_MAP provides appropriate icon associations for activity event groups, using tabler icons consistent with the rest of the codebase.


171-195: Event parsing logic is sound for standard event formats.

The method correctly extracts event groups from formats like server:backup.createbackup and backup.createbackup, then falls back to actor-based icons when no mapping exists.


197-216: Clean refactoring of actor-based icon logic.

The previous getIcon() implementation is now appropriately moved to a private getActorIcon() helper, maintaining the same fallback behavior while allowing the public getIcon() to prioritize event-based icon selection.


222-222: Minor formatting improvements for readability.

Added spacing around concatenation operators in trans_choice calls, improving code consistency.

Also applies to: 311-311

app/Filament/Admin/Pages/ViewLogs.php (1)

36-38: Fix correctly addresses log path construction issue.

The configurable prefix and extension ensure the constructed path matches actual log filenames. While the config keys filament-log-viewer.pattern.prefix and filament-log-viewer.pattern.extension are not formally documented in the package documentation, the defaults ('laravel-' and '.log') align with Laravel's standard log naming convention and provide sensible fallback values for proper functionality.

Copy link
Member

@Boy132 Boy132 left a comment

Choose a reason for hiding this comment

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

Seems like some changes from your other PR snuck in.

Copy link
Member

@notAreYouScared notAreYouScared left a comment

Choose a reason for hiding this comment

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

LGTM

@notAreYouScared notAreYouScared merged commit 576f04b into pelican-dev:main Dec 23, 2025
25 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Dec 23, 2025
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.

3 participants