From e9c7b3f054ea8ee71697eff7b43b0afbd4e69105 Mon Sep 17 00:00:00 2001 From: Ben Griffiths Date: Thu, 19 Oct 2023 11:57:23 +0100 Subject: [PATCH] Make the audit log marginally easier to look at --- .../adminAuditLog/components/AuditLog.js | 36 ++++++++++++------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/src/plugins/adminAuditLog/components/AuditLog.js b/src/plugins/adminAuditLog/components/AuditLog.js index ad34157..6c54757 100644 --- a/src/plugins/adminAuditLog/components/AuditLog.js +++ b/src/plugins/adminAuditLog/components/AuditLog.js @@ -20,7 +20,7 @@ import { useTranslation } from "react-i18next"; import { auditLog } from "@ractf/api"; import { - PageHead, Card, ModalSpinner + PageHead, Card, ModalSpinner, TreeWrap, TreeValue, Tree } from "@ractf/ui-kit"; @@ -39,6 +39,19 @@ export default () => { loadItems(); }, []); + const RecursiveObjectTree = ({obj}) => + Object.entries(obj).map(([k, v]) => + typeof(v) === "object" ? + + + : + + ); + + const ObjectTree = ({obj}) => + + ; + return <> @@ -61,26 +74,25 @@ export default () => { } else if (item.action === "update_model") { return - {details._username} updated the following fields on {details.model_name} with ID {details.model_id}:
- {Object.entries(details.updated_fields).map(([field_name, values]) => - <>{field_name}: from {String(values.old)} to {String(values.new)}.
) - } + {details._username} updated the following fields on a + {details.model_name} with ID {details.model_id}:
+ +
; } else if (item.action === "create_model") { return {details._username} created a {details.model_name}:
- {Object.entries(details.model_fields).map(([field_name, value]) => - <>{field_name}: {String(value)}.
) - } + +
; } else if (item.action === "destroy_model") { return - {details._username} deleted {details.model_name} with ID {details.model_id} which had the following fields:
- {Object.entries(details.model_fields).map(([field_name, value]) => - <>{field_name}: {String(value)}.
) - } + {details._username} deleted a {details.model_name} + with ID {details.model_id} which had the following fields:
+ +
; // ...Otherwise, fall back on translations.