Skip to content

Commit

Permalink
add in feature flag to control the new column
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholas-codecov committed Dec 11, 2024
1 parent 68c092e commit 38e5544
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@ import { MemoryRouter, Route } from 'react-router-dom'

import { AssetsTable, ChangeOverTime } from './AssetsTable'

const mocks = vi.hoisted(() => ({
useFlags: vi.fn().mockReturnValue({ renderBundleFilePathColumn: true }),
}))

vi.mock('shared/featureFlags', async (importOriginal) => {
const original = await vi.importActual('shared/featureFlags')
return {
...original,
useFlags: mocks.useFlags,
}
})

const mockAssets = ({
hasNextPage = true,
pluginName = '@codecov/vite-plugin',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { useParams } from 'react-router-dom'

import { OrderingDirection } from 'types'

import { useFlags } from 'shared/featureFlags'
import {
formatSizeToString,
formatTimeToString,
Expand Down Expand Up @@ -228,6 +229,9 @@ export const AssetsTable: React.FC = () => {
const [expanded, setExpanded] = useState<ExpandedState>({})
const [sorting, setSorting] = useState([{ id: 'size', desc: true }])
const { provider, owner, repo, branch, bundle } = useParams<URLParams>()
const { renderBundleFilePathColumn } = useFlags({
renderBundleFilePathColumn: false,
})

let ordering: 'NAME' | 'SIZE' | 'TYPE' | undefined
const sortColumn = sorting?.[0]?.id
Expand Down Expand Up @@ -295,9 +299,9 @@ export const AssetsTable: React.FC = () => {
[data?.pages]
)

const includeFilePath = SUPPORTED_FILE_PATH_PLUGINS.includes(
tableData.bundleInfo?.pluginName ?? ''
)
const includeFilePath =
renderBundleFilePathColumn &&
SUPPORTED_FILE_PATH_PLUGINS.includes(tableData.bundleInfo?.pluginName ?? '')

const columns = useMemo(
() => createColumns(bundleSize, includeFilePath),
Expand Down

0 comments on commit 38e5544

Please sign in to comment.