defmodule LivebookWeb.OpenLive.UrlComponent do
use LivebookWeb, :live_component
alias Livebook.{Utils, Notebook}
@impl true
def mount(socket) do
{:ok, assign(socket, url: "", error_message: nil)}
end
@impl true
def update(assigns, socket) do
if url = assigns[:url] do
{:ok, do_import(socket, url)}
else
{:ok, socket}
end
end
@impl true
def render(assigns) do
~H"""
<%= @error_message %>
Paste the URL to a .livemd file, to a GitHub file, or to a Gist.