mirror of
https://github.com/pelican-dev/panel.git
synced 2025-10-29 23:26:52 +01:00
Add changelog preview when a new update is available (#1792)
Co-authored-by: Boy132 <mail@boy132.de>
This commit is contained in:
parent
266e3779d5
commit
e589f972fb
@ -43,7 +43,18 @@ class UpdateWidget extends FormWidget
|
|||||||
->iconColor('warning')
|
->iconColor('warning')
|
||||||
->schema([
|
->schema([
|
||||||
TextEntry::make('info')
|
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()])),
|
||||||
|
Section::make(trans('admin/dashboard.sections.intro-update-available.button_changelog'))
|
||||||
|
->icon('tabler-script')
|
||||||
|
->collapsible()
|
||||||
|
->collapsed()
|
||||||
|
->schema([
|
||||||
|
TextEntry::make('changelog')
|
||||||
|
->hiddenLabel()
|
||||||
|
->state($this->softwareVersionService->latestPanelVersionChangelog())
|
||||||
|
->markdown(),
|
||||||
|
]),
|
||||||
])
|
])
|
||||||
->headerActions([
|
->headerActions([
|
||||||
Action::make('update')
|
Action::make('update')
|
||||||
|
|||||||
@ -7,6 +7,24 @@ use Illuminate\Support\Facades\Http;
|
|||||||
|
|
||||||
class SoftwareVersionService
|
class SoftwareVersionService
|
||||||
{
|
{
|
||||||
|
public function latestPanelVersionChangelog(): string
|
||||||
|
{
|
||||||
|
$key = 'panel:latest_version_changelog';
|
||||||
|
if (cache()->get($key) === 'error') {
|
||||||
|
cache()->forget($key);
|
||||||
|
}
|
||||||
|
|
||||||
|
return cache()->remember($key, now()->addMinutes(config('panel.cdn.cache_time', 60)), function () {
|
||||||
|
try {
|
||||||
|
$response = Http::timeout(5)->connectTimeout(1)->get('https://api.github.com/repos/pelican-dev/panel/releases/latest')->throw()->json();
|
||||||
|
|
||||||
|
return $response['body'];
|
||||||
|
} catch (Exception) {
|
||||||
|
return 'error';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public function latestPanelVersion(): string
|
public function latestPanelVersion(): string
|
||||||
{
|
{
|
||||||
$key = 'panel:latest_version';
|
$key = 'panel:latest_version';
|
||||||
|
|||||||
@ -17,6 +17,7 @@ return [
|
|||||||
'intro-update-available' => [
|
'intro-update-available' => [
|
||||||
'heading' => 'Update available',
|
'heading' => 'Update available',
|
||||||
'content' => ':latestVersion is now available! Read our documentation to update your Panel.',
|
'content' => ':latestVersion is now available! Read our documentation to update your Panel.',
|
||||||
|
'button_changelog' => 'What\'s New?',
|
||||||
],
|
],
|
||||||
'intro-no-update' => [
|
'intro-no-update' => [
|
||||||
'heading' => 'Your Panel is up to date',
|
'heading' => 'Your Panel is up to date',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user