Skip to content

Commit 43f8e1d

Browse files
nshkiCopilot
andauthored
feat(hub): search and filter the real prototype index (#221)
<!-- Use a conventional commit-style title, such as "fix(hub): retain prototype history". --> ## Why <!-- Explain the problem and why this change matters in a short, plain-English paragraph. Link the issue when applicable. --> The rebuilt Hub's real prototype index needs search, user filters, and pagination so members can find registered prototypes as the list grows. ## What changes <!-- Describe what becomes different for a first-time reader. Explain necessary terms. Include accurate Mermaid diagrams when they clarify the proposal, using before/after diagrams when helpful. Add screenshots for meaningful UI changes. --> Members can search by prototype name, description, branch, or user login and name, filter by the signed-in user or another user, and move through results 24 at a time. The user filter lists eligible users 20 at a time. A page beyond the last result shows the final page. The real index now exposes the same search, user filter, and pagination controls as mock mode. The shared filter copy calls people users. <!-- Omit validation sections, checklists, and routine test/CI summaries such as "CI is green" or "tests passed". Mention only known verification gaps that affect the change, not disclaimers about drafting this description. --> <!-- For UI changes, prune obsolete and duplicate stories in the affected catalogues as part of the change. Explain removed UI or consolidated coverage where needed; see hub/docs/storybook.md#ui-changes-and-pull-request-evidence. --> ## Storybook screenshots <!-- For Hub or canvas UI changes, follow hub/docs/storybook.md#ui-changes-and-pull-request-evidence. Embed uploaded screenshots of EVERY added or changed story, including stories affected indirectly by shared code, styles, copy, or fixtures. Label each with its full story title/name, theme, and viewport. Keep this section last and refresh images after UI revisions. Name any missing story and its rendering/upload blocker; incomplete evidence is not completion. Remove this section only when no story presentation changes. --> <details> <summary>Hub/Pages/Repositories/Show stories (light, 1440 × 1000)</summary> ![Hub/Pages/Repositories/Show — Empty (light, 1440 × 1000)](https://github.com/user-attachments/assets/74969c91-9778-460f-abeb-cad2d9442c50) ![Hub/Pages/Repositories/Show — Ready To Build (light, 1440 × 1000)](https://github.com/user-attachments/assets/a9a44c33-206b-4e56-a002-549c636c3add) ![Hub/Pages/Repositories/Show — Workflow Update Failed (light, 1440 × 1000)](https://github.com/user-attachments/assets/e379b773-6829-494b-a686-c33f94382797) ![Hub/Pages/Repositories/Show — Workflow Already Current (light, 1440 × 1000)](https://github.com/user-attachments/assets/777a47d2-2636-4575-b8f6-f7aa8f984a4d) ![Hub/Pages/Repositories/Show — Local Repository (light, 1440 × 1000)](https://github.com/user-attachments/assets/de72c59d-b536-4159-942c-ae1cab9b8a1a) ![Hub/Pages/Repositories/Show — Single (light, 1440 × 1000)](https://github.com/user-attachments/assets/e7e59d46-ce81-448f-b7d3-1663079e229a) ![Hub/Pages/Repositories/Show — Multiple (light, 1440 × 1000)](https://github.com/user-attachments/assets/9d9b8d63-1f13-4e16-9a29-b70ee90f3fa0) ![Hub/Pages/Repositories/Show — Read Only (light, 1440 × 1000)](https://github.com/user-attachments/assets/ffaca382-b2c2-473b-a56d-0181eb3155e5) ![Hub/Pages/Repositories/Show — Real Index (light, 1440 × 1000)](https://github.com/user-attachments/assets/96afe906-9d29-4793-80bd-ccbc19f15025) ![Hub/Pages/Repositories/Show — Real Index List (light, 1440 × 1000)](https://github.com/user-attachments/assets/eec28d39-5741-4119-8d61-f3a80110cff5) ![Hub/Pages/Repositories/Show — Real Index Empty (light, 1440 × 1000)](https://github.com/user-attachments/assets/f626fa65-09d7-4986-acf9-998023510eec) ![Hub/Pages/Repositories/Show — Real Index Single (light, 1440 × 1000)](https://github.com/user-attachments/assets/d7cf8d7d-f386-4595-acf5-1a04e308534c) ![Hub/Pages/Repositories/Show — Wide View Switching (light, 1440 × 1000)](https://github.com/user-attachments/assets/e73cd101-98f7-4425-af63-ec141e61695c) ![Hub/Pages/Repositories/Show — Searched (light, 1440 × 1000)](https://github.com/user-attachments/assets/8c3b0209-de23-4d52-8f33-601a3aff5876) ![Hub/Pages/Repositories/Show — Me Selected (light, 1440 × 1000)](https://github.com/user-attachments/assets/2dff4f04-2b82-40e1-a150-f1549fd4649a) ![Hub/Pages/Repositories/Show — Paginated (light, 1440 × 1000)](https://github.com/user-attachments/assets/3a82bd19-079c-4007-baf5-a715f7982d4b) ![Hub/Pages/Repositories/Show — No Matches (light, 1440 × 1000)](https://github.com/user-attachments/assets/2c8cdef5-e3e1-43f6-a811-f751b75df636) ![Hub/Pages/Repositories/Show — Updating (light, 1440 × 1000)](https://github.com/user-attachments/assets/d64525d7-2d43-454c-b3a2-52b4ab82638d) ![Hub/Pages/Repositories/Show — Request Failed (light, 1440 × 1000)](https://github.com/user-attachments/assets/5d42bd8b-e7c6-4925-9da3-b229b5cb6f58) ![Hub/Pages/Repositories/Show — List (light, 1440 × 1000)](https://github.com/user-attachments/assets/a595304a-654b-4578-a297-e134a0d0fd4a) ![Hub/Pages/Repositories/Show — Writer With Unlisted Branches (light, 1440 × 1000)](https://github.com/user-attachments/assets/3e4f92c6-af4a-4f29-90fc-2e4f021815de) ![Hub/Pages/Repositories/Show — Multiple Recent Branches (light, 1440 × 1000)](https://github.com/user-attachments/assets/324dbfa0-93eb-4cdf-a739-ea64cffb78ca) ![Hub/Pages/Repositories/Show — Local Writer With Unlisted Branches (light, 1440 × 1000)](https://github.com/user-attachments/assets/f9bb33b1-ec72-4518-b71d-2f97f2046cc6) ![Hub/Pages/Repositories/Show — Fresh Local Example (light, 1440 × 1000)](https://github.com/user-attachments/assets/78d69412-96c5-49ce-bfd2-cd750f8a9746) </details> <details> <summary>Features/Prototype Author Filter stories (light, 1440 × 1000; menu open)</summary> ![Features/Prototype Author Filter — Empty (light, 1440 × 1000; menu open)](https://github.com/user-attachments/assets/06afac19-86c3-4349-ac5b-ee333637a8f3) ![Features/Prototype Author Filter — Single (light, 1440 × 1000; menu open)](https://github.com/user-attachments/assets/ffcc18e3-031f-4ae7-90c5-3644cedd7e38) ![Features/Prototype Author Filter — Me (light, 1440 × 1000; menu open)](https://github.com/user-attachments/assets/ff62fa96-4aa9-4595-bb7c-d5c31e97393b) ![Features/Prototype Author Filter — Long Author (light, 1440 × 1000; menu open)](https://github.com/user-attachments/assets/b60b8c16-e21c-44f2-9ec2-2156473ae8c9) ![Features/Prototype Author Filter — Failed (light, 1440 × 1000; menu open)](https://github.com/user-attachments/assets/9ac1c3a3-7b21-47b9-9944-3a95a10478b5) ![Features/Prototype Author Filter — Loading (light, 1440 × 1000; menu open)](https://github.com/user-attachments/assets/2dada7e2-3f13-4f36-ae93-713fc00df718) </details> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 64725675-86e0-488d-ab25-e86df5b78abe
1 parent 8dd8b45 commit 43f8e1d

22 files changed

Lines changed: 488 additions & 93 deletions

File tree

‎hub/client/application/hub/routes/journey.test.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ describe("Hub repository journey", () => {
4747
server.events.on("request:end", complete)
4848
onTestFinished(() => server.events.removeListener("request:end", complete))
4949
})
50-
fireEvent.click(screen.getByRole("button", { name: "Author: All authors" }))
50+
fireEvent.click(screen.getByRole("button", { name: "User: All users" }))
5151
await router.settle(() => authorsLoaded)
5252
await router.settle(() =>
5353
fireEvent.click(screen.getByRole("menuitemradio", { name: /^@mona\b/ })),
@@ -69,7 +69,7 @@ describe("Hub repository journey", () => {
6969
await waitFor(() =>
7070
expect(screen.getByRole("searchbox", { name: "Search prototypes" })).toHaveValue("journey"),
7171
)
72-
expect(screen.getByRole("button", { name: "Author: @mona" })).toBeInTheDocument()
72+
expect(screen.getByRole("button", { name: "User: @mona" })).toBeInTheDocument()
7373
await router.go(-1)
7474
await within(results).findByRole("link", { name: "Welcome" })
7575
await router.go(-1)

‎hub/client/application/hub/routes/real-prototype-index.test.tsx‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,12 @@ describe("real prototype index", () => {
210210
: new HttpResponse(null, { status: 401 }),
211211
),
212212
)
213-
server.events.on("request:start", ({ request }) => requests.push(new URL(request.url).pathname))
213+
const searches: string[] = []
214+
server.events.on("request:start", ({ request }) => {
215+
const url = new URL(request.url)
216+
requests.push(url.pathname)
217+
searches.push(`${url.pathname}${url.search}`)
218+
})
214219
server.listen({ onUnhandledRequest: "error" })
215220
onTestFinished(() => server.close())
216221
const router = await renderApplication("/")
@@ -236,8 +241,7 @@ describe("real prototype index", () => {
236241
expect(detailLinks(results, repositoryId)).toHaveLength(0)
237242
expect(githubAuthorPaths(results)).toContain("/mona")
238243
expect(githubAuthorPaths(results).every((path) => path === "/mona")).toBe(true)
239-
expect(screen.queryByRole("searchbox", { name: "Search prototypes" })).not.toBeInTheDocument()
240-
expect(screen.queryByRole("button", { name: /^Author:/ })).not.toBeInTheDocument()
244+
expect(screen.getByRole("button", { name: "User: All users" })).toBeInTheDocument()
241245
expect(screen.queryByRole("link", { name: /build prototype/i })).not.toBeInTheDocument()
242246
expect(screen.queryByRole("button", { name: /build prototype/i })).not.toBeInTheDocument()
243247
expect(screen.queryByRole("link", { name: /edit prototype listings/i })).not.toBeInTheDocument()
@@ -261,7 +265,11 @@ describe("real prototype index", () => {
261265
within(listResults).queryByRole("columnheader", { name: "Build" }),
262266
).not.toBeInTheDocument()
263267
expect(within(listResults).queryByText("No Build yet")).not.toBeInTheDocument()
264-
expect(requests).not.toContain(`/api/repositories/${repositoryId}/authors`)
268+
269+
const search = screen.getByRole("searchbox", { name: "Search prototypes" })
270+
fireEvent.change(search, { target: { value: " welcome " } })
271+
fireEvent.keyDown(search, { key: "Enter" })
272+
await waitFor(() => expect(searches).toContain(`/api/repositories/${repositoryId}?q=welcome`))
265273
}, 15_000)
266274

267275
it("shows a repository failure instead of an empty index", async () => {

‎hub/client/application/hub/screens/repository-screen/index.tsx‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ export function RepositoryScreen({
4848
<RepositoriesShowPage
4949
key={data.repository.id}
5050
data={repositoryShowData(workspace, data, search, { detailsAvailable: mock, real: !mock })}
51-
filtersAvailable={mock}
5251
buildStatusAvailable={mock}
5352
view={view}
5453
onViewChange={(value) => changeFilter("view", value === "gallery" ? "" : value)}

‎hub/client/application/hub/view-models/repository-show-data/index.ts‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ export function repositoryShowData(
2323
: selectedAuthor
2424
? `@${selectedAuthor.login}`
2525
: author
26-
? "Selected author"
27-
: "All authors"
26+
? "Selected user"
27+
: "All users"
2828
const count = data.pagination.totalCount
2929

3030
return {
@@ -47,7 +47,7 @@ export function repositoryShowData(
4747
notPassingLabel: "not passing",
4848
noBuildLabel: "No Build yet",
4949
noSearchResultsHeading: "No prototypes found",
50-
noSearchResultsDescription: "Try a different search or author, or clear the current filters.",
50+
noSearchResultsDescription: "Try a different search or user, or clear the current filters.",
5151
pageTitle: data.repository.nameWithOwner,
5252
prototypes: data.prototypes.map((prototype) => {
5353
const builds = [...prototype.builds].sort((first, second) => second.number - first.number)
@@ -112,16 +112,16 @@ export function repositoryShowData(
112112
authorsPath: `/api/repositories/${data.repository.id}/authors`,
113113
path: search.size ? `${path}?${search}` : path,
114114
copy: {
115-
author: "Author",
115+
author: "User",
116116
me: "Me",
117-
allAuthors: "All authors",
118-
searchAuthors: "Search authors",
117+
allAuthors: "All users",
118+
searchAuthors: "Search users",
119119
moreAuthors: "More",
120-
firstAuthors: "First authors",
121-
noAuthors: "No matching authors",
122-
loading: "Loading authors",
120+
firstAuthors: "First users",
121+
noAuthors: "No matching users",
122+
loading: "Loading users",
123123
retry: "Retry",
124-
authorsFailed: "Hub could not load authors. Try again.",
124+
authorsFailed: "Hub could not load users. Try again.",
125125
resultsFailed: "Hub could not load prototypes. Try again.",
126126
previous: "Previous",
127127
next: "Next",

‎hub/client/features/prototype-author-filter/index.test.tsx‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ describe("PrototypeAuthorFilter()", () => {
1313
const { rerender } = render(
1414
<PrototypeAuthorFilter listing={prototypeListing} onChange={onChange} onSearch={onSearch} />,
1515
)
16-
const trigger = screen.getByRole("button", { name: "Author: All authors" })
16+
const trigger = screen.getByRole("button", { name: "User: All users" })
1717
fireEvent.click(trigger)
18-
const menu = screen.getByRole("menu", { name: "Author" })
18+
const menu = screen.getByRole("menu", { name: "User" })
1919
expect(within(menu).getAllByRole("menuitemradio")[0]).toHaveTextContent("Me")
2020
expect(within(menu).getByRole("searchbox")).toHaveFocus()
2121
expect(
22-
within(menu).getByRole("menuitemradio", { name: "All authors", checked: true }),
22+
within(menu).getByRole("menuitemradio", { name: "All users", checked: true }),
2323
).toBeInTheDocument()
2424
fireEvent.keyDown(within(menu).getByRole("searchbox"), { key: "ArrowDown" })
2525
const me = within(menu).getByRole("menuitemradio", { name: "Me" })
@@ -35,8 +35,8 @@ describe("PrototypeAuthorFilter()", () => {
3535
onSearch={onSearch}
3636
/>,
3737
)
38-
fireEvent.click(screen.getByRole("button", { name: "Author: Me" }))
39-
const all = screen.getByRole("menuitemradio", { name: "All authors", checked: false })
38+
fireEvent.click(screen.getByRole("button", { name: "User: Me" }))
39+
const all = screen.getByRole("menuitemradio", { name: "All users", checked: false })
4040
all.focus()
4141
fireEvent.keyDown(all, { key: "Enter" })
4242
expect(onChange).toHaveBeenCalledTimes(2)
@@ -68,7 +68,7 @@ describe("PrototypeAuthorFilter()", () => {
6868
render(
6969
<PrototypeAuthorFilter listing={prototypeListing} onChange={vi.fn()} onSearch={onSearch} />,
7070
)
71-
fireEvent.click(screen.getByRole("button", { name: "Author: All authors" }))
71+
fireEvent.click(screen.getByRole("button", { name: "User: All users" }))
7272
expect(await screen.findByRole("menuitemradio", { name: "@octocat" })).toBeInTheDocument()
7373
fireEvent.click(screen.getByRole("button", { name: "More" }))
7474
expect(await screen.findByRole("menuitemradio", { name: "@mona" })).toBeInTheDocument()
@@ -103,14 +103,14 @@ describe("PrototypeAuthorFilter()", () => {
103103
render(
104104
<PrototypeAuthorFilter listing={prototypeListing} onChange={vi.fn()} onSearch={onSearch} />,
105105
)
106-
fireEvent.click(screen.getByRole("button", { name: "Author: All authors" }))
106+
fireEvent.click(screen.getByRole("button", { name: "User: All users" }))
107107
expect(await screen.findByRole("alert")).toHaveTextContent(prototypeListing.copy.authorsFailed)
108108
expect(screen.getByRole("menuitemradio", { name: "Me" })).toBeInTheDocument()
109109
fireEvent.click(screen.getByRole("button", { name: "Retry" }))
110110
expect(await screen.findByRole("status")).toHaveTextContent(prototypeListing.copy.loading)
111111
await waitFor(() => expect(screen.queryByRole("status")).not.toBeInTheDocument())
112112
expect(screen.getByRole("menuitemradio", { name: "Me" })).toBeInTheDocument()
113113
fireEvent.change(screen.getByRole("searchbox"), { target: { value: "missing" } })
114-
await waitFor(() => expect(screen.getByRole("status")).toHaveTextContent("No matching authors"))
114+
await waitFor(() => expect(screen.getByRole("status")).toHaveTextContent("No matching users"))
115115
})
116116
})

‎hub/client/features/prototype-author-filter/stories.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const meta = {
3535
? "Me"
3636
: author === "2"
3737
? `@${mona.login}`
38-
: "All authors",
38+
: "All users",
3939
}}
4040
onChange={(value) => {
4141
setAuthor(value)

‎hub/client/features/prototype-index-header/index.tsx‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ export function PrototypeIndexHeader({
1919
searchLabel,
2020
searchQuery,
2121
searchMaxLength,
22-
searchVisible = true,
2322
searchShortcutEnabled = true,
2423
tools,
2524
trailingTools,
@@ -33,15 +32,14 @@ export function PrototypeIndexHeader({
3332
searchLabel: string
3433
searchQuery: string
3534
searchMaxLength?: number
36-
searchVisible?: boolean
3735
searchShortcutEnabled?: boolean
3836
tools?: ReactNode
3937
trailingTools?: ReactNode
4038
}) {
4139
const searchInputRef = useRef<HTMLInputElement>(null)
4240

4341
useEffect(() => {
44-
if (!searchShortcutEnabled || !searchVisible) return
42+
if (!searchShortcutEnabled) return
4543

4644
function focusSearch(event: KeyboardEvent) {
4745
if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "k") {
@@ -52,7 +50,7 @@ export function PrototypeIndexHeader({
5250

5351
window.addEventListener("keydown", focusSearch)
5452
return () => window.removeEventListener("keydown", focusSearch)
55-
}, [searchShortcutEnabled, searchVisible])
53+
}, [searchShortcutEnabled])
5654

5755
return (
5856
<header className="repository-page-header prototype-index-header">
@@ -67,7 +65,7 @@ export function PrototypeIndexHeader({
6765
<div className="prototype-index-header__tools">
6866
{tools}
6967

70-
<div className="prototype-index-header__search" hidden={!searchVisible}>
68+
<div className="prototype-index-header__search">
7169
<input
7270
ref={searchInputRef}
7371
type="search"

‎hub/client/pages/repositories-show-page/index.tsx‎

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,13 @@ export function RepositoriesShowPage({
2525
data,
2626
controls,
2727
buildStatusAvailable = true,
28-
filtersAvailable = true,
2928
managingPrototypes = false,
3029
view: controlledView,
3130
onViewChange,
3231
}: {
3332
data: RepositoriesShowPageData
3433
controls: PrototypeListingControls
3534
buildStatusAvailable?: boolean
36-
filtersAvailable?: boolean
3735
managingPrototypes?: boolean
3836
view?: PrototypeViewMode
3937
onViewChange?: (view: PrototypeViewMode) => void
@@ -94,7 +92,6 @@ export function RepositoriesShowPage({
9492
searchLabel={data.searchLabel}
9593
searchQuery={controls.query}
9694
searchMaxLength={200}
97-
searchVisible={filtersAvailable}
9895
tools={
9996
<div className="repository-detail__toolbar" data-view={view}>
10097
<Text size="100" className="repository-detail__count" aria-live="polite">
@@ -104,14 +101,12 @@ export function RepositoriesShowPage({
104101
: ""}
105102
</Text>
106103

107-
{filtersAvailable ? (
108-
<PrototypeAuthorFilter
109-
key={data.listing.authorsPath}
110-
listing={data.listing}
111-
onChange={controls.onAuthorChange}
112-
onSearch={controls.loadAuthors}
113-
/>
114-
) : null}
104+
<PrototypeAuthorFilter
105+
key={data.listing.authorsPath}
106+
listing={data.listing}
107+
onChange={controls.onAuthorChange}
108+
onSearch={controls.loadAuthors}
109+
/>
115110
</div>
116111
}
117112
trailingTools={
@@ -258,7 +253,7 @@ export function RepositoriesShowPage({
258253
</table>
259254
)}
260255

261-
{filtersAvailable && data.listing.pageCount > 1 ? (
256+
{data.listing.pageCount > 1 ? (
262257
<Pagination
263258
className="repository-detail__pagination"
264259
aria-label={data.listing.copy.pagination}

‎hub/client/pages/repositories-show-page/stories.tsx‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,6 @@ const realIndexData: RepositoriesShowPageData = {
251251
export const RealIndex: Story = {
252252
args: {
253253
buildStatusAvailable: false,
254-
filtersAvailable: false,
255254
data: realIndexData,
256255
},
257256
}

‎hub/client/storybook/fixtures/prototype-listing.ts‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,24 @@ import type { PrototypeListing } from "@utils/prototype-listing/types"
33
export const prototypeListing: PrototypeListing = {
44
query: "",
55
author: "",
6-
authorLabel: "All authors",
6+
authorLabel: "All users",
77
matchingCount: 1,
88
page: 1,
99
pageCount: 1,
1010
pagePath: "/repositories/2001",
1111
authorsPath: "/repositories/2001/prototype_authors",
1212
path: "/repositories/2001",
1313
copy: {
14-
author: "Author",
14+
author: "User",
1515
me: "Me",
16-
allAuthors: "All authors",
17-
searchAuthors: "Search authors",
16+
allAuthors: "All users",
17+
searchAuthors: "Search users",
1818
moreAuthors: "More",
19-
firstAuthors: "First authors",
20-
noAuthors: "No matching authors",
21-
loading: "Loading authors",
19+
firstAuthors: "First users",
20+
noAuthors: "No matching users",
21+
loading: "Loading users",
2222
retry: "Retry",
23-
authorsFailed: "Hub could not load authors. Try again.",
23+
authorsFailed: "Hub could not load users. Try again.",
2424
resultsFailed: "Hub could not load prototypes. Your previous results are still shown.",
2525
previous: "Previous",
2626
next: "Next",

0 commit comments

Comments
 (0)