Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
leandrocp committed Oct 19, 2023
1 parent 1b6fdb3 commit 0c05dc7
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
15 changes: 6 additions & 9 deletions lib/beacon/live_admin/live/page_editor_live/form_component.ex
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
defmodule Beacon.LiveAdmin.PageEditorLive.FormComponent do
require IEx
require Logger
use Beacon.LiveAdmin.Web, :live_component

alias Beacon.LiveAdmin.Config
alias Beacon.LiveAdmin.Content
alias Beacon.LiveAdmin.WebAPI

@impl true
def update(
%{site: site, page: page, visual_mode: visual_mode, components: components} = assigns,
socket
) do
def update(%{site: site, page: page} = assigns, socket) do
# FIXME: new pages
page = Map.put_new(page, :path, "/")

changeset = Content.change_page(site, page)
layouts = Content.list_layouts(site)
%{data: builder_page} = BeaconWeb.API.PageJSON.show(%{page: page})
%{data: builder_page} = WebAPI.Page.show(site, page)

{:ok,
socket
Expand All @@ -23,8 +22,6 @@ defmodule Beacon.LiveAdmin.PageEditorLive.FormComponent do
|> assign(:language, language(page.format))
|> assign(:template, page.template)
|> assign(:changed_template, page.template)
|> assign(:visual_mode, visual_mode)
|> assign(:components, components)
|> assign(:builder_page, builder_page)
|> assign_extra_fields(changeset)}
end
Expand Down
5 changes: 2 additions & 3 deletions lib/beacon/live_admin/page_builder.ex
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ defmodule Beacon.LiveAdmin.PageBuilder do
defmacro __using__(opts) do
quote location: :keep, bind_quoted: [opts: opts] do
use Phoenix.Component
import Beacon.LiveAdmin.AdminComponents
import Beacon.LiveAdmin.Components, only: [template_error: 1]

import Beacon.LiveAdmin.Router,
only: [
Expand All @@ -70,7 +68,8 @@ defmodule Beacon.LiveAdmin.PageBuilder do
]

import Phoenix.LiveView

import Beacon.LiveAdmin.AdminComponents
import Beacon.LiveAdmin.Components, only: [template_error: 1]
import LiveSvelte

alias Phoenix.LiveView.JS
Expand Down
11 changes: 11 additions & 0 deletions lib/beacon/live_admin/web_api.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
defmodule Beacon.LiveAdmin.WebAPI.Page do
@moduledoc """
Calls Beacon Web API through the cluster.
"""

import Beacon.LiveAdmin.Cluster, only: [call: 4]

def show(site, page) do
call(site, BeaconWeb.API.PageJSON, :show, [%{page: page}])
end
end
3 changes: 1 addition & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,12 @@ defmodule Beacon.LiveAdmin.MixProject do
{:phoenix_live_reload, "~> 1.2", only: :dev},
{:phoenix_live_view, "~> 0.19"},
{:floki, ">= 0.30.0", only: :test},
# {:esbuild, "~> 0.5", only: :dev},
{:tailwind, "~> 0.2"},
{:gettext, "~> 0.20"},
{:jason, "~> 1.0"},
{:plug_cowboy, "~> 2.5"},
{:dialyxir, "~> 1.2", only: :dev, runtime: false},
{:live_svelte, "~> 0.12.0"}
{:live_svelte, "~> 0.12"}
]
end

Expand Down

0 comments on commit 0c05dc7

Please sign in to comment.