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

Enable/disable tabs and flag select based on team plan and private repo status #2377

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
pullFileviewString,
pullTreeviewString,
} from 'pages/PullRequestPage/utils'
import { useRepoSettings } from 'services/repo'
import { TierNames, useTier } from 'services/tier'
import { useFlags } from 'shared/featureFlags'
import ToggleHeader from 'ui/FileViewer/ToggleHeader'
import TabNavigation from 'ui/TabNavigation'
Expand All @@ -19,12 +21,15 @@
directChangedFilesCount,
commitsCount,
} = useTabsCounts()
const { pullRequestPageFlagMultiSelect } = useFlags({
const { data: settings, isLoading: settingsLoading } = useRepoSettings()
const { pullRequestPageFlagMultiSelect, multipleTiers } = useFlags({

Check warning on line 25 in src/pages/PullRequestPage/PullRequestPageTabs/PullRequestPageTabs.jsx

View check run for this annotation

Codecov - Staging / codecov/patch

src/pages/PullRequestPage/PullRequestPageTabs/PullRequestPageTabs.jsx#L24-L25

Added lines #L24 - L25 were not covered by tests

Check warning on line 25 in src/pages/PullRequestPage/PullRequestPageTabs/PullRequestPageTabs.jsx

View check run for this annotation

Codecov - QA / codecov/patch

src/pages/PullRequestPage/PullRequestPageTabs/PullRequestPageTabs.jsx#L24-L25

Added lines #L24 - L25 were not covered by tests

Check warning on line 25 in src/pages/PullRequestPage/PullRequestPageTabs/PullRequestPageTabs.jsx

View check run for this annotation

Codecov / codecov/patch

src/pages/PullRequestPage/PullRequestPageTabs/PullRequestPageTabs.jsx#L24-L25

Added lines #L24 - L25 were not covered by tests
pullRequestPageFlagMultiSelect: false,
multipleTiers: false,
})

const { pathname, search } = useLocation()
const { provider, owner, repo, pullId } = useParams()
const { data: tierData, isLoading } = useTier({ provider, owner })

Check warning on line 32 in src/pages/PullRequestPage/PullRequestPageTabs/PullRequestPageTabs.jsx

View check run for this annotation

Codecov - Staging / codecov/patch

src/pages/PullRequestPage/PullRequestPageTabs/PullRequestPageTabs.jsx#L32

Added line #L32 was not covered by tests

Check warning on line 32 in src/pages/PullRequestPage/PullRequestPageTabs/PullRequestPageTabs.jsx

View check run for this annotation

Codecov - QA / codecov/patch

src/pages/PullRequestPage/PullRequestPageTabs/PullRequestPageTabs.jsx#L32

Added line #L32 was not covered by tests

Check warning on line 32 in src/pages/PullRequestPage/PullRequestPageTabs/PullRequestPageTabs.jsx

View check run for this annotation

Codecov / codecov/patch

src/pages/PullRequestPage/PullRequestPageTabs/PullRequestPageTabs.jsx#L32

Added line #L32 was not covered by tests
const searchParams = qs.parse(search, { ignoreQueryPrefix: true })
const flags = searchParams?.flags ?? []

Expand All @@ -43,6 +48,57 @@
}
}

if (isLoading || settingsLoading) {
return null

Check warning on line 52 in src/pages/PullRequestPage/PullRequestPageTabs/PullRequestPageTabs.jsx

View check run for this annotation

Codecov - Staging / codecov/patch

src/pages/PullRequestPage/PullRequestPageTabs/PullRequestPageTabs.jsx#L52

Added line #L52 was not covered by tests

Check warning on line 52 in src/pages/PullRequestPage/PullRequestPageTabs/PullRequestPageTabs.jsx

View check run for this annotation

Codecov - QA / codecov/patch

src/pages/PullRequestPage/PullRequestPageTabs/PullRequestPageTabs.jsx#L52

Added line #L52 was not covered by tests

Check warning on line 52 in src/pages/PullRequestPage/PullRequestPageTabs/PullRequestPageTabs.jsx

View check run for this annotation

Codecov / codecov/patch

src/pages/PullRequestPage/PullRequestPageTabs/PullRequestPageTabs.jsx#L52

Added line #L52 was not covered by tests
}

