From 39bc601826a7c684b733649c5efb8cc4d4d7fd66 Mon Sep 17 00:00:00 2001 From: Alexandre Bourdin Date: Mon, 26 Jun 2023 16:49:51 +0300 Subject: [PATCH] Merge pull request #13482 from overleaf/ab-group-settings-page [web] Group settings button and page enabled based on env var GitOrigin-RevId: 77574a3705b3f1301935b72010022af61f7fe552 --- .../Subscription/SubscriptionController.js | 6 ++++++ .../views/subscriptions/dashboard-react.pug | 1 + .../web/frontend/extracted-translations.json | 8 ++++++++ .../dashboard/managed-group-subscriptions.tsx | 11 +++++++++++ .../frontend/stylesheets/_style_includes.less | 1 + .../web/frontend/stylesheets/main-style.less | 1 + .../stylesheets/modules/managed-users.less | 19 +++++++++++++++++++ services/web/locales/en.json | 8 ++++++++ .../SubscriptionControllerTests.js | 8 ++++++++ 9 files changed, 63 insertions(+) create mode 100644 services/web/frontend/stylesheets/modules/managed-users.less diff --git a/services/web/app/src/Features/Subscription/SubscriptionController.js b/services/web/app/src/Features/Subscription/SubscriptionController.js index 7da3a2cebf..3c6122c180 100644 --- a/services/web/app/src/Features/Subscription/SubscriptionController.js +++ b/services/web/app/src/Features/Subscription/SubscriptionController.js @@ -24,6 +24,7 @@ const { expressify } = require('../../util/promises') const OError = require('@overleaf/o-error') const SplitTestHandler = require('../SplitTests/SplitTestHandler') const SubscriptionHelper = require('./SubscriptionHelper') +const ManagedUsersManager = require('../../../../modules/managed-users/app/src/ManagedUsersManager') const groupPlanModalOptions = Settings.groupPlanModalOptions const validGroupPlanModalOptions = { @@ -237,6 +238,10 @@ async function userSubscriptionPage(req, res) { const groupPlansDataForDash = formatGroupPlansDataForDash() + const groupSettingsEnabledFor = (managedGroupSubscriptions || []) + .map(sub => sub._id.toString()) + .filter(id => ManagedUsersManager.hasManagedUsersFeature(id)) + const data = { title: 'your_subscription', plans: plansData?.plans, @@ -252,6 +257,7 @@ async function userSubscriptionPage(req, res) { currentInstitutionsWithLicence, cancelButtonNewCopy, groupPlans: groupPlansDataForDash, + groupSettingsEnabledFor, } res.render('subscriptions/dashboard-react', data) } diff --git a/services/web/app/views/subscriptions/dashboard-react.pug b/services/web/app/views/subscriptions/dashboard-react.pug index 12ea293c41..bfce645c72 100644 --- a/services/web/app/views/subscriptions/dashboard-react.pug +++ b/services/web/app/views/subscriptions/dashboard-react.pug @@ -17,6 +17,7 @@ block append meta meta(name="ol-hasSubscription" data-type="boolean" content=hasSubscription) meta(name="ol-fromPlansPage" data-type="boolean" content=fromPlansPage) meta(name="ol-plans", data-type="json" content=plans) + meta(name="ol-groupSettingsEnabledFor", data-type="json" content=groupSettingsEnabledFor) if (personalSubscription && personalSubscription.recurly) meta(name="ol-recurlyApiKey" content=settings.apis.recurly.publicKey) meta(name="ol-recommendedCurrency" content=personalSubscription.recurly.currency) diff --git a/services/web/frontend/extracted-translations.json b/services/web/frontend/extracted-translations.json index 90abf207b9..02c96cdbad 100644 --- a/services/web/frontend/extracted-translations.json +++ b/services/web/frontend/extracted-translations.json @@ -10,6 +10,7 @@ "about_to_delete_tag": "", "about_to_delete_the_following_project": "", "about_to_delete_the_following_projects": "", + "about_to_enable_managed_users": "", "about_to_leave_projects": "", "about_to_trash_projects": "", "accepted_invite": "", @@ -261,6 +262,8 @@ "email_or_password_wrong_try_again": "", "emails_and_affiliations_explanation": "", "emails_and_affiliations_title": "", + "enable_managed_users": "", + "enabling": "", "end_of_document": "", "enter_image_url": "", "error": "", @@ -561,6 +564,8 @@ "manage_files_from_your_dropbox_folder": "", "manage_group_managers": "", "manage_group_members_subtext": "", + "manage_group_settings": "", + "manage_group_settings_subtext": "", "manage_institution_managers": "", "manage_labs_program_membership": "", "manage_managers_subtext": "", @@ -569,6 +574,8 @@ "manage_publisher_managers": "", "manage_sessions": "", "manage_subscription": "", + "managed_users": "", + "managed_users_explanation": "", "managers_management": "", "mark_as_resolved": "", "math_display": "", @@ -1076,6 +1083,7 @@ "vat": "", "vat_number": "", "view_all": "", + "view_group_members": "", "view_hub": "", "view_hub_subtext": "", "view_in_template_gallery": "", 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 1108f7cbe3..de06196d8e 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 @@ -1,4 +1,5 @@ import { Trans, useTranslation } from 'react-i18next' +import getMeta from '../../../../utils/meta' import { useSubscriptionDashboardContext } from '../../context/subscription-dashboard-context' import { RowLink } from './row-link' @@ -10,6 +11,8 @@ export default function ManagedGroupSubscriptions() { return null } + const groupSettingsEnabledFor = getMeta('ol-groupSettingsEnabledFor', []) + return ( <> {managedGroupSubscriptions.map(subscription => ( @@ -49,6 +52,14 @@ export default function ManagedGroupSubscriptions() { subtext={t('manage_managers_subtext')} icon="manage_accounts" /> + {groupSettingsEnabledFor.includes(subscription._id) && ( + + )} Read more about Managed Users.", "managers_cannot_remove_admin": "Admins cannot be removed", "managers_cannot_remove_self": "Managers cannot remove themselves", "managers_management": "Managers management", @@ -1738,6 +1745,7 @@ "vat_number": "VAT Number", "view_all": "View All", "view_collab_edits": "View collaborator edits ", + "view_group_members": "View group members", "view_hub": "View hub", "view_hub_subtext": "Access collaboration and usage data from users of your Commons subscription", "view_in_template_gallery": "View it in the template gallery", diff --git a/services/web/test/unit/src/Subscription/SubscriptionControllerTests.js b/services/web/test/unit/src/Subscription/SubscriptionControllerTests.js index 60739e2ed6..0da31405b0 100644 --- a/services/web/test/unit/src/Subscription/SubscriptionControllerTests.js +++ b/services/web/test/unit/src/Subscription/SubscriptionControllerTests.js @@ -158,6 +158,10 @@ describe('SubscriptionController', function () { recordEventForSession: sinon.stub(), setUserPropertyForUser: sinon.stub(), }), + '../../../../modules/managed-users/app/src/ManagedUsersManager': + (this.ManagedUsersManager = { + hasManagedUsersFeature: sinon.stub(), + }), }, }) @@ -482,6 +486,10 @@ describe('SubscriptionController', function () { it('should load the plans', function () { expect(this.data.plans).to.deep.equal(this.plans) }) + + it('should load an empty list of groups with settings available', function () { + expect(this.data.groupSettingsEnabledFor).to.deep.equal([]) + }) }) describe('createSubscription', function () {