Merge pull request #17166 from overleaf/ab-fix-group-settings-label

[web] Cleanup managed users env var and fix group settings label

GitOrigin-RevId: 817ed86a6c94c03adb41e8c10115d6404180142e
This commit is contained in:
Jessica Lawshe
2024-02-19 09:07:16 -06:00
committed by Copybot
parent 864741bf2c
commit bd10c4e78d
6 changed files with 235 additions and 75 deletions

View File

@@ -243,6 +243,16 @@ const groupPlans = [
organization: true,
},
},
{
feature: 'managed_users_accounts',
info: 'managed_users_accounts_plan_info',
value: 'bool',
plans: {
group_standard: false,
group_professional: true,
organization: false,
},
},
{
feature: 'sso_integration',
info: 'sso_integration_info',
@@ -636,20 +646,6 @@ const studentPlans = [
},
]
if (Settings.managedUsers?.enabled) {
const row = 2
groupPlans[1].items.splice(row, 0, {
feature: 'managed_users_accounts',
info: 'managed_users_accounts_plan_info',
value: 'bool',
plans: {
group_standard: false,
group_professional: true,
organization: false,
},
})
}
module.exports = {
individual: individualPlans,
group: groupPlans,

View File

@@ -420,6 +420,7 @@ module.exports = function (webRouter, privateApiRouter, publicApiRouter) {
cookieDomain: Settings.cookieDomain,
templateLinks: Settings.templateLinks,
labsEnabled: Settings.labs && Settings.labs.enable,
groupSSOEnabled: Settings.groupSSO?.enabled,
}
next()
})

View File

