Skip to content

Commit

Permalink
fix: Clean up okta feature flag (#3144)
Browse files Browse the repository at this point in the history
  • Loading branch information
RulaKhaled authored Aug 26, 2024
1 parent 5426f0b commit 79bdab2
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 39 deletions.
6 changes: 1 addition & 5 deletions src/pages/AccountSettings/AccountSettings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { SentryRoute } from 'sentry'
import SidebarLayout from 'layouts/SidebarLayout'
import { usePlanData } from 'services/account'
import { useIsCurrentUserAnAdmin, useUser } from 'services/user'
import { useFlags } from 'shared/featureFlags'
import { isEnterprisePlan } from 'shared/utils/billing'
import LoadingLogo from 'ui/LoadingLogo'

Expand All @@ -35,10 +34,7 @@ function AccountSettings() {
const { data: currentUser } = useUser()

const { data } = usePlanData({ provider, owner })
const { oktaSettings } = useFlags({
oktaSettings: false,
})
const viewOktaAccess = oktaSettings && isEnterprisePlan(data?.plan?.value)
const viewOktaAccess = isEnterprisePlan(data?.plan?.value)

const isViewingPersonalSettings =
currentUser?.user?.username?.toLowerCase() === owner?.toLowerCase()
Expand Down
4 changes: 0 additions & 4 deletions src/pages/AccountSettings/AccountSettings.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@ import { MemoryRouter, Route } from 'react-router-dom'

import config from 'config'

import { useFlags } from 'shared/featureFlags'

import AccountSettings from './AccountSettings'

jest.mock('config')
jest.mock('shared/featureFlags')

jest.mock('./shared/Header', () => () => 'Header')
jest.mock('./AccountSettingsSideMenu', () => () => 'AccountSettingsSideMenu')
Expand Down Expand Up @@ -143,7 +140,6 @@ describe('AccountSettings', () => {
) {
config.IS_SELF_HOSTED = isSelfHosted
config.HIDE_ACCESS_TAB = hideAccessTab
useFlags.mockReturnValue({ oktaSettings: true })

server.use(
graphql.query('CurrentUser', (req, res, ctx) => {
Expand Down
6 changes: 1 addition & 5 deletions src/pages/AccountSettings/AccountSettingsSideMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import config from 'config'

import { usePlanData } from 'services/account'
import { useIsCurrentUserAnAdmin, useUser } from 'services/user'
import { useFlags } from 'shared/featureFlags'
import { isEnterprisePlan } from 'shared/utils/billing'
import Sidemenu from 'ui/Sidemenu'

Expand Down Expand Up @@ -67,10 +66,7 @@ function AccountSettingsSideMenu() {
currentUser?.user?.username?.toLowerCase() === owner?.toLowerCase()

const { data } = usePlanData({ provider, owner })
const { oktaSettings } = useFlags({
oktaSettings: false,
})
const viewOktaAccess = oktaSettings && isEnterprisePlan(data?.plan?.value)
const viewOktaAccess = isEnterprisePlan(data?.plan?.value)

const links = generateLinks({
isAdmin,
Expand Down
4 changes: 0 additions & 4 deletions src/pages/AccountSettings/AccountSettingsSideMenu.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@ import { MemoryRouter, Route } from 'react-router-dom'

import config from 'config'

import { useFlags } from 'shared/featureFlags'

import AccountSettingsSideMenu from './AccountSettingsSideMenu'

jest.mock('config')
jest.mock('shared/featureFlags')

const mockPlanData = {
baseUnitPrice: 10,
Expand Down Expand Up @@ -132,7 +129,6 @@ describe('AccountSettingsSideMenu', () => {
) {
config.IS_SELF_HOSTED = isSelfHosted
config.HIDE_ACCESS_TAB = hideAccessTab
useFlags.mockReturnValue({ oktaSettings: true })

server.use(
graphql.query('CurrentUser', (req, res, ctx) => {
Expand Down
11 changes: 0 additions & 11 deletions src/shared/GlobalTopBanners/OktaBanners/OktaBanners.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,11 @@ import { setupServer } from 'msw/node'
import { Suspense } from 'react'
import { MemoryRouter, Route } from 'react-router-dom'

import { useFlags } from 'shared/featureFlags'

import OktaBanners from './OktaBanners'

jest.mock('../OktaEnabledBanner', () => () => 'OktaEnabledBanner')
jest.mock('../OktaEnforcedBanner', () => () => 'OktaEnforcedBanner')

jest.mock('shared/featureFlags')
const mockedUseFlags = useFlags as jest.Mock<{
oktaSettings: boolean
}>

const wrapper =
(initialEntries = ['/gh/owner']): React.FC<React.PropsWithChildren> =>
({ children }) => (
Expand All @@ -43,10 +36,6 @@ afterAll(() => server.close())

describe('OktaBanners', () => {
function setup(data = {}) {
mockedUseFlags.mockReturnValue({
oktaSettings: true,
})

server.use(
graphql.query('GetOktaConfig', (req, res, ctx) =>
res(ctx.status(200), ctx.data(data))
Expand Down
11 changes: 1 addition & 10 deletions src/shared/GlobalTopBanners/OktaBanners/OktaBanners.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { lazy } from 'react'
import { useParams } from 'react-router'

import { useOktaConfig } from 'pages/AccountSettings/tabs/OktaAccess/hooks'
import { useFlags } from 'shared/featureFlags'

interface URLParams {
provider: string
Expand All @@ -14,9 +13,6 @@ const OktaEnforcedBanner = lazy(() => import('../OktaEnforcedBanner'))

function OktaBanners() {
const { provider, owner } = useParams<URLParams>()
const { oktaSettings } = useFlags({
oktaSettings: false,
})

const { data } = useOktaConfig({
provider,
Expand All @@ -26,12 +22,7 @@ function OktaBanners() {

const oktaConfig = data?.owner?.account?.oktaConfig

if (
!oktaSettings ||
!owner ||
!oktaConfig?.enabled ||
data?.owner?.isUserOktaAuthenticated
)
if (!owner || !oktaConfig?.enabled || data?.owner?.isUserOktaAuthenticated)
return null

return oktaConfig?.enforced ? <OktaEnforcedBanner /> : <OktaEnabledBanner />
Expand Down

0 comments on commit 79bdab2

Please sign in to comment.