Skip to content

Commit

Permalink
undo work that belongs in #780
Browse files Browse the repository at this point in the history
  • Loading branch information
taylordowns2000 committed Apr 7, 2023
1 parent 5d27c8b commit 0a58e95
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 49 deletions.
7 changes: 1 addition & 6 deletions assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}
});

Expand Down
26 changes: 2 additions & 24 deletions lib/lightning_web/live/job_live/job_builder.ex
Original file line number Diff line number Diff line change
Expand Up @@ -224,18 +224,11 @@ defmodule LightningWeb.JobLive.JobBuilder do
</LightningWeb.Components.Common.panel_content>
</div>
<div class="flex-none sticky p-3 border-t">
<!-- BUTTONS -->
<Common.button
id="close_job_builder"
text="Close"
target={@myself}
phx-click="close_job_builder"
/>
<%!-- <%= 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
) %> --%>
) %>
<Form.submit_button
disabled={!(@changeset.valid? and @can_edit_job)}
phx-disable-with="Saving"
Expand Down Expand Up @@ -276,11 +269,6 @@ defmodule LightningWeb.JobLive.JobBuilder do

@impl true
def handle_event("validate", %{"job_form" => params}, socket) do
send(
self(),
{:job_saved, false}
)

{:noreply, socket |> assign_changeset_and_params(params)}
end

Expand Down Expand Up @@ -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}")
Expand Down Expand Up @@ -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

Expand Down
19 changes: 0 additions & 19 deletions lib/lightning_web/live/workflow_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0a58e95

Please sign in to comment.