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

feat: Update CommitDetailPage FilesChangedTable to pass along flags #2334

Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import cs from 'classnames'
import isArray from 'lodash/isArray'
import isEmpty from 'lodash/isEmpty'
import isNumber from 'lodash/isNumber'
import PropTypes from 'prop-types'
import qs from 'qs'
import { lazy, Suspense } from 'react'
import { useParams } from 'react-router-dom'
import { useLocation, useParams } from 'react-router-dom'

import Table from 'old_ui/Table'
import { useCommit } from 'services/commit'
import { useFlags } from 'shared/featureFlags'
import A from 'ui/A'
import Icon from 'ui/Icon'
import Spinner from 'ui/Spinner'
Expand Down Expand Up @@ -147,6 +150,21 @@

function FilesChangedTable() {
const { provider, owner, repo, commit: commitSha } = useParams()
const location = useLocation()

Check warning on line 153 in src/pages/CommitDetailPage/subRoute/FilesChangedTab/FilesChangedTable/FilesChangedTable.jsx

View check run for this annotation

Codecov / codecov/patch

src/pages/CommitDetailPage/subRoute/FilesChangedTab/FilesChangedTable/FilesChangedTable.jsx#L153

Added line #L153 was not covered by tests

Check warning on line 153 in src/pages/CommitDetailPage/subRoute/FilesChangedTab/FilesChangedTable/FilesChangedTable.jsx

View check run for this annotation

Codecov - QA / codecov/patch

src/pages/CommitDetailPage/subRoute/FilesChangedTab/FilesChangedTable/FilesChangedTable.jsx#L153

Added line #L153 was not covered by tests

Check warning on line 153 in src/pages/CommitDetailPage/subRoute/FilesChangedTab/FilesChangedTable/FilesChangedTable.jsx

View check run for this annotation

Codecov Public QA / codecov/patch

src/pages/CommitDetailPage/subRoute/FilesChangedTab/FilesChangedTable/FilesChangedTable.jsx#L153

Added line #L153 was not covered by tests

const { commitTabFlagMultiSelect } = useFlags({

Check warning on line 155 in src/pages/CommitDetailPage/subRoute/FilesChangedTab/FilesChangedTable/FilesChangedTable.jsx

View check run for this annotation

Codecov / codecov/patch

src/pages/CommitDetailPage/subRoute/FilesChangedTab/FilesChangedTable/FilesChangedTable.jsx#L155

Added line #L155 was not covered by tests

Check warning on line 155 in src/pages/CommitDetailPage/subRoute/FilesChangedTab/FilesChangedTable/FilesChangedTable.jsx

View check run for this annotation

Codecov - QA / codecov/patch

src/pages/CommitDetailPage/subRoute/FilesChangedTab/FilesChangedTable/FilesChangedTable.jsx#L155

Added line #L155 was not covered by tests

Check warning on line 155 in src/pages/CommitDetailPage/subRoute/FilesChangedTab/FilesChangedTable/FilesChangedTable.jsx

View check run for this annotation

Codecov Public QA / codecov/patch

src/pages/CommitDetailPage/subRoute/FilesChangedTab/FilesChangedTable/FilesChangedTable.jsx#L155

Added line #L155 was not covered by tests
commitTabFlagMultiSelect: false,
})

const queryParams = qs.parse(location.search, {

Check warning on line 159 in src/pages/CommitDetailPage/subRoute/FilesChangedTab/FilesChangedTable/FilesChangedTable.jsx

View check run for this annotation

Codecov / codecov/patch

src/pages/CommitDetailPage/subRoute/FilesChangedTab/FilesChangedTable/FilesChangedTable.jsx#L159

Added line #L159 was not covered by tests

Check warning on line 159 in src/pages/CommitDetailPage/subRoute/FilesChangedTab/FilesChangedTable/FilesChangedTable.jsx

View check run for this annotation

Codecov - QA / codecov/patch

src/pages/CommitDetailPage/subRoute/FilesChangedTab/FilesChangedTable/FilesChangedTable.jsx#L159

Added line #L159 was not covered by tests

Check warning on line 159 in src/pages/CommitDetailPage/subRoute/FilesChangedTab/FilesChangedTable/FilesChangedTable.jsx

View check run for this annotation

Codecov Public QA / codecov/patch

src/pages/CommitDetailPage/subRoute/FilesChangedTab/FilesChangedTable/FilesChangedTable.jsx#L159

Added line #L159 was not covered by tests
ignoreQueryPrefix: true,
depth: 1,
})

const flags =
queryParams?.flags?.length > 0 && commitTabFlagMultiSelect
? queryParams?.flags
: undefined

Check warning on line 167 in src/pages/CommitDetailPage/subRoute/FilesChangedTab/FilesChangedTable/FilesChangedTable.jsx

View check run for this annotation

Codecov / codecov/patch

src/pages/CommitDetailPage/subRoute/FilesChangedTab/FilesChangedTable/FilesChangedTable.jsx#L166-L167

Added lines #L166 - L167 were not covered by tests

Check warning on line 167 in src/pages/CommitDetailPage/subRoute/FilesChangedTab/FilesChangedTable/FilesChangedTable.jsx

View check run for this annotation

Codecov - QA / codecov/patch

src/pages/CommitDetailPage/subRoute/FilesChangedTab/FilesChangedTable/FilesChangedTable.jsx#L166-L167

Added lines #L166 - L167 were not covered by tests

Check warning on line 167 in src/pages/CommitDetailPage/subRoute/FilesChangedTab/FilesChangedTable/FilesChangedTable.jsx

View check run for this annotation

Codecov Public QA / codecov/patch

src/pages/CommitDetailPage/subRoute/FilesChangedTab/FilesChangedTable/FilesChangedTable.jsx#L166-L167

Added lines #L166 - L167 were not covered by tests

const { data: commitData, isLoading } = useCommit({
provider,
Expand All @@ -155,6 +173,7 @@
commitid: commitSha,
filters: {
hasUnintendedChanges: false,
flags: flags,
},
})

Expand All @@ -172,6 +191,18 @@
}