if (
multipleTiers &&
tierData === TierNames.TEAM &&
settings?.repository?.private

Check warning on line 58 in src/pages/PullRequestPage/PullRequestPageTabs/PullRequestPageTabs.jsx

View check run for this annotation

Codecov - Staging / codecov/patch

src/pages/PullRequestPage/PullRequestPageTabs/PullRequestPageTabs.jsx#L57-L58

Added lines #L57 - L58 were not covered by tests

Check warning on line 58 in src/pages/PullRequestPage/PullRequestPageTabs/PullRequestPageTabs.jsx

View check run for this annotation

Codecov - QA / codecov/patch

src/pages/PullRequestPage/PullRequestPageTabs/PullRequestPageTabs.jsx#L57-L58

Added lines #L57 - L58 were not covered by tests

Check warning on line 58 in src/pages/PullRequestPage/PullRequestPageTabs/PullRequestPageTabs.jsx

View check run for this annotation

Codecov / codecov/patch

src/pages/PullRequestPage/PullRequestPageTabs/PullRequestPageTabs.jsx#L57-L58

Added lines #L57 - L58 were not covered by tests
) {
return (

Check warning on line 60 in src/pages/PullRequestPage/PullRequestPageTabs/PullRequestPageTabs.jsx

View check run for this annotation

Codecov - Staging / codecov/patch

src/pages/PullRequestPage/PullRequestPageTabs/PullRequestPageTabs.jsx#L60

Added line #L60 was not covered by tests

Check warning on line 60 in src/pages/PullRequestPage/PullRequestPageTabs/PullRequestPageTabs.jsx

View check run for this annotation

Codecov - QA / codecov/patch

src/pages/PullRequestPage/PullRequestPageTabs/PullRequestPageTabs.jsx#L60

Added line #L60 was not covered by tests

Check warning on line 60 in src/pages/PullRequestPage/PullRequestPageTabs/PullRequestPageTabs.jsx

View check run for this annotation

Codecov / codecov/patch

src/pages/PullRequestPage/PullRequestPageTabs/PullRequestPageTabs.jsx#L60

Added line #L60 was not covered by tests
<TabNavigation
tabs={[
{
pageName: 'pullDetail',
children: (
<>
Files changed
<sup className="text-xs">{directChangedFilesCount}</sup>
</>
),
options: { queryParams: { flags } },
exact: true,
},
{
pageName: 'pullCommits',
children: (
<>
Commits
<sup className="text-xs">{commitsCount}</sup>
</>
),
options: { queryParams: { flags } },
},
{
pageName: 'pullTreeView',
children: 'File explorer',
options: { pullId, queryParams: { flags } },
location: customLocation,
},
]}
component={
<ToggleHeader
coverageIsLoading={false}
showHitCount={true}
showFlagsSelect={false}
/>
}
/>
)
}

return (
<TabNavigation
tabs={[
Expand Down Expand Up @@ -108,7 +164,10 @@
<ToggleHeader
coverageIsLoading={false}
showHitCount={true}
showFlagsSelect={pullRequestPageFlagMultiSelect}
showFlagsSelect={
pullRequestPageFlagMultiSelect &&
(tierData !== TierNames.TEAM || !settings?.repository?.private)

Check warning on line 169 in src/pages/PullRequestPage/PullRequestPageTabs/PullRequestPageTabs.jsx

View check run for this annotation

Codecov - Staging / codecov/patch

src/pages/PullRequestPage/PullRequestPageTabs/PullRequestPageTabs.jsx#L169

Added line #L169 was not covered by tests

Check warning on line 169 in src/pages/PullRequestPage/PullRequestPageTabs/PullRequestPageTabs.jsx

View check run for this annotation

Codecov - QA / codecov/patch

src/pages/PullRequestPage/PullRequestPageTabs/PullRequestPageTabs.jsx#L169

Added line #L169 was not covered by tests

Check warning on line 169 in src/pages/PullRequestPage/PullRequestPageTabs/PullRequestPageTabs.jsx

View check run for this annotation

Codecov / codecov/patch

src/pages/PullRequestPage/PullRequestPageTabs/PullRequestPageTabs.jsx#L169

Added line #L169 was not covered by tests
}
/>
}
/>
Expand Down
Loading
Loading