Merge branch 'list-installed-frontends' into 'develop'
List installed frontend refs in admin API See merge request pleroma/pleroma!3862
This commit is contained in:
commit
248f914e6e
|
@ -1585,6 +1585,7 @@ Returns the content of the document
|
||||||
"build_url": "https://git.pleroma.social/pleroma/fedi-fe/-/jobs/artifacts/${ref}/download?job=build",
|
"build_url": "https://git.pleroma.social/pleroma/fedi-fe/-/jobs/artifacts/${ref}/download?job=build",
|
||||||
"git": "https://git.pleroma.social/pleroma/fedi-fe",
|
"git": "https://git.pleroma.social/pleroma/fedi-fe",
|
||||||
"installed": true,
|
"installed": true,
|
||||||
|
"installed_refs": ["master"],
|
||||||
"name": "fedi-fe",
|
"name": "fedi-fe",
|
||||||
"ref": "master"
|
"ref": "master"
|
||||||
},
|
},
|
||||||
|
@ -1592,6 +1593,7 @@ Returns the content of the document
|
||||||
"build_url": "https://git.pleroma.social/lambadalambda/kenoma/-/jobs/artifacts/${ref}/download?job=build",
|
"build_url": "https://git.pleroma.social/lambadalambda/kenoma/-/jobs/artifacts/${ref}/download?job=build",
|
||||||
"git": "https://git.pleroma.social/lambadalambda/kenoma",
|
"git": "https://git.pleroma.social/lambadalambda/kenoma",
|
||||||
"installed": false,
|
"installed": false,
|
||||||
|
"installed_refs": [],
|
||||||
"name": "kenoma",
|
"name": "kenoma",
|
||||||
"ref": "master"
|
"ref": "master"
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,13 +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} ->
|
||||||
Map.put(desc, "installed", name in installed)
|
desc
|
||||||
|
|> Map.put("installed", name in installed)
|
||||||
|
|> 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
|
||||||
|
|
||||||
|
@ -43,4 +54,12 @@ defp installed do
|
||||||
[]
|
[]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def installed_refs(name) do
|
||||||
|
if name in installed() do
|
||||||
|
File.ls!(Path.join(Pleroma.Frontend.dir(), name))
|
||||||
|
else
|
||||||
|
[]
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,7 +15,8 @@ def render("show.json", %{frontend: frontend}) do
|
||||||
git: frontend["git"],
|
git: frontend["git"],
|
||||||
build_url: frontend["build_url"],
|
build_url: frontend["build_url"],
|
||||||
ref: frontend["ref"],
|
ref: frontend["ref"],
|
||||||
installed: frontend["installed"]
|
installed: frontend["installed"],
|
||||||
|
installed_refs: frontend["installed_refs"]
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -51,8 +51,9 @@ defp list_of_frontends do
|
||||||
name: %Schema{type: :string},
|
name: %Schema{type: :string},
|
||||||
git: %Schema{type: :string, format: :uri, nullable: true},
|
git: %Schema{type: :string, format: :uri, nullable: true},
|
||||||
build_url: %Schema{type: :string, format: :uri, nullable: true},
|
build_url: %Schema{type: :string, format: :uri, nullable: true},
|
||||||
ref: %Schema{type: :string},
|
ref: %Schema{type: :string, nullable: true},
|
||||||
installed: %Schema{type: :boolean}
|
installed: %Schema{type: :boolean},
|
||||||
|
installed_refs: %Schema{type: :array, items: %Schema{type: :string}}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,6 +89,7 @@ test "from available frontends", %{conn: conn} do
|
||||||
"build_url" => "http://gensokyo.2hu/builds/${ref}",
|
"build_url" => "http://gensokyo.2hu/builds/${ref}",
|
||||||
"git" => nil,
|
"git" => nil,
|
||||||
"installed" => true,
|
"installed" => true,
|
||||||
|
"installed_refs" => ["fantasy"],
|
||||||
"name" => "pleroma",
|
"name" => "pleroma",
|
||||||
"ref" => "fantasy"
|
"ref" => "fantasy"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue