A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.
fix(admin): broken report controls (#12)
hampus-fluxeredb36f406df3
diff --git a/fluxer_admin/src/fluxer_admin/components/layout.gleam b/fluxer_admin/src/fluxer_admin/components/layout.gleamindex a835ba25a..5ed9946cc 100644--- a/fluxer_admin/src/fluxer_admin/components/layout.gleam+++ b/fluxer_admin/src/fluxer_admin/components/layout.gleam@@ -434,9 +434,7 @@ fn sidebar_interaction_script() {)}-fn admin_acls_from(- current_admin: Option(UserLookupResult),-) -> List(String) {+fn admin_acls_from(current_admin: Option(UserLookupResult)) -> List(String) {case current_admin {option.Some(admin) -> admin.aclsoption.None -> []diff --git a/fluxer_admin/src/fluxer_admin/pages/report_detail_page.gleam b/fluxer_admin/src/fluxer_admin/pages/report_detail_page.gleamindex 869ef725f..2ab7d0d42 100644--- a/fluxer_admin/src/fluxer_admin/pages/report_detail_page.gleam+++ b/fluxer_admin/src/fluxer_admin/pages/report_detail_page.gleam@@ -21,7 +21,7 @@ import fluxer_admin/components/flashimport fluxer_admin/components/layoutimport fluxer_admin/components/message_listimport fluxer_admin/components/ui-import fluxer_admin/web.{type Context, type Session, href}+import fluxer_admin/web.{type Context, type Session, action, href}import gleam/listimport gleam/optionimport gleam/string@@ -378,19 +378,27 @@ fn render_actions_card(ctx: Context, report: reports.Report) {h.div([a.class("space-y-3")], [case report.status {0 ->- h.button(+ h.form([- a.class(- "w-full px-4 py-2 bg-neutral-900 text-white rounded-lg label hover:bg-neutral-800 transition-colors",- ),+ a.method("post"),+ action(ctx, "/reports/" <> report.report_id <> "/resolve"),a.attribute(- "onclick",- "if(confirm('Resolve this report?')) { fetch('/reports/"- <> report.report_id- <> "/resolve', { method: 'POST', headers: { 'Content-Type': 'application/json' } }).then(() => location.reload()) }",+ "onsubmit",+ "if(!confirm('Resolve this report?')) return false;",+ ),+ ],+ [+ h.input([a.type_("hidden"), a.name("public_comment"), a.value("")]),+ h.button(+ [+ a.type_("submit"),+ a.class(+ "w-full px-4 py-2 bg-neutral-900 text-white rounded-lg label hover:bg-neutral-800 transition-colors",+ ),+ ],+ [element.text("Resolve Report")],),],- [element.text("Resolve Report")],)_ -> element.none()},diff --git a/fluxer_admin/src/fluxer_admin/pages/reports_page.gleam b/fluxer_admin/src/fluxer_admin/pages/reports_page.gleamindex 84611f7ef..bd407d084 100644--- a/fluxer_admin/src/fluxer_admin/pages/reports_page.gleam+++ b/fluxer_admin/src/fluxer_admin/pages/reports_page.gleam@@ -21,7 +21,7 @@ import fluxer_admin/components/date_timeimport fluxer_admin/components/flashimport fluxer_admin/components/layoutimport fluxer_admin/components/ui-import fluxer_admin/web.{type Context, type Session, href}+import fluxer_admin/web.{type Context, type Session, action, href}import gleam/intimport gleam/listimport gleam/option@@ -756,7 +756,7 @@ fn render_actions_cell(ctx: Context, report: reports.SearchReportResult) {h.form([a.method("post"),- a.attribute("action", "/reports/" <> report.report_id <> "/resolve"),+ action(ctx, "/reports/" <> report.report_id <> "/resolve"),a.attribute("data-report-action", "resolve"),a.attribute("data-report-id", report.report_id),a.attribute("data-confirm", "Resolve this report?"),@@ -1073,7 +1073,14 @@ fn reports_script() -> element.Element(a) {function markResolved(reportId) {const pill = table.querySelector('[data-status-pill=\"' + reportId + '\"]');- if (pill) pill.textContent = 'Resolved';+ if (pill) {+ const inner = pill.querySelector('span');+ if (inner) {+ inner.textContent = 'Resolved';+ inner.classList.remove('bg-yellow-100', 'text-yellow-700');+ inner.classList.add('bg-green-100', 'text-green-700');+ }+ }const form = table.querySelector('form[data-report-id=\"' + reportId + '\"]');if (form) {form.remove();diff --git a/fluxer_admin/src/fluxer_admin/pages/strange_place_page.gleam b/fluxer_admin/src/fluxer_admin/pages/strange_place_page.gleamindex 7e3901047..4b25a12b9 100644--- a/fluxer_admin/src/fluxer_admin/pages/strange_place_page.gleam+++ b/fluxer_admin/src/fluxer_admin/pages/strange_place_page.gleam@@ -37,22 +37,16 @@ pub fn view(ui.heading_page("You find yourself in a strange place..."),ui.card(ui.PaddingMedium, [ui.stack("4", [- h.p(- [a.class("text-neutral-700 leading-relaxed")],- [- element.text(- "Your account is authenticated, but no admin tabs are available for your current permissions.",- ),- ],- ),- h.p(- [a.class("text-neutral-600 leading-relaxed")],- [- element.text(- "If you believe this is a mistake, reach out to an administrator to request the necessary access.",- ),- ],- ),+ h.p([a.class("text-neutral-700 leading-relaxed")], [+ element.text(+ "Your account is authenticated, but no admin tabs are available for your current permissions.",+ ),+ ]),+ h.p([a.class("text-neutral-600 leading-relaxed")], [+ element.text(+ "If you believe this is a mistake, reach out to an administrator to request the necessary access.",+ ),+ ]),]),]),])diff --git a/fluxer_admin/src/fluxer_admin/router.gleam b/fluxer_admin/src/fluxer_admin/router.gleamindex 4fe9929f6..adbbe5c39 100644--- a/fluxer_admin/src/fluxer_admin/router.gleam+++ b/fluxer_admin/src/fluxer_admin/router.gleam@@ -23,6 +23,7 @@ import fluxer_admin/api/usersimport fluxer_admin/components/errorsimport fluxer_admin/components/flashimport fluxer_admin/constants+import fluxer_admin/navigationimport fluxer_admin/oauth2import fluxer_admin/pages/archives_pageimport fluxer_admin/pages/asset_purge_page@@ -55,7 +56,6 @@ import fluxer_admin/pages/users_pageimport fluxer_admin/pages/voice_regions_pageimport fluxer_admin/pages/voice_servers_pageimport fluxer_admin/session-import fluxer_admin/navigationimport fluxer_admin/web.{type Context, prepend_base_path}import gleam/http.{Get, Post}import gleam/http/request@@ -238,7 +238,8 @@ pub fn handle_request(req: Request, ctx: Context) -> Response {case wisp.get_cookie(req, "session", wisp.Signed) {Ok(cookie) ->case session.get(ctx, cookie) {- Ok(_session) -> wisp.redirect(prepend_base_path(ctx, "/dashboard"))+ Ok(_session) ->+ wisp.redirect(prepend_base_path(ctx, "/dashboard"))Error(_) -> login_page.view(ctx, error_msg)}Error(_) -> login_page.view(ctx, error_msg)diff --git a/fluxer_api/src/middleware/AuditLogMiddleware.ts b/fluxer_api/src/middleware/AuditLogMiddleware.tsindex b4d892101..d79608b3b 100644--- a/fluxer_api/src/middleware/AuditLogMiddleware.ts+++ b/fluxer_api/src/middleware/AuditLogMiddleware.ts@@ -34,6 +34,8 @@ export const AuditLogMiddleware = createMiddleware<HonoEnv>(async (ctx, next) =>);}ctx.set('auditLogReason', result.data);+ } else {+ ctx.set('auditLogReason', null);}await next();