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

Merge pull request #21884 from overleaf/msm-remove-group-sso-enabled-flag

[web] Cleanup `GROUP_SSO_ENABLED` env variable

GitOrigin-RevId: b41ce989348c70c3b4ca59ebf4986edf059534aa
Miguel Serrano 1 год назад
Родитель
Сommit
3e0428d450

+ 1 - 3
services/web/app/src/Features/Subscription/plansFeatures.js

@@ -1,5 +1,3 @@
-const Settings = require('@overleaf/settings')
-
 const individualPlans = [
   {
     divider: false,
@@ -259,7 +257,7 @@ const groupPlans = [
         value: 'bool',
         plans: {
           group_standard: false,
-          group_professional: Settings.groupSSO?.enabled === true,
+          group_professional: true,
           organization: true,
         },
       },

+ 0 - 1
services/web/app/src/infrastructure/ExpressLocals.js

@@ -425,7 +425,6 @@ module.exports = function (webRouter, privateApiRouter, publicApiRouter) {
       cookieDomain: Settings.cookieDomain,
       templateLinks: Settings.templateLinks,
       labsEnabled: Settings.labs && Settings.labs.enable,
-      groupSSOEnabled: Settings.groupSSO?.enabled,
       wikiEnabled: Settings.overleaf != null || Settings.proxyLearn,
       templatesEnabled:
         Settings.overleaf != null || Settings.templates?.user_id != null,

+ 2 - 2
services/web/app/src/models/Subscription.js

@@ -33,8 +33,8 @@ const SubscriptionSchema = new Schema(
     membersLimit: { type: Number, default: 0 },
     customAccount: Boolean,
     features: {
-      managedUsers: { type: Boolean, default: null },
-      groupSSO: { type: Boolean, default: null },
+      managedUsers: { type: Boolean, default: true },
+      groupSSO: { type: Boolean, default: true },
     },
     addOns: Schema.Types.Mixed,
     overleaf: {

+ 1 - 4
services/web/frontend/js/features/subscription/components/dashboard/group-settings-button.tsx

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

+ 21 - 0
services/web/migrations/20241111133330_remove_null_managed_users_sso_from_subscriptions.mjs

@@ -0,0 +1,21 @@
+const tags = ['saas']
+
+const migrate = async client => {
+  const { db } = client
+  await db.subscriptions.updateMany(
+    { 'features.managedUsers': { $eq: null } },
+    { $set: { 'features.managedUsers': true } }
+  )
+  await db.subscriptions.updateMany(
+    { 'features.groupSSO': { $eq: null } },
+    { $set: { 'features.groupSSO': true } }
+  )
+}
+
+const rollback = async () => {}
+
+export default {
+  tags,
+  migrate,
+  rollback,
+}

+ 64 - 197
services/web/test/frontend/features/subscription/components/dashboard/managed-group-subscriptions.test.tsx

@@ -6,7 +6,6 @@ import {
   cleanUpContext,
   renderWithSubscriptionDashContext,
 } from '../../helpers/render-with-subscription-dash-context'
-import getMeta from '@/utils/meta'
 
 function getManagedGroupSubscriptions(
   groupSSO: boolean | null,
@@ -180,209 +179,77 @@ describe('<ManagedGroupSubscriptions />', function () {
       .be.null
   })
 
-  describe('with group SSO off by default', function () {
-    beforeEach(function () {
-      Object.assign(getMeta('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')
+  it('renders Managed Group / Group SSO settings row when both features are 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')
-      })
+  it('renders Group SSO settings when the feature is null', async function () {
+    renderWithSubscriptionDashContext(<ManagedGroupSubscriptions />, {
+      metaTags: [
+        {
+          name: 'ol-managedGroupSubscriptions',
+          value: managedGroupSubscriptions5,
+        },
+        {
+          name: 'ol-groupSettingsEnabledFor',
+          value: [managedGroupSubscriptions5[0]._id],
+        },
+      ],
     })
+    await screen.findAllByText('Manage group settings')
+    await screen.findAllByText('Configure and manage SSO and Managed Users')
   })
 
-  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')
+  it('does not render Group SSO settings when the feature is turned off', async function () {
+    renderWithSubscriptionDashContext(<ManagedGroupSubscriptions />, {
+      metaTags: [
+        {
+          name: 'ol-managedGroupSubscriptions',
+          value: managedGroupSubscriptions4,
+        },
+        {
+          name: 'ol-groupSettingsEnabledFor',
+          value: [managedGroupSubscriptions4[0]._id],
+        },
+      ],
     })
+    await screen.findAllByText('Manage group settings')
+    await screen.findAllByText('Turn on Managed Users')
+    expect(screen.queryByText('Configure and manage SSO and Managed Users')).to
+      .not.exist
+    expect(screen.queryByText('Configure and manage SSO')).to.not.exist
+  })
 
-    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')
-      })
+  it('does not render MAnaged Group settings when the feature is turned off', async function () {
+    renderWithSubscriptionDashContext(<ManagedGroupSubscriptions />, {
+      metaTags: [
+        {
+          name: 'ol-managedGroupSubscriptions',
+          value: managedGroupSubscriptions3,
+        },
+        {
+          name: 'ol-groupSettingsEnabledFor',
+          value: [managedGroupSubscriptions3[0]._id],
+        },
+      ],
     })
+    await screen.findAllByText('Manage group settings')
+    await screen.findAllByText('Configure and manage SSO')
+    expect(screen.queryByText('Turn on Managed Users')).to.not.exist
+    expect(screen.queryByText('Configure and manage SSO and Managed Users')).to
+      .not.exist
   })
 })

+ 0 - 1
services/web/types/exposed-settings.ts

@@ -47,7 +47,6 @@ export type ExposedSettings = {
   fileIgnorePattern: string
   templateLinks?: TemplateLink[]
   labsEnabled: boolean
-  groupSSOEnabled?: boolean
   wikiEnabled?: boolean
   templatesEnabled?: boolean
 }