From cf0a4c472f1efc97f9bca914d9317dffad7eb9d4 Mon Sep 17 00:00:00 2001 From: Miguel Serrano Date: Thu, 31 Jul 2025 10:42:19 +0200 Subject: [PATCH] [web] Group audit log link in settings (#27390) * [web] Group audit log link in settings Adds a link to access the `/manage/groups/:subscription_id/audit-logs` endpoint * [web] Add `group-audit-logs` split test for gradual rollout GitOrigin-RevId: 60d6c9917ca54ff5e228996e7454a901f0f3b9ca --- .../Subscription/SubscriptionController.js | 4 +++ .../web/frontend/extracted-translations.json | 2 ++ .../dashboard/managed-group-subscriptions.tsx | 12 +++++++++ services/web/locales/en.json | 2 ++ .../managed-group-subscriptions.test.tsx | 27 ++++++++++++------- 5 files changed, 37 insertions(+), 10 deletions(-) diff --git a/services/web/app/src/Features/Subscription/SubscriptionController.js b/services/web/app/src/Features/Subscription/SubscriptionController.js index def0abf7ac..6c2ad53a92 100644 --- a/services/web/app/src/Features/Subscription/SubscriptionController.js +++ b/services/web/app/src/Features/Subscription/SubscriptionController.js @@ -177,6 +177,10 @@ async function userSubscriptionPage(req, res) { premiumSource: aiAssistViaWritefullSource, } = await UserGetter.promises.getWritefullData(user._id) + // populate splitTestVariants in locals with a value for the split test, so + // it's available in meta ol-splitTestVariants in the browser + await SplitTestHandler.promises.getAssignment(req, res, 'group-audit-logs') + const data = { title: 'your_subscription', plans: plansData?.plans, diff --git a/services/web/frontend/extracted-translations.json b/services/web/frontend/extracted-translations.json index 982176c2e9..af65723998 100644 --- a/services/web/frontend/extracted-translations.json +++ b/services/web/frontend/extracted-translations.json @@ -161,6 +161,7 @@ "ask_repo_owner_to_reconnect": "", "ask_repo_owner_to_renew_overleaf_subscription": "", "at_most_x_libraries_can_be_selected": "", + "audit_logs": "", "auto_close_brackets": "", "auto_compile": "", "auto_complete": "", @@ -2050,6 +2051,7 @@ "verify_email_address_before_enabling_managed_users": "", "view": "", "view_all": "", + "view_audit_logs_group_subtext": "", "view_billing_details": "", "view_code": "", "view_configuration": "", diff --git a/services/web/frontend/js/features/subscription/components/dashboard/managed-group-subscriptions.tsx b/services/web/frontend/js/features/subscription/components/dashboard/managed-group-subscriptions.tsx index a79cac06ac..0ad9274af6 100644 --- a/services/web/frontend/js/features/subscription/components/dashboard/managed-group-subscriptions.tsx +++ b/services/web/frontend/js/features/subscription/components/dashboard/managed-group-subscriptions.tsx @@ -97,6 +97,10 @@ export default function ManagedGroupSubscriptions() { getMeta('ol-groupSettingsAdvertisedFor') || [] const groupSettingsEnabledFor = getMeta('ol-groupSettingsEnabledFor') || [] + const splitTestVariants = getMeta('ol-splitTestVariants') + const displayAuditLogsLink = + splitTestVariants?.['group-audit-logs'] === 'active' + return ( <> {managedGroupSubscriptions.map(subscription => { @@ -125,6 +129,14 @@ export default function ManagedGroupSubscriptions() { {groupSettingsAdvertisedFor?.includes(subscription._id) && ( )} + {displayAuditLogsLink && ( + + )} __repoOwnerEmail__) to reconnect the project.", "ask_repo_owner_to_renew_overleaf_subscription": "Ask the GitHub repository owner (<0>__repoOwnerEmail__) to renew their __appName__ subscription and reconnect the project.", "at_most_x_libraries_can_be_selected": "At most __maxCount__ libraries can be selected", + "audit_logs": "Audit logs", "august": "August", "author": "Author", "auto_close_brackets": "Auto-close brackets", @@ -2594,6 +2595,7 @@ "verify_email_address_before_enabling_managed_users": "You need to verify your email address before enabling managed users.", "view": "View", "view_all": "View all", + "view_audit_logs_group_subtext": "View and download audit logs for your group subscription", "view_billing_details": "View billing details", "view_code": "View code", "view_configuration": "View configuration", diff --git a/services/web/test/frontend/features/subscription/components/dashboard/managed-group-subscriptions.test.tsx b/services/web/test/frontend/features/subscription/components/dashboard/managed-group-subscriptions.test.tsx index b4e701e5b5..76a334e410 100644 --- a/services/web/test/frontend/features/subscription/components/dashboard/managed-group-subscriptions.test.tsx +++ b/services/web/test/frontend/features/subscription/components/dashboard/managed-group-subscriptions.test.tsx @@ -97,6 +97,10 @@ describe('', function () { value: managedGroupSubscriptions, }, { name: 'ol-usersEmail', value: 'admin@example.com' }, + { + name: 'ol-splitTestVariants', + value: { 'group-audit-logs': 'active' }, + }, ], }) @@ -124,28 +128,31 @@ describe('', function () { expect(links[2].getAttribute('href')).to.equal( '/manage/groups/bcd567/managers' ) - expect(links[3].getAttribute('href')).to.equal('/metrics/groups/bcd567') - expect(links[5].getAttribute('href')).to.equal( + expect(links[3].getAttribute('href')).to.equal( + '/manage/groups/bcd567/audit-logs' + ) + expect(links[4].getAttribute('href')).to.equal('/metrics/groups/bcd567') + expect(links[6].getAttribute('href')).to.equal( '/manage/groups/def456/members' ) - expect(links[6].getAttribute('href')).to.equal( + expect(links[7].getAttribute('href')).to.equal( '/manage/groups/def456/managers' ) - expect(links[7].getAttribute('href')).to.equal('/metrics/groups/def456') - expect(links[9].getAttribute('href')).to.equal( + expect(links[9].getAttribute('href')).to.equal('/metrics/groups/def456') + expect(links[11].getAttribute('href')).to.equal( '/manage/groups/group2abc/members' ) - expect(links[10].getAttribute('href')).to.equal( + expect(links[12].getAttribute('href')).to.equal( '/manage/groups/group2abc/managers' ) - expect(links[11].getAttribute('href')).to.equal('/metrics/groups/group2abc') - expect(links[13].getAttribute('href')).to.equal( + expect(links[14].getAttribute('href')).to.equal('/metrics/groups/group2abc') + expect(links[16].getAttribute('href')).to.equal( '/manage/groups/group123abc/members' ) - expect(links[14].getAttribute('href')).to.equal( + expect(links[17].getAttribute('href')).to.equal( '/manage/groups/group123abc/managers' ) - expect(links[15].getAttribute('href')).to.equal( + expect(links[19].getAttribute('href')).to.equal( '/metrics/groups/group123abc' ) })