Skip to content

Commit 90ff363

Browse files
committed
Fix members link
1 parent 41f09b6 commit 90ff363

File tree

2 files changed

+27
-35
lines changed

2 files changed

+27
-35
lines changed

src/pages/PlanPage/subRoutes/CurrentOrgPlan/AccountOrgs/AccountOrgs.test.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -281,17 +281,17 @@ describe('AccountOrgs', () => {
281281
})
282282
})
283283

284-
describe('when user clicks on an org', () => {
284+
describe('when user clicks on activated user count', () => {
285285
describe('and they are a member of that org', () => {
286286
it('redirects them to the member page for that org', async () => {
287287
setup()
288288
const user = userEvent.setup()
289289
render(<AccountOrgs account={mockAccount} />, { wrapper })
290290

291-
const org1 = await screen.findByText('org1')
292-
expect(org1).toBeInTheDocument()
291+
const org1Members = await screen.findByRole('link', { name: '7' })
292+
expect(org1Members).toBeInTheDocument()
293293

294-
await user.click(org1)
294+
await user.click(org1Members)
295295

296296
await waitFor(() =>
297297
expect(testLocation.pathname).toBe('/members/gh/org1')
@@ -305,10 +305,10 @@ describe('AccountOrgs', () => {
305305
const user = userEvent.setup()
306306
render(<AccountOrgs account={mockAccount} />, { wrapper })
307307

308-
const org2 = await screen.findByText('org2')
309-
expect(org2).toBeInTheDocument()
308+
const org2Members = await screen.findByRole('cell', { name: '4' })
309+
expect(org2Members).toBeInTheDocument()
310310

311-
await user.click(org2)
311+
await user.click(org2Members)
312312

313313
await waitFor(() =>
314314
expect(testLocation.pathname).toBe('/plan/gh/codecov')

src/pages/PlanPage/subRoutes/CurrentOrgPlan/AccountOrgs/AccountOrgs.tsx

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ import {
77
} from '@tanstack/react-table'
88
import { useEffect, useMemo, useState } from 'react'
99
import { useInView } from 'react-intersection-observer'
10-
import { useHistory, useParams } from 'react-router'
10+
import { useParams } from 'react-router'
1111

12-
import { useNavLinks } from 'services/navigation'
1312
import A from 'ui/A'
1413
import { Card } from 'ui/Card'
1514
import Icon from 'ui/Icon'
@@ -96,8 +95,6 @@ interface URLParams {
9695
}
9796

9897
export default function AccountOrgs({ account }: AccountOrgsArgs) {
99-
const history = useHistory()
100-
const { membersTab } = useNavLinks()
10198
const { provider, owner } = useParams<URLParams>()
10299
const { ref, inView } = useInView()
103100
const [sorting, setSorting] = useState<SortingState>([
@@ -107,11 +104,6 @@ export default function AccountOrgs({ account }: AccountOrgsArgs) {
107104
},
108105
])
109106

110-
const linkToMembersTab = (orgOwner: string) =>
111-
history.push(
112-
membersTab.path({ owner: encodeURIComponent(orgOwner), provider })
113-
)
114-
115107
const { data, isLoading, hasNextPage, fetchNextPage, isFetchingNextPage } =
116108
useInfiniteAccountOrganizations({
117109
provider,
@@ -223,36 +215,25 @@ export default function AccountOrgs({ account }: AccountOrgsArgs) {
223215
) : (
224216
table.getRowModel().rows.map((row) =>
225217
row.original.isCurrentUserPartOfOrg ? (
226-
<tr
227-
key={row.id}
228-
className="h-14 hover:cursor-pointer hover:bg-ds-gray-primary"
229-
onClick={() => linkToMembersTab(row.original.name)}
230-
>
231-
{row.getVisibleCells().map((cell) => (
232-
<td key={cell.id}>
233-
{flexRender(
234-
cell.column.columnDef.cell,
235-
cell.getContext()
236-
)}
237-
</td>
238-
))}
239-
</tr>
240-
) : (
241218
<tr key={row.id} className="h-14">
242219
{row.getVisibleCells().map((cell) => (
243220
<td key={cell.id}>
244-
{cell.id === 'activatedUserCount' ? (
245-
<div className="flex justify-items-end">
221+
{cell.column.id === 'activatedUserCount' ? (
222+
<div className="flex w-full justify-end">
246223
{/* @ts-ignore-error */}
247224
<A
248225
to={{
249226
pageName: 'membersTab',
250227
options: {
251-
owner: cell.getValue(),
228+
owner: encodeURIComponent(
229+
row.original.name
230+
),
252231
provider,
253232
},
254233
}}
255-
/>
234+
>
235+
{cell.getValue()}
236+
</A>
256237
</div>
257238
) : (
258239
flexRender(
@@ -263,6 +244,17 @@ export default function AccountOrgs({ account }: AccountOrgsArgs) {
263244
</td>
264245
))}
265246
</tr>
247+
) : (
248+
<tr key={row.id} className="h-14">
249+
{row.getVisibleCells().map((cell) => (
250+
<td key={cell.id}>
251+
{flexRender(
252+
cell.column.columnDef.cell,
253+
cell.getContext()
254+
)}
255+
</td>
256+
))}
257+
</tr>
266258
)
267259
)
268260
)}

0 commit comments

Comments
 (0)