Merge pull request #13916 from overleaf/bg-managed-users-hide-leave-group-action

managed users hide leave group action

GitOrigin-RevId: 160e31e6935cd3737356714020e057f8c1acc5b8
This commit is contained in:
Brian Gough 2023-07-20 11:14:21 +01:00 committed by Copybot
parent d298a258e0
commit 558992d947
6 changed files with 23 additions and 7 deletions

View file

@ -297,6 +297,8 @@ async function userSubscriptionPage(req, res) {
cancelButtonNewCopy, cancelButtonNewCopy,
groupPlans: groupPlansDataForDash, groupPlans: groupPlansDataForDash,
groupSettingsEnabledFor, groupSettingsEnabledFor,
isManagedAccount: !!req.managedBy,
userRestrictions: Array.from(req.userRestrictions || []),
} }
res.render('subscriptions/dashboard-react', data) res.render('subscriptions/dashboard-react', data)
} }

View file

@ -23,6 +23,7 @@ module.exports = {
webRouter.get( webRouter.get(
'/user/subscription', '/user/subscription',
AuthenticationController.requireLogin(), AuthenticationController.requireLogin(),
PermissionsController.useCapabilities(),
SubscriptionController.userSubscriptionPage SubscriptionController.userSubscriptionPage
) )

View file

@ -126,7 +126,7 @@ async function settingsPage(req, res) {
showPersonalAccessToken, showPersonalAccessToken,
personalAccessTokens, personalAccessTokens,
emailAddressLimit: Settings.emailAddressLimit, emailAddressLimit: Settings.emailAddressLimit,
isManagedAccount: !!user.enrollment?.managedBy, isManagedAccount: !!req.managedBy,
userRestrictions: Array.from(req.userRestrictions || []), userRestrictions: Array.from(req.userRestrictions || []),
}) })
} }

View file

@ -64,6 +64,7 @@ html(
indexName : settings.templates.indexName indexName : settings.templates.indexName
}) })
meta(name="ol-isManagedAccount" data-type="boolean" content=isManagedAccount)
each restriction in userRestrictions || [] each restriction in userRestrictions || []
meta(name='ol-cannot-' + restriction data-type="boolean" content=true) meta(name='ol-cannot-' + restriction data-type="boolean" content=true)

View file

@ -25,7 +25,6 @@ block append meta
meta(name="ol-showPersonalAccessToken", data-type="boolean" content=showPersonalAccessToken) meta(name="ol-showPersonalAccessToken", data-type="boolean" content=showPersonalAccessToken)
meta(name="ol-personalAccessTokens", data-type="json" content=personalAccessTokens) meta(name="ol-personalAccessTokens", data-type="json" content=personalAccessTokens)
meta(name="ol-emailAddressLimit", data-type="json", content=emailAddressLimit) meta(name="ol-emailAddressLimit", data-type="json", content=emailAddressLimit)
meta(name="ol-isManagedAccount" data-type="boolean" content=isManagedAccount)
block content block content
main.content.content-alt#settings-page-root main.content.content-alt#settings-page-root

View file

@ -4,6 +4,7 @@ import { MemberGroupSubscription } from '../../../../../../types/subscription/da
import { useSubscriptionDashboardContext } from '../../context/subscription-dashboard-context' import { useSubscriptionDashboardContext } from '../../context/subscription-dashboard-context'
import { LEAVE_GROUP_MODAL_ID } from './leave-group-modal' import { LEAVE_GROUP_MODAL_ID } from './leave-group-modal'
import PremiumFeaturesLink from './premium-features-link' import PremiumFeaturesLink from './premium-features-link'
import getMeta from '../../../../utils/meta.js'
type GroupSubscriptionMembershipProps = { type GroupSubscriptionMembershipProps = {
subscription: MemberGroupSubscription subscription: MemberGroupSubscription
@ -23,6 +24,11 @@ export default function GroupSubscriptionMembership({
setLeavingGroupId(subscription._id) setLeavingGroupId(subscription._id)
} }
// Hide leave group button for managed users
const hideLeaveButton = getMeta(
'ol-cannot-leave-group-subscription'
) as boolean
return ( return (
<div> <div>
<p> <p>
@ -43,11 +49,18 @@ export default function GroupSubscriptionMembership({
</p> </p>
)} )}
{isLast && <PremiumFeaturesLink />} {isLast && <PremiumFeaturesLink />}
{hideLeaveButton ? (
<span>
{' '}
{t('need_to_leave')} {t('contact_group_admin')}{' '}
</span>
) : (
<span> <span>
<Button bsStyle="danger" onClick={leaveGroup}> <Button bsStyle="danger" onClick={leaveGroup}>
{t('leave_group')} {t('leave_group')}
</Button> </Button>
</span> </span>
)}
<hr /> <hr />
</div> </div>
) )