From a55d6ea9deeceb1cd7ec3f9401ee461ffc51bc62 Mon Sep 17 00:00:00 2001 From: ajugo Date: Fri, 15 Jul 2022 10:43:07 +0200 Subject: [PATCH] Replaced default ruby error pages [SCI-6967] (#4230) * Replaced default ruby error pages [SCI-6967] * Remove error 500 in controller [SCI-6967] --- app/controllers/application_controller.rb | 27 ++- config/routes.rb | 1 + public/403.html | 92 +-------- public/404.html | 67 +----- public/422.html | 77 ++----- public/500.html | 76 ++----- public/error_pages.css | 91 ++++++++ public/images/genericError.svg | 138 +++++++++++++ public/images/undraw_through_the_park.svg | 239 +++++++++++----------- 9 files changed, 410 insertions(+), 398 deletions(-) create mode 100644 public/error_pages.css create mode 100644 public/images/genericError.svg diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 027347934..30f72a157 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -13,15 +13,6 @@ class ApplicationController < ActionController::Base redirect_to root_path end - def respond_422(message = t('client_api.permission_error')) - respond_to do |format| - format.json do - render json: { message: message }, - status: 422 - end - end - end - def forbidden render_403 end @@ -30,6 +21,10 @@ class ApplicationController < ActionController::Base render_404 end + def respond_422(message = t('client_api.permission_error')) + render_422(message) + end + def is_current_page_root? controller_name == 'projects' && action_name == 'index' end @@ -79,6 +74,20 @@ class ApplicationController < ActionController::Base end end + def render_422(message = t('client_api.permission_error')) + respond_to do |format| + format.html do + render file: 'public/422.html', status: :unprocessable_entity, layout: false + end + format.json do + render json: { message: message }, status: :unprocessable_entity + end + format.any do + render plain: 'UNPROCESSABLE ENTITY', status: :unprocessable_entity + end + end + end + private def update_current_team diff --git a/config/routes.rb b/config/routes.rb index 9e166ec96..e7c808ff0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -25,6 +25,7 @@ Rails.application.routes.draw do get 'forbidden', to: 'application#forbidden', as: 'forbidden' get 'not_found', to: 'application#not_found', as: 'not_found' + get 'unprocessable_entity', to: 'application#respond_422', as: 'unprocessable_entity' # JS backend helpers get 'helpers/to_user_date_format', diff --git a/public/403.html b/public/403.html index b76b059d7..9fcd2608c 100644 --- a/public/403.html +++ b/public/403.html @@ -3,95 +3,7 @@ Access to this page is denied (403). - + @@ -100,7 +12,7 @@
- +

It would seem that you are not allowed in here.

You should request access from your team administrators.

diff --git a/public/404.html b/public/404.html index d5be50add..f6b496886 100644 --- a/public/404.html +++ b/public/404.html @@ -3,71 +3,18 @@ This page could not be found (404). - + +
-
-

This page could not be found (404).

-

You may have mistyped the address or the page may have moved.

-
-

- If you are the application owner check the logs for more information. - You can go back to - home page - or try - searching. -

+ +

Ooops, something went wrong.

+

Please contact your SciNote administrator.

diff --git a/public/422.html b/public/422.html index a21f82b3b..a703283e0 100644 --- a/public/422.html +++ b/public/422.html @@ -1,67 +1,20 @@ - - The change you wanted was rejected (422) - - - - - - -
-
-

The change you wanted was rejected.

-

Maybe you tried to change something you didn't have access to.

+ + + -

If you are the application owner check the logs for more information.

-
- +
+ +

Ooops, something went wrong.

+

Please contact your SciNote administrator.

+
+ diff --git a/public/500.html b/public/500.html index 061abc587..b79f5a552 100644 --- a/public/500.html +++ b/public/500.html @@ -1,66 +1,20 @@ - - We're sorry, but something went wrong (500) - - - - - - -
-
-

We're sorry, but something went wrong.

+ + + -

If you are the application owner check the logs for more information.

-
- +
+ +

Ooops, something went wrong.

+

Please contact your SciNote administrator.

+
+ diff --git a/public/error_pages.css b/public/error_pages.css new file mode 100644 index 000000000..3bf909820 --- /dev/null +++ b/public/error_pages.css @@ -0,0 +1,91 @@ +body { + background-color: #F0F0F6; + color: #2E2F30; + text-align: center; + font-family: arial, sans-serif; + margin: 0; +} + +div.navbar { + background: #FFFFFF; + box-shadow: 0px 1px 4px rgba(35, 31, 32, 0.15); + height: 52px; + left: 0%; + position: absolute; + right: 0%; + top: 0%; +} + +div.navbar > img { + width: 121px; + height: 24px; + left: 21px; + position: absolute; + top: calc(50% - 24px/2 - 0px); +} + +div.dialog { + width: 95%; + margin: 4em auto 0; +} + +div.dialog > h1 { + color: #404048; + font-family: Lato; + font-style: normal; + font-weight: bold; + font-size: 1.5em; + line-height: 29px; + margin: 0.5em; + text-align: center; +} + +div.dialog > p { + color: #404048; + font-family: Lato; + font-style: normal; + font-weight: normal; + font-size: 1.1em; + margin: 0.5em; +} + +div.dialog > img { + margin: 1em; +} + +div.back-button { + margin-top: 3em; + text-align: center; +} + +a.back-button { + background: #104DA9; + border-radius: 4px; + color: #FFFFFF; + display: inline-block; + font-family: Lato; + font-style: normal; + font-weight: normal; + font-size: 0.9em; + margin-top: 3em; + padding: 0.8em 1em; + text-decoration: none; +} + +a.back-button > img { + filter: invert(100%); + width: 1em; + height: 1em; + margin-right: 0.5em; + vertical-align:middle; +} + +a.back-button > span { + color: #FFFFFF; + width: 1em; + height: 1em; +} + +.illustration { + margin-top: 64px !important; +} diff --git a/public/images/genericError.svg b/public/images/genericError.svg new file mode 100644 index 000000000..801d0568b --- /dev/null +++ b/public/images/genericError.svg @@ -0,0 +1,138 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/public/images/undraw_through_the_park.svg b/public/images/undraw_through_the_park.svg index 45b86bb9b..6c3b49a4b 100644 --- a/public/images/undraw_through_the_park.svg +++ b/public/images/undraw_through_the_park.svg @@ -1,117 +1,124 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +