Skip to content
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

Errors blade #1639

Merged
merged 9 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 11 additions & 25 deletions packages/Webkul/Admin/src/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,6 @@ public function render($request, Throwable $exception)
return parent::render($request, $exception);
}

/**
* Report the exception.
*
* @return void
*/
public function report(Throwable $exception)
{
//
}

/**
* Convert an authentication exception into a response.
*
Expand All @@ -84,48 +74,44 @@ protected function unauthenticated($request, AuthenticationException $exception)
*/
private function renderCustomResponse(Throwable $exception)
{
$path = request()->routeIs('admin.*') ? 'admin' : 'front';

if ($path == 'front') {
return redirect()->route('admin.session.create');
}

if ($exception instanceof HttpException) {
$statusCode = in_array($exception->getStatusCode(), [401, 403, 404, 503])
? $exception->getStatusCode()
: 500;

return $this->response($path, $statusCode);
return $this->response($statusCode);
}

if ($exception instanceof ValidationException) {
return parent::render(request(), $exception);
}

if ($exception instanceof ModelNotFoundException) {
return $this->response($path, 404);
return $this->response(404);
} elseif ($exception instanceof PDOException || $exception instanceof \ParseError) {
return $this->response($path, 500);
return $this->response(500);
} else {
return $this->response(500);
}
}

/**
* Return custom response.
*
* @param string $path
* @param string $statusCode
* @param string $errorCode
* @return mixed
*/
private function response($path, $statusCode)
private function response($errorCode)
{
if (request()->expectsJson()) {
return response()->json([
'message' => isset($this->jsonErrorMessages[$statusCode])
? $this->jsonErrorMessages[$statusCode]
'message' => isset($this->jsonErrorMessages[$errorCode])
? $this->jsonErrorMessages[$errorCode]
: trans('admin::app.common.something-went-wrong'),
], $statusCode);
], $errorCode);
}

return response()->view("{$path}::errors.{$statusCode}", [], $statusCode);
return response()->view('admin::errors.index', compact('errorCode'));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,13 @@ public function massUpdate(MassUpdateRequest $massUpdateRequest): JsonResponse
*/
public function download(int $id): StreamedResponse
{
$file = $this->fileRepository->findOrFail($id);
try {
$file = $this->fileRepository->findOrFail($id);

return Storage::download($file->path);
return Storage::download($file->path);
} catch (\Exception $exception) {
abort(404);
}
}

