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

@ -311,7 +311,7 @@
(div ("id" "tokens") ("style" "display: contents"))
(div
("class" "flex justify_between")
("class" "flex justify_right gap_2")
(a
("href" "/auth/login")
("class" "button")
@ -323,7 +323,8 @@
("class" "lowered")
("onclick" "document.getElementById('tokens_dialog').close()")
("type" "button")
(icon (text "check")))))))
(icon (text "check"))
(str (text "dialog:action.okay")))))))
; user scripts
(text "{%- endif %} {% if user and use_user_theme -%} {{ components::theme(user=user, theme_preference=user.settings.theme_preference) }}

View file

@ -37,7 +37,7 @@
("name" "is_forum")
("class" "w_content"))
(span
(text "Is forum")))
(text "Make this a forum community")))
(button
(text "{{ text \"communities:action.create\" }}"))))
(text "{% if list|length >= 4 -%} {{ components::supporter_ad(body=\"Become a supporter to create up to 10 communities!\") }} {%- endif %} {%- endif %}")

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