Skip to content

Commit

Permalink
Create maintenance page (LycheeOrg#2332)
Browse files Browse the repository at this point in the history
  • Loading branch information
ildyria committed Apr 6, 2024
1 parent 1a5fbb1 commit d80662b
Show file tree
Hide file tree
Showing 24 changed files with 308 additions and 2 deletions.
35 changes: 35 additions & 0 deletions app/Livewire/Components/Pages/Maintenance.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace App\Livewire\Components\Pages;

use App\Livewire\Components\Menus\LeftMenu;
use App\Models\Configs;
use App\Policies\SettingsPolicy;
use Illuminate\Support\Facades\Gate;
use Illuminate\View\View;
use Livewire\Component;

/**
* Admin page to manage lychee install and other commands.
*/
class Maintenance extends Component
{
/**
* Rendering of the front-end.
*
* @return View
*/
public function render(): View
{
Gate::authorize(SettingsPolicy::CAN_UPDATE, Configs::class);

return view('livewire.pages.maintenance');
}

public function back(): mixed
{
$this->dispatch('closeLeftMenu')->to(LeftMenu::class);

return $this->redirect(route('livewire-gallery'), true);
}
}
11 changes: 11 additions & 0 deletions lang/cz/maintenance.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

return [
/*
|--------------------------------------------------------------------------
| Update Page
|--------------------------------------------------------------------------
*/
'title' => 'Maintenance',
'description' => 'You will find on this page, all the required actions to keep your Lychee installation running smooth and nicely.',
];
11 changes: 11 additions & 0 deletions lang/de/maintenance.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

return [
/*
|--------------------------------------------------------------------------
| Update Page
|--------------------------------------------------------------------------
*/
'title' => 'Maintenance',
'description' => 'You will find on this page, all the required actions to keep your Lychee installation running smooth and nicely.',
];
11 changes: 11 additions & 0 deletions lang/el/maintenance.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

return [
/*
|--------------------------------------------------------------------------
| Update Page
|--------------------------------------------------------------------------
*/
'title' => 'Maintenance',
'description' => 'You will find on this page, all the required actions to keep your Lychee installation running smooth and nicely.',
];
11 changes: 11 additions & 0 deletions lang/en/maintenance.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

return [
/*
|--------------------------------------------------------------------------
| Update Page
|--------------------------------------------------------------------------
*/
'title' => 'Maintenance',
'description' => 'You will find on this page, all the required actions to keep your Lychee installation running smooth and nicely.',
];
11 changes: 11 additions & 0 deletions lang/es/maintenance.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

return [
/*
|--------------------------------------------------------------------------
| Update Page
|--------------------------------------------------------------------------
*/
'title' => 'Maintenance',
'description' => 'You will find on this page, all the required actions to keep your Lychee installation running smooth and nicely.',
];
4 changes: 2 additions & 2 deletions lang/fr/lychee.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
'ABOUT_LYCHEE' => 'À propos de Lychee',
'DIAGNOSTICS' => 'Diagnostiques',
'DIAGNOSTICS_GET_SIZE' => 'Calculer l’espace utilisé',
'JOBS' => 'Afficher l’historique des Jobs',
'LOGS' => 'Afficher les logs',
'JOBS' => 'Historique des Jobs',
'LOGS' => 'Logs',
'SIGN_OUT' => 'Déconnexion',
'UPDATE_AVAILABLE' => 'Une mise-à-jour est disponible !',
'MIGRATION_AVAILABLE' => 'Une migration est disponible !',
Expand Down
11 changes: 11 additions & 0 deletions lang/fr/maintenance.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

return [
/*
|--------------------------------------------------------------------------
| Update Page
|--------------------------------------------------------------------------
*/
'title' => 'Maintenance',
'description' => 'Vous trouverez sur cette page toutes les actions necessaire au bon fonctionment de Lychee.',
];
11 changes: 11 additions & 0 deletions lang/hu/maintenance.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

return [
/*
|--------------------------------------------------------------------------
| Update Page
|--------------------------------------------------------------------------
*/
'title' => 'Maintenance',
'description' => 'You will find on this page, all the required actions to keep your Lychee installation running smooth and nicely.',
];
11 changes: 11 additions & 0 deletions lang/it/maintenance.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

return [
/*
|--------------------------------------------------------------------------
| Update Page
|--------------------------------------------------------------------------
*/
'title' => 'Maintenance',
'description' => 'You will find on this page, all the required actions to keep your Lychee installation running smooth and nicely.',
];
11 changes: 11 additions & 0 deletions lang/nl/maintenance.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

return [
/*
|--------------------------------------------------------------------------
| Update Page
|--------------------------------------------------------------------------
*/
'title' => 'Maintenance',
'description' => 'You will find on this page, all the required actions to keep your Lychee installation running smooth and nicely.',
];
11 changes: 11 additions & 0 deletions lang/no/maintenance.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

return [
/*
|--------------------------------------------------------------------------
| Update Page
|--------------------------------------------------------------------------
*/
'title' => 'Maintenance',
'description' => 'You will find on this page, all the required actions to keep your Lychee installation running smooth and nicely.',
];
11 changes: 11 additions & 0 deletions lang/pl/maintenance.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

return [
/*
|--------------------------------------------------------------------------
| Update Page
|--------------------------------------------------------------------------
*/
'title' => 'Maintenance',
'description' => 'You will find on this page, all the required actions to keep your Lychee installation running smooth and nicely.',
];
11 changes: 11 additions & 0 deletions lang/pt/maintenance.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

return [
/*
|--------------------------------------------------------------------------
| Update Page
|--------------------------------------------------------------------------
*/
'title' => 'Maintenance',
'description' => 'You will find on this page, all the required actions to keep your Lychee installation running smooth and nicely.',
];
11 changes: 11 additions & 0 deletions lang/ru/maintenance.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

return [
/*
|--------------------------------------------------------------------------
| Update Page
|--------------------------------------------------------------------------
*/
'title' => 'Maintenance',
'description' => 'You will find on this page, all the required actions to keep your Lychee installation running smooth and nicely.',
];
11 changes: 11 additions & 0 deletions lang/sk/maintenance.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

return [
/*
|--------------------------------------------------------------------------
| Update Page
|--------------------------------------------------------------------------
*/
'title' => 'Maintenance',
'description' => 'You will find on this page, all the required actions to keep your Lychee installation running smooth and nicely.',
];
11 changes: 11 additions & 0 deletions lang/sv/maintenance.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

return [
/*
|--------------------------------------------------------------------------
| Update Page
|--------------------------------------------------------------------------
*/
'title' => 'Maintenance',
'description' => 'You will find on this page, all the required actions to keep your Lychee installation running smooth and nicely.',
];
11 changes: 11 additions & 0 deletions lang/vi/maintenance.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

return [
/*
|--------------------------------------------------------------------------
| Update Page
|--------------------------------------------------------------------------
*/
'title' => 'Maintenance',
'description' => 'You will find on this page, all the required actions to keep your Lychee installation running smooth and nicely.',
];
11 changes: 11 additions & 0 deletions lang/zh_CN/maintenance.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

return [
/*
|--------------------------------------------------------------------------
| Update Page
|--------------------------------------------------------------------------
*/
'title' => 'Maintenance',
'description' => 'You will find on this page, all the required actions to keep your Lychee installation running smooth and nicely.',
];
11 changes: 11 additions & 0 deletions lang/zh_TW/maintenance.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

return [
/*
|--------------------------------------------------------------------------
| Update Page
|--------------------------------------------------------------------------
*/
'title' => 'Maintenance',
'description' => 'You will find on this page, all the required actions to keep your Lychee installation running smooth and nicely.',
];
5 changes: 5 additions & 0 deletions resources/views/livewire/components/left-menu.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ class="z-40 w-0 h-screen transition-width duration-500 select-none" aria-label="
{{ __('lychee.DIAGNOSTICS') }}
</x-leftbar.leftbar-item>
@endcan
@can(SettingsPolicy::CAN_EDIT, [App\Models\Configs::class])
<x-leftbar.leftbar-item href="{{ route('maintenance') }}" wire:navigate icon="timer">
{{ __('maintenance.title') }}
</x-leftbar.leftbar-item>
@endcan
<x-leftbar.leftbar-item wire:click="openAboutModal" icon="info">
{{ __('lychee.ABOUT_LYCHEE') }}
</x-leftbar.leftbar-item>
Expand Down
18 changes: 18 additions & 0 deletions resources/views/livewire/pages/maintenance.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<div class="w-full">
<x-header.bar class="h-14 select-none">
<x-header.back @keydown.escape.window="$wire.back();" wire:click="back" />
<x-header.title>{{ __('maintenance.title') }}</x-header.title>
</x-header.bar>
<div class="overflow-x-clip overflow-y-auto h-[calc(100vh-56px)] pt-4">
<div class="settings_view max-w-3xl text-text-main-400 text-sm mx-auto mb-9">
<div class="w-full mt-5">
<p class="text-center">
{{ __('maintenance.description') }}
</p>
</div>
<div class=" mt-9 grid grid-cols-1 gap-4 sm:grid-cols-2 sm:items-stretch md:grid-cols-3 md:gap-8 w-full">
{{-- Here are the maintenance modules to be added. --}}
</div>
</div>
</div>
</div>
1 change: 1 addition & 0 deletions routes/web-livewire.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
Route::get('/users', Users::class)->name('users');
Route::get('/sharing', Sharing::class)->name('sharing');
Route::get('/jobs', Jobs::class)->name('jobs');
Route::get('/maintenance', Maintenance::class)->name('maintenance');
Route::get('/map/{albumId?}', Map::class)->name('livewire-map');
Route::get('/frame/{albumId?}', Frame::class)->name('livewire-frame');
Route::get('/gallery', Albums::class)->name('livewire-gallery');
Expand Down
49 changes: 49 additions & 0 deletions tests/Livewire/Pages/MaintenanceTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

/**
* We don't care for unhandled exceptions in tests.
* It is the nature of a test to throw an exception.
* Without this suppression we had 100+ Linter warning in this file which
* don't help anything.
*
* @noinspection PhpDocMissingThrowsInspection
* @noinspection PhpUnhandledExceptionInspection
*/

namespace Tests\Livewire\Pages;

// use App\Livewire\Components\Modules\Maintenance\Cleaning;
// use App\Livewire\Components\Modules\Maintenance\FixJobs;
// use App\Livewire\Components\Modules\Maintenance\Optimize;
// use App\Livewire\Components\Modules\Maintenance\Update;
use App\Livewire\Components\Pages\Maintenance;
use Livewire\Livewire;
use Tests\Livewire\Base\BaseLivewireTest;

class MaintenanceTest extends BaseLivewireTest
{
public function testDiagnosticsLoggedOut(): void
{
Livewire::test(Maintenance::class)
->assertForbidden();

Livewire::actingAs($this->userMayUpload1)->test(Maintenance::class)
->assertForbidden();
}

public function testMaintenanceLogged(): void
{
Livewire::actingAs($this->admin)->test(Maintenance::class)
->assertViewIs('livewire.pages.maintenance')
// ->assertSeeLivewire(Cleaning::class)
// ->assertSeeLivewire(Optimize::class)
// ->assertSeeLivewire(Update::class)
// ->assertSeeLivewire(FixJobs::class)
->assertSee('Maintenance');

Livewire::actingAs($this->admin)->test(Maintenance::class)
->call('back')
->assertDispatched('closeLeftMenu')
->assertRedirect(route('livewire-gallery'));
}
}

0 comments on commit d80662b

Please sign in to comment.