if (isEmpty(filesChanged)) {
if (
isArray(flags) ||
(commit?.compareWithParent?.__typename === 'Comparison' &&
commit?.compareWithParent?.impactedFiles?.__typename === 'UnknownFlags')

Check warning on line 197 in src/pages/CommitDetailPage/subRoute/FilesChangedTab/FilesChangedTable/FilesChangedTable.jsx

View check run for this annotation

Codecov / codecov/patch

src/pages/CommitDetailPage/subRoute/FilesChangedTab/FilesChangedTable/FilesChangedTable.jsx#L196-L197

Added lines #L196 - L197 were not covered by tests

Check warning on line 197 in src/pages/CommitDetailPage/subRoute/FilesChangedTab/FilesChangedTable/FilesChangedTable.jsx

View check run for this annotation

Codecov - QA / codecov/patch

src/pages/CommitDetailPage/subRoute/FilesChangedTab/FilesChangedTable/FilesChangedTable.jsx#L196-L197

Added lines #L196 - L197 were not covered by tests

Check warning on line 197 in src/pages/CommitDetailPage/subRoute/FilesChangedTab/FilesChangedTable/FilesChangedTable.jsx

View check run for this annotation

Codecov Public QA / codecov/patch

src/pages/CommitDetailPage/subRoute/FilesChangedTab/FilesChangedTable/FilesChangedTable.jsx#L196-L197

Added lines #L196 - L197 were not covered by tests
) {
return (

Check warning on line 199 in src/pages/CommitDetailPage/subRoute/FilesChangedTab/FilesChangedTable/FilesChangedTable.jsx

View check run for this annotation

Codecov / codecov/patch

src/pages/CommitDetailPage/subRoute/FilesChangedTab/FilesChangedTable/FilesChangedTable.jsx#L199

Added line #L199 was not covered by tests

Check warning on line 199 in src/pages/CommitDetailPage/subRoute/FilesChangedTab/FilesChangedTable/FilesChangedTable.jsx

View check run for this annotation

Codecov - QA / codecov/patch

src/pages/CommitDetailPage/subRoute/FilesChangedTab/FilesChangedTable/FilesChangedTable.jsx#L199

Added line #L199 was not covered by tests

Check warning on line 199 in src/pages/CommitDetailPage/subRoute/FilesChangedTab/FilesChangedTable/FilesChangedTable.jsx

View check run for this annotation

Codecov Public QA / codecov/patch

src/pages/CommitDetailPage/subRoute/FilesChangedTab/FilesChangedTable/FilesChangedTable.jsx#L199

Added line #L199 was not covered by tests
<p className="m-4">
No files covered by tests and selected flags were changed
</p>
)
}

return <p className="m-4">No files covered by tests were changed</p>
}

Expand Down
Loading
Loading