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

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

GitOrigin-RevId: 77574a3705b3f1301935b72010022af61f7fe552
This commit is contained in:
Alexandre Bourdin 2023-06-26 16:49:51 +03:00 committed by Copybot
parent c4db2fa4ca
commit 39bc601826
9 changed files with 63 additions and 0 deletions

View file

@ -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)
}

View file

@ -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)

View file

@ -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": "",

View file

@ -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')}

View file

@ -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';

View file

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

View file

@ -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;
}
}

View file

@ -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": "Youre about to enable Managed Users for your organization. Once Managed Users is enabled, you cant 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 doesnt 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 organizations 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",

View file

@ -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 () {