Skip to content

Commit 8c3d9aa

Browse files
fix: Add back sync repos feature in list (#3790)
1 parent bb7cec7 commit 8c3d9aa

File tree

4 files changed

+65
-15
lines changed

4 files changed

+65
-15
lines changed

src/shared/ListRepo/ListRepo.test.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ describe('ListRepo', () => {
157157
describe('renders', () => {
158158
it('renders the children', () => {
159159
setup({})
160-
render(<ListRepo />, {
160+
render(<ListRepo canRefetch />, {
161161
wrapper: wrapper({}),
162162
})
163163

@@ -166,7 +166,7 @@ describe('ListRepo', () => {
166166

167167
it('renders the repo table', () => {
168168
setup({})
169-
render(<ListRepo />, {
169+
render(<ListRepo canRefetch />, {
170170
wrapper: wrapper({}),
171171
})
172172

@@ -177,7 +177,7 @@ describe('ListRepo', () => {
177177
describe('reads URL parameters', () => {
178178
it('reads search parameter from URL', () => {
179179
setup({})
180-
render(<ListRepo />, {
180+
render(<ListRepo canRefetch />, {
181181
wrapper: wrapper({ url: '?search=thisisaquery' }),
182182
})
183183

@@ -189,7 +189,7 @@ describe('ListRepo', () => {
189189
describe('update params after typing', () => {
190190
it('calls setSearchValue', async () => {
191191
const { user } = setup({})
192-
render(<ListRepo />, {
192+
render(<ListRepo canRefetch />, {
193193
wrapper: wrapper({}),
194194
})
195195

@@ -207,7 +207,7 @@ describe('ListRepo', () => {
207207
describe('when rendered for team plan', () => {
208208
it('renders the team table', async () => {
209209
setup({ isTeamPlan: true })
210-
render(<ListRepo />, {
210+
render(<ListRepo canRefetch />, {
211211
wrapper: wrapper({}),
212212
})
213213
const table = await screen.findByText(/ReposTableTeam/)
@@ -218,7 +218,7 @@ describe('ListRepo', () => {
218218
describe('welcome demo alert banner', () => {
219219
it('shows alert banner if it is my owner page and I came from onboarding', async () => {
220220
const { me } = setup({})
221-
render(<ListRepo />, {
221+
render(<ListRepo canRefetch />, {
222222
wrapper: wrapper({
223223
url: '/gh/janedoe?source=onboarding',
224224
path: '/:provider/:owner',
@@ -231,7 +231,7 @@ describe('ListRepo', () => {
231231

232232
it('does not show alert banner if I did not come from onboarding', async () => {
233233
const { me } = setup({})
234-
render(<ListRepo />, {
234+
render(<ListRepo canRefetch />, {
235235
wrapper: wrapper({
236236
url: '/gh/janedoe',
237237
path: '/:provider/:owner',
@@ -246,7 +246,7 @@ describe('ListRepo', () => {
246246
describe('user does not have gh app installed', () => {
247247
it('displays github app config banner if showDemoAlert is false', async () => {
248248
setup({})
249-
render(<ListRepo hasGhApp={false} />, {
249+
render(<ListRepo canRefetch hasGhApp={false} />, {
250250
wrapper: wrapper({
251251
url: '/gh/janedoe',
252252
path: '/:provider/:owner',
@@ -258,7 +258,7 @@ describe('ListRepo', () => {
258258
})
259259
it('does not display github app config banner if showDemoAlert is true', async () => {
260260
setup({})
261-
render(<ListRepo hasGhApp={false} />, {
261+
render(<ListRepo canRefetch hasGhApp={false} />, {
262262
wrapper: wrapper({
263263
url: '/gh/janedoe?source=onboarding',
264264
path: '/:provider/:owner',
@@ -272,7 +272,7 @@ describe('ListRepo', () => {
272272
})
273273
it('does not display github app config banner if isAdmin is false', async () => {
274274
setup({ isAdmin: false })
275-
render(<ListRepo hasGhApp={false} />, {
275+
render(<ListRepo canRefetch hasGhApp={false} />, {
276276
wrapper: wrapper({
277277
url: '/gh/janedoe',
278278
path: '/:provider/:owner',
@@ -285,7 +285,7 @@ describe('ListRepo', () => {
285285
describe('user has gh app installed', () => {
286286
it('does not display github app config banner if hasGhApp is true', async () => {
287287
setup({})
288-
render(<ListRepo hasGhApp={true} />, {
288+
render(<ListRepo canRefetch hasGhApp={true} />, {
289289
wrapper: wrapper({
290290
url: '/gh/janedoe',
291291
path: '/:provider/:owner',

src/shared/ListRepo/ListRepo.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const defaultQueryParams = {
2323
}
2424

2525
interface ListRepoProps {
26+
canRefetch: boolean
2627
hasGhApp?: boolean
2728
}
2829

@@ -31,7 +32,7 @@ interface URLParams {
3132
owner: string
3233
}
3334

34-
function ListRepo({ hasGhApp }: ListRepoProps) {
35+
function ListRepo({ canRefetch, hasGhApp }: ListRepoProps) {
3536
const { provider, owner } = useParams<URLParams>()
3637
const { params, updateParams } = useLocationParams(defaultQueryParams)
3738
// @ts-expect-error useLocationParams needs to be typed
@@ -63,6 +64,7 @@ function ListRepo({ hasGhApp }: ListRepoProps) {
6364
setSearchValue={(search) => {
6465
updateParams({ search })
6566
}}
67+
canRefetch={canRefetch}
6668
/>
6769

6870
{showDemoAlert ? (

src/shared/ListRepo/OrgControlTable/OrgControlTable.test.tsx

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@ describe('OrgControlTable', () => {
1515
it(`doesn't call setSearchValue yet`, async () => {
1616
const { user } = setup()
1717
const setSearchValue = vi.fn()
18-
render(<OrgControlTable setSearchValue={setSearchValue} searchValue="" />)
18+
render(
19+
<OrgControlTable
20+
canRefetch={true}
21+
setSearchValue={setSearchValue}
22+
searchValue=""
23+
/>
24+
)
1925

2026
const searchInput = screen.getByRole('textbox', {
2127
name: /search/i,
@@ -30,7 +36,11 @@ describe('OrgControlTable', () => {
3036
const { user } = setup()
3137
const setSearchValue = vi.fn()
3238
render(
33-
<OrgControlTable setSearchValue={setSearchValue} searchValue="" />
39+
<OrgControlTable
40+
canRefetch={true}
41+
setSearchValue={setSearchValue}
42+
searchValue=""
43+
/>
3444
)
3545

3646
const searchInput = screen.getByRole('textbox', {
@@ -43,9 +53,42 @@ describe('OrgControlTable', () => {
4353
})
4454
})
4555

56+
describe('when the user can refetch', () => {
57+
it('renders the RepoOrgNotFound', () => {
58+
render(
59+
<OrgControlTable
60+
setSearchValue={vi.fn()}
61+
searchValue=""
62+
canRefetch={true}
63+
/>
64+
)
65+
expect(screen.getByText(/RepoOrgNotFound/)).toBeInTheDocument()
66+
})
67+
})
68+
69+
describe('when the user cannot refetch', () => {
70+
it(`doesn't render the RepoOrgNotFound`, () => {
71+
render(
72+
<OrgControlTable
73+
setSearchValue={vi.fn()}
74+
searchValue=""
75+
canRefetch={false}
76+
/>
77+
)
78+
79+
expect(screen.queryByText(/RepoOrgNotFound/)).not.toBeInTheDocument()
80+
})
81+
})
82+
4683
describe('when show team plan passed in', () => {
4784
it('does not render the ordering select', () => {
48-
render(<OrgControlTable setSearchValue={vi.fn()} searchValue="" />)
85+
render(
86+
<OrgControlTable
87+
canRefetch={false}
88+
setSearchValue={vi.fn()}
89+
searchValue=""
90+
/>
91+
)
4992

5093
const select = screen.queryByRole('combobox', {
5194
name: /Sort Order/i,

src/shared/ListRepo/OrgControlTable/OrgControlTable.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@ import useDebounce from 'react-use/lib/useDebounce'
33

44
import TextInput from 'ui/TextInput'
55

6+
import RepoOrgNotFound from './RepoOrgNotFound'
7+
68
interface OrgControlTableProps {
79
setSearchValue: (search: string) => void
810
searchValue: string
11+
canRefetch: boolean
912
}
1013

1114
function OrgControlTable({
1215
setSearchValue,
1316
searchValue,
17+
canRefetch,
1418
}: OrgControlTableProps) {
1519
const [search, setSearch] = useState(searchValue)
1620

@@ -34,6 +38,7 @@ function OrgControlTable({
3438
}
3539
data-testid="org-control-search"
3640
/>
41+
{canRefetch && <RepoOrgNotFound />}
3742
</div>
3843
)
3944
}

0 commit comments

Comments
 (0)