From 941fd0f064fba47075ebc4e8913d3bf456a0653e Mon Sep 17 00:00:00 2001 From: Floatingghost Date: Sat, 11 May 2024 05:25:29 +0100 Subject: [PATCH] add basic rendering for option types --- config/description.exs | 3 +- .../admin_control/admin_control_controller.ex | 7 +- .../web/admin_control/admin_control_html.ex | 49 +++- .../admin_control_html/index.html.heex | 269 +----------------- priv/static/assets/app.css | 265 ++++------------- 5 files changed, 108 insertions(+), 485 deletions(-) diff --git a/config/description.exs b/config/description.exs index d9c90edd7..9f746859b 100644 --- a/config/description.exs +++ b/config/description.exs @@ -2525,6 +2525,7 @@ config :pleroma, :config_description, [ group: :pleroma, key: :emoji, type: :group, + description: "Configuration options related to emoji", children: [ %{ key: :shortcode_globs, @@ -2561,7 +2562,7 @@ config :pleroma, :config_description, [ key: :shared_pack_cache_seconds_per_file, label: "Shared pack cache s/file", type: :integer, - descpiption: + description: "When an emoji pack is shared, the archive is created and cached in memory" <> " for this amount of seconds multiplied by the number of files.", suggestions: [60] diff --git a/lib/pleroma/web/admin_control/admin_control_controller.ex b/lib/pleroma/web/admin_control/admin_control_controller.ex index b1027c326..b97ac5d1d 100644 --- a/lib/pleroma/web/admin_control/admin_control_controller.ex +++ b/lib/pleroma/web/admin_control/admin_control_controller.ex @@ -1,7 +1,7 @@ defmodule Pleroma.Web.AdminControl.AdminControlController do use Pleroma.Web, :controller - @descriptions Pleroma.Docs.JSON.compiled_descriptions() + plug(:put_root_layout, {Pleroma.Web.AdminControl.AdminControlView, :layout}) plug(:put_layout, false) @@ -9,8 +9,9 @@ defmodule Pleroma.Web.AdminControl.AdminControlController do defp label_for(%{label: label}), do: label defp label_for(_), do: "Unknown" + defp descriptions, do: Pleroma.Docs.JSON.compiled_descriptions() def config_headings do - @descriptions + descriptions() |> Enum.map(&label_for(&1)) |> Enum.sort() end @@ -19,7 +20,7 @@ defmodule Pleroma.Web.AdminControl.AdminControlController do IO.inspect(heading) possible_values = - @descriptions + descriptions() |> Enum.filter(fn section -> label_for(section) == heading end) possible_values diff --git a/lib/pleroma/web/admin_control/admin_control_html.ex b/lib/pleroma/web/admin_control/admin_control_html.ex index 9966f7ce8..9970dec60 100644 --- a/lib/pleroma/web/admin_control/admin_control_html.ex +++ b/lib/pleroma/web/admin_control/admin_control_html.ex @@ -1,5 +1,6 @@ defmodule Pleroma.Web.AdminControl.AdminControlView do use Pleroma.Web, :html + require Logger embed_templates "admin_control_html/*" @@ -29,33 +30,65 @@ defmodule Pleroma.Web.AdminControl.AdminControlView do """ end - def config_value(%{config_value: %{type: :integer} = value} = assigns) do + def config_value(%{config_value: %{type: :integer, key: key} = value} = assigns) do value = value_of(assigns) - assigns = assign(assigns, value: value) + assigns = assign(assigns, value: value, key: key) ~H""" -
-

<%= @config_value.label %>

-

<%= @config_value.description %>

- +
+ +
+ +
+

<%= @config_value.description %>

""" end - def config_value(%{config_value: %{type: :boolean} = value} = assigns) do + def config_value(%{config_value: %{type: :string, key: key} = value} = assigns) do + value = value_of(assigns) + assigns = assign(assigns, value: value, key: key) + ~H""" +
+ +
+ +
+

<%= @config_value.description %>

+
+ """ + end + + def config_value(%{config_value: %{type: :boolean, key: key} = value} = assigns) do value = value_of(assigns) == "true" + assigns = assign(assigns, value: value, key: key) + ~H""" +
+ + +
+ +

<%= @config_value.description %>

+ +
+
+ """ + end + def config_value(%{config_value: %{type: {:list, :string}} = value} = assigns) do + value = value_of(assigns) assigns = assign(assigns, value: value) ~H"""

<%= @config_value.label %>

<%= @config_value.description %> - + <%= @value %>
""" end def config_value(assigns) do + Logger.info("Cannot render config!") IO.inspect(assigns) ~H""" Cannot render diff --git a/lib/pleroma/web/admin_control/admin_control_html/index.html.heex b/lib/pleroma/web/admin_control/admin_control_html/index.html.heex index 1c2ffa64d..0ba0208ab 100644 --- a/lib/pleroma/web/admin_control/admin_control_html/index.html.heex +++ b/lib/pleroma/web/admin_control/admin_control_html/index.html.heex @@ -1,269 +1,6 @@
- - -