Skip to content

Commit

Permalink
Merge pull request #1020 from OpenFn/download-limbo-fix
Browse files Browse the repository at this point in the history
Fix hanging downloads with link
  • Loading branch information
stuartc authored Aug 14, 2023
2 parents 036e5ca + 1282c39 commit 5bee89a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
4 changes: 0 additions & 4 deletions lib/lightning_web/live/project_live/settings.ex
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,6 @@ defmodule LightningWeb.ProjectLive.Settings do
end
end

def handle_event("export_project", %{"id" => id}, socket) do
{:noreply, push_navigate(socket, to: "/download/yaml?id=#{id}")}
end

defp dispatch_flash(change_result, socket) do
case change_result do
{:ok, %ProjectUser{}} ->
Expand Down
8 changes: 3 additions & 5 deletions lib/lightning_web/live/project_live/settings.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,12 @@
<div class="hidden sm:block" aria-hidden="true">
<div class="py-2"></div>
</div>
<button
type="button"
phx-click="export_project"
phx-value-id={@project.id}
<a
href={~p"/download/yaml?id=#{@project.id}"}
class="bg-primary-600 hover:bg-primary-700 inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500 "
>
Export project
</button>
</a>
</div>
</div>
<%= if @can_delete_project do %>
Expand Down
4 changes: 2 additions & 2 deletions test/lightning_web/live/project_live_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,10 @@ defmodule LightningWeb.ProjectLiveTest do
assert html =~
"Export your project as code, to save this version or edit your project locally"

assert index_live |> element("button", "Export project") |> has_element?()
assert index_live |> element("a", "Export project") |> has_element?()

assert index_live
|> element("button", "Export project")
|> element("a", "Export project")
|> render_click()
|> follow_redirect(conn, "/download/yaml?id=#{project.id}")
end
Expand Down

0 comments on commit 5bee89a

Please sign in to comment.