add: ability to convert existing communities into forums

This commit is contained in:
trisua 2025-08-05 22:36:25 -04:00
parent 3958d5eaef
commit 2407e6b213
8 changed files with 125 additions and 24 deletions

View file

@ -37,14 +37,14 @@
(text "{{ icon \"rss\" }}")
(span
(text "{{ text \"communities:tab.channels\" }}")))
(text "{%- endif %} {% if community.is_forum -%}")
(text "{%- endif %}")
(a
("href" "#/topics")
("data-tab-button" "topics")
(icon (text "list"))
(span
(str (text "communities:tab.topics"))))
(text "{%- endif %} {% if can_manage_emojis -%}")
(text "{% if can_manage_emojis -%}")
(a
("href" "#/emojis")
("data-tab-button" "emojis")
@ -825,6 +825,42 @@
]);
});
}"))
(text "{% else %}")
(div
("class" "card lowered w_full hidden flex flex_col gap_2")
("data-tab" "topics")
(p (text "You can only manage topics for forum communities. You can convert this community into a forum, but you will not be able to go back."))
(p (text "This will permanently change your community. Currently existing posts will no longer be visible on the community."))
(button
("onclick" "convert_to_forum()")
(icon (text "circle-fading-arrow-up"))
(text "Switch to forum")))
(script
(text "globalThis.convert_to_forum = async () => {
if (
!(await trigger(\"atto::confirm\", [
\"Are you sure you would like to do this? It cannot be undone.\",
]))
) {
return;
}
fetch(\"/api/v1/communities/{{ community.id }}/is_forum\", {
method: \"POST\",
})
.then((res) => res.json())
.then((res) => {
trigger(\"atto::toast\", [
res.ok ? \"success\" : \"error\",
res.message,
]);
if (res.ok) {
window.location.reload();
}
});
}"))
(text "{%- endif %}"))
(script