Also list frontends that are not in the config file

This commit is contained in:
Ekaterina Vaartis 2023-03-30 11:16:40 +03:00
parent d3b27d45a9
commit 3037d2780c

View File

@ -18,15 +18,24 @@ defmodule Pleroma.Web.AdminAPI.FrontendController do
def index(conn, _params) do def index(conn, _params) do
installed = installed() installed = installed()
# FIrst get frontends from config,
# then add frontends that are installed but not in the config
frontends = frontends =
[:frontends, :available] Config.get([:frontends, :available], [])
|> Config.get([])
|> Enum.map(fn {name, desc} -> |> Enum.map(fn {name, desc} ->
desc desc
|> Map.put("installed", name in installed) |> Map.put("installed", name in installed)
|> Map.put("installed_refs", installed_refs(name)) |> Map.put("installed_refs", installed_refs(name))
end) end)
frontends =
frontends ++
(installed
|> Enum.filter(fn n -> not Enum.any?(frontends, fn f -> f["name"] == n end) end)
|> Enum.map(fn name ->
%{"name" => name, "installed" => true, "installed_refs" => installed_refs(name)}
end))
render(conn, "index.json", frontends: frontends) render(conn, "index.json", frontends: frontends)
end end