Skip to content

Conversation

@LetterN
Copy link
Contributor

@LetterN LetterN commented Oct 10, 2025

implements #1744

image

@coderabbitai
Copy link

coderabbitai bot commented Oct 10, 2025

📝 Walkthrough

Walkthrough

Adds a collapsible, markdown-rendered "Changelog" section (collapsed by default, hidden label) to the admin UpdateWidget and a new SoftwareVersionService::latestPanelVersionChangelog() method that fetches and caches the latest GitHub release body; also adds a localization string for the changelog button.

Changes

Cohort / File(s) Summary
Admin Widget UI
app/Filament/Admin/Widgets/UpdateWidget.php
Introduces a new collapsible Section labeled via intro-update-available.button_changelog containing a TextEntry for changelog (hidden label), rendered as Markdown, sourcing state from SoftwareVersionService::latestPanelVersionChangelog(), collapsed by default.
Version Service Enhancements
app/Services/Helpers/SoftwareVersionService.php
Adds public function latestPanelVersionChangelog(): string which uses cache key panel:latest_version_changelog, clears cached 'error' sentinel if present, and cache()->remember to GET /repos/pelican-dev/panel/releases/latest, returning the release body or 'error'.
Localization
lang/en/admin/dashboard.php
Adds button_changelog => 'What\'s New?' under sections['intro-update-available'] for the new collapsible section label.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Admin as Admin User
  participant UI as UpdateWidget
  participant SV as SoftwareVersionService
  participant Cache as Cache Store
  participant GH as GitHub API

  Admin->>UI: Open Update Widget
  UI->>SV: latestPanelVersion()
  SV->>Cache: get/remember latest_version
  alt Cache miss or 'error'
    SV->>GH: GET /repos/pelican-dev/panel/releases/latest
    GH-->>SV: tag_name or error
    SV->>Cache: set latest_version or 'error'
  end
  UI->>SV: latestPanelVersionChangelog()
  SV->>Cache: get/remember panel:latest_version_changelog
  alt Cache miss or 'error'
    SV->>GH: GET /repos/pelican-dev/panel/releases/latest
    GH-->>SV: body or error
    SV->>Cache: set panel:latest_version_changelog or 'error'
  end
  SV-->>UI: changelog markdown or 'error'
  UI-->>Admin: Render version info and collapsible changelog (markdown)
Loading

Pre-merge checks

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% 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 clearly summarizes the main change by stating that a changelog preview is added when an update is available. It is concise, specific, and free of unnecessary details. This phrasing allows a teammate scanning the history to understand the core change at a glance.
Description Check ✅ Passed The description indicates that issue #1744 is implemented and provides a relevant screenshot of the UI change. Although brief, the description remains focused on the changeset and offers context for reviewers. It does not deviate from the pull request's objectives.

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: 4

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1f56b8e and c77d952.