/*
Expand Down
101 changes: 101 additions & 0 deletions packages/Webkul/Admin/src/Resources/assets/images/dark-error.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions packages/Webkul/Admin/src/Resources/assets/images/error.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 28 additions & 1 deletion packages/Webkul/Admin/src/Resources/lang/ar/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -2018,6 +2018,33 @@
],

'errors' => [
'401' => 'أنت غير مخول للوصول إلى هذه الصفحة',
'dashboard' => 'لوحة التحكم',
'go-back' => 'العودة',
'support' => 'إذا استمرت المشكلة، تواصل معنا على <a href=":link" class=":class">:email</a> للحصول على المساعدة.',

'404' => [
'description' => 'عذرًا! الصفحة التي تبحث عنها في إجازة. يبدو أننا لم نجد ما كنت تبحث عنه.',
'title' => '404 الصفحة غير موجودة',
],

'401' => [
'description' => 'عذرًا! يبدو أنك غير مصرح لك بالوصول إلى هذه الصفحة. يبدو أنك تفتقد الأوراق اللازمة.',
'title' => '401 غير مصرح',
],

'403' => [
'description' => 'عذرًا! هذه الصفحة محظورة. يبدو أنك لا تملك الأذونات اللازمة لعرض هذا المحتوى.',
'title' => '403 ممنوع الدخول',
],

'500' => [
'description' => 'عذرًا! حدث خطأ ما. يبدو أننا نواجه مشكلة في تحميل الصفحة التي تبحث عنها.',
'title' => '500 خطأ داخلي في الخادم',
],

'503' => [
'description' => 'عذرًا! يبدو أننا متوقفون مؤقتًا للصيانة. يرجى العودة لاحقًا.',
'title' => '503 الخدمة غير متوفرة',
],
],
];
29 changes: 28 additions & 1 deletion packages/Webkul/Admin/src/Resources/lang/en/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -2018,6 +2018,33 @@
],

'errors' => [
'401' => 'You are not authorized to access this page',
'dashboard' => 'Dashboard',
'go-back' => 'Go Back',
'support' => 'If the problem persists, reach out to us at <a href=":link" class=":class">:email</a> for assistance.',

'404' => [
'description' => 'Oops! The page you\'re looking for is on vacation. It seems we couldn\'t find what you were searching for.',
'title' => '404 Page Not Found',
],

'401' => [
'description' => 'Oops! Looks like you\'re not allowed to access this page. It seems you\'re missing the necessary credentials.',
'title' => '401 Unauthorized',
],

'403' => [
'description' => 'Oops! This page is off-limits. It appears you don\'t have the required permissions to view this content.',
'title' => '403 Forbidden',
],

'500' => [
'description' => 'Oops! Something went wrong. It seems we\'re having trouble loading the page you\'re looking for.',
'title' => '500 Internal Server Error',
],

'503' => [
'description' => 'Oops! Looks like we\'re temporarily down for maintenance. Please check back in a bit.',
'title' => '503 Service Unavailable',
],
],
];
29 changes: 28 additions & 1 deletion packages/Webkul/Admin/src/Resources/lang/es/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -2018,6 +2018,33 @@
],

'errors' => [
'401' => 'No estás autorizado para acceder a esta página',
'dashboard' => 'Tablero',
'go-back' => 'Volver',
'support' => 'Si el problema persiste, contáctanos en <a href=":link" class=":class">:email</a> para obtener ayuda.',

'404' => [
'description' => '¡Ups! La página que estás buscando está de vacaciones. Parece que no pudimos encontrar lo que estabas buscando.',
'title' => '404 Página No Encontrada',
],

'401' => [
'description' => '¡Ups! Parece que no tienes permiso para acceder a esta página. Parece que te faltan las credenciales necesarias.',
'title' => '401 No Autorizado',
],

'403' => [
'description' => '¡Ups! Esta página está fuera de límites. Parece que no tienes los permisos necesarios para ver este contenido.',
'title' => '403 Prohibido',
],

'500' => [
'description' => '¡Ups! Algo salió mal. Parece que tenemos problemas para cargar la página que estás buscando.',
'title' => '500 Error Interno del Servidor',
],

'503' => [
'description' => '¡Ups! Parece que estamos temporalmente fuera de servicio por mantenimiento. Vuelve a intentarlo en un rato.',
'title' => '503 Servicio No Disponible',
],
],
];
29 changes: 28 additions & 1 deletion packages/Webkul/Admin/src/Resources/lang/fa/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -2018,6 +2018,33 @@
],

'errors' => [
'401' => 'شما مجاز به دسترسی به این صفحه نیستید',
'dashboard' => 'داشبورد',
'go-back' => 'بازگشت',
'support' => 'اگر مشکل ادامه داشت، برای کمک با ما از طریق <a href=":link" class=":class">:email</a> تماس بگیرید.',

'404' => [
'description' => 'اوه! به نظر می‌رسد صفحه‌ای که دنبال آن بودید، در دسترس نیست. نتوانستیم چیزی که دنبالش بودید را پیدا کنیم.',
'title' => '404 صفحه پیدا نشد',
],

'401' => [
'description' => 'اوه! به نظر می‌رسد که شما مجاز به دسترسی به این صفحه نیستید. شما مجوزهای لازم را ندارید.',
'title' => '401 مجاز نیست',
],

'403' => [
'description' => 'اوه! این صفحه ممنوع است. به نظر می‌رسد شما مجوزهای لازم برای مشاهده این محتوا را ندارید.',
'title' => '403 ممنوع',
],

'500' => [
'description' => 'اوه! مشکلی پیش آمده است. به نظر می‌رسد مشکلی در بارگذاری صفحه مورد نظر شما وجود دارد.',
'title' => '500 خطای سرور داخلی',
],

'503' => [
'description' => 'اوه! به نظر می‌رسد که به طور موقت برای نگهداری آفلاین هستیم. لطفاً بعداً دوباره بررسی کنید.',
'title' => '503 سرویس در دسترس نیست',
],
],
];
29 changes: 28 additions & 1 deletion packages/Webkul/Admin/src/Resources/lang/tr/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -2018,6 +2018,33 @@
],

'errors' => [
'401' => 'Bu sayfaya erişme yetkiniz yok',
'dashboard' => 'Kontrol Paneli',
'go-back' => 'Geri Dön',
'support' => 'Sorun devam ederse, yardım için bize <a href=":link" class=":class">:email</a> adresinden ulaşın.',

'404' => [
'description' => 'Oops! Aradığınız sayfa tatilde. Aradığınız şeyi bulamadık gibi görünüyor.',
'title' => '404 Sayfa Bulunamadı',
],

'401' => [
'description' => 'Oops! Bu sayfaya erişim izniniz yok gibi görünüyor. Gerekli yetkilere sahip değilsiniz.',
'title' => '401 Yetkisiz',
],

'403' => [
'description' => 'Oops! Bu sayfa erişime kapalı. Bu içeriği görüntülemek için gerekli izinlere sahip değilsiniz gibi görünüyor.',
'title' => '403 Yasak',
],

'500' => [
'description' => 'Oops! Bir şeyler ters gitti. Aradığınız sayfa yüklenirken sorun yaşıyoruz gibi görünüyor.',
'title' => '500 Sunucu Hatası',
],

'503' => [
'description' => 'Oops! Görünüşe göre geçici bir bakım nedeniyle kapalıyız. Lütfen kısa süre sonra tekrar kontrol edin.',
'title' => '503 Hizmet Kullanılamıyor',
],
],
];
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ class="peer hidden"
>

<span
class="icon-checkbox-outline cursor-pointer rounded-md text-2xl text-gray-500 peer-checked:text-blue-600"
class="icon-checkbox-outline cursor-pointer rounded-md text-2xl text-gray-500 peer-checked:text-brandColor"
:class="[
applied.massActions.meta.mode === 'all' ? 'peer-checked:icon-checkbox-select peer-checked:text-brandColor ' : (
applied.massActions.meta.mode === 'partial' ? 'peer-checked:icon-checkbox-partial peer-checked:brandColor' : ''
applied.massActions.meta.mode === 'partial' ? 'peer-checked:icon-checkbox-multiple peer-checked:brandColor' : ''
),
]"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@isset($content)
<template #content="{ isActive, positionStyles }">
<div
{{ $content->attributes->merge(['class' => 'absolute z-10 w-max rounded bg-white py-5 shadow-[0px_10px_20px_0px_#0000001F] dark:bg-gray-900']) }}
{{ $content->attributes->merge(['class' => 'absolute z-10 w-max rounded bg-white py-5 shadow-[0px_10px_20px_0px_#0000001F] dark:bg-gray-900 border border-gray-300 dark:border-gray-800']) }}
:style="positionStyles"
v-show="isActive"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class="flex w-full items-center overflow-hidden rounded-md border text-sm text-g
type="{{ $type }}"
v-bind="{ name: field.name }"
:class="[errors.length ? 'border !border-red-600 hover:border-red-600' : '']"
{{ $attributes->except(['value', ':value', 'v-model', 'rules', ':rules', 'label', ':label'])->merge(['class' => 'w-full rounded border border-gray-200 px-2.5 py-2 text-sm font-normal text-gray-800 transition-all hover:border-gray-400 focus:border-gray-400 dark:border-gray-800 dark:bg-gray-900 dark:text-gray-300 dark:hover:border-gray-400 dark:focus:border-gray-400']) }}
{{ $attributes->except(['value', ':value', 'v-model', 'rules', ':rules', 'label', ':label'])->merge(['class' => 'w-full dark:file:bg-gray-800 dark:file:dark:text-white rounded border border-gray-200 px-2.5 py-2 text-sm font-normal text-gray-800 transition-all hover:border-gray-400 focus:border-gray-400 dark:border-gray-800 dark:bg-gray-900 dark:text-gray-300 dark:hover:border-gray-400 dark:focus:border-gray-400']) }}
@change="handleChange"
@blur="handleBlur"
/>
Expand Down
Loading
Loading