summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEkaterina Vaartis <vaartis@kotobank.ch>2023-03-29 23:18:44 +0300
committerEkaterina Vaartis <vaartis@kotobank.ch>2023-03-29 23:23:06 +0300
commitd3b27d45a9115c04d4e469d1a9dc372ff8576d52 (patch)
treed2714ef5a829e1b2e25dd598057bf5744c04c832 /lib
parent4f7c11b2814f22fd7f28832462569a78faf223b5 (diff)
downloadpleroma-d3b27d45a9115c04d4e469d1a9dc372ff8576d52.tar.gz
pleroma-d3b27d45a9115c04d4e469d1a9dc372ff8576d52.zip
List installed frontend refs in admin API
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/web/admin_api/controllers/frontend_controller.ex12
-rw-r--r--lib/pleroma/web/admin_api/views/frontend_view.ex3
-rw-r--r--lib/pleroma/web/api_spec/operations/admin/frontend_operation.ex3
3 files changed, 15 insertions, 3 deletions
diff --git a/lib/pleroma/web/admin_api/controllers/frontend_controller.ex b/lib/pleroma/web/admin_api/controllers/frontend_controller.ex
index b4dbb82fe..145c1fa4a 100644
--- a/lib/pleroma/web/admin_api/controllers/frontend_controller.ex
+++ b/lib/pleroma/web/admin_api/controllers/frontend_controller.ex
@@ -22,7 +22,9 @@ defmodule Pleroma.Web.AdminAPI.FrontendController do
[:frontends, :available]
|> Config.get([])
|> Enum.map(fn {name, desc} ->
- Map.put(desc, "installed", name in installed)
+ desc
+ |> Map.put("installed", name in installed)
+ |> Map.put("installed_refs", installed_refs(name))
end)
render(conn, "index.json", frontends: frontends)
@@ -43,4 +45,12 @@ defmodule Pleroma.Web.AdminAPI.FrontendController do
[]
end
end
+
+ def installed_refs(name) do
+ if name in installed() do
+ File.ls!(Path.join(Pleroma.Frontend.dir(), name))
+ else
+ []
+ end
+ end
end
diff --git a/lib/pleroma/web/admin_api/views/frontend_view.ex b/lib/pleroma/web/admin_api/views/frontend_view.ex
index 0ca3d67cb..ae4016581 100644
--- a/lib/pleroma/web/admin_api/views/frontend_view.ex
+++ b/lib/pleroma/web/admin_api/views/frontend_view.ex
@@ -15,7 +15,8 @@ defmodule Pleroma.Web.AdminAPI.FrontendView do
git: frontend["git"],
build_url: frontend["build_url"],
ref: frontend["ref"],
- installed: frontend["installed"]
+ installed: frontend["installed"],
+ installed_refs: frontend["installed_refs"]
}
end
end
diff --git a/lib/pleroma/web/api_spec/operations/admin/frontend_operation.ex b/lib/pleroma/web/api_spec/operations/admin/frontend_operation.ex
index 4bfe5ac5a..89b1c474c 100644
--- a/lib/pleroma/web/api_spec/operations/admin/frontend_operation.ex
+++ b/lib/pleroma/web/api_spec/operations/admin/frontend_operation.ex
@@ -52,7 +52,8 @@ defmodule Pleroma.Web.ApiSpec.Admin.FrontendOperation do
git: %Schema{type: :string, format: :uri, nullable: true},
build_url: %Schema{type: :string, format: :uri, nullable: true},
ref: %Schema{type: :string},
- installed: %Schema{type: :boolean}
+ installed: %Schema{type: :boolean},
+ installed_refs: %Schema{type: :array, items: %Schema{type: :string}}
}
}
}