Browse Source

List available frontends also when no static/frontends folder is present yet

* To see what front ends are installed, it ls static/frontends. When this folder doesn't exists yet, it will return an empty array.
* Installing still works since the folder is created during installation already

Backport of: https://git.pleroma.social/pleroma/pleroma/-/merge_requests/3510
stable^2
Ilja Haelwenn (lanodan) Monnier 2 years ago
parent
commit
53b0dd4ecc
No known key found for this signature in database GPG Key ID: D5B7A8E43C997DEE
3 changed files with 22 additions and 1 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +7
    -1
      lib/pleroma/web/admin_api/controllers/frontend_controller.ex
  3. +14
    -0
      test/pleroma/web/admin_api/controllers/frontend_controller_test.exs

+ 1
- 0
CHANGELOG.md View File

@@ -27,6 +27,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- AdminAPI: Fix rendering reports containing a `nil` object
- Mastodon API: Activity Search fallbacks on status fetching after a DB Timeout/Error
- Mastodon API: Fix crash in Streamer related to reblogging
- AdminAPI: List available frontends when `static/frontends` folder is missing

## 2.4.0 - 2021-08-08



+ 7
- 1
lib/pleroma/web/admin_api/controllers/frontend_controller.ex View File

@@ -35,6 +35,12 @@ defmodule Pleroma.Web.AdminAPI.FrontendController do
end

defp installed do
File.ls!(Pleroma.Frontend.dir())
frontend_directory = Pleroma.Frontend.dir()

if File.exists?(frontend_directory) do
File.ls!(frontend_directory)
else
[]
end
end
end

+ 14
- 0
test/pleroma/web/admin_api/controllers/frontend_controller_test.exs View File

@@ -42,6 +42,20 @@ defmodule Pleroma.Web.AdminAPI.FrontendControllerTest do

refute Enum.any?(response, fn frontend -> frontend["installed"] == true end)
end

test "it lists available frontends when no frontend folder was created yet", %{conn: conn} do
File.rm_rf(@dir)

response =
conn
|> get("/api/pleroma/admin/frontends")
|> json_response_and_validate_schema(:ok)

assert Enum.map(response, & &1["name"]) ==
Enum.map(Config.get([:frontends, :available]), fn {_, map} -> map["name"] end)

refute Enum.any?(response, fn frontend -> frontend["installed"] == true end)
end
end

describe "POST /api/pleroma/admin/frontends/install" do


Loading…
Cancel
Save