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,
groupPlans: groupPlansDataForDash,
groupSettingsEnabledFor,
isManagedAccount: !!req.managedBy,
userRestrictions: Array.from(req.userRestrictions || []),
}
res.render('subscriptions/dashboard-react', data)
}

View file

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

View file

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

View file

@ -64,6 +64,7 @@ html(
indexName : settings.templates.indexName
})
meta(name="ol-isManagedAccount" data-type="boolean" content=isManagedAccount)
each restriction in userRestrictions || []
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-personalAccessTokens", data-type="json" content=personalAccessTokens)
meta(name="ol-emailAddressLimit", data-type="json", content=emailAddressLimit)
meta(name="ol-isManagedAccount" data-type="boolean" content=isManagedAccount)
block content
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 { LEAVE_GROUP_MODAL_ID } from './leave-group-modal'
import PremiumFeaturesLink from './premium-features-link'
import getMeta from '../../../../utils/meta.js'
type GroupSubscriptionMembershipProps = {
subscription: MemberGroupSubscription
@ -23,6 +24,11 @@ export default function GroupSubscriptionMembership({
setLeavingGroupId(subscription._id)
}
// Hide leave group button for managed users
const hideLeaveButton = getMeta(
'ol-cannot-leave-group-subscription'
) as boolean
return (
<div>
<p>
@ -43,11 +49,18 @@ export default function GroupSubscriptionMembership({
</p>
)}
{isLast && <PremiumFeaturesLink />}
<span>
<Button bsStyle="danger" onClick={leaveGroup}>
{t('leave_group')}
</Button>
</span>
{hideLeaveButton ? (
<span>
{' '}
{t('need_to_leave')} {t('contact_group_admin')}{' '}
</span>
) : (
<span>
<Button bsStyle="danger" onClick={leaveGroup}>
{t('leave_group')}
</Button>
</span>
)}
<hr />
</div>
)