@@ -1,5 +1,7 @@
import { RowLink } from '@/features/subscription/components/dashboard/row-link'
import getMeta from '@/utils/meta'
import { useTranslation } from 'react-i18next'
import { ExposedSettings } from '../../../../../../types/exposed-settings'
import { ManagedGroupSubscription } from '../../../../../../types/subscription/dashboard/subscription'
export default function GroupSettingsButton({
@@ -9,8 +11,16 @@ export default function GroupSettingsButton({
}) {
const { t } = useTranslation()
const subscriptionHasGroupSSO = subscription?.features?.groupSSO
const subscriptionHasManagedUsers = subscription?.features?.managedUsers
const { groupSSOEnabled } = getMeta(
'ol-ExposedSettings',
{}
) as ExposedSettings
const subscriptionHasManagedUsers =
subscription.features?.managedUsers !== false
const subscriptionHasGroupSSO =
subscription.features?.groupSSO === true ||
(groupSSOEnabled && subscription.features?.groupSSO === null)
let groupSettingRowSubText = ''
if (subscriptionHasGroupSSO && subscriptionHasManagedUsers) {

View File

@@ -12,7 +12,10 @@ import {
} from '../../helpers/render-with-subscription-dash-context'
import { UserId } from '../../../../../../types/user'
function getManagedGroupSubscription(groupSSO: boolean, managedUsers: boolean) {
function getManagedGroupSubscriptions(
groupSSO: boolean | null,
managedUsers: boolean | null
): ManagedGroupSubscription[] {
const subscriptionOne = {
...groupActiveSubscription,
userIsGroupMember: true,
@@ -44,13 +47,15 @@ function getManagedGroupSubscription(groupSSO: boolean, managedUsers: boolean) {
}
const managedGroupSubscriptions: ManagedGroupSubscription[] =
getManagedGroupSubscription(false, false)
getManagedGroupSubscriptions(false, false)
const managedGroupSubscriptions2: ManagedGroupSubscription[] =
getManagedGroupSubscription(true, true)
getManagedGroupSubscriptions(true, true)
const managedGroupSubscriptions3: ManagedGroupSubscription[] =
getManagedGroupSubscription(true, false)
getManagedGroupSubscriptions(true, false)
const managedGroupSubscriptions4: ManagedGroupSubscription[] =
getManagedGroupSubscription(false, true)
getManagedGroupSubscriptions(false, true)
const managedGroupSubscriptions5: ManagedGroupSubscription[] =
getManagedGroupSubscriptions(null, true)
describe('<ManagedGroupSubscriptions />', function () {
afterEach(function () {
@@ -122,63 +127,209 @@ describe('<ManagedGroupSubscriptions />', function () {
.be.null
})
it('renders the Manage group settings row when feature is turned on', async function () {
renderWithSubscriptionDashContext(<ManagedGroupSubscriptions />, {
metaTags: [
{
name: 'ol-managedGroupSubscriptions',
value: managedGroupSubscriptions2,
},
{
name: 'ol-groupSettingsEnabledFor',
value: [managedGroupSubscriptions2[0]._id],
},
],
describe('with group SSO off by default', function () {
beforeEach(function () {
window.metaAttributesCache.set('ol-ExposedSettings', {
groupSSOEnabled: false,
})
})
it('renders the Manage group settings row when feature is turned on', async function () {
renderWithSubscriptionDashContext(<ManagedGroupSubscriptions />, {
metaTags: [
{
name: 'ol-managedGroupSubscriptions',
value: managedGroupSubscriptions2,
},
{
name: 'ol-groupSettingsEnabledFor',
value: [managedGroupSubscriptions2[0]._id],
},
],
})
await screen.findAllByText('Manage group settings')
await screen.findAllByText('Configure and manage SSO and Managed Users')
})
describe('renders the the correct subText for Manage Group settings row', async function () {
it('with managedUsers.enabled=true and groupSSO.enabled=true', async function () {
renderWithSubscriptionDashContext(<ManagedGroupSubscriptions />, {
metaTags: [
{
name: 'ol-managedGroupSubscriptions',
value: managedGroupSubscriptions2,
},
{
name: 'ol-groupSettingsEnabledFor',
value: [managedGroupSubscriptions2[0]._id],
},
],
})
await screen.findAllByText('Configure and manage SSO and Managed Users')
})
it('with managedUsers.enabled=false and groupSSO.enabled=true', async function () {
renderWithSubscriptionDashContext(<ManagedGroupSubscriptions />, {
metaTags: [
{
name: 'ol-managedGroupSubscriptions',
value: managedGroupSubscriptions3,
},
{
name: 'ol-groupSettingsEnabledFor',
value: [managedGroupSubscriptions3[0]._id],
},
],
})
await screen.findAllByText('Configure and manage SSO')
})
it('with managedUsers.enabled=true and groupSSO.enabled=false', async function () {
renderWithSubscriptionDashContext(<ManagedGroupSubscriptions />, {
metaTags: [
{
name: 'ol-managedGroupSubscriptions',
value: managedGroupSubscriptions4,
},
{
name: 'ol-groupSettingsEnabledFor',
value: [managedGroupSubscriptions4[0]._id],
},
],
})
await screen.findAllByText('Turn on Managed Users')
})
it('with managedUsers.enabled=true and groupSSO.enabled=null', async function () {
renderWithSubscriptionDashContext(<ManagedGroupSubscriptions />, {
metaTags: [
{
name: 'ol-managedGroupSubscriptions',
value: managedGroupSubscriptions5,
},
{
name: 'ol-groupSettingsEnabledFor',
value: [managedGroupSubscriptions5[0]._id],
},
],
})
await screen.findAllByText('Turn on Managed Users')
})
})
await screen.findAllByText('Manage group settings')
await screen.findAllByText('Configure and manage SSO and Managed Users')
})
it('renders the the correct subText for Manage Group settings row', async function () {
renderWithSubscriptionDashContext(<ManagedGroupSubscriptions />, {
metaTags: [
{
name: 'ol-managedGroupSubscriptions',
value: managedGroupSubscriptions2,
},
{
name: 'ol-groupSettingsEnabledFor',
value: [managedGroupSubscriptions2[0]._id],
},
],
describe('with group SSO on by default', function () {
it('renders the Manage group settings row when features are turned on', async function () {
renderWithSubscriptionDashContext(<ManagedGroupSubscriptions />, {
metaTags: [
{
name: 'ol-managedGroupSubscriptions',
value: managedGroupSubscriptions2,
},
{
name: 'ol-groupSettingsEnabledFor',
value: [managedGroupSubscriptions2[0]._id],
},
{
name: 'ol-ExposedSettings',
value: {
groupSSOEnabled: true,
},
},
],
})
await screen.findAllByText('Manage group settings')
await screen.findAllByText('Configure and manage SSO and Managed Users')
})
await screen.findAllByText('Configure and manage SSO and Managed Users')
renderWithSubscriptionDashContext(<ManagedGroupSubscriptions />, {
metaTags: [
{
name: 'ol-managedGroupSubscriptions',
value: managedGroupSubscriptions3,
},
{
name: 'ol-groupSettingsEnabledFor',
value: [managedGroupSubscriptions3[0]._id],
},
],
describe('renders the the correct subText for Manage Group settings row', async function () {
it('with managedUsers.enabled=true and groupSSO.enabled=true', async function () {
renderWithSubscriptionDashContext(<ManagedGroupSubscriptions />, {
metaTags: [
{
name: 'ol-managedGroupSubscriptions',
value: managedGroupSubscriptions2,
},
{
name: 'ol-groupSettingsEnabledFor',
value: [managedGroupSubscriptions2[0]._id],
},
{
name: 'ol-ExposedSettings',
value: {
groupSSOEnabled: true,
},
},
],
})
await screen.findAllByText('Configure and manage SSO and Managed Users')
})
it('with managedUsers.enabled=false and groupSSO.enabled=true', async function () {
renderWithSubscriptionDashContext(<ManagedGroupSubscriptions />, {
metaTags: [
{
name: 'ol-managedGroupSubscriptions',
value: managedGroupSubscriptions3,
},
{
name: 'ol-groupSettingsEnabledFor',
value: [managedGroupSubscriptions3[0]._id],
},
{
name: 'ol-ExposedSettings',
value: {
groupSSOEnabled: true,
},
},
],
})
await screen.findAllByText('Configure and manage SSO')
})
it('with managedUsers.enabled=true and groupSSO.enabled=false', async function () {
renderWithSubscriptionDashContext(<ManagedGroupSubscriptions />, {
metaTags: [
{
name: 'ol-managedGroupSubscriptions',
value: managedGroupSubscriptions4,
},
{
name: 'ol-groupSettingsEnabledFor',
value: [managedGroupSubscriptions4[0]._id],
},
{
name: 'ol-ExposedSettings',
value: {
groupSSOEnabled: true,
},
},
],
})
await screen.findAllByText('Turn on Managed Users')
})
it('with managedUsers.enabled=true and groupSSO.enabled=null', async function () {
renderWithSubscriptionDashContext(<ManagedGroupSubscriptions />, {
metaTags: [
{
name: 'ol-managedGroupSubscriptions',
value: managedGroupSubscriptions5,
},
{
name: 'ol-groupSettingsEnabledFor',
value: [managedGroupSubscriptions5[0]._id],
},
{
name: 'ol-ExposedSettings',
value: {
groupSSOEnabled: true,
},
},
],
})
await screen.findAllByText('Configure and manage SSO and Managed Users')
})
})
await screen.findAllByText('Configure and manage SSO')
renderWithSubscriptionDashContext(<ManagedGroupSubscriptions />, {
metaTags: [
{
name: 'ol-managedGroupSubscriptions',
value: managedGroupSubscriptions4,
},
{
name: 'ol-groupSettingsEnabledFor',
value: [managedGroupSubscriptions4[0]._id],
},
],
})
await screen.findAllByText('Turn on Managed Users')
})
})

View File

@@ -45,4 +45,6 @@ export type ExposedSettings = {
fileIgnorePattern: string
templateLinks?: TemplateLink[]
labsEnabled: boolean
managedUsersEnabled?: boolean
groupSSOEnabled?: boolean
}

View File

@@ -78,8 +78,8 @@ export type ManagedGroupSubscription = Omit<GroupSubscription, 'admin_id'> & {
planLevelName: string
admin_id: User
features: {
groupSSO: boolean
managedUsers: boolean
groupSSO: boolean | null
managedUsers: boolean | null
}
}