Просмотр исходного кода

Merge pull request #13482 from overleaf/ab-group-settings-page

[web] Group settings button and page enabled based on env var

GitOrigin-RevId: 77574a3705b3f1301935b72010022af61f7fe552
Alexandre Bourdin 3 лет назад
Родитель
Сommit
39bc601826

+ 6 - 0
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)
 }

+ 1 - 0
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)

+ 8 - 0
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": "",

+ 11 - 0
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) && (
+            <RowLink
+              href={`/manage/groups/${subscription._id}/settings`}
+              heading={t('manage_group_settings')}
+              subtext={t('manage_group_settings_subtext')}
+              icon="settings"
+            />
+          )}
           <RowLink
             href={`/metrics/groups/${subscription._id}`}
             heading={t('view_metrics')}

+ 1 - 0
services/web/frontend/stylesheets/_style_includes.less

@@ -114,5 +114,6 @@
 // TODO: find a way for modules to add styles dynamically
 @import 'modules/symbol-palette.less';
 @import 'modules/galileo.less';
+@import 'modules/managed-users.less';
 
 @import 'modules/admin-panel.less';

+ 1 - 0
services/web/frontend/stylesheets/main-style.less

@@ -147,3 +147,4 @@
 @import 'modules/symbol-palette.less';
 @import 'modules/galileo.less';
 @import 'modules/admin-panel.less';
+@import 'modules/managed-users.less';

+ 19 - 0
services/web/frontend/stylesheets/modules/managed-users.less

@@ -0,0 +1,19 @@
+.group-settings-title {
+  min-width: 0;
+  color: @content-secondary;
+  font-family: Lato, sans-serif;
+  font-size: @font-size-large;
+  line-height: 28px;
+  font-weight: bold;
+  overflow: hidden;
+  text-overflow: ellipsis;
+}
+
+.managed-users-enabled {
+  font-family: Lato, sans-serif;
+  color: @ol-green;
+
+  .icon {
+    vertical-align: text-bottom;
+  }
+}

+ 8 - 0
services/web/locales/en.json

@@ -21,6 +21,7 @@
   "about_to_delete_tag": "You are about to delete the following tag (any projects in them will not be deleted):",
   "about_to_delete_the_following_project": "You are about to delete the following project",
   "about_to_delete_the_following_projects": "You are about to delete the following projects",
+  "about_to_enable_managed_users": "You’re about to enable Managed Users for your organization. Once Managed Users is enabled, you can’t disable it.",
   "about_to_leave_projects": "You are about to leave the following projects:",
   "about_to_trash_projects": "You are about to trash the following projects:",
   "abstract": "Abstract",
@@ -440,6 +441,8 @@
   "emails_and_affiliations_title": "Emails and Affiliations",
   "empty_zip_file": "Zip doesn’t contain any file",
   "en": "English",
+  "enable_managed_users": "Enable Managed Users",
+  "enabling": "Enabling",
   "end_of_document": "End of document",
   "enter_image_url": "Enter image URL",
   "enter_institution_email_to_log_in": "Enter your institutional email to log in through your institution.",
@@ -936,6 +939,8 @@
   "manage_files_from_your_dropbox_folder": "Manage files from your Dropbox folder",
   "manage_group_managers": "Manage group managers",
   "manage_group_members_subtext": "Add, edit, or remove members from your group subscription",
+  "manage_group_settings": "Manage group settings",
+  "manage_group_settings_subtext": "Turn on Managed Users",
   "manage_institution_managers": "Manage institution managers",
   "manage_labs_program_membership": "Manage Labs Program Membership",
   "manage_managers_subtext": "Assign, edit, or revoke manager privileges",
@@ -944,6 +949,8 @@
   "manage_publisher_managers": "Manage publisher managers",
   "manage_sessions": "Manage Your Sessions",
   "manage_subscription": "Manage Subscription",
+  "managed_users": "Managed Users",
+  "managed_users_explanation": "Managed Users ensures you stay in control of your organization’s projects and who owns them. <0>Read more about Managed Users.</0>",
   "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",

+ 8 - 0
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 () {