Skip to content

Commit

Permalink
Merge branch 'main' into pr3522
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-codecov authored Dec 3, 2024
2 parents 8be746f + a9d3bbd commit 0cb17db
Show file tree
Hide file tree
Showing 155 changed files with 6,699 additions and 10,699 deletions.
432 changes: 318 additions & 114 deletions .eslintrc.cjs

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const config: StorybookConfig = {
'@storybook/addon-a11y',
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/preset-create-react-app',
'@chromatic-com/storybook',
],
docs: {},
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
24.11.1
24.12.2
22 changes: 15 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
},
"devDependencies": {
"@acemarke/react-prod-sourcemaps": "^0.3.1",
"@babel/eslint-parser": "^7.25.9",
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@chromatic-com/storybook": "^1",
"@codecov/vite-plugin": "^1.2.1",
Expand All @@ -100,21 +101,22 @@
"@storybook/builder-vite": "^8.3.4",
"@storybook/manager-api": "^8.3.4",
"@storybook/node-logger": "^8.3.4",
"@storybook/preset-create-react-app": "^8.3.4",
"@storybook/react": "^8.3.4",
"@storybook/react-vite": "^8.3.4",
"@storybook/theming": "^8.3.4",
"@tailwindcss/container-queries": "^0.1.1",
"@tanstack/eslint-plugin-query": "^4.29.4",
"@tanstack/eslint-plugin-query": "^4.38.0",
"@tanstack/react-query-devtools": "^4.29.6",
"@testing-library/dom": "10.3.2",
"@testing-library/jest-dom": "^6.4.2",
"@testing-library/react": "^16.0.0",
"@testing-library/user-event": "^14.5.2",
"@total-typescript/ts-reset": "^0.4.2",
"@types/confusing-browser-globals": "^1",
"@types/d3": "7.4.3",
"@types/d3-array": "3.2.1",
"@types/d3-scale": "4.0.8",
"@types/eslint-plugin-jsx-a11y": "^6.9.0",
"@types/js-cookie": "3.0.6",
"@types/lodash": "4.17.6",
"@types/node": "^20.5.7",
Expand All @@ -126,27 +128,33 @@
"@types/react-modal": "^3.16.2",
"@types/react-router-dom": "^5.3.3",
"@types/semver": "^7",
"@typescript-eslint/eslint-plugin": "^8.14.0",
"@typescript-eslint/parser": "^8.14.0",
"@vitejs/plugin-legacy": "^5.4.3",
"@vitejs/plugin-react": "^4.3.3",
"@vitest/coverage-istanbul": "^2.1.3",
"@vitest/eslint-plugin": "^1.1.7",
"@vitest/ui": "^2.1.3",
"autoprefixer": "^10.4.14",
"eslint": "^8.39.0",
"babel-preset-react-app": "^10.0.1",
"confusing-browser-globals": "^1.0.11",
"eslint": "^8.57.1",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-alias": "^1.1.2",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jsx-a11y": "^6.10.2",
"eslint-plugin-react": "^7.37.2",
"eslint-plugin-react-hooks": "^5.0.0",
"eslint-plugin-storybook": "^0.8.0",
"eslint-plugin-tailwindcss": "^3.17.4",
"eslint-plugin-testing-library": "^6.3.0",
"eslint-plugin-tailwindcss": "^3.17.5",
"eslint-plugin-testing-library": "^6.4.0",
"http-proxy-middleware": "^2.0.7",
"husky": "^9.1.4",
"jsdom": "^25.0.0",
"lint-staged": "^15.2.8",
"msw": "^2.4.11",
"postcss": "^8.4.31",
"prettier": "^3.3.3",
"react-scripts": "^5.0.1",
"react-test-renderer": "^18.3.1",
"remark-gfm": "^3.0.1",
"resolve-url-loader": "^5.0.0",
Expand Down
1 change: 1 addition & 0 deletions scripts/icon-list.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const enabledIcons = [
'light-bulb',
'lock-closed',
'merge',
'minus',
'moon',
'no-symbol',
'plus-circle',
Expand Down
56 changes: 37 additions & 19 deletions src/App.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import {
QueryClientProvider as QueryClientProviderV5,
QueryClient as QueryClientV5,
} from '@tanstack/react-queryV5'
import { render, screen, waitFor } from '@testing-library/react'
import { graphql, http, HttpResponse } from 'msw'
import { setupServer } from 'msw/node'
Expand Down Expand Up @@ -121,32 +125,43 @@ const mockRepoOverview = {
},
}

const queryClient = new QueryClient({
defaultOptions: {
queries: {
retry: false,
const mockNavigatorData = {
owner: {
isCurrentUserPartOfOrg: true,
repository: {
__typename: 'Repository',
name: 'test-repo',
},
},
}

const queryClient = new QueryClient({
defaultOptions: { queries: { retry: false } },
})
const queryClientV5 = new QueryClientV5({
defaultOptions: { queries: { retry: false } },
})

let testLocation: ReturnType<typeof useLocation>
const wrapper =
(initialEntries = ['']): React.FC<React.PropsWithChildren> =>
({ children }) => (
<QueryClientProvider client={queryClient}>
<MemoryRouter initialEntries={initialEntries}>
<Suspense fallback={<p>Loading</p>}>
{children}
<Route
path="*"
render={({ location }) => {
testLocation = location
return null
}}
/>
</Suspense>
</MemoryRouter>
</QueryClientProvider>
<QueryClientProviderV5 client={queryClientV5}>
<QueryClientProvider client={queryClient}>
<MemoryRouter initialEntries={initialEntries}>
<Suspense fallback={<p>Loading</p>}>
{children}
<Route
path="*"
render={({ location }) => {
testLocation = location
return null
}}
/>
</Suspense>
</MemoryRouter>
</QueryClientProvider>
</QueryClientProviderV5>
)

const server = setupServer()
Expand Down Expand Up @@ -230,7 +245,10 @@ describe('App', () => {
return HttpResponse.json({ data: mockRepoOverview })
}),
graphql.query('GetUploadTokenRequired', (info) => {
return HttpResponse.json({ data: {} })
return HttpResponse.json({ data: { owner: null } })
}),
graphql.query('NavigatorData', () => {
return HttpResponse.json({ data: mockNavigatorData })
})
)
}
Expand Down
Binary file added src/assets/onboarding/env_variable_screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 40 additions & 18 deletions src/layouts/BaseLayout/BaseLayout.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import {
QueryClientProvider as QueryClientProviderV5,
QueryClient as QueryClientV5,
} from '@tanstack/react-queryV5'
import { render, screen, waitFor } from '@testing-library/react'
import { graphql, http, HttpResponse } from 'msw'
import { setupServer } from 'msw/node'
Expand Down Expand Up @@ -156,34 +160,48 @@ const internalUserHasSyncedProviders = {
termsAgreement: true,
}

const mockNavigatorData = {
owner: {
isCurrentUserPartOfOrg: true,
repository: {
__typename: 'Repository',
name: 'test-repo',
},
},
}

const server = setupServer()
const queryClient = new QueryClient({
defaultOptions: {
queries: {
retry: false,
suspense: false,
},
queries: { retry: false, suspense: false },
},
})
const queryClientV5 = new QueryClientV5({
defaultOptions: {
queries: { retry: false },
},
})
const server = setupServer()

let testLocation: ReturnType<typeof useLocation>
const wrapper: (
initialEntries?: string[]
) => React.FC<React.PropsWithChildren> =
(initialEntries = ['/bb/batman/batcave']) =>
({ children }) => (
<QueryClientProvider client={queryClient}>
<MemoryRouter initialEntries={initialEntries}>
<Route path="/:provider/:owner/:repo">{children}</Route>
<Route
path="*"
render={({ location }) => {
testLocation = location
return null
}}
/>
</MemoryRouter>
</QueryClientProvider>
<QueryClientProviderV5 client={queryClientV5}>
<QueryClientProvider client={queryClient}>
<MemoryRouter initialEntries={initialEntries}>
<Route path="/:provider/:owner/:repo">{children}</Route>
<Route
path="*"
render={({ location }) => {
testLocation = location
return null
}}
/>
</MemoryRouter>
</QueryClientProvider>
</QueryClientProviderV5>
)

beforeAll(() => {
Expand All @@ -192,6 +210,7 @@ beforeAll(() => {

afterEach(() => {
queryClient.clear()
queryClientV5.clear()
server.resetHandlers()
vi.clearAllMocks()
})
Expand Down Expand Up @@ -236,7 +255,7 @@ describe('BaseLayout', () => {
}),
// Self hosted only
graphql.query('HasAdmins', (info) => {
return HttpResponse.json({ data: {} })
return HttpResponse.json({ data: { config: null } })
}),
graphql.query('Seats', (info) => {
return HttpResponse.json({ data: {} })
Expand All @@ -261,6 +280,9 @@ describe('BaseLayout', () => {
graphql.mutation('updateDefaultOrganization', (info) => {
return HttpResponse.json({ data: {} })
}),
graphql.query('NavigatorData', () => {
return HttpResponse.json({ data: mockNavigatorData })
}),
http.get('/internal/users/current', (info) => {
return HttpResponse.json({})
})
Expand Down
37 changes: 31 additions & 6 deletions src/layouts/BaseLayout/BaseLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useQuery as useQueryV5 } from '@tanstack/react-queryV5'
import { lazy, Suspense } from 'react'
import { Redirect } from 'react-router-dom'
import { Redirect, useParams } from 'react-router-dom'

import Footer from 'layouts/Footer'
import Header from 'layouts/Header'
Expand All @@ -14,6 +15,7 @@ import GlobalBanners from 'shared/GlobalBanners'
import GlobalTopBanners from 'shared/GlobalTopBanners'
import LoadingLogo from 'ui/LoadingLogo'

import { NavigatorDataQueryOpts } from './hooks/NavigatorDataQueryOpts'
import { useUserAccessGate } from './hooks/useUserAccessGate'

const DefaultOrgSelector = lazy(() => import('pages/DefaultOrgSelector'))
Expand Down Expand Up @@ -65,19 +67,42 @@ function OnboardingOrChildren({
return <>{children}</>
}

interface URLParams {
provider?: string
owner?: string
repo?: string
}

function BaseLayout({ children }: React.PropsWithChildren) {
const { provider, owner, repo } = useParams<URLParams>()
useTracking()
const { isImpersonating } = useImpersonate()
const {
isFullExperience,
showAgreeToTerms,
showDefaultOrgSelector,
redirectToSyncPage,
isLoading,
isLoading: isUserAccessGateLoading,
} = useUserAccessGate()
useTracking()
const { isImpersonating } = useImpersonate()

// we have to fetch the data for the navigator up here as we can't
// conditionally call a suspense query, as well we need a way to have the
// loader be shown while we're loading
const { data, isLoading: isNavigatorDataLoading } = useQueryV5({
enabled: !!provider && !!owner && !!repo,
...NavigatorDataQueryOpts({
// if these aren't provided, the query is disabled so we don't need to
// worry about the empty strings causing errors
provider: provider ?? '',
owner: owner ?? '',
repo: repo ?? '',
}),
})

// Pause rendering of a page till we know if the user is logged in or not
if (isLoading) return <FullPageLoader />
if (isUserAccessGateLoading || isNavigatorDataLoading) {
return <FullPageLoader />
}

return (
<>
Expand All @@ -89,7 +114,7 @@ function BaseLayout({ children }: React.PropsWithChildren) {
{isFullExperience || isImpersonating ? (
<>
<GlobalTopBanners />
<Header />
<Header hasRepoAccess={data?.hasRepoAccess} />
</>
) : (
<>
Expand Down
Loading

0 comments on commit 0cb17db

Please sign in to comment.