From 9a8a252bb9e9da2a7f16822f46c3902cc12cd1ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonatan=20K=C5=82osko?= Date: Wed, 21 Jun 2023 00:46:12 +0200 Subject: [PATCH] Unify error pages (#1999) --- lib/livebook_web/controllers/error_html.ex | 56 ++++++++++++++++++- .../controllers/error_html/403.html.heex | 24 -------- .../controllers/error_html/404.html.heex | 24 -------- .../controllers/error_html/500.html.heex | 27 --------- 4 files changed, 54 insertions(+), 77 deletions(-) delete mode 100644 lib/livebook_web/controllers/error_html/403.html.heex delete mode 100644 lib/livebook_web/controllers/error_html/404.html.heex delete mode 100644 lib/livebook_web/controllers/error_html/500.html.heex diff --git a/lib/livebook_web/controllers/error_html.ex b/lib/livebook_web/controllers/error_html.ex index a9d87ae1c..edab10b80 100644 --- a/lib/livebook_web/controllers/error_html.ex +++ b/lib/livebook_web/controllers/error_html.ex @@ -1,9 +1,61 @@ defmodule LivebookWeb.ErrorHTML do use LivebookWeb, :html - embed_templates "error_html/*" + def render("404.html", assigns) do + ~H""" + <.error_page status={@status} title="No Numbats here!" /> + """ + end + + def render("403.html", assigns) do + ~H""" + <.error_page status={@status} title="No Numbats allowed here!" /> + """ + end def render(_template, assigns) do - render("500.html", assigns) + ~H""" + <.error_page + status={@status} + title="Something went wrong." + details="Check out the console for logs for more information." + /> + """ + end + + attr :status, :integer, required: true + attr :title, :string, required: true + attr :details, :string, default: nil + + defp error_page(assigns) do + ~H""" + + + + + + + + + <%= @status %> - Livebook + + + +
+
+ + livebook + +
+ <%= @title %> +
+
+ <%= @details %> +
+
+
+ + + """ end end diff --git a/lib/livebook_web/controllers/error_html/403.html.heex b/lib/livebook_web/controllers/error_html/403.html.heex deleted file mode 100644 index 402c77d30..000000000 --- a/lib/livebook_web/controllers/error_html/403.html.heex +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - <%= @status %> - Livebook - - - -
-
- - livebook - -
- No Numbats allowed here! -
-
-
- - diff --git a/lib/livebook_web/controllers/error_html/404.html.heex b/lib/livebook_web/controllers/error_html/404.html.heex deleted file mode 100644 index 7c2d8d85c..000000000 --- a/lib/livebook_web/controllers/error_html/404.html.heex +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - <%= @status %> - Livebook - - - -
-
- - livebook - -
- No Numbats here! -
-
-
- - diff --git a/lib/livebook_web/controllers/error_html/500.html.heex b/lib/livebook_web/controllers/error_html/500.html.heex deleted file mode 100644 index 7f39b044b..000000000 --- a/lib/livebook_web/controllers/error_html/500.html.heex +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - <%= @status %> - Livebook - - - -
-
- - livebook - -
- Something went wrong. -
-
- Check out the console for logs for more information. -
-
-
- -