Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make root layout configurable #2310

Merged
merged 4 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ and this project adheres to
### Added

### Changed
- Make root layout configurable
[#2310](https://github.com/OpenFn/lightning/pull/2310)

### Fixed
- Fix an intermittent bug when trying to intern Kafka offset reset policy.
Expand Down
3 changes: 3 additions & 0 deletions lib/lightning_web/components/layouts.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ defmodule LightningWeb.Layouts do
use LightningWeb, :html

embed_templates "layouts/*"

slot :header_tags
def root(assigns)
end
1 change: 1 addition & 0 deletions lib/lightning_web/components/layouts/root.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
src={Routes.static_path(@conn, "/assets/js/app.js")}
>
</script>
<%= render_slot(@header_tags) %>
</head>
<body class="h-full">
<div class="min-h-full">
Expand Down
9 changes: 9 additions & 0 deletions lib/lightning_web/live/workflow_live/edit.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1366,6 +1366,7 @@ defmodule LightningWeb.WorkflowLive.Edit do
|> assign_workflow(workflow, snapshot)
|> put_flash(:info, "Workflow saved")
|> push_patches_applied(initial_params)
|> maybe_push_workflow_created(workflow)
|> push_patch(
to: ~p"/projects/#{project.id}/w/#{workflow.id}?#{query_params}",
replace: true
Expand Down Expand Up @@ -2016,6 +2017,14 @@ defmodule LightningWeb.WorkflowLive.Edit do
|> push_event("patches-applied", %{patches: patches})
end

defp maybe_push_workflow_created(socket, workflow) do
if socket.assigns.live_action == :new do
push_event(socket, "workflow_created", %{id: workflow.id})
else
socket
end
end

# In situations where a new job is added, specifically by the WorkflowDiagram
# component, the job will not have an adaptor set. This function will set the
# adaptor to the current latest version of the adaptor, instead of the
Expand Down
8 changes: 7 additions & 1 deletion lib/lightning_web/router.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,17 @@ defmodule LightningWeb.Router do
alias ProjectLive
alias UserLive

@root_layout Application.compile_env(
:lightning,
:root_layout,
{LightningWeb.Layouts, :root}
)

pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_live_flash
plug :put_root_layout, {LightningWeb.Layouts, :root}
plug :put_root_layout, @root_layout
plug :protect_from_forgery
plug :put_secure_browser_headers
plug :fetch_current_user
Expand Down