Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Clean up okta feature flag #3144

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading