From a15a69175bc3d1314306435568405538d788a477 Mon Sep 17 00:00:00 2001 From: lkarthee Date: Mon, 22 Jan 2024 13:26:39 +0530 Subject: [PATCH] Enable copy button for error output (#2435) --- lib/livebook_web/live/output.ex | 49 ++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/lib/livebook_web/live/output.ex b/lib/livebook_web/live/output.ex index 5d411ca8e..97fd8d84e 100644 --- a/lib/livebook_web/live/output.ex +++ b/lib/livebook_web/live/output.ex @@ -257,9 +257,9 @@ defmodule LivebookWeb.Output do defp render_output( %{type: :error, context: {:missing_secret, secret_name}} = output, - %{session_id: session_id} + %{session_id: session_id, id: id} ) do - assigns = %{message: output.message, secret_name: secret_name, session_id: session_id} + assigns = %{message: output.message, secret_name: secret_name, session_id: session_id, id: id} ~H"""
@@ -278,16 +278,21 @@ defmodule LivebookWeb.Output do Add secret
- <%= render_formatted_error_message(@message) %> + <%= render_formatted_error_message(@id, @message) %> """ end defp render_output( %{type: :error, context: {:file_entry_forbidden, file_entry_name}} = output, - %{session_id: session_id} + %{session_id: session_id, id: id} ) do - assigns = %{message: output.message, file_entry_name: file_entry_name, session_id: session_id} + assigns = %{ + message: output.message, + file_entry_name: file_entry_name, + session_id: session_id, + id: id + } ~H"""
@@ -306,7 +311,7 @@ defmodule LivebookWeb.Output do Review access
- <%= render_formatted_error_message(@message) %> + <%= render_formatted_error_message(@id, @message) %> """ end @@ -346,8 +351,8 @@ defmodule LivebookWeb.Output do """ end - defp render_output(%{type: :error, message: message}, %{}) do - render_formatted_error_message(message) + defp render_output(%{type: :error, message: message}, %{id: id}) do + render_formatted_error_message(id, message) end defp render_output(output, %{}) do @@ -373,16 +378,28 @@ defmodule LivebookWeb.Output do """ end - defp render_formatted_error_message(formatted) do - assigns = %{message: formatted} + defp render_formatted_error_message(id, message) do + assigns = %{id: id, message: message} ~H""" - +
+ + +
""" end end