diff --git a/assets/js/app.js b/assets/js/app.js index a46af2a9de..60fe6593ad 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -116,20 +116,15 @@ window.addEventListener('phx:page-loading-stop', () => { }); window.addEventListener('keydown', event => { - // define our edit_job_path const currentURL = window.location.pathname; const edit_job_url = /\/projects\/(.+)\/w\/(.+)\/j\/(.+)/; - // Check if the user pressed CTRL+S if ((event.ctrlKey || event.metaKey) && event.key === 's') { - // Prevent the default behavior - event.preventDefault(); if (edit_job_url.test(currentURL)) { + event.preventDefault(); console.log('Saving the job'); let form = document.querySelector("button[form='job-form']"); form.click(); } - // Trigger a custom event named "ctrl-s-pressed" - // document.dispatchEvent(new Event('ctrl-s-pressed')); } }); diff --git a/lib/lightning_web/live/job_live/job_builder.ex b/lib/lightning_web/live/job_live/job_builder.ex index d5f6d1c962..cb7f23d4fa 100644 --- a/lib/lightning_web/live/job_live/job_builder.ex +++ b/lib/lightning_web/live/job_live/job_builder.ex @@ -224,18 +224,11 @@ defmodule LightningWeb.JobLive.JobBuilder do
- - - <%!-- <%= live_patch("Close", + <%= live_patch("Close", class: "inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-secondary-700 hover:bg-secondary-800 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-secondary-500", to: @return_to - ) %> --%> + ) %> params}, socket) do - send( - self(), - {:job_saved, false} - ) - {:noreply, socket |> assign_changeset_and_params(params)} end @@ -388,11 +376,6 @@ defmodule LightningWeb.JobLive.JobBuilder do do: "Job created successfully", else: "Job updated successfully" - send( - self(), - {:job_saved, true} - ) - socket |> put_flash(:info, message) |> push_patch(to: socket.assigns.return_to <> "/j/#{job.id}") @@ -439,11 +422,6 @@ defmodule LightningWeb.JobLive.JobBuilder do @impl true def mount(socket) do - send( - self(), - {:job_saved, true} - ) - {:ok, socket |> assign(follow_run_id: nil)} end diff --git a/lib/lightning_web/live/workflow_live.ex b/lib/lightning_web/live/workflow_live.ex index 526fabf4a4..c61f2bda1e 100644 --- a/lib/lightning_web/live/workflow_live.ex +++ b/lib/lightning_web/live/workflow_live.ex @@ -262,18 +262,6 @@ defmodule LightningWeb.WorkflowLive do end end - def handle_event("close_job_builder", _, socket) do - if !socket.assigns.saved do - {:noreply, socket |> put_flash(:error, "Not saved")} - else - {:noreply, socket} - # socket - # |> push_patch( - # to: socket.assigns.return_to <> "/j/#{socket.assigns.job.id}" - # ) - end - end - @impl true def handle_event("copied_to_clipboard", _, socket) do {:noreply, @@ -354,13 +342,6 @@ defmodule LightningWeb.WorkflowLive do )} end - def handle_info( - {:job_saved, saved}, - socket - ) do - {:noreply, socket |> assign(saved: saved)} - end - # A generic handler for forwarding updates from PubSub @impl true def handle_info({:forward, mod, opts}, socket) do