📒 Files selected for processing (2)
  • app/Filament/Admin/Widgets/UpdateWidget.php (1 hunks)
  • app/Services/Helpers/SoftwareVersionService.php (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
app/Filament/Admin/Widgets/UpdateWidget.php (1)
app/Services/Helpers/SoftwareVersionService.php (1)
  • latestPanelVersionChangelog (10-26)

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.

Thanks for your contribution!
Could you change the changelog to be a header action with a modal instead? Otherwise the page might get very long.

Something like this: (pseudo code)

->headerActions([
    .....
    Action::make('changelog')
        ->label('What\'s New')
        ->icon('tabler-icon')
        ->schema([
            TextEntry::make('changelog')
                ->hiddenLabel()
                ->state($this->softwareVersionService->latestPanelVersionChangelog())
                ->markdown(),
        ]),
]),

@LetterN
Copy link
Contributor Author

LetterN commented Oct 10, 2025

how about this?
image

changelog is collapsed by default

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: 1

♻️ Duplicate comments (1)
app/Filament/Admin/Widgets/UpdateWidget.php (1)

53-56: Error state still not handled.

The previous major concern about error handling remains unaddressed. When latestPanelVersionChangelog() returns 'error' (on API failure), it will be rendered as markdown text "error" and displayed to users, degrading UX.

Apply one of the previously suggested solutions:

Option 1: Hide the field when an error occurs

                                TextEntry::make('Changelog')
                                    ->hiddenLabel()
                                    ->state($this->softwareVersionService->latestPanelVersionChangelog())
                                    ->markdown()
+                                   ->hidden(fn ($state) => $state === 'error')

Option 2: Display a fallback message

                                TextEntry::make('Changelog')
                                    ->hiddenLabel()
-                                   ->state($this->softwareVersionService->latestPanelVersionChangelog())
+                                   ->state(function () {
+                                       $changelog = $this->softwareVersionService->latestPanelVersionChangelog();
+                                       return $changelog === 'error' ? 'Changelog unavailable.' : $changelog;
+                                   })
                                    ->markdown()
🧹 Nitpick comments (1)
app/Filament/Admin/Widgets/UpdateWidget.php (1)

48-48: Use a more specific icon.

'tabler-icon' appears to be a generic placeholder name rather than an actual icon identifier. Consider a more descriptive icon.

Apply this diff:

-                           ->icon('tabler-icon')
+                           ->icon('tabler-list')

Alternative icons: 'tabler-file-text', 'tabler-notes', or 'tabler-list-details'.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d2d05e5 and d145791.

📒 Files selected for processing (1)
  • app/Filament/Admin/Widgets/UpdateWidget.php (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
app/Filament/Admin/Widgets/UpdateWidget.php (1)
app/Services/Helpers/SoftwareVersionService.php (1)
  • latestPanelVersionChangelog (10-26)

@lancepioch
Copy link
Member

This looks great @LetterN - can you quick add the translation key and it's good to go!

@lancepioch lancepioch self-assigned this Oct 10, 2025
@lancepioch lancepioch requested a review from Boy132 October 11, 2025 19:07
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

♻️ Duplicate comments (1)
app/Filament/Admin/Widgets/UpdateWidget.php (1)

53-57: Handle ‘error’ state from latestPanelVersionChangelog().

Avoid rendering the sentinel value to users. Hide the field when it errors.

Apply:

-                                TextEntry::make('changelog')
-                                    ->hiddenLabel()
-                                    ->state($this->softwareVersionService->latestPanelVersionChangelog())
-                                    ->markdown(),
+                                TextEntry::make('changelog')
+                                    ->hiddenLabel()
+                                    ->state($this->softwareVersionService->latestPanelVersionChangelog())
+                                    ->markdown()
+                                    ->hidden(fn ($state) => $state === 'error'),
🧹 Nitpick comments (2)
app/Filament/Admin/Widgets/UpdateWidget.php (2)

45-47: Guard the update text when latest version lookup fails.

If latestPanelVersion() returns 'error', hide this entry to avoid “error is now available!” UI.

Apply:

                         TextEntry::make('info')
                             ->hiddenLabel()
-                            ->state(trans('admin/dashboard.sections.intro-update-available.content', ['latestVersion' => $this->softwareVersionService->latestPanelVersion()])),
+                            ->state(trans('admin/dashboard.sections.intro-update-available.content', [
+                                'latestVersion' => $this->softwareVersionService->latestPanelVersion(),
+                            ]))
+                            ->hidden(fn () => $this->softwareVersionService->latestPanelVersion() === 'error'),

55-56: Confirm Markdown sanitization (strip HTML, block unsafe links).

Rendering remote Markdown can include raw HTML. Ensure TextEntry::markdown() strips HTML and disallows unsafe links; otherwise pre-sanitize.

If needed:

-                                    ->state($this->softwareVersionService->latestPanelVersionChangelog())
-                                    ->markdown()
+                                    ->state(fn () => \Illuminate\Support\Str::markdown(
+                                        (string) $this->softwareVersionService->latestPanelVersionChangelog(),
+                                        ['html_input' => 'strip', 'allow_unsafe_links' => false]
+                                    ))
+                                    ->html()
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 02266e6 and 373e027.

📒 Files selected for processing (3)
  • app/Filament/Admin/Widgets/UpdateWidget.php (1 hunks)
  • app/Services/Helpers/SoftwareVersionService.php (1 hunks)
  • lang/en/admin/dashboard.php (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/Services/Helpers/SoftwareVersionService.php
🧰 Additional context used
🧬 Code graph analysis (1)
app/Filament/Admin/Widgets/UpdateWidget.php (1)
app/Services/Helpers/SoftwareVersionService.php (2)
  • latestPanelVersion (28-44)
  • latestPanelVersionChangelog (10-26)
🔇 Additional comments (2)
lang/en/admin/dashboard.php (1)

20-21: Translation key added correctly.

Key matches usage in UpdateWidget. Thanks for keeping i18n consistent.

Please ensure this key is added to other locales before merge.

app/Filament/Admin/Widgets/UpdateWidget.php (1)

46-46: LGTM on hiddenLabel usage.

Improves accessibility and visual cleanliness.

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

Add a 'What's new' button on the admin dashboard when an update is available

4